:root {
  color-scheme: light;
  --ink: #17231f;
  --muted: #66716c;
  --paper: #f4f1ea;
  --surface: #fffdf8;
  --surface-soft: #ebe7dc;
  --line: #d9d4c7;
  --green: #18342d;
  --green-soft: #dfe9e3;
  --gold: #a36a1e;
  --gold-soft: #f4e5c7;
  --danger: #8a3329;
  --shadow: 0 12px 34px rgb(24 52 45 / 8%);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.48;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
input,
select,
textarea,
summary {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--green);
}

:focus-visible {
  outline: 3px solid #277c68;
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: none;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: env(safe-area-inset-top) 1rem 0;
  border-bottom: 1px solid rgb(217 212 199 / 70%);
  background: rgb(244 241 234 / 94%);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
}

.brand-mark,
.leo-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: #f5d99b;
  background: var(--green);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
}

.quick-capture {
  min-height: 44px;
  padding: 0.58rem 0.85rem;
  border: 1px solid var(--green);
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 700;
}

.app-frame {
  width: 100%;
  min-width: 0;
}

.desktop-sidebar {
  display: none;
}

.main-content {
  width: min(100%, 900px);
  min-width: 0;
  margin: 0 auto;
  padding: 1.25rem 1rem calc(7rem + env(safe-area-inset-bottom));
}

.mobile-nav {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  padding: 0.45rem 0.2rem calc(0.45rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgb(255 253 248 / 97%);
}

.mobile-nav a {
  display: flex;
  min-width: 0;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.12rem;
  border-radius: 9px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 650;
}

.mobile-nav a span {
  min-height: 1.2rem;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
}

.mobile-nav a[aria-current="page"] {
  color: var(--green);
  background: var(--green-soft);
}

.page-header {
  display: flex;
  min-width: 0;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.35rem;
}

.page-header h1,
.login-card h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 8vw, 3.25rem);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.02;
}

.page-header p {
  margin: 0.35rem 0 0;
}

.eyebrow {
  margin: 0 0 0.4rem;
  color: var(--gold);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.muted,
.meta,
.empty-state,
.help-text {
  color: var(--muted);
}

.meta,
.help-text {
  font-size: 0.84rem;
}

.section {
  margin: 0 0 1.6rem;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 0.65rem;
}

.section-heading h2,
.card h2,
.card h3 {
  margin: 0;
  line-height: 1.25;
}

.section-heading h2 {
  font-size: 0.86rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-heading a,
.text-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 700;
}

.card-grid,
.stack {
  display: grid;
  gap: 0.8rem;
  min-width: 0;
}

.card {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgb(24 52 45 / 2%);
  overflow-wrap: anywhere;
}

.card.featured {
  padding: 1.15rem;
  border-color: #9db6aa;
  background: var(--green);
  color: #fffdf8;
  box-shadow: var(--shadow);
}

.card.featured .muted,
.card.featured .meta {
  color: #c9d9d1;
}

.card.featured .button {
  border-color: #b7d6c8;
  color: #fffdf8;
}

.card.featured .button:hover {
  background: rgb(255 253 248 / 12%);
}

.next-action {
  margin: 0.5rem 0 1rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
  line-height: 1.25;
}

.card-row,
.actions,
.split-row,
.badge-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.55rem;
}

.card-row,
.split-row {
  justify-content: space-between;
}

.card-row > :first-child,
.split-row > :first-child {
  min-width: 0;
}

.actions {
  flex-wrap: wrap;
  margin-top: 0.8rem;
}

.badge-row {
  flex-wrap: wrap;
  margin: 0.5rem 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 0.74rem;
  font-weight: 750;
}

.badge.attention {
  color: #6f4512;
  background: var(--gold-soft);
}

.badge.complete {
  color: #3c5a4e;
  background: #e6eee9;
}

.original-text {
  margin: 0.7rem 0;
  padding: 0.8rem 0.9rem;
  border-left: 3px solid #c59445;
  background: #f8f3e8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0.62rem 0.9rem;
  border: 1px solid var(--green);
  border-radius: 10px;
  color: var(--green);
  background: transparent;
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
}

.button:hover {
  background: var(--green-soft);
}

.button.primary {
  color: #fffdf8;
  background: var(--green);
}

.button.primary:hover {
  background: #244b41;
}

.button.soft {
  border-color: transparent;
  background: var(--green-soft);
}

