/* Notes — warm Gold Coast paper · clinical knowledge notebook */
:root {
  --paper: #FBF6EE;
  --paper-2: #FFFDF8;
  --ink: #1C1917;
  --ink-soft: #4A433C;
  --muted: #7A7268;
  --coral: #E07A5F;
  --coral-soft: #F4C7B8;
  --teal: #2A9D8F;
  --teal-soft: #C9E8E3;
  --gold: #C9A227;
  --gold-line: rgba(201, 162, 39, 0.45);
  --sky: #7EB8D4;
  --navy: #1B365D;
  --danger: #B44A3A;
  --shadow: 0 10px 40px rgba(27, 54, 93, 0.08), 0 1px 0 rgba(201, 162, 39, 0.28);
  --radius: 18px;
  --font-ui: "Nunito", system-ui, sans-serif;
  --font-write: "Fraunces", "Palatino Linotype", serif;
  --top: 72px;
}
[data-theme="night"] {
  --paper: #121821;
  --paper-2: #1A2230;
  --ink: #F4EDE0;
  --ink-soft: #D5CBBA;
  --muted: #9A9084;
  --coral: #E08B74;
  --coral-soft: #4A2E28;
  --teal: #4DB6A8;
  --teal-soft: #1A3A36;
  --gold: #D4B84A;
  --gold-line: rgba(212, 184, 74, 0.35);
  --sky: #8EC4D8;
  --navy: #C9D7EA;
  --danger: #E07A6A;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35), 0 1px 0 rgba(212, 184, 74, 0.18);
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font-ui);
  background: var(--paper);
  color: var(--ink);
  min-height: 100dvh;
  line-height: 1.5;
  padding-bottom: 2.4rem;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

.grain {
  pointer-events: none;
  position: fixed; inset: 0; z-index: 0;
  opacity: 0.18;
  background-image:
    radial-gradient(rgba(28, 25, 23, 0.07) 0.6px, transparent 0.7px),
    repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(201,162,39,0.03) 3px, rgba(201,162,39,0.03) 4px);
  background-size: 5px 5px, 100% 4px;
}
[data-theme="night"] .grain { opacity: 0.22; mix-blend-mode: overlay; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0.65rem 1.25rem;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--gold-line);
}
.brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; color: inherit; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong {
  font-family: var(--font-write);
  font-size: 1.45rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.brand-text em {
  font-style: normal;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.clock { display: flex; align-items: center; gap: 0.55rem; margin-left: 0.2rem; }
.analog { flex: none; filter: drop-shadow(0 2px 4px rgba(27,54,93,0.08)); }
.clock-time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--navy);
  font-size: 1.05rem;
}
.clock-date { font-size: 0.72rem; color: var(--muted); letter-spacing: 0.04em; }

.search-wrap { margin-left: auto; min-width: 180px; flex: 0 1 240px; }
.search-wrap input {
  width: 100%;
  padding: 0.45rem 0.8rem 0.45rem 2rem;
  border-radius: 999px;
  border: 1px solid var(--gold-line);
  background: var(--paper-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%237A7268' stroke-width='1.6'%3E%3Ccircle cx='7' cy='7' r='4.5'/%3E%3Cpath d='M10.5 10.5 14 14'/%3E%3C/svg%3E") 0.7rem center no-repeat;
}
.search-wrap input:focus, .input:focus, .title-input:focus, .body-input:focus, .tags-input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 22%, transparent);
}

.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.18rem;
  border: 1px solid var(--gold-line);
  border-radius: 999px;
  background: var(--paper-2);
}
.tab {
  padding: 0.32rem 0.85rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-soft);
}
.tab.active {
  background: var(--navy);
  color: #fff;
}
[data-theme="night"] .tab.active { background: var(--coral); color: #1C1917; }

.top-actions { display: flex; gap: 0.35rem; }
.icon-btn {
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--gold-line);
  background: var(--paper-2);
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 600;
}
.icon-btn:hover, .btn-ghost:hover { background: color-mix(in srgb, var(--gold) 12%, var(--paper-2)); }
#btn-list-mobile { display: none; }

