:root {
  color-scheme: light;
  --ink: #25241f;
  --muted: #706d64;
  --paper: #f7f4ed;
  --surface: #fffdf8;
  --surface-2: #eee9de;
  --line: #ddd6c8;
  --plum: #5e4968;
  --plum-dark: #46344f;
  --sage: #a9b9a4;
  --sage-dark: #48614e;
  --peach: #e7b699;
  --shadow: 0 18px 60px rgba(54, 47, 37, 0.09);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 82% 12%, rgba(169, 185, 164, 0.28), transparent 27rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, textarea, select, input { font: inherit; }
button { color: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 22px;
  border-right: 1px solid var(--line);
  background: rgba(247, 244, 237, 0.86);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; margin: 0 8px 38px; }
.brand-mark { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: var(--plum); color: white; font-weight: 800; letter-spacing: -0.04em; }
.brand strong, .brand small { display: block; line-height: 1.03; }
.brand strong { font-family: Georgia, serif; font-size: 20px; }
.brand small { color: var(--muted); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
nav { display: grid; gap: 7px; }
.nav-item { border: 0; background: transparent; padding: 12px 14px; border-radius: 13px; text-align: left; cursor: pointer; display: flex; gap: 12px; align-items: center; color: var(--muted); }
.nav-item:hover, .nav-item:focus-visible { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--plum); color: white; box-shadow: 0 8px 24px rgba(94,73,104,.22); }
.nav-item span { width: 18px; text-align: center; }
.privacy-note { margin-top: auto; display: flex; gap: 10px; padding: 14px 10px; color: var(--muted); }
.privacy-note strong, .privacy-note small { display: block; }
.privacy-note strong { color: var(--ink); font-size: 13px; }
.privacy-note small { margin-top: 2px; font-size: 11px; line-height: 1.4; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #5d8f66; box-shadow: 0 0 0 4px rgba(93,143,102,.12); margin-top: 4px; flex: 0 0 auto; }

main { min-width: 0; padding: 42px clamp(24px, 5vw, 76px) 80px; }
.page { max-width: 1160px; margin: 0 auto; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 7px; color: var(--plum); font-weight: 800; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-weight: 600; letter-spacing: -.025em; }
h1 { font-size: clamp(36px, 5vw, 62px); line-height: 1; }
h2 { font-size: clamp(25px, 3vw, 36px); }
h3 { font-size: 21px; }
.lead { max-width: 650px; color: var(--muted); font-size: 17px; line-height: 1.65; }
.date-label { color: var(--muted); font-size: 14px; }

.hero {
  overflow: hidden;
  position: relative;
  padding: clamp(28px, 5vw, 54px);
  border-radius: 30px;
  color: white;
  background: linear-gradient(130deg, var(--plum-dark), #705977 62%, #85718c);
  box-shadow: var(--shadow);
}
.hero::after { content: ""; position: absolute; width: 260px; height: 260px; border: 55px solid rgba(255,255,255,.08); border-radius: 50%; right: -70px; top: -90px; }
.hero h1 { max-width: 740px; }
.hero p { max-width: 600px; line-height: 1.65; color: rgba(255,255,255,.78); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; position: relative; z-index: 1; }

.button { border: 0; border-radius: 13px; padding: 12px 17px; font-weight: 750; cursor: pointer; transition: transform .15s ease, background .15s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--plum); color: white; }
.hero .button.primary { background: white; color: var(--plum-dark); }
.button.secondary { background: var(--surface-2); color: var(--ink); }
.hero .button.secondary { background: rgba(255,255,255,.12); color: white; border: 1px solid rgba(255,255,255,.15); }
.button.ghost { background: transparent; border: 1px solid var(--line); }
.button.danger { background: #f5dfda; color: #783f36; }

.section { margin-top: 38px; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.section-head p { margin: 0; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: rgba(255,253,248,.9); border: 1px solid rgba(221,214,200,.82); border-radius: var(--radius); padding: 22px; box-shadow: 0 8px 30px rgba(54,47,37,.045); }
.card p { color: var(--muted); line-height: 1.55; }
.quick-card { min-height: 174px; display: flex; flex-direction: column; align-items: flex-start; text-align: left; cursor: pointer; transition: transform .18s ease, border-color .18s ease; }
.quick-card:hover { transform: translateY(-3px); border-color: var(--sage); }
.quick-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: #ebe4ef; color: var(--plum); font-weight: 900; margin-bottom: 28px; }
.quick-card:nth-child(2) .quick-icon { background: #e5ede2; color: var(--sage-dark); }
.quick-card:nth-child(3) .quick-icon { background: #f7e6da; color: #8b5941; }
.quick-card h3 { font-family: inherit; font-size: 17px; font-weight: 800; letter-spacing: 0; }
.quick-card p { margin: 7px 0 0; font-size: 13px; }

.entry-list { display: grid; gap: 10px; }
.entry { display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: 14px; padding: 17px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.entry-type { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: var(--surface-2); color: var(--plum); font-weight: 900; }
.entry p { margin: 4px 0 9px; color: var(--ink); line-height: 1.45; white-space: pre-wrap; }
.entry small { color: var(--muted); }
.entry-side { display: grid; justify-items: end; gap: 8px; }
.entry-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.entry-actions .button { padding: 7px 9px; font-size: 11px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: var(--surface-2); padding: 5px 8px; border-radius: 999px; color: var(--muted); font-size: 11px; }
.empty { text-align: center; padding: 42px 24px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); background: rgba(255,255,255,.35); }

.metric { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.metric strong { font-family: Georgia, serif; font-size: 34px; color: var(--plum); }
.pattern-card .confidence { display: inline-flex; padding: 5px 9px; background: #e7efe5; color: var(--sage-dark); border-radius: 999px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.evidence-line { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 16px 0 8px; }
.evidence-line span { display: block; height: 100%; background: var(--sage-dark); border-radius: inherit; }

.strategy-card { display: flex; flex-direction: column; }
.strategy-card .strategy-meta { display: flex; gap: 8px; margin: 12px 0 4px; }
.strategy-card button { margin-top: auto; align-self: flex-start; }

.settings-section { margin-bottom: 18px; }
.settings-section h3 { margin-bottom: 14px; }
.field { display: grid; gap: 7px; margin-top: 16px; }
.field > span, legend { font-weight: 750; font-size: 13px; }
.field textarea, .field select, .field input { width: 100%; border: 1px solid var(--line); border-radius: 12px; background: white; padding: 12px 13px; color: var(--ink); outline: none; }
.field textarea:focus, .field select:focus, .field input:focus { border-color: var(--plum); box-shadow: 0 0 0 3px rgba(94,73,104,.1); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.provider-choice { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.provider-choice label { cursor: pointer; }
.provider-choice input { position: absolute; opacity: 0; }
.provider-choice span { display: block; text-align: center; border: 1px solid var(--line); border-radius: 12px; padding: 12px 8px; background: var(--surface); }
.provider-choice input:checked + span { border-color: var(--plum); color: var(--plum); background: #f0eaf3; font-weight: 800; }
.notice { padding: 13px 15px; border-radius: 12px; background: #fff3db; color: #6b5630; font-size: 13px; line-height: 1.5; }
.hidden { display: none !important; }
.discovery-status { margin-top: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: var(--surface-2); font-size: 13px; line-height: 1.45; }
.discovery-status.loading { color: var(--plum); border-color: #c9b8d0; background: #f0eaf3; }
.discovery-status.success { color: var(--sage-dark); border-color: #b9cbb5; background: #e7efe5; }
.discovery-status.error { color: #783f36; border-color: #dfb9b0; background: #f8e5e0; }
.ai-response { color: var(--ink); font-size: 15px; line-height: 1.7; white-space: normal; }
.button:disabled { opacity: .55; cursor: wait; transform: none; }

.dialog { width: min(680px, calc(100% - 24px)); max-height: 90vh; overflow: auto; border: 0; border-radius: 26px; padding: 0; background: var(--surface); box-shadow: 0 30px 100px rgba(36,32,28,.28); }
.dialog::backdrop { background: rgba(34,29,37,.48); backdrop-filter: blur(3px); }
.dialog form, .compact-dialog > div { padding: 26px; }
.dialog-head { display: flex; justify-content: space-between; gap: 18px; align-items: start; }
.icon-button { border: 0; background: var(--surface-2); width: 38px; height: 38px; border-radius: 50%; font-size: 24px; cursor: pointer; }
fieldset { border: 0; padding: 0; margin: 22px 0 0; }
legend small { color: var(--muted); font-weight: 500; margin-left: 4px; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 9px; }
.choice { border: 1px solid var(--line); padding: 11px; border-radius: 12px; background: white; cursor: pointer; }
.choice.selected { background: #f0eaf3; color: var(--plum); border-color: var(--plum); font-weight: 800; }
.chip-grid { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 8px 11px; background: white; cursor: pointer; font-size: 12px; }
.chip.selected { background: var(--plum); border-color: var(--plum); color: white; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 25px; }
.compact-dialog { width: min(480px, calc(100% - 24px)); }
.compact-dialog .dialog-actions { padding: 0 26px 26px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; background: var(--ink); color: white; padding: 11px 16px; border-radius: 999px; box-shadow: var(--shadow); transition: .2s ease; z-index: 20; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 850px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; padding: 8px max(10px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom)); border: 0; border-top: 1px solid var(--line); }
  .brand, .privacy-note { display: none; }
  nav { grid-template-columns: repeat(5, 1fr); gap: 2px; }
  .nav-item { padding: 8px 4px; display: grid; justify-items: center; gap: 2px; text-align: center; font-size: 10px; }
  .nav-item span { font-size: 15px; }
  main { padding: 28px 16px 100px; }
  .grid, .grid.two { grid-template-columns: 1fr; }
  .hero { border-radius: 24px; }
  .page-head { display: block; }
  .date-label { margin-top: 12px; }
}

@media (max-width: 520px) {
  .form-row, .choice-grid, .provider-choice { grid-template-columns: 1fr; }
  h1 { font-size: 38px; }
  .hero-actions .button { width: 100%; }
  .entry { grid-template-columns: auto 1fr; }
  .entry-side { grid-column: 2; justify-items: start; }
  .entry-actions { justify-content: flex-start; }
}

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