/* Clarity Atlas web reader — brand palette, read-only, no inline styles
   (the CSP forbids them). Dark near-black + gold, matching the app. */

:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel2: #1e222b;
  --ink: #f7f7f5;
  --muted: #9aa1ac;
  --gold: #8a6e33;
  --gold-lite: #c8a15a;
  --line: #2a2f3a;
  --warn: #e0b341;
  --err: #ef6b6b;
  --radius: 12px;
  --maxw: 1100px;
}

* {
  box-sizing: border-box;
}

/* THE FIX for the dead search filter (V3): author `display:` rules (e.g.
   .noteitem { display: block }) silently beat the browser's built-in
   [hidden] { display: none }, so JS setting el.hidden visually did nothing.
   Reassert it with !important so `hidden` always means hidden. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

#app {
  min-height: 100%;
}

/* ---- centered cards (link / unlock) ---- */

.card {
  max-width: 560px;
  margin: 8vh auto;
  padding: 32px 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* ---- brand mark (V3) ---- */

.cardbrand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
}
.cardlogo {
  width: 44px;
  height: 44px;
  display: block;
}
.brandname {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 24px;
  letter-spacing: 0.04em;
  color: var(--gold-lite);
}
.barlogo {
  width: 28px;
  height: 28px;
  display: block;
}

h1 {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 26px;
  margin: 0 0 12px;
}

.lede {
  color: var(--muted);
  margin: 0 0 20px;
}

.steps {
  color: var(--ink);
  padding-left: 20px;
  margin: 0 0 22px;
}
.steps li {
  margin: 6px 0;
}

form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