.shell {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1.25rem;
  padding: 1rem 1.25rem 2rem;
  max-width: 1380px;
  margin: 0 auto;
}
.shell[data-view="links"] {
  grid-template-columns: 1fr;
}
.shell[data-view="links"] .sidebar { display: none; }

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  min-width: 0;
}
.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.list-title {
  margin: 0;
  font-family: var(--font-write);
  font-size: 1.15rem;
  font-weight: 600;
}
.note-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  overflow: auto;
  max-height: calc(100dvh - 11rem);
  padding-right: 0.15rem;
}
.note-item {
  text-align: left;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--gold-line);
  border-radius: 14px;
  background: var(--paper-2);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}
.note-item:hover { background: color-mix(in srgb, var(--gold) 8%, var(--paper-2)); }
.note-item.active {
  border-color: var(--navy);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--navy) 22%, transparent);
}
[data-theme="night"] .note-item.active { border-color: var(--coral); }
.note-item-top {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}
.note-item-top b {
  font-family: var(--font-write);
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.note-pin { color: var(--gold); font-size: 0.85rem; }
.note-item small { color: var(--muted); font-size: 0.72rem; }
.note-preview {
  color: var(--ink-soft);
  font-size: 0.82rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.note-tags { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.chip {
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--teal);
  background: color-mix(in srgb, var(--teal) 12%, transparent);
  padding: 0.08rem 0.4rem;
  border-radius: 999px;
}
.list-empty { color: var(--muted); font-family: var(--font-write); font-style: italic; margin: 0.4rem 0 0; }

.main { min-width: 0; display: flex; flex-direction: column; gap: 0.9rem; }
.day-kicker {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
}
.day-title {
  margin: 0.1rem 0 0;
  font-family: var(--font-write);
  font-weight: 600;
  font-size: 2rem;
  letter-spacing: -0.02em;
}
.panel-kicker {
  margin: 0 0 0.45rem;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
}
.muted { color: var(--muted); font-size: 0.85rem; }

.paper, .editor-card {
  background: var(--paper-2);
  border: 1px solid var(--gold-line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  position: relative;
}
.editor-card {
  padding: 1.1rem 1.25rem 1.2rem;
  background-image:
    linear-gradient(180deg, color-mix(in srgb, var(--gold) 10%, transparent), transparent 42px),
    repeating-linear-gradient(
      transparent,
      transparent calc(1.75rem - 1px),
      color-mix(in srgb, var(--sky) 22%, transparent) calc(1.75rem - 1px),
      color-mix(in srgb, var(--sky) 22%, transparent) 1.75rem
    );
  background-position: 0 5.4rem;
}
.editor-card::before {
  content: "";
  position: absolute; left: 2.4rem; top: 0; bottom: 0; width: 1px;
  background: color-mix(in srgb, var(--coral) 35%, transparent);
  pointer-events: none;
}
.editor-meta { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.6rem; margin-bottom: 0.4rem; }
.editor-kicker {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
}

.save-pill {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  border: 1px solid transparent;
}
.save-pill.saving { color: var(--gold); }
.save-pill.saved { color: var(--teal); }
.save-pill.err { color: var(--danger); }

.title-input {
  width: 100%;
  border: none;
  background: transparent;
  font-family: var(--font-write);
  font-size: 1.55rem;
  font-weight: 600;
  padding: 0.2rem 0 0.5rem 1.5rem;
}
.body-input {
  width: 100%;
  border: none;
  background: transparent;
  font-family: var(--font-write);
  font-size: 1.12rem;
  line-height: 1.75rem;
  padding: 0.15rem 0.4rem 0.8rem 1.5rem;
  resize: vertical;
  min-height: 18rem;
}
.interim {
  margin: 0 0 0.5rem 1.5rem;
  font-family: var(--font-write);
  font-style: italic;
  color: var(--muted);
  min-height: 1.3em;
}

.toolbar {
  display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap;
  padding-top: 0.6rem;
  border-top: 1px solid var(--gold-line);
}
.grow { flex: 1; }
.word-count { font-size: 0.78rem; color: var(--muted); }
.tags-input {
  width: min(220px, 40vw);
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--gold-line);
  background: var(--paper);
  font-size: 0.82rem;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  padding: 0.42rem 0.85rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  border: 1px solid transparent;
}
.btn-coral { background: var(--coral); color: #fff; }
.btn-coral:hover { filter: brightness(1.05); }
.btn-teal { background: var(--teal); color: #fff; }
.btn-ghost { border-color: var(--gold-line); background: var(--paper-2); color: var(--ink-soft); }
.btn-danger { color: var(--danger); }
.btn-dictate {
  background: var(--coral);
  color: #fff;
  padding: 0.55rem 1.1rem;
  font-size: 0.95rem;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--coral) 35%, transparent);
}
.btn-dictate .mic {
  width: 10px; height: 14px; border-radius: 6px;
  background: #fff; display: inline-block; position: relative;
}
.btn-dictate .mic::after {
  content: ""; position: absolute; left: -3px; right: -3px; bottom: -4px;
  border: 2px solid #fff; border-top: none; border-radius: 0 0 8px 8px; height: 6px;
}
.btn-dictate.listening { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--coral) 50%, transparent); }
  50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--coral) 0%, transparent); }
}
.dictate-fallback { margin: 0.35rem 0 0; font-size: 0.8rem; color: var(--muted); }