.button.danger {
  border-color: #c49a95;
  color: var(--danger);
}

.button.small {
  min-height: 44px;
  padding: 0.42rem 0.7rem;
  font-size: 0.82rem;
}

.button.full {
  width: 100%;
}

button:disabled {
  cursor: wait;
  opacity: 0.58;
}

label,
legend {
  color: #34433d;
  font-size: 0.83rem;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 0.7rem 0.75rem;
  border: 1px solid #bcb7ab;
  border-radius: 9px;
  color: var(--ink);
  background: #fff;
}

textarea {
  min-height: 116px;
  resize: vertical;
}

.capture-input {
  min-height: 180px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  line-height: 1.45;
}

.field {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
}

.field-grid {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

details {
  min-width: 0;
  margin-top: 0.75rem;
  border-top: 1px solid var(--line);
  padding-top: 0.65rem;
}

summary {
  min-height: 40px;
  cursor: pointer;
  color: var(--green);
  font-size: 0.86rem;
  font-weight: 750;
}

.filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
  margin-bottom: 1rem;
}

.list-clean {
  display: grid;
  gap: 0.65rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.list-clean li {
  min-width: 0;
}

.divider-list li + li {
  padding-top: 0.65rem;
  border-top: 1px solid var(--line);
}

.definition-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem 1rem;
  margin: 0;
}

.definition-list dt {
  color: var(--muted);
}

.definition-list dd {
  margin: 0;
  text-align: right;
  font-weight: 750;
}

.empty-state {
  margin: 0;
  padding: 1rem;
  border: 1px dashed #c7c1b5;
  border-radius: 12px;
  text-align: center;
}

.loading-state {
  padding: 4rem 1rem;
  color: var(--muted);
  text-align: center;
}

.error-state {
  padding: 1rem;
  border: 1px solid #d9aaa5;
  border-radius: 12px;
  color: var(--danger);
  background: #fff4f2;
}

.form-status {
  min-height: 1.3em;
  margin: 0;
  color: var(--danger);
  font-size: 0.88rem;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 1rem;
  bottom: calc(5.4rem + env(safe-area-inset-bottom));
  left: 1rem;
  max-width: 500px;
  margin: auto;
  padding: 0;
  border-radius: 12px;
  color: #fff;
  background: var(--green);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
}

.toast.visible {
  padding: 0.8rem 1rem;
  opacity: 1;
}

.hidden {
  display: none !important;
}

.login-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1rem;
  background:
    radial-gradient(circle at 20% 15%, #dce8e1 0, transparent 33%),
    var(--paper);
}

.login-shell {
  width: min(100%, 430px);
}

.login-card {
  padding: clamp(1.5rem, 7vw, 2.5rem);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card .leo-mark {
  width: 48px;
  height: 48px;
  margin-bottom: 1.3rem;
  font-size: 1.4rem;
}

.login-card .muted {
  margin: 0.75rem 0 1.4rem;
}

.setup-note {
  margin: 1rem 0 0;
  padding: 0.75rem;
  border-radius: 9px;
  color: #6f4512;
  background: var(--gold-soft);
  font-size: 0.84rem;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (min-width: 700px) {
  .main-content {
    padding: 2rem 1.5rem 4rem;
  }

  .card-grid.two,
  .field-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filters {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .toast {
    right: 2rem;
    bottom: 2rem;
    left: auto;
  }
}

@media (min-width: 980px) {
  .topbar {
    padding-right: 2rem;
    padding-left: 2rem;
  }

  .app-frame {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    width: min(100%, 1240px);
    margin: 0 auto;
  }

  .desktop-sidebar {
    position: sticky;
    top: 64px;
    display: flex;
    height: calc(100vh - 64px);
    flex-direction: column;
    justify-content: space-between;
    padding: 2rem 1rem 2rem 2rem;
  }

  .side-nav {
    display: grid;
    gap: 0.3rem;
  }

  .side-nav a {
    min-height: 44px;
    padding: 0.65rem 0.8rem;
    border-radius: 10px;
    color: var(--muted);
    font-weight: 700;
    text-decoration: none;
  }

  .side-nav a[aria-current="page"] {
    color: var(--green);
    background: var(--green-soft);
  }

  .sidebar-note {
    padding: 0 0.8rem;
    color: var(--muted);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 0.88rem;
  }

  .main-content {
    width: min(100%, 920px);
    padding: 3rem 2rem 5rem;
  }

  .mobile-nav {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}
