:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --ink: #28243a;
  --ink-soft: #504a63;
  --muted: #827c90;
  --line: #ece9f2;
  --line-strong: #ddd8e8;
  --purple: #7771d7;
  --purple-deep: #5d57bc;
  --purple-soft: #f1efff;
  --purple-soft-2: #e8e5ff;
  --pink: #fff0f6;
  --peach: #fff1e8;
  --sky: #eef7ff;
  --mint: #edf9f5;
  --danger: #b34f69;
  --danger-soft: #fff0f3;
  --shadow-dialog: 0 26px 70px rgba(43, 35, 72, .16);
  --radius: 12px;
  --radius-dialog: 20px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
button, summary { -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; display: block; }
svg { display: block; }

input, textarea, select {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 10px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input, textarea { padding: 10px 12px; }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus {
  border-color: #aaa5ea;
  box-shadow: 0 0 0 3px rgba(119, 113, 215, .11);
}
select {
  min-height: 42px;
  padding: 8px 38px 8px 12px;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--purple) 50%),
    linear-gradient(135deg, var(--purple) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 18px,
    calc(100% - 12px) 18px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.eyebrow {
  margin: 0;
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .12em;
  color: var(--purple);
}
.muted { color: var(--muted); }
.compact { margin: 7px 0 0; }
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Top bar */
.topbar {
  height: 68px;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(260px, 560px) minmax(180px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.96);
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(14px);
}
.brand, .auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  font-weight: 850;
  letter-spacing: -.02em;
}
.brand { font-size: 1.1rem; }
.brand-mark, .auth-mark {
  width: 34px;
  height: 34px;
  display: block;
  object-fit: contain;
  flex: 0 0 auto;
}
.auth-mark { width: 42px; height: 42px; }
.global-search {
  height: 39px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: #faf9fd;
  border-radius: 12px;
  padding: 0 11px;
}
.global-search:focus-within { border-color: #c2bdf1; background: #fff; box-shadow: 0 0 0 3px rgba(119,113,215,.08); }
.global-search svg { width: 17px; height: 17px; fill: none; stroke: var(--muted); stroke-width: 1.8; }
.global-search input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 0; box-shadow: none; }
.search-clear { color: var(--muted); font-size: 1.25rem; line-height: 1; }
.topbar-actions { justify-self: end; display: flex; align-items: center; gap: 14px; }
.review-top-button {
  border: 1px solid #dcd8fb;
  background: var(--purple-soft);
  color: var(--purple-deep);
  border-radius: 10px;
  padding: 7px 13px;
  font-weight: 750;
}
.review-top-button:hover { background: var(--purple-soft-2); }
.avatar-button, .avatar {
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: var(--purple-soft);
  color: var(--purple-deep);
  font-weight: 800;
  flex: 0 0 auto;
}
.avatar-button { width: 37px; height: 37px; border: 1px solid #dcd8fb; padding: 0; }
.avatar-button img, .avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.small { width: 33px; height: 33px; font-size: .8rem; }
.avatar.tiny { width: 30px; height: 30px; font-size: .74rem; }
.everyone-avatar { font-size: 1rem; font-weight: 500; }

/* Main layout */
.nest-layout {
  width: min(1510px, 100%);
  margin: 0 auto;
  padding: 30px 24px 90px;
  display: grid;
  grid-template-columns: 220px minmax(0, 860px);
  gap: clamp(42px, 6vw, 92px);
  justify-content: center;
}
.nest-rail { position: sticky; top: 98px; align-self: start; min-width: 0; }
.rail-heading { margin-bottom: 25px; }
.rail-heading h1 { font-size: 1.45rem; line-height: 1.15; margin: 5px 0 0; letter-spacing: -.03em; }
.people-list { display: grid; gap: 3px; }
.person-filter {
  display: grid;
  grid-template-columns: 30px minmax(0,1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 6px 8px;
  margin-left: -8px;
  border-radius: 11px;
}
.person-filter:hover { background: #faf9fe; }
.person-filter.is-active { background: var(--purple-soft); color: var(--purple-deep); }
.person-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; font-weight: 650; }
.streak { display: inline-flex; align-items: center; gap: 2px; color: #8a82ca; font-size: .75rem; font-variant-numeric: tabular-nums; }
.streak b { font-weight: 750; }
.streak svg { width: 14px; height: 14px; fill: currentColor; }
.rail-tools { margin-top: 27px; padding-top: 16px; border-top: 1px solid var(--line); display: grid; gap: 4px; }
.rail-button {
  border: 0;
  background: transparent;
  border-radius: 9px;
  padding: 8px 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ink-soft);
  text-align: left;
}
.rail-button:hover { background: #faf9fe; color: var(--purple-deep); }
.rail-button b { color: var(--muted); font-size: .75rem; font-weight: 700; }
.feed-column { min-width: 0; width: 100%; }

/* Composer */
.composer { border-bottom: 1px solid var(--line); padding: 4px 0 20px; }
.composer-form { display: grid; gap: 12px; }
.highlight-editor { position: relative; min-width: 0; }
.highlight-mirror,
.highlight-editor textarea {
  width: 100%;
  margin: 0;
  padding: 10px 0;
  border: 0;
  border-radius: 0;
  font: inherit;
  line-height: 1.6;
  letter-spacing: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.highlight-mirror {
  position: absolute;
  inset: 0;
  pointer-events: none;
  color: var(--ink);
  overflow: hidden;
}
.highlight-mirror .live-tag, .highlight-mirror .live-mention { color: var(--purple); font-weight: 700; }
.highlight-editor textarea {
  position: relative;
  z-index: 1;
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--ink);
  resize: none;
  box-shadow: none;
  overflow: hidden;
}
.highlight-editor textarea::placeholder { color: var(--muted); -webkit-text-fill-color: var(--muted); }
.highlight-editor textarea:focus { box-shadow: none; }
.composer-editor textarea, .composer-editor .highlight-mirror { min-height: 58px; font-size: 1.04rem; }
.compact-editor textarea, .compact-editor .highlight-mirror { padding: 9px 11px; border-radius: 10px; min-height: 66px; }
.compact-editor { border: 1px solid var(--line-strong); border-radius: 10px; }
.compact-editor:focus-within { border-color: #aaa5ea; box-shadow: 0 0 0 3px rgba(119,113,215,.08); }
.composer-extra { display: grid; gap: 11px; }
.composer-media-row { display: flex; align-items: center; gap: 11px; min-height: 38px; }
.composer-image-strip { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; }
.image-previews { display: contents; }
.image-add-button, .image-preview {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 9px;
}
.image-add-button {
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--purple);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.image-add-button:hover { border-color: #bdb7ef; background: var(--purple-soft); transform: translateY(-1px); }
.image-add-button:focus-within { outline: 3px solid rgba(119,113,215,.12); outline-offset: 1px; }
.image-add-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.image-add-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.image-add-plus { display: none; font-size: 1.35rem; font-weight: 500; line-height: 1; transform: translateY(-1px); }
.image-add-button.has-images .image-add-icon { display: none; }
.image-add-button.has-images .image-add-plus { display: block; }
.image-preview {
  position: relative;
  overflow: visible;
  border: 1px solid #dedaf4;
  background: #f7f6fb;
}
.image-preview img { width: 100%; height: 100%; display: block; object-fit: cover; border-radius: 8px; }
.image-preview-remove {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #d6d1ee;
  border-radius: 50%;
  background: #fff;
  color: #6b668b;
  font-size: 12px;
  line-height: 1;
  opacity: 0;
  transition: opacity .12s ease, transform .12s ease;
}
.image-preview:hover .image-preview-remove, .image-preview-remove:focus-visible { opacity: 1; }
.image-preview-remove:hover { color: var(--danger); transform: scale(1.07); }
.composer-submit { margin-left: auto; }

/* Filters + feed */
.active-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 16px 0 4px; }
.filter-chip { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 9px; background: var(--purple-soft); color: var(--purple-deep); font-size: .82rem; font-weight: 700; }
.entry { padding: 25px 0 22px; border-bottom: 1px solid var(--line); }
.entry-header { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 11px; }
.entry-person { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.entry-person strong { font-size: .94rem; }
.entry-meta { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; color: var(--muted); font-size: .78rem; }
.entry-body { font-size: 1rem; line-height: 1.63; word-break: break-word; }
.inline-tag, .inline-mention { color: var(--purple); font-weight: 700; }
.inline-tag:hover, .inline-mention:hover, .plain-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.plain-link { color: #5f5aa4; overflow-wrap: anywhere; text-decoration: underline; text-decoration-color: #cdc9ec; text-underline-offset: 3px; }
.entry-images { margin-top: 14px; display: grid; gap: 7px; width: min(520px, 100%); }
.entry-images.images-1 { grid-template-columns: minmax(0, 420px); }
.entry-images.images-2, .entry-images.images-3, .entry-images.images-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.entry-image-button { border: 0; padding: 0; background: #f5f4f8; border-radius: 10px; overflow: hidden; aspect-ratio: 4 / 3; }
.entry-image-button img { width: 100%; height: 100%; object-fit: cover; transition: transform .18s ease; }
.entry-image-button:hover img { transform: scale(1.015); }
.reply-preview { margin: 15px 0 4px 40px; padding-left: 13px; border-left: 2px solid #dedaf8; color: var(--ink-soft); font-size: .91rem; }
.reply-preview strong { margin-right: 7px; color: var(--ink); }
.subtle-button { margin: 8px 0 0 40px; border: 0; background: none; padding: 2px 0; color: var(--muted); font-size: .84rem; }
.subtle-button:hover { color: var(--purple-deep); }
.entry-actions, .reply-actions, .review-toolbar, .account-actions, .form-actions { display: flex; align-items: center; gap: 13px; flex-wrap: wrap; }
.entry-actions { margin-top: 13px; }
.entry-actions form, .reply-actions form, .review-toolbar form, .account-actions form { display: contents; }
.text-action, .text-button { border: 0; background: none; padding: 0; color: var(--muted); font-size: .85rem; }
.text-action:hover, .text-button:hover { color: var(--purple-deep); }
.text-action.is-active { color: var(--purple); font-weight: 700; }
.passive-action { cursor: default; color: var(--purple); }
.danger { color: var(--danger) !important; }
.inline-reply-form { margin: 13px 0 0 40px; }
.inline-reply-form > div:last-child { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.replies-container { margin: 12px 0 0 40px; padding-left: 13px; border-left: 2px solid #dedaf8; }
.reply-row { padding: 12px 0; border-bottom: 1px solid #f0eef5; }
.reply-row:last-child { border-bottom: 0; }
.reply-head { display: flex; gap: 7px; align-items: baseline; color: var(--muted); font-size: .77rem; }
.reply-head strong { color: var(--ink); font-size: .88rem; }
.reply-body { margin-top: 3px; font-size: .94rem; line-height: 1.55; }
.reply-actions { gap: 10px; margin-top: 6px; }
.review-progress-entry { border-left: 3px solid var(--purple); padding: 3px 0 3px 14px; }
.review-progress-entry h3 { margin: 3px 0 10px; }
.progress-grid, .review-counts { display: flex; gap: 18px; flex-wrap: wrap; }
.progress-grid span, .review-counts span { display: grid; }
.progress-grid b, .review-counts b { font-size: 1.12rem; }
.archive-break, .empty-state { padding: 44px 0; text-align: center; color: var(--muted); }
.feed-sentinel { padding: 34px 0; text-align: center; color: var(--muted); }

/* Menus */
.action-menu { position: relative; margin-left: auto; }
.action-menu > summary { list-style: none; cursor: pointer; color: var(--muted); letter-spacing: .08em; line-height: 1; padding: 4px 5px; border-radius: 7px; }
.action-menu > summary::-webkit-details-marker { display: none; }
.action-menu > summary:hover { background: var(--purple-soft); color: var(--purple); }
.action-menu-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 5px);
  z-index: 15;
  min-width: 132px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(45, 37, 72, .12);
}
.action-menu-popover button, .action-menu-popover form button { width: 100%; border: 0; background: transparent; border-radius: 7px; padding: 8px 9px; text-align: left; font-size: .85rem; }
.action-menu-popover button:hover { background: #f7f5ff; }
.root-menu { margin-left: auto; }
.reply-menu { margin-left: 2px; }

/* Buttons */
.primary-button, .secondary-button, .danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 39px;
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 750;
  border: 1px solid transparent;
}
.primary-button { background: var(--purple); color: #fff; border-color: var(--purple); }
.primary-button:hover { background: var(--purple-deep); border-color: var(--purple-deep); }
.secondary-button { background: #fff; color: var(--ink-soft); border-color: var(--line-strong); }
.secondary-button:hover { border-color: #c9c4ef; color: var(--purple-deep); background: #fbfaff; }
.danger-button { background: var(--danger); color: #fff; border-color: var(--danger); }
.small-button { min-height: 32px; padding: 5px 10px; font-size: .84rem; }

/* Dialogs */
.sheet-dialog, .confirm-dialog, .image-viewer-dialog {
  border: 0;
  padding: 0;
  background: transparent;
}
.sheet-dialog { width: min(570px, calc(100vw - 28px)); max-height: min(88vh, 840px); }
.sheet-dialog.wide { width: min(860px, calc(100vw - 28px)); }
.sheet-dialog.extra-wide { width: min(1040px, calc(100vw - 28px)); }
.sheet-dialog::backdrop, .confirm-dialog::backdrop { background: rgba(45, 39, 66, .26); backdrop-filter: blur(3px); }
.study-dialog::backdrop { background: rgba(39, 32, 62, .42); backdrop-filter: blur(12px) saturate(.8); }
.dialog-panel, .confirm-panel {
  background: #fff;
  border: 1px solid #e4e0ec;
  border-radius: var(--radius-dialog);
  padding: 23px;
  max-height: 88vh;
  overflow: auto;
  box-shadow: var(--shadow-dialog);
}
.dialog-header { display: flex; align-items: start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.dialog-header h2 { margin: 2px 0 0; font-size: 1.35rem; letter-spacing: -.025em; }
.dialog-header small { color: var(--muted); }
.icon-button { border: 0; background: #f7f5fb; color: var(--muted); width: 32px; height: 32px; border-radius: 50%; font-size: 1.25rem; line-height: 1; display: grid; place-items: center; }
.icon-button:hover { background: var(--purple-soft); color: var(--purple-deep); }
.stack-form { display: grid; gap: 14px; }
.stack-form label { display: grid; gap: 6px; font-weight: 700; font-size: .87rem; }
.stack-form label input, .stack-form label textarea, .stack-form label select { font-weight: 400; width: 100%; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-choice { background: var(--purple-soft); padding: 6px 9px; border-radius: 999px; }
.tag-choice small { color: #7670aa; margin-left: 3px; }
.reference-list { display: grid; }
.reference-list a { display: grid; gap: 2px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.reference-list a:hover strong { color: var(--purple-deep); }
.reference-list a:last-child { border-bottom: 0; }
.reference-list span, .reference-list small { color: var(--muted); }
.reference-list small { font-size: .74rem; }

/* Review */
.review-panel-shell { min-height: 560px; }
.review-filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.review-filter-row label { display: grid; gap: 5px; font-size: .8rem; font-weight: 750; }
.review-toolbar { padding: 15px 0; border-bottom: 1px solid var(--line); }
.review-counts { padding: 16px 0 13px; }
.review-counts span { min-width: 110px; color: var(--muted); font-size: .8rem; }
.review-counts b { color: var(--ink); }
.review-list-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: .78rem; padding: 9px 0 12px; }
.review-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.review-card { border: 1px solid var(--line); border-radius: 13px; padding: 13px; min-width: 0; background: #fff; }
.review-card:hover { border-color: #d8d3ef; }
.review-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.review-card-head > div { min-width: 0; display: grid; }
.review-card-head strong { font-size: 1.02rem; line-height: 1.25; }
.review-detail { color: var(--purple); font-size: .84rem; font-weight: 650; margin-top: 2px; }
.review-context { margin: 8px 0 8px; color: var(--ink-soft); font-size: .88rem; line-height: 1.45; }
.review-card small { color: var(--muted); font-size: .72rem; }
.review-state-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 11px; }
.review-state-strip form { display: contents; }
.state-dot { min-height: 31px; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 4px 5px; font-size: .68rem; color: var(--muted); }
.state-dot.is-selected { font-weight: 750; color: var(--ink); }
.state-needs_attention.is-selected { background: var(--peach); border-color: #f0cdbc; color: #865647; }
.state-active.is-selected { background: var(--sky); border-color: #c8deef; color: #4f6e86; }
.state-confident.is-selected { background: var(--purple-soft); border-color: #d4d0f6; color: var(--purple-deep); }
.archived-label { display: inline-flex; margin-top: 11px; border-radius: 999px; background: #f3f2f5; color: var(--muted); padding: 4px 8px; font-size: .72rem; font-weight: 700; }
.review-empty { grid-column: 1 / -1; }
.review-pagination { display: flex; align-items: center; justify-content: center; gap: 13px; margin-top: 17px; }
.review-pagination span { color: var(--muted); font-size: .8rem; }
.collection-list > div { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.collection-list > div:last-child { border-bottom: 0; }
.collection-list span { display: grid; gap: 2px; }
.collection-list small { color: var(--muted); }

/* Study / review session */
.review-session-panel { overflow: visible; }
.review-session-header { margin-bottom: 7px; }
.review-session-title { display: flex; align-items: center; gap: 13px; padding: 24px 0 6px; }
.review-session-title h3 { margin: 0; font-size: clamp(2rem, 6vw, 3.5rem); line-height: 1.08; letter-spacing: -.035em; }
.review-session-collection { margin: 0 0 22px; color: var(--muted); }
.tts-button { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid #d7d3ef; border-radius: 50%; background: var(--purple-soft); color: var(--purple-deep); }
.tts-button:hover, .tts-button[aria-pressed="true"] { background: var(--purple-soft-2); }
.tts-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.review-reveal { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 14px 0; margin: 10px 0 24px; }
.review-reveal summary { cursor: pointer; color: var(--purple); font-weight: 750; }
.review-reveal-body { display: grid; gap: 10px; padding: 16px 0 3px; }
.review-reveal-body section { background: #faf9ff; border-left: 3px solid #d6d1fa; padding: 11px 13px; border-radius: 0 10px 10px 0; }
.review-reveal-body p { margin: 4px 0 0; }
.review-session-prompt { margin: 0 0 10px; font-weight: 750; }
.review-state-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.review-state-actions form { display: contents; }
.review-state-button { min-height: 46px; border: 1px solid var(--line); border-radius: 10px; font-weight: 750; }
.review-state-button.state-needs_attention { background: var(--peach); border-color: #efcfbf; color: #805445; }
.review-state-button.state-active { background: var(--sky); border-color: #c9deed; color: #4e6b80; }
.review-state-button.state-confident { background: var(--purple-soft); border-color: #d2cef4; color: var(--purple-deep); }
.result-panel { text-align: center; }
.result-panel h2 { font-size: 3rem; margin: 8px 0; color: var(--purple-deep); }
.result-panel .review-toolbar { justify-content: center; border: 0; }

/* Quiz */
.continue-quiz-card { padding: 18px; border-radius: 14px; background: var(--purple-soft); border: 1px solid #ddd8fb; }
.continue-quiz-card h3 { margin: 4px 0 5px; }
.quiz-header { position: sticky; top: -23px; background: #fff; z-index: 4; padding: 4px 0 14px; border-bottom: 1px solid var(--line); }
.quiz-question { border: 0; padding: 22px 0; margin: 0; border-bottom: 1px solid var(--line); }
.quiz-question legend { font-weight: 780; font-size: 1.05rem; line-height: 1.45; }
.quiz-question legend span { color: var(--purple); margin-right: 4px; }
.quiz-direction { margin: 5px 0 10px; color: var(--muted); font-size: .73rem; font-weight: 750; text-transform: uppercase; letter-spacing: .08em; }
.quiz-options { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.quiz-option { display: flex; align-items: flex-start; gap: 9px; min-height: 48px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 11px; cursor: pointer; }
.quiz-option:hover { border-color: #cfcaf1; background: #fbfaff; }
.quiz-option:has(input:checked) { border-color: #aaa5ea; background: var(--purple-soft); }
.quiz-option input { margin-top: 3px; accent-color: var(--purple); }
.quiz-footer { display: flex; justify-content: flex-end; padding-top: 20px; }

/* Account */
.account-panel { display: grid; gap: 18px; }
.account-profile-form { gap: 16px; }
.account-profile-form > label { min-width: 0; }
.profile-avatar-row { display: flex; align-items: center; gap: 14px; padding: 2px 0; }
.profile-avatar-preview { width: 46px; height: 46px; flex: 0 0 46px; }
.profile-avatar-copy { display: grid; gap: 7px; min-width: 0; }
.profile-avatar-picker { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.field-label { font-size: .88rem; font-weight: 650; color: var(--ink); }
.profile-save-row { display: flex; justify-content: flex-end; padding-top: 2px; }
.account-actions { border-top: 1px solid var(--line); padding-top: 15px; justify-content: space-between; }

/* Image viewer + confirmation */
.image-viewer-dialog { width: min(1100px, calc(100vw - 26px)); max-height: calc(100vh - 26px); }
.image-viewer-dialog::backdrop { background: rgba(22, 19, 31, .86); backdrop-filter: blur(6px); }
.image-viewer-dialog img { max-width: 100%; max-height: calc(100vh - 34px); margin: auto; object-fit: contain; border-radius: 8px; }
.image-viewer-close { position: fixed; top: 16px; right: 18px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(255,255,255,.14); color: #fff; font-size: 1.45rem; z-index: 2; }
.confirm-dialog { width: min(430px, calc(100vw - 28px)); }
.confirm-panel h2 { margin: 0 0 7px; font-size: 1.2rem; }
.confirm-panel p { color: var(--muted); margin: 0 0 20px; }
.confirm-panel .form-actions { justify-content: flex-end; }

/* Auth */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: #fff; }
.auth-panel { width: min(430px, 100%); }
.auth-brand { margin-bottom: 34px; font-size: 1.12rem; }
.auth-panel h1 { margin: 5px 0 6px; font-size: 2.5rem; line-height: 1.05; letter-spacing: -.045em; }
.auth-panel > .muted { margin: 0 0 25px; }
.auth-form { margin-top: 22px; }
.password-field {
  position: relative;
  display: block;
}
.password-field input {
  width: 100%;
  padding-right: 46px;
}
.password-toggle {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}
.password-toggle:hover, .password-toggle:focus-visible {
  background: var(--purple-soft);
  color: var(--purple-deep);
  outline: none;
}
.password-eye {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.password-eye-hide { display: none; }
.password-toggle[aria-pressed="true"] .password-eye-show { display: none; }
.password-toggle[aria-pressed="true"] .password-eye-hide { display: block; }

.forced-password-exit { margin-top: 16px; }

/* Feedback */
.flash-stack, .toast-stack { position: fixed; right: 20px; top: 82px; z-index: 120; width: min(360px, calc(100vw - 40px)); display: grid; gap: 8px; }
.flash, .toast { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 11px 13px; box-shadow: 0 10px 28px rgba(45,37,72,.1); font-size: .88rem; }
.flash.success, .toast.success { border-color: #cfe9df; background: #f7fffb; }
.flash.error, .toast.error { border-color: #f0ccd6; background: #fff8fa; color: #8c4055; }
.toast { animation: toast-in .18s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-5px); } }

@media (max-width: 900px) {
  .topbar { grid-template-columns: auto minmax(180px,1fr) auto; gap: 14px; padding: 0 18px; }
  .brand span { display: none; }
  .nest-layout { grid-template-columns: 190px minmax(0,1fr); gap: 34px; padding-left: 18px; padding-right: 18px; }
}

@media (max-width: 720px) {
  .topbar { height: auto; min-height: 64px; grid-template-columns: auto 1fr auto; padding: 10px 14px; }
  .global-search { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .nest-layout { display: block; padding: 19px 14px 70px; }
  .nest-rail { position: static; display: grid; grid-template-columns: auto 1fr; gap: 11px; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 13px; margin-bottom: 4px; }
  .rail-heading { margin: 0; }
  .rail-heading h1 { font-size: 1.05rem; margin-top: 2px; }
  .rail-heading .eyebrow { display: none; }
  .people-list { display: flex; overflow-x: auto; gap: 5px; justify-self: end; max-width: 100%; }
  .person-filter { grid-template-columns: 30px; padding: 5px; margin: 0; }
  .person-label, .streak { display: none; }
  .rail-tools { grid-column: 1 / -1; display: flex; gap: 6px; margin: 0; padding: 0; border: 0; }
  .rail-button { border: 1px solid var(--line); padding: 5px 9px; font-size: .8rem; }
  .rail-button b { margin-left: 5px; }
  .reply-preview, .replies-container, .inline-reply-form, .subtle-button { margin-left: 24px; }
  .review-card-grid { grid-template-columns: 1fr; }
  .review-filter-row { grid-template-columns: 1fr; }
  .quiz-options { grid-template-columns: 1fr; }
  .entry-images { width: 100%; }
}

@media (max-width: 500px) {
  .topbar-actions { gap: 8px; }
  .review-top-button { padding: 6px 10px; }
  .entry { padding-top: 21px; }
  .entry-time { font-size: .72rem; }
  .entry-images.images-3, .entry-images.images-4 { grid-template-columns: repeat(2, 1fr); }
  .review-state-actions { grid-template-columns: 1fr; }
  .review-session-title h3 { font-size: 2.2rem; }
  .dialog-panel { padding: 18px; }
  .sheet-dialog { width: calc(100vw - 18px); }
  .composer-media-row { align-items: flex-start; flex-wrap: wrap; }
  .composer-submit { margin-left: auto; }
}
.image-add-button[hidden] { display: none; }