.empty-state { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty-mark { font-size: 2.2rem; margin: 0; color: var(--gold); }
.empty-state h2 { font-family: var(--font-write); color: var(--ink); font-weight: 500; }

.lock-screen {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  background: var(--paper);
}
.lock-card { width: min(380px, calc(100% - 2rem)); padding: 2rem 1.5rem; text-align: center; }
.lock-card h1 { font-family: var(--font-write); margin: 0; font-size: 2.2rem; }
.lock-sub { letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-size: 0.75rem; }
.lock-sun { color: var(--coral); font-size: 1.6rem; }
.lock-disclaimer { margin: 1.1rem 0 0; font-size: 0.72rem; color: var(--muted); }
.pin-dots { display: flex; justify-content: center; gap: 0.7rem; margin: 0.8rem 0; }
.pin-dots i {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--coral); display: block;
}
.pin-dots i.on { background: var(--coral); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 72px); gap: 0.55rem; justify-content: center; }
.pin-pad button {
  height: 52px; border-radius: 14px;
  background: var(--paper);
  border: 1px solid var(--gold-line);
  font-size: 1.2rem; font-weight: 700;
}
.pin-muted { font-size: 0.78rem !important; color: var(--muted); }
.pin-error { color: var(--danger); min-height: 1.2em; font-size: 0.85rem; }

.scrim { position: fixed; inset: 0; background: rgba(27,54,93,0.35); z-index: 50; }
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal-card {
  width: min(520px, 100%);
  max-height: 90dvh; overflow: auto;
  padding: 1.35rem 1.4rem;
}
.modal-card.slim { width: min(380px, 100%); }
.modal-card h2 { font-family: var(--font-write); margin: 0 0 0.3rem; }
.modal-card h3 { margin: 1.1rem 0 0.4rem; font-size: 0.8rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold); }
.row { display: flex; gap: 0.45rem; flex-wrap: wrap; align-items: center; }
.input {
  padding: 0.45rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--gold-line);
  background: var(--paper);
  width: 9rem;
}
.grow-input { width: auto; flex: 1 1 12rem; min-width: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.4rem; margin-top: 1.1rem; }
.disclaimer-box {
  margin: 0.7rem 0 0;
  padding: 0.7rem 0.85rem;
  border-left: 3px solid var(--coral);
  background: color-mix(in srgb, var(--coral) 10%, transparent);
  border-radius: 0 12px 12px 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.toasts {
  position: fixed; bottom: 2.4rem; left: 50%; transform: translateX(-50%);
  z-index: 90; display: flex; flex-direction: column; gap: 0.4rem;
  width: min(360px, calc(100% - 2rem));
}
.toast {
  background: var(--paper-2);
  border: 1px solid var(--gold-line);
  box-shadow: var(--shadow);
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  font-size: 0.88rem;
}
.toast.err { color: var(--danger); }
.toast.ok { color: var(--teal); }

.todo-card {
  padding: 1.05rem 1.2rem 1.15rem;
  background-image: linear-gradient(180deg, color-mix(in srgb, var(--gold) 10%, transparent), transparent 42px);
}
.todo-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}
.todo-title {
  margin: 0;
  font-family: var(--font-write);
  font-size: 1.45rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.todo-caption {
  margin: 0.15rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  font-style: italic;
  font-family: var(--font-write);
}
.todo-rolled {
  flex: none;
  display: inline-block;
  background: color-mix(in srgb, var(--teal) 16%, var(--paper-2));
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--teal) 28%, transparent);
  white-space: nowrap;
}
.todo-list { list-style: none; margin: 0; padding: 0; }
.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.45rem 0.1rem;
  border-bottom: 1px solid color-mix(in srgb, var(--gold) 22%, transparent);
}
.todo-item:last-child { border-bottom: none; }
.todo-check {
  flex: none;
  width: 22px;
  height: 22px;
  margin-top: 0.18rem;
  accent-color: var(--teal);
  cursor: pointer;
}
.todo-text {
  flex: 1;
  min-width: 0;
  font-family: var(--font-write);
  font-size: 1.05rem;
  line-height: 1.45;
  word-break: break-word;
  background: transparent;
  border: none;
  padding: 0.1rem 0.15rem;
  border-radius: 6px;
}
.todo-text:focus {
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--teal) 28%, transparent);
  background: var(--paper);
}
.todo-item.done .todo-text { color: var(--muted); text-decoration: line-through; }
.todo-del {
  flex: none;
  color: var(--muted);
  opacity: 0.45;
  padding: 0.15rem 0.4rem;
  font-size: 0.95rem;
  border-radius: 8px;
  line-height: 1;
}
.todo-del:hover { opacity: 1; color: var(--danger); background: color-mix(in srgb, var(--coral) 12%, transparent); }
.todo-empty {
  margin: 0.4rem 0 0.7rem;
  color: var(--muted);
  font-family: var(--font-write);
  font-style: italic;
  text-align: center;
  padding: 0.6rem 0.4rem;
}
.todo-add {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.7rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--gold-line);
}
.todo-add input {
  flex: 1 1 12rem;
  min-width: 0;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--gold-line);
  background: var(--paper);
  font-family: var(--font-write);
  font-size: 1.02rem;
}
.todo-add input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 22%, transparent);
}
.todo-add .btn-dictate {
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--coral) 28%, transparent);
}