input[type='text'],
input[type='password'] {
  width: 100%;
  padding: 13px 14px;
  font-size: 18px;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
input[type='text'] {
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
input:focus {
  outline: 2px solid var(--gold-lite);
  border-color: transparent;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

button.primary {
  background: var(--gold);
  color: #fff;
  border: none;
  padding: 12px 18px;
  font-size: 16px;
  border-radius: 10px;
  cursor: pointer;
}
button.primary:hover {
  background: var(--gold-lite);
}
button.primary:disabled {
  opacity: 0.6;
  cursor: default;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  margin: -4px 0 0;
}
.foot {
  color: var(--muted);
  font-size: 13px;
  margin: 22px 0 0;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
.error {
  color: var(--err);
  font-size: 14px;
  margin: 0;
  min-height: 1.2em;
}
.linklike {
  color: var(--gold-lite);
  cursor: pointer;
  text-decoration: underline;
}

/* ---- reader ---- */

.reader {
  /* Full-bleed like the app window — no floating column. */
  max-width: none;
  margin: 0;
  /* Fixed to the viewport (not min-height): the page itself never scrolls —
   * the note list and the note view each scroll on their own. */
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  /* The app's sidebar color — the dark chrome over the light workspace. */
  background: #0F1115;
  border-bottom: 1px solid var(--line);
}
.bar .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: Georgia, serif;
  letter-spacing: 0.12em;
  font-size: 18px;
  color: var(--gold-lite);
}
.bar .spacer {
  flex: 1;
}
button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
button.ghost:hover {
  color: var(--ink);
  border-color: var(--gold);
}

/* ---- reader: the APP's look (V4) ------------------------------------------
   The link/unlock cards keep the dark branded style, but once you're reading,
   this mirrors the Windows app: dark #0F1115 chrome (its sidebar color) over
   a warm #F7F7F5 workspace, white cards with #e2e8f0 borders, gold #8A6E33
   accents, cream #F3EDDE hovers — values lifted verbatim from
   packages/ui/src/styles.css so the two stay visually identical. */

.reader {
  --app-bg: #F7F7F5;
  --app-card: #ffffff;
  --app-line: #e2e8f0;
  --app-ink: #0F1115;
  --app-slate: #64748b;
  --app-meta: #94a3b8;
  --app-gold: #8A6E33;
  --app-gold-border: #D9C48F;
  --app-cream: #F3EDDE;
  background: var(--app-bg);
  color: var(--app-ink);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
}

.banner {
  margin: 0;
  padding: 9px 16px;
  font-size: 12.5px;
  color: var(--app-slate);
  background: #FBF9F2;
  border-bottom: 1px solid var(--app-line);
}
.banner.warn {
  color: #92400e;
  background: #fef3c7;
}
.banner.nudge {
  color: #23262B;
  background: var(--app-cream);
}
.banner.nudge .linklike {
  color: var(--app-gold);
  margin-left: 6px;
}

.panes {
  flex: 1;
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 0;
}
.notelist {
  border-right: 1px solid var(--app-line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--app-bg);
}

/* Pinned search: fixed at the top of the pane; only the items below scroll. */
.notesearch {
  padding: 10px;
  border-bottom: 1px solid var(--app-line);
  background: var(--app-bg);
  flex-shrink: 0;
}
.notesearch input {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  color: var(--app-ink);
  background: var(--app-card);
  border: 1px solid var(--app-line);
  border-radius: 8px;
}
.notesearch input:focus {
  outline: 2px solid var(--app-gold-border);
  border-color: transparent;
}
.searchstatus {
  margin: 6px 2px 0;
  font-size: 12px;
  color: var(--app-meta);
}

.noteitems {
  overflow-y: auto;
  padding: 10px;
  flex: 1;
  min-height: 0;
}

/* Breadcrumb — same as the app's Browse screen. */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.crumb {
  background: none;
  border: none;
  color: var(--app-slate);
  font-size: 13px;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 6px;
  font-family: inherit;
}
.crumb:hover {
  background: var(--app-cream);
  color: var(--app-gold);
}
.crumb.active {
  color: var(--app-ink);
  font-weight: 600;
}
.crumb-sep {
  color: #cbd5e1;
  font-size: 12px;
}

/* Folder chips — same as the app. */
.folder-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.folder-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.folder-chip {
  flex: 1;
  min-width: 0;
  text-align: left;
  background: var(--app-card);
  border: 1px solid var(--app-line);
  border-radius: 9px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  color: #23262B;
  font-family: inherit;
}
.folder-chip:hover {
  border-color: var(--app-gold-border);
  background: var(--app-cream);
}
.count {
  color: var(--app-meta);
  font-weight: 400;
}

/* Note cards — same as the app's Browse list. */
.note-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--app-card);
  border: 1px solid var(--app-line);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  color: var(--app-ink);
  font-family: inherit;
  font-size: inherit;
  margin-bottom: 10px;
}
.note-card:hover {
  border-color: var(--app-gold-border);
  box-shadow: 0 1px 4px rgba(200, 161, 90, 0.18);
}
.note-card.active {
  border-color: var(--app-gold-border);
  box-shadow: inset 3px 0 0 var(--app-gold);
}
.note-card-title {
  font-weight: 600;
  font-size: 14.5px;
}
.note-card-meta {
  color: var(--app-meta);
  font-size: 12px;
  margin-top: 4px;
}

/* Note view — the app's NoteView: title, meta row, then the note text in its
   own defined field (.note-body, the white card). */
.noteview {
  padding: 24px 28px;
  overflow-y: auto;
  background: var(--app-bg);
}
.noteview h2 {
  margin: 0 0 6px;
  font-size: 22px;
  max-width: 760px;
}
.note-meta {
  color: var(--app-meta);
  font-size: 12.5px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.tag {
  background: var(--app-cream);
  color: var(--app-gold);
  border-radius: 5px;
  padding: 1px 7px;
  font-size: 11.5px;
}
.note-body {
  background: var(--app-card);
  border: 1px solid var(--app-line);
  border-radius: 10px;
  padding: 20px 22px;
  line-height: 1.65;
  max-width: 760px;
  word-wrap: break-word;
}
.note-body a {
  color: var(--app-gold);
}
.note-body mark {
  background: #fef08a;
  border-radius: 3px;
  padding: 0 2px;
}
.empty,
.loading {
  color: var(--app-slate);
}

/* ---- attachments (V2: decrypted in-browser, shown via blob: URLs) ---- */

.attach-photo {
  margin: 14px 0;
}
.attach-photo img {
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--app-line);
}

.attach-audio,
.attach-file {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 10px 0;
  padding: 10px 14px;
  background: var(--app-bg);
  border: 1px solid var(--app-line);
  border-radius: 10px;
}
.attach-name {
  color: var(--app-ink);
  font-size: 14px;
  word-break: break-all;
}
.attach-audio audio {
  flex: 1;
  min-width: 200px;
  height: 36px;
}
.attach-file .ghost {
  color: var(--app-gold);
  border-color: var(--app-line);
}
.attach-file .ghost:hover {
  border-color: var(--app-gold-border);
  color: var(--app-gold);
}
.noteview .hint {
  color: var(--app-slate);
  font-size: 13px;
  margin: 18px 0 0;
  max-width: 760px;
}
.noteview .error {
  color: #b91c1c;
}

@media (max-width: 720px) {
  .panes {
    grid-template-columns: 1fr;
  }
  .notelist {
    border-right: none;
    border-bottom: 1px solid var(--app-line);
    max-height: 38vh;
  }
}
