/* Fonts are served from this site so no visit is reported to a font CDN. Licences: fonts/OFL-*.txt */
@font-face {
  font-family: "Figtree"; font-style: normal; font-weight: 300 900; font-display: swap;
  src: url(fonts/figtree-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: "Figtree"; font-style: normal; font-weight: 300 900; font-display: swap;
  src: url(fonts/figtree-latin-ext-wght-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: "Source Serif 4"; font-style: normal; font-weight: 200 900; font-display: swap;
  src: url(fonts/source-serif-4-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: "Source Serif 4"; font-style: normal; font-weight: 200 900; font-display: swap;
  src: url(fonts/source-serif-4-latin-ext-wght-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: "Source Serif 4"; font-style: italic; font-weight: 200 900; font-display: swap;
  src: url(fonts/source-serif-4-latin-wght-italic.woff2) format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: "Source Serif 4"; font-style: italic; font-weight: 200 900; font-display: swap;
  src: url(fonts/source-serif-4-latin-ext-wght-italic.woff2) format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

/* Layout: toolbar across the top, client card + session list on the left, the note page on the right */
:root {
  --bg: #eef2f1;
  --panel: #ffffff;
  --ink: #1d2a2c;
  --muted: #5f6f72;
  --line: #d6dfdd;
  --accent: #2c6b66;
  --accent-ink: #ffffff;
  --accent-soft: #dfedeb;
  --danger: #a93c2a;
  --rec: #b8392b;
  --shadow: 0 1px 2px rgba(20,40,40,.06), 0 4px 14px rgba(20,40,40,.05);
  --font-ui: "Figtree", "Segoe UI", system-ui, sans-serif;
  --font-notes: "Source Serif 4", Georgia, "Times New Roman", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121a1b; --panel: #1a2426; --ink: #e2eae8; --muted: #93a3a1; --line: #2b3739;
    --accent: #63b5aa; --accent-ink: #0b1416; --accent-soft: #203432; --danger: #e28069; --rec: #ef6b5b;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121a1b; --panel: #1a2426; --ink: #e2eae8; --muted: #93a3a1; --line: #2b3739;
  --accent: #63b5aa; --accent-ink: #0b1416; --accent-soft: #203432; --danger: #e28069; --rec: #ef6b5b;
  --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { height: 100%; }
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font-ui);
  display: grid;
  grid-template-rows: auto 1fr;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 16px;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- Top toolbar ---------- */
header.app-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px;
  padding-block: 8px;
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 16px; margin-right: 14px; white-space: nowrap; letter-spacing: -.01em; }
.brand span { color: var(--accent); }
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 84px; padding: 6px 10px;
  background: none; border: 1px solid transparent; border-radius: 10px;
  font-size: 12.5px; font-weight: 500; color: var(--ink);
}
.tool svg { width: 26px; height: 26px; stroke: var(--accent); }
.tool:hover { background: var(--accent-soft); }
.tool.recording { background: color-mix(in srgb, var(--rec) 14%, transparent); border-color: var(--rec); }
.tool.recording svg { stroke: var(--rec); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.spacer { flex: 1; }
.tool.small { min-width: 64px; }
.tool.small svg { width: 20px; height: 20px; stroke: var(--muted); }

/* ---------- Layout ---------- */
main { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 16px; padding-top: 16px; min-height: 0; }
aside {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.section { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.label { font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
select#clientPicker {
  width: 100%; margin-top: 6px; padding: 7px 8px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
.field { display: grid; grid-template-columns: 56px minmax(0, 1fr); align-items: center; gap: 8px; margin-top: 8px; }
.field label { font-size: 13px; color: var(--muted); }
.field input {
  width: 100%; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 7px; background: var(--bg);
}
.link-btn { background: none; border: none; padding: 0; color: var(--danger); font-size: 12.5px; margin-top: 10px; }
.link-btn:hover { text-decoration: underline; }

.sessions-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; }
.add-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 11px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); border: none; font-size: 13px; font-weight: 600;
}
.add-btn:disabled { opacity: .4; cursor: default; }
ul#sessionList { list-style: none; margin: 0; padding: 0 8px 8px; overflow-y: auto; flex: 1; min-height: 60px; }
ul#sessionList li {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px; margin: 2px 0; border-radius: 8px; cursor: pointer;
}
ul#sessionList li:hover { background: var(--bg); }
ul#sessionList li.active { background: var(--accent-soft); }
ul#sessionList li.active .s-title { color: var(--accent); font-weight: 600; }
.s-text { flex: 1; min-width: 0; }
.s-title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-date { display: block; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.s-del { opacity: 0; background: none; border: none; color: var(--muted); font-size: 18px; line-height: 1; padding: 2px 6px; border-radius: 4px; }
li:hover .s-del, li.active .s-del, .s-del:focus-visible { opacity: 1; }
.s-del:hover { color: var(--danger); }
.rename-input { width: 100%; padding: 2px 6px; border: 1px solid var(--accent); border-radius: 5px; background: var(--panel); }
.hint { font-size: 12px; color: var(--muted); padding: 0 18px 12px; }

/* ---------- Editor ---------- */
.workspace { display: flex; flex-direction: column; min-height: 0; min-width: 0; gap: 10px; }
.doc { display: contents; }
.doc-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.title-input {
  flex: 1; min-width: 0; font-size: 21px; font-weight: 700; letter-spacing: -.01em; padding: 3px 8px;
  border: 1px solid transparent; border-radius: 8px; background: transparent;
}
.title-input:hover { border-color: var(--line); }
.date-input { padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); font-variant-numeric: tabular-nums; }
.client-tag { color: var(--muted); font-size: 13px; padding-left: 9px; margin-top: -8px; }

.notice {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; border-radius: 10px; font-size: 13.5px;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.notice > div { flex: 1; min-width: 200px; }
.notice .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.notice.rec { background: color-mix(in srgb, var(--rec) 10%, var(--panel)); border-color: color-mix(in srgb, var(--rec) 40%, transparent); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--rec); animation: pulse 1.2s infinite; flex: none; }
#interim { flex: 1; color: var(--muted); font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.notice select { padding: 2px 4px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); }

.editor-card { flex: 1; min-height: 260px; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.editor-card:focus-within { border-color: var(--accent); }
.format-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  padding: 4px 6px; border-bottom: 1px solid var(--line);
}
.fmt {
  min-width: 32px; height: 30px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: none; border-radius: 6px; color: var(--ink);
}
.fmt:hover { background: var(--bg); }
.fmt svg { width: 17px; height: 17px; stroke: currentColor; }
.sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
#editor {
  flex: 1; overflow-y: auto;
  padding: 22px 28px;
  font: 17px/1.7 var(--font-notes);
  overflow-wrap: anywhere;
}
#editor > * { max-width: 70ch; }
#editor:focus { outline: none; }
#editor:empty::before { content: attr(data-placeholder); color: var(--muted); }
#editor h2 { font: 600 13px var(--font-ui); letter-spacing: .07em; text-transform: uppercase; color: var(--accent); margin: 18px 0 4px; }
#editor h2:first-child { margin-top: 0; }
#editor p { margin: 0 0 10px; }
#editor ul, #editor ol { margin: 0 0 10px; padding-left: 1.4em; }
.status-bar { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; color: var(--muted); padding: 0 4px; font-variant-numeric: tabular-nums; }
.status-bar .warn { color: var(--danger); font-weight: 600; }

.empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  color: var(--muted); text-align: center; padding: 40px 16px;
  border: 1px dashed var(--line); border-radius: 12px;
}
.empty h2 { color: var(--ink); margin: 0; font-size: 20px; text-wrap: balance; }

/* ---------- Dialogs ---------- */
dialog {
  border: none; border-radius: 14px; padding: 22px 24px; width: min(420px, calc(100vw - 32px));
  background: var(--panel); color: var(--ink); box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(10,20,22,.45); }
dialog h2 { margin: 0 0 6px; font-size: 18px; }
dialog p { margin: 4px 0 0; color: var(--muted); }
dialog .field { grid-template-columns: 70px minmax(0, 1fr); margin-top: 12px; }
#confirmTypeWrap { margin-top: 14px; display: grid; gap: 6px; font-size: 13px; }
#confirmTypeWrap input { padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.btn { padding: 7px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.danger { background: var(--danger); color: var(--panel); border-color: var(--danger); font-weight: 600; }
.btn:disabled { opacity: .45; cursor: default; }

dialog#trashDialog { width: min(560px, calc(100vw - 32px)); }
.trash-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.trash-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.trash-list li > div { flex: 1; min-width: 0; }
.trash-list .meta { display: block; font-size: 12.5px; color: var(--muted); }
.trash-empty { color: var(--muted); padding: 8px 0; }
.trash-head { margin-top: 16px; }

#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 999px; font-size: 13.5px;
  max-width: calc(100vw - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.2); z-index: 20;
}

/* ---------- Login / lock screen ---------- */
/* While locked, the app is hidden entirely and its notes are cleared from the page */
body.locked > header, body.locked > main { visibility: hidden; }
#authScreen {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  background: var(--bg);
}
.auth-card {
  width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 26px 24px; box-shadow: var(--shadow);
}
.auth-card .brand { font-size: 19px; margin: 0 0 4px; }
.auth-card p { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.auth-card label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.auth-card input {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
.auth-card .btn { width: 100%; margin-top: 14px; padding: 9px 16px; }
.auth-error { color: var(--danger); font-size: 13.5px; margin-top: 10px; min-height: 1.2em; }

@media (max-width: 760px) {
  body { height: auto; min-height: 100%; }
  main { grid-template-columns: minmax(0, 1fr); }
  .tool { min-width: 58px; padding: 6px 6px; }
  .brand { width: 100%; }
  #editor { padding: 16px 18px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