.links-view { min-width: 0; display: flex; flex-direction: column; gap: 1rem; }
.link-form { padding: 1.05rem 1.2rem 1.15rem; }
.link-form-grid {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}
.links-board { display: flex; flex-direction: column; gap: 1.1rem; }
.folder-block h3 {
  margin: 0 0 0.55rem;
  font-family: var(--font-write);
  font-size: 1.2rem;
  font-weight: 600;
}
.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.7rem;
}
.link-card {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.85rem 0.9rem;
  background: var(--paper-2);
  border: 1px solid var(--gold-line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  text-align: left;
}
.link-card img {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--paper);
  flex: none;
}
.link-card-body { flex: 1; min-width: 0; }
.link-card-body a {
  color: var(--navy);
  font-weight: 700;
  text-decoration: none;
  font-family: var(--font-write);
  font-size: 1.05rem;
}
.link-card-body a:hover { color: var(--teal); }
.link-host { display: block; font-size: 0.72rem; color: var(--muted); margin-top: 0.1rem; word-break: break-all; }
.link-note { margin: 0.25rem 0 0; font-size: 0.82rem; color: var(--ink-soft); }
.link-actions { display: flex; flex-direction: column; gap: 0.2rem; }
.link-actions button {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  padding: 0.15rem 0.35rem;
  border-radius: 8px;
}
.link-actions button:hover { color: var(--navy); background: color-mix(in srgb, var(--gold) 12%, transparent); }
.link-actions .danger:hover { color: var(--danger); }

.site-footer {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 0.4rem 1rem 1.1rem;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--muted);
}

@media (max-width: 960px) {
  #btn-list-mobile { display: inline-flex; }
  .shell { grid-template-columns: 1fr; padding: 0.75rem 0.75rem 4rem; }
  .sidebar {
    position: fixed; z-index: 55; top: var(--top); left: 0; bottom: 0;
    width: min(340px, 92vw); overflow: auto;
    padding: 0.75rem;
    background: var(--paper);
    border-right: 1px solid var(--gold-line);
    transform: translateX(-110%);
    transition: transform 0.22s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .note-list { max-height: none; }
  .clock-digital { display: none; }
  .search-wrap { flex: 1; min-width: 0; }
  .day-title { font-size: 1.45rem; }
  .editor-card::before { left: 1.2rem; }
  .title-input, .body-input, .interim { padding-left: 0.9rem; }
  .brand-text em { display: none; }
  .topbar { flex-wrap: wrap; }
  .link-form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .top-actions .icon-btn { padding: 0.35rem 0.5rem; font-size: 0.72rem; }
  .todo-add input { flex: 1 1 100%; }
  .tabs { order: 5; width: 100%; justify-content: center; }
}

[hidden] { display: none !important; }
