/* Notes - SFR Business look.
   Light and dark are both SELECTED, not flipped, and the brand red splits into a
   FILL that white text sits on and an INK for accents on the surface, because one
   red cannot clear 4.5:1 in both roles. */

:root {
  color-scheme: light;
  --sfr-red: #e2001a;
  --sfr-ink: #b80016;
  --sfr-wash: #fdeced;
  --sfr-fill: #e2001a;
  --on-fill: #ffffff;

  --bg: #f4f4f2;
  --surface-1: #ffffff;
  --surface-2: #fafaf9;
  --surface-3: #f0efec;
  --border: #e2e1dd;
  --border-strong: #cfcec9;

  --text-primary: #14140f;
  --text-secondary: #55544e;
  --text-muted: #86847c;
  --muted-ink: #6b6a63;

  --accent: #2a78d6;
  --accent-wash: #e6effb;
  --accent-ink: #1c5cab;
  --good: #167a4b;
  --good-wash: #e6f4ec;
  --warn-ink: #8a5200;
  --warn-wash: #fdf2dd;
  --critical: #c02128;
  --critical-wash: #fdecec;

  --radius: 10px;
  --radius-lg: 14px;
  --shadow-1: 0 1px 2px rgba(20,20,15,.06), 0 1px 3px rgba(20,20,15,.04);
  --shadow-2: 0 12px 34px rgba(20,20,15,.14);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Poppins", var(--font);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --header-h: 58px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --sfr-red: #ff6b78;
    --sfr-ink: #ff8a94;
    --sfr-wash: #35181c;
    --sfr-fill: #e01b30;
    --on-fill: #ffffff;
    --bg: #131312;
    --surface-1: #1a1a19;
    --surface-2: #202020;
    --surface-3: #2a2a28;
    --border: #333331;
    --border-strong: #4a4a46;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #918f85;
    --muted-ink: #aaa89e;
    --accent: #3987e5;
    --accent-wash: #16283f;
    --accent-ink: #86b6ef;
    --good: #35c07d;
    --good-wash: #12291f;
    --warn-ink: #e0a52c;
    --warn-wash: #2e2413;
    --critical: #ff6b6b;
    --critical-wash: #33191a;
    --shadow-1: 0 1px 2px rgba(0,0,0,.4);
    --shadow-2: 0 12px 34px rgba(0,0,0,.55);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text-primary);
  font: 400 14px/1.55 var(--font); -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; margin: 0; }
button { font: inherit; }
a { color: var(--accent-ink); }

/* ---------- brand ---------- */
.logo { display: inline-flex; align-items: center; flex: none; }
.logo-mark {
  background: var(--sfr-fill); color: var(--on-fill);
  font-family: var(--font-display); font-weight: 700; font-size: 15px;
  padding: 6px 8px; line-height: 1;
}
.logo-word { font-family: var(--font-display); font-weight: 600; font-size: 15px; padding-left: 7px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface-1);
  color: var(--text-primary); padding: 8px 13px; font-size: 13.5px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--sfr-fill); border-color: var(--sfr-fill); color: var(--on-fill); font-weight: 600; }
.btn-primary:hover { filter: brightness(.93); }
.btn-danger { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 40%, transparent); }
.btn-danger:hover { background: var(--critical-wash); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text-primary); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; }

/* ---------- forms ---------- */
label.field { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=search] {
  width: 100%; padding: 10px 12px; border-radius: 9px; font: inherit;
  border: 1px solid var(--border-strong); background: var(--surface-1); color: var(--text-primary);
}
input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 1px; border-color: var(--accent); }
.help { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

.lang { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 999px; overflow: hidden; }
.lang button { border: 0; background: transparent; color: var(--text-secondary); padding: 5px 11px; font-size: 12px; font-weight: 600; cursor: pointer; }
.lang button[aria-pressed="true"] { background: var(--text-primary); color: var(--surface-1); }

/* ---------- auth screen ---------- */
.auth-wrap { min-height: 100%; display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: min(420px, 100%); background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); padding: 26px; }
.auth-card h1 { font-size: 20px; margin-bottom: 4px; }
.auth-card > p.sub { color: var(--text-secondary); font-size: 13.5px; margin: 0 0 20px; }
.auth-top { display: flex; align-items: center; margin-bottom: 22px; }
.auth-top .lang { margin-left: auto; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs button { border: 0; background: none; padding: 9px 13px; cursor: pointer; font-size: 13.5px; color: var(--text-secondary); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--sfr-ink); border-bottom-color: var(--sfr-fill); font-weight: 600; }
.field-row { margin-bottom: 14px; }
.form-error { background: var(--critical-wash); color: var(--critical); border: 1px solid color-mix(in srgb, var(--critical) 32%, transparent); padding: 9px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }

/* ---------- app shell ---------- */
.header {
  height: var(--header-h); display: flex; align-items: center; gap: 14px; padding: 0 18px;
  background: var(--surface-1); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.header .divider { width: 1px; height: 24px; background: var(--border); }
.header h1 { font-size: 15px; }
.header .spacer { flex: 1; }
.who { font-size: 12.5px; color: var(--text-muted); }
.avatar { width: 30px; height: 30px; border-radius: 999px; background: var(--sfr-wash); color: var(--sfr-ink); display: grid; place-items: center; font-weight: 700; font-size: 11.5px; flex: none; }

.shell { display: grid; grid-template-columns: 330px 1fr; height: calc(100vh - var(--header-h)); }
@media (max-width: 900px) { .shell { grid-template-columns: 1fr; } .shell.editing .pane-list { display: none; } .shell:not(.editing) .pane-edit { display: none; } }

.pane-list { border-right: 1px solid var(--border); background: var(--surface-1); display: flex; flex-direction: column; min-height: 0; }
.list-top { padding: 14px; border-bottom: 1px solid var(--border); display: grid; gap: 10px; }
.tagbar { display: flex; gap: 6px; flex-wrap: wrap; }
.tagchip {
  border: 1px solid var(--border-strong); background: var(--surface-1); color: var(--text-secondary);
  border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer;
}
.tagchip:hover { background: var(--surface-3); }
.tagchip[aria-pressed="true"] { background: var(--accent-wash); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

.note-list { overflow-y: auto; flex: 1; min-height: 0; }
.note-item { padding: 13px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.note-item:hover { background: var(--surface-2); }
.note-item[aria-current="true"] { background: var(--sfr-wash); box-shadow: inset 3px 0 0 var(--sfr-fill); }
.note-item h3 { font-size: 14px; font-weight: 600; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-item p { margin: 0; font-size: 12.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-item .meta { display: flex; gap: 7px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.note-item .when { font-size: 11.5px; color: var(--text-muted); }
.tag-mini { font-size: 11px; background: var(--surface-3); color: var(--muted-ink); border-radius: 999px; padding: 2px 7px; }
.pin { color: var(--warn-ink); font-size: 11.5px; font-weight: 700; }

.empty { padding: 40px 20px; text-align: center; color: var(--text-muted); font-size: 13.5px; }

/* ---------- editor ---------- */
.pane-edit { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.edit-top { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--border); background: var(--surface-1); }
.edit-top .spacer { flex: 1; }
.saved-hint { font-size: 12px; color: var(--text-muted); }
.saved-hint.on { color: var(--good); }

/* align-items:flex-start keeps the sheet the height of its content - stretched, it
   left a tall band of empty white below the tags. */
.edit-body { flex: 1; overflow-y: auto; padding: 22px; display: flex; justify-content: center; align-items: flex-start; }
.sheet { width: min(820px, 100%); background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); display: flex; flex-direction: column; }
.title-input { border: 0; outline: 0; width: 100%; padding: 20px 22px 10px; font-family: var(--font-display); font-size: 22px; font-weight: 600; background: transparent; color: var(--text-primary); }
.title-input::placeholder { color: var(--text-muted); }

.toolbar { display: flex; gap: 3px; flex-wrap: wrap; padding: 7px 18px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface-1); z-index: 2; }
.toolbar button {
  border: 1px solid transparent; background: transparent; color: var(--text-secondary);
  min-width: 30px; height: 30px; padding: 0 7px; border-radius: 7px; cursor: pointer; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}
.toolbar button:hover { background: var(--surface-3); color: var(--text-primary); }
.toolbar .sep { width: 1px; background: var(--border); margin: 4px 5px; }

.editor {
  padding: 18px 22px 40px; min-height: 320px; outline: 0; font-size: 15px; line-height: 1.7; color: var(--text-primary);
}
.editor:empty::before { content: attr(data-placeholder); color: var(--text-muted); }
.editor h1 { font-size: 24px; margin: 18px 0 8px; }
.editor h2 { font-size: 19px; margin: 16px 0 7px; }
.editor h3 { font-size: 16px; margin: 14px 0 6px; }
.editor p { margin: 0 0 10px; }
.editor ul, .editor ol { margin: 0 0 10px; padding-left: 24px; }
.editor blockquote { margin: 0 0 10px; padding: 4px 0 4px 14px; border-left: 3px solid var(--border-strong); color: var(--text-secondary); }
.editor code { background: var(--surface-3); padding: 1px 5px; border-radius: 5px; font-family: var(--mono); font-size: .9em; }
.editor pre { background: var(--surface-3); padding: 12px 14px; border-radius: 9px; overflow-x: auto; }
.editor a { color: var(--accent-ink); }
.editor hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

.tag-edit { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; padding: 12px 22px 18px; border-top: 1px solid var(--border); }
.tag-edit .tagchip { cursor: default; }
.tag-edit .tagchip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 0 0 5px; font-size: 13px; line-height: 1; }
.tag-input { border: 1px dashed var(--border-strong); background: transparent; border-radius: 999px; padding: 3px 10px; font: inherit; font-size: 12px; width: 130px; color: var(--text-primary); }
.tag-input:focus { outline: 0; border-color: var(--accent); border-style: solid; }

/* ---------- modal & toast ---------- */
.scrim { position: fixed; inset: 0; background: rgba(20,20,15,.4); z-index: 60; }
.modal-wrap { position: fixed; inset: 0; z-index: 61; display: grid; place-items: center; padding: 20px; }
.modal { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-2); width: min(430px, 100%); padding: 22px; }
.modal h3 { font-size: 16px; margin-bottom: 8px; }
.modal p { margin: 0 0 18px; color: var(--text-secondary); font-size: 13.5px; }
.modal-foot { display: flex; gap: 9px; justify-content: flex-end; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(12px); z-index: 90;
  background: var(--text-primary); color: var(--bg); padding: 11px 17px; border-radius: 9px; font-size: 13px;
  box-shadow: var(--shadow-2); opacity: 0; transition: all .18s; pointer-events: none; }
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { background: var(--critical); color: #fff; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
