/* ============================================================
   ROOT PALETTE
============================================================ */
:root {
  --charcoal: #696969;
  --steel: #4682b4;
  --midgray: #808080;
  --softgray: #a9a9a9;
  --offwhite: #ececec;

  --bg: var(--offwhite);
  --panel: #ffffff;
  --card-bg: #ffffff;
  --input-bg: #ffffff;
  --text: #222;
  --text-soft: #333;
  --accent: var(--steel);
  --danger: #c0392b;
  --ok: #27ae60;
  --hover-bg: rgba(70, 130, 180, 0.12);
  --focus-ring: rgba(70, 130, 180, 0.2);
  --header-grad-1: rgba(70, 130, 180, 0.08);
  --header-grad-2: rgba(105, 105, 105, 0.05);
  --chip-hover-bg: rgba(0, 0, 0, 0.04);
  --row-border: rgba(0, 0, 0, 0.1);
  --active-chip-bg: rgba(255, 255, 255, 0.3);
  --overlay: rgba(0, 0, 0, 0.55);
  --radius: 10px;
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
  --shadow-strong: 0 10px 30px rgba(0, 0, 0, 0.12);
  color-scheme: light;
}

[data-theme="dark"] {
  --charcoal: #d0d4da;
  --steel: #5f9fd6;
  --midgray: #9aa1ab;
  --softgray: #3d424c;
  --offwhite: #333943;

  --bg: #1b1e24;
  --panel: #242830;
  --card-bg: #262b34;
  --input-bg: #1b1e24;
  --text: #e6e8ec;
  --text-soft: #c3c7cf;
  --accent: var(--steel);
  --danger: #e5523f;
  --ok: #27ae60;
  --hover-bg: rgba(95, 159, 214, 0.18);
  --focus-ring: rgba(95, 159, 214, 0.35);
  --header-grad-1: rgba(95, 159, 214, 0.1);
  --header-grad-2: rgba(105, 105, 105, 0.08);
  --chip-hover-bg: rgba(255, 255, 255, 0.06);
  --row-border: rgba(255, 255, 255, 0.08);
  --active-chip-bg: rgba(255, 255, 255, 0.25);
  --overlay: rgba(0, 0, 0, 0.7);
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  --shadow-strong: 0 10px 30px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

/* ============================================================
   GLOBAL RESET
============================================================ */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 24px;
  background: var(--bg);
  font-family: Inter, system-ui, sans-serif;
  color: var(--text);
  line-height: 1.45;
}

/* ============================================================
   HEADERS & NAVIGATION
============================================================ */
header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  background: linear-gradient(
    90deg,
    var(--header-grad-1),
    var(--header-grad-2)
  );
  padding: 14px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

#addNoteBtn {
  margin-left: auto;
}

header h1 {
  margin: 0;
  color: var(--charcoal);
}

header a {
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
  color: var(--charcoal);
  transition: 0.18s ease;
}

header a:hover {
  background: var(--hover-bg);
  color: var(--steel);
}

header a.active,
.nav-more.has-active .nav-more-toggle {
  background: var(--steel);
  color: #fff;
}

.nav-more {
  position: relative;
}

.nav-more-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--charcoal);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: 0.18s ease;
}

.nav-more-toggle::after {
  content: "▾";
  font-size: 0.75em;
  transition: transform 0.18s ease;
}

.nav-more.open .nav-more-toggle::after {
  transform: rotate(180deg);
}

.nav-more-toggle:hover {
  background: var(--hover-bg);
  color: var(--steel);
}

.nav-more.open .nav-more-toggle {
  background: var(--hover-bg);
  color: var(--steel);
}

.nav-more-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  flex-direction: column;
  gap: 2px;
  min-width: 180px;
  padding: 6px;
  background: var(--card-bg);
  border: 1px solid var(--softgray);
  border-radius: 10px;
  box-shadow: var(--shadow-strong);
  z-index: 300;
}

.nav-more.open .nav-more-menu {
  display: flex;
}

.nav-more-menu a {
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--charcoal);
}

.nav-more-menu a.active {
  background: var(--steel);
  color: #fff;
}

.nav-more-menu a:hover {
  background: var(--hover-bg);
  color: var(--steel);
}

.nav-more-menu .nav-settings-btn {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--charcoal);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: 0.18s ease;
}

.nav-more-menu .nav-settings-btn:hover {
  background: var(--hover-bg);
  color: var(--steel);
}

/* ============================================================
   LINKS
============================================================ */
a {
  color: var(--steel);
  font-weight: 600;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ============================================================
   FORMS (Signup, Login, Note Form)
============================================================ */
form {
  background: var(--panel);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 500px;
  margin-bottom: 20px;
}

form input,
form textarea {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--softgray);
  margin-bottom: 12px;
  font-size: 1rem;
  background: var(--input-bg);
  transition: 0.15s ease;
}

form input:focus,
form textarea:focus {
  border-color: var(--steel);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* ============================================================
   AUTH PAGES (login / signup)
============================================================ */
body.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

body.auth-page .auth-card {
  margin: auto;
  width: 100%;
  max-width: 620px;
  background: var(--panel);
  padding: 40px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

body.auth-page .auth-card form {
  background: none;
  box-shadow: none;
  padding: 0;
  margin: 0;
  max-width: none;
}

body.auth-page form input {
  padding: 16px;
  font-size: 1.1rem;
}

body.auth-page form button {
  width: 100%;
  padding: 16px;
  font-size: 1.1rem;
}

body.auth-page .auth-card a {
  display: block;
  text-align: center;
  margin-top: 12px;
  color: var(--steel);
}

/* ============================================================
   BUTTONS
============================================================ */
button {
  padding: 10px 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: 700;
  background: var(--steel);
  color: #fff;
  box-shadow: var(--shadow);
  transition: 0.15s ease;
}

button:hover {
  transform: translateY(-2px);
  opacity: 0.95;
}

button.danger,
#resetDbBtn {
  background: var(--danger) !important;
  color: #fff !important;
}

/* ============================================================
   NOTES VIEW (Home + All Notes)
============================================================ */
.notes-toolbar {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 18px;
}

.toolbar-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.notes-search {
  flex: 1;
  min-width: 200px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--softgray);
  background: var(--input-bg);
  font-size: 0.95rem;
}

.notes-search:focus {
  border-color: var(--steel);
  box-shadow: 0 0 0 3px var(--focus-ring);
  outline: none;
}

.notes-select {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--softgray);
  background: var(--input-bg);
  font-size: 0.95rem;
  cursor: pointer;
}

.toolbar-clear {
  background: transparent;
  color: var(--steel);
  border: 1px solid var(--steel);
  box-shadow: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
}

.toolbar-clear:hover {
  background: var(--hover-bg);
  transform: none;
  opacity: 1;
}

.toolbar-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.chip-subject {
  background: transparent;
  border: 1px solid var(--softgray);
  color: var(--charcoal);
  cursor: pointer;
  box-shadow: none;
}

.chip-subject::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--chip-color, var(--softgray));
}

[data-theme="dark"] .chip-subject::before {
  filter: brightness(1.35);
}

.chip-subject:hover {
  background: var(--chip-hover-bg);
  transform: none;
  opacity: 1;
}

.chip-subject.active {
  background: var(--steel);
  color: #fff;
  border-color: var(--steel);
}

.chip-subject.active::before {
  background: #fff;
}

.chip-count {
  background: var(--offwhite);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.75rem;
}

.chip-subject.active .chip-count {
  background: var(--active-chip-bg);
}

.chip-category {
  background: var(--offwhite);
  color: var(--midgray);
}

.chip-category::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--cat-accent, var(--softgray));
}

[data-theme="dark"] .chip-category::before {
  filter: brightness(1.35);
}

.note-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

/* ============================================================
   CATEGORY SECTIONS
============================================================ */
.category-section {
  margin-bottom: 10px;
}

.category-section.collapsed .note-grid {
  display: none;
}

.category-header {
  margin: 0 0 10px 0;
  padding: 8px 10px;
  border-bottom: 2px solid var(--cat-accent, var(--steel));
  color: var(--charcoal);
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  user-select: none;
}

[data-theme="dark"] .category-header {
  border-bottom-color: color-mix(
    in srgb,
    var(--cat-accent, var(--steel)) 55%,
    white
  );
}

.category-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--cat-accent, var(--softgray));
  flex-shrink: 0;
}

[data-theme="dark"] .category-dot {
  filter: brightness(1.35);
}

.category-header:hover {
  background: var(--hover-bg);
}

.category-header .category-count {
  margin-left: auto;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--steel);
}

.category-header::after {
  content: "−";
  font-size: 0.9rem;
  color: var(--steel);
}

.category-section.collapsed .category-header::after {
  content: "+";
}

/* ============================================================
   NOTE CARDS
============================================================ */
.note-card {
  background: var(--card-bg);
  border: 1px solid var(--softgray);
  border-left: 6px solid var(--card-accent, var(--steel));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

[data-theme="dark"] .note-card {
  border-left-color: color-mix(in srgb, var(--card-accent, var(--steel)) 55%, white);
}

.note-card.pinned {
  box-shadow: var(--shadow-strong);
  border-color: var(--softgray);
  border-left-color: var(--card-accent, var(--steel));
}

.note-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.note-card-title {
  margin: 0;
  color: var(--charcoal);
  font-size: 1.1rem;
  line-height: 1.3;
}

.note-card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.note-card-actions button {
  padding: 6px 10px;
  font-size: 0.8rem;
  box-shadow: none;
}

.note-card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--midgray);
}

.note-author {
  font-weight: 600;
  color: var(--charcoal);
}

.note-date {
  margin-left: auto;
}

.note-card-body {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text-soft);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-card.expanded .note-card-body {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
}

.note-card.clickable {
  cursor: pointer;
}

.note-card .note-card-authors {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--midgray);
  border-top: 1px solid var(--softgray);
  padding-top: 8px;
  margin-top: auto;
}

.note-card .note-card-authors strong {
  font-weight: 600;
  color: var(--charcoal);
}

.note-card .note-card-authors ul {
  margin: 0;
  padding-left: 18px;
}

.note-merged-badge {
  align-self: flex-start;
  font-size: 0.75rem;
  color: var(--midgray);
  border: 1px solid var(--softgray);
  border-radius: 999px;
  padding: 2px 10px;
}

.note-expand {
  align-self: flex-start;
  background: transparent;
  color: var(--steel);
  padding: 4px 8px;
  font-size: 0.8rem;
  box-shadow: none;
}

.note-expand:hover {
  background: var(--hover-bg);
  transform: none;
  opacity: 1;
}

/* ============================================================
   EMPTY STATE
============================================================ */
.empty-state {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 20px;
  text-align: center;
}

.empty-title {
  margin: 0 0 6px 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--charcoal);
}

.empty-body {
  margin: 0 0 16px 0;
  color: var(--midgray);
}

/* ============================================================
   ADMIN DASHBOARD
============================================================ */
#adminOutput,
#analyticsContainer {
  background: var(--panel);
  padding: 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-top: 20px;
}

.admin-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 0;
  border-bottom: 1px dashed var(--row-border);
}

.admin-row:last-child {
  border-bottom: none;
}

.admin-name-input {
  flex: 1;
  padding: 8px;
}

.admin-color-input {
  width: 120px;
  padding: 8px;
}

.admin-color-swatch {
  padding: 0;
  height: 32px;
  width: 48px;
}

.admin-inline-select {
  padding: 8px;
}

.admin-count-label {
  color: var(--softgray);
  font-size: 0.85rem;
  white-space: nowrap;
}

#adminOutput,
#suggestionsOutput {
  margin-top: 20px;
}

#suggestionsCounts {
  color: var(--softgray);
  font-size: 0.9rem;
}

#refreshSuggestionsBtn {
  margin-left: auto;
}

.flex-1 {
  flex: 1;
}

.mt-14 {
  margin-top: 14px;
}

.mt-16 {
  margin-top: 16px;
}

/* ============================================================
   MODAL EDITOR
============================================================ */
#textEditor,
#reassignModal,
#allNotesEditor,
#mergeDialog {
  position: fixed;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  background: var(--overlay);
  z-index: 999;
}

#textEditor > div,
#reassignModal > div,
#allNotesEditor > div,
#mergeDialog > div {
  background: var(--card-bg);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-strong);
  max-height: 90vh;
  overflow-y: auto;
}

#textEditor > div,
#allNotesEditor > div,
#mergeDialog > div {
  width: 80%;
  max-width: 900px;
}

#reassignModal > div {
  width: 80%;
  max-width: 700px;
}

.editor-modal {
  background: var(--card-bg);
}

#allNotesEditor label {
  display: block;
  font-weight: 600;
  margin: 10px 0 4px;
}

#allNotesEditor input,
#allNotesEditor select,
#allNotesEditor textarea {
  width: 100%;
  padding: 12px;
  margin-bottom: 12px;
  border-radius: 8px;
  border: 1px solid var(--softgray);
  background: var(--input-bg);
  font-size: 1rem;
}

#allNotesEditor .editor-inputs {
  display: grid;
  grid-template-columns: 1fr;
}

.merge-dialog-hint {
  color: var(--muted);
  margin-bottom: 10px;
}

.merge-match-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.merge-match-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--softgray);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
}

.merge-match-list input[type="radio"] {
  width: auto;
  margin: 0;
}

.merge-preview {
  border: 1px solid var(--softgray);
  border-radius: 8px;
  padding: 12px;
  background: var(--input-bg);
  min-height: 120px;
  max-height: 240px;
  overflow: auto;
}

#editForm input,
#editForm textarea {
  width: 100%;
  padding: 12px;
  margin-bottom: 12px;
  border-radius: 8px;
  border: 1px solid var(--softgray);
  background: var(--input-bg);
  font-size: 1rem;
}

.editor-buttons {
  display: flex;
  gap: 10px;
}

.autosave-status {
  align-self: center;
  color: var(--text-soft);
  font-size: 0.85rem;
}

/* ============================================================
   MARKDOWN RENDERING
============================================================ */
.markdown > *:first-child {
  margin-top: 0;
}

.markdown > *:last-child {
  margin-bottom: 0;
}

.markdown p {
  margin: 0 0 0.75em;
}

.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4,
.markdown h5,
.markdown h6 {
  margin: 1em 0 0.4em;
  line-height: 1.3;
  color: var(--text);
}

.markdown ul,
.markdown ol {
  margin: 0 0 0.75em;
  padding-left: 1.4em;
}

.markdown ul {
  list-style: disc;
}

.markdown ol {
  list-style: decimal;
}

.markdown li {
  margin: 0.2em 0;
}

.markdown a {
  color: var(--steel);
  text-decoration: underline;
}

.markdown code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--input-bg);
  border: 1px solid var(--softgray);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

.markdown pre {
  background: var(--input-bg);
  border: 1px solid var(--softgray);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  margin: 0 0 0.75em;
}

.markdown pre code {
  background: transparent;
  border: none;
  padding: 0;
}

.markdown blockquote {
  margin: 0 0 0.75em;
  padding: 0.25em 1em;
  border-left: 4px solid var(--softgray);
  color: var(--text-soft);
  background: var(--input-bg);
  border-radius: 0 8px 8px 0;
}

.markdown img {
  max-width: 100%;
  border-radius: 8px;
}

.markdown hr {
  border: none;
  border-top: 1px solid var(--softgray);
  margin: 1em 0;
}

.markdown table {
  border-collapse: collapse;
  margin: 0 0 0.75em;
  width: 100%;
}

.markdown th,
.markdown td {
  border: 1px solid var(--softgray);
  padding: 6px 10px;
  text-align: left;
}

.markdown th {
  background: var(--input-bg);
}

/* ============================================================
   EDITOR TOOLBAR + PREVIEW
============================================================ */
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 6px;
  margin-bottom: 10px;
  background: var(--input-bg);
  border: 1px solid var(--softgray);
  border-radius: 8px;
}

.editor-toolbar button {
  background: transparent;
  color: var(--steel);
  border: 1px solid transparent;
  box-shadow: none;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
}

.editor-toolbar button:hover {
  background: var(--hover-bg);
  border-color: var(--softgray);
  transform: none;
  opacity: 1;
}

.editor-toolbar button.preview-toggle.active {
  background: var(--steel);
  color: #fff;
}

.editor-toolbar-sep {
  width: 1px;
  align-self: stretch;
  background: var(--softgray);
  margin: 0 4px;
}

.editor-inputs {
  position: relative;
}

/* ============================================================
   TAGS
============================================================ */
.tag-editor input {
  width: 100%;
  padding: 12px;
  margin-bottom: 8px;
  border-radius: 8px;
  border: 1px solid var(--softgray);
  background: var(--input-bg);
  font-size: 1rem;
}

.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--input-bg);
  border: 1px solid var(--softgray);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
}

.tag-chip:hover {
  border-color: var(--steel);
}

.keyword-editor {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.keyword-editor input {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--softgray);
  background: var(--input-bg);
  font-size: 1rem;
}

/* ============================================================
   EXAMPLES (note form)
============================================================ */
.examples-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.examples-editor textarea {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--softgray);
  background: var(--input-bg);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
}

.examples-editor button {
  align-self: flex-start;
}

.examples-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.example-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--softgray);
  border-radius: 8px;
  background: var(--input-bg);
}

.example-item .example-text {
  flex: 1;
  white-space: pre-wrap;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.4;
}

.example-remove {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  box-shadow: none;
}

.example-remove:hover {
  color: var(--danger);
  background: transparent;
  transform: none;
}

.keyword-editor button {
  white-space: nowrap;
  box-shadow: none;
}

.note-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.note-card-tags .tag-chip {
  cursor: pointer;
}

.note-card-tags .tag-chip:hover {
  color: var(--steel);
}

/* ============================================================
   EXAMPLES (note cards + viewer)
============================================================ */
.viewer-examples-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 8px;
}

.note-example,
.viewer-example {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.note-example-num {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--input-bg);
  border: 1px solid var(--softgray);
  font-size: 0.7rem;
  color: var(--muted);
}

.note-example-body,
.viewer-example-body {
  flex: 1;
  min-width: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text-soft);
}

.note-example-body > :first-child,
.viewer-example-body > :first-child {
  margin-top: 0;
}

.note-example-body > :last-child,
.viewer-example-body > :last-child {
  margin-bottom: 0;
}

.note-example-by {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--muted);
}

.note-example-remove {
  align-self: flex-start;
  background: transparent;
  color: var(--muted);
  padding: 2px 6px;
  font-size: 0.75rem;
  box-shadow: none;
}

.note-example-remove:hover {
  background: transparent;
  color: var(--danger);
  transform: none;
}

.note-example-add {
  align-self: flex-start;
  background: transparent;
  color: var(--steel);
  padding: 2px 6px;
  font-size: 0.8rem;
  box-shadow: none;
}

.note-example-add:hover {
  background: var(--hover-bg);
  transform: none;
}

.note-example-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.note-example-form[hidden] {
  display: none;
}

.note-example-form .note-example-input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--softgray);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
}

.note-example-form .note-example-go {
  align-self: flex-end;
}

.viewer-examples {
  margin-top: 14px;
  border-top: 1px solid var(--softgray);
  padding-top: 12px;
}

/* Examples modal */
#examplesModal {
  position: fixed;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  background: var(--overlay);
  z-index: 999;
}

.examples-modal {
  background: var(--card-bg);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-strong);
  width: 80%;
  max-width: 560px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.examples-modal-title {
  margin: 0 0 12px;
  font-size: 1.05rem;
}

.examples-modal-list {
  overflow-y: auto;
  margin-bottom: 12px;
}

.examples-modal-empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 8px 0;
}

#topicModal {
  position: fixed;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  background: var(--overlay);
  z-index: 999;
}

.topic-modal {
  background: var(--card-bg);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-strong);
  width: 80%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.topic-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.topic-modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.topic-modal-examples {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--panel-bg, var(--card-bg));
  border-radius: 8px;
}

.topic-modal-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.topic-modal-nav button:disabled {
  opacity: 0.4;
  cursor: default;
}

#topicModalMergeSection h4 {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.topic-modal-merge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.85rem;
  padding: 6px 0;
  border-top: 1px solid var(--softgray);
}

.topic-modal-merge-row:first-child {
  border-top: none;
}

.topic-modal-body {
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text-soft);
}

.editor-inputs textarea,
.editor-preview {
  width: 100%;
  min-height: 280px;
  max-height: 60vh;
  overflow-y: auto;
}

.editor-preview {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--softgray);
  background: var(--input-bg);
  box-sizing: border-box;
  display: none;
}

.editor-preview:not([hidden]) {
  display: block;
}

/* ============================================================
   TOASTS
============================================================ */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  z-index: 1200;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--card-bg, #ffffff);
  color: var(--text, #222);
  border: 1px solid var(--softgray, #ccc);
  border-left: 4px solid var(--steel, #4682b4);
  box-shadow: var(--shadow-strong, 0 8px 30px rgba(0, 0, 0, 0.2));
  font-size: 0.92rem;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  border-left-color: #27ae60;
}

.toast-error {
  border-left-color: #c0392b;
}

.toast-info {
  border-left-color: var(--steel, #4682b4);
}

.toast-icon {
  font-weight: 700;
}

.toast-success .toast-icon {
  color: #27ae60;
}

.toast-error .toast-icon {
  color: #c0392b;
}

.toast-info .toast-icon {
  color: var(--steel, #4682b4);
}

.toast-close {
  margin-left: auto;
  background: transparent;
  border: none;
  box-shadow: none;
  color: var(--text-soft, #777);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}

.toast-close:hover {
  transform: none;
  opacity: 1;
  color: var(--text, #222);
}

/* ============================================================
   THEME TOGGLE
============================================================ */
.theme-toggle {
  background: transparent;
  color: var(--steel);
  border: 1px solid var(--steel);
  box-shadow: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
  margin-left: auto;
}

.theme-toggle:hover {
  background: var(--hover-bg);
  transform: none;
  opacity: 1;
}

.logout-btn {
  background: transparent;
  color: var(--danger, #c0392b);
  border: 1px solid var(--danger, #c0392b);
  box-shadow: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
  margin-left: auto;
}

.logout-btn:hover {
  background: var(--danger, #c0392b);
  color: #fff;
  transform: none;
  opacity: 1;
}

/* ============================================================
   SETTINGS MODAL (More → Settings)
============================================================ */
#settingsModal {
  position: fixed;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  background: var(--overlay);
  z-index: 999;
}

#settingsModal[hidden] {
  display: none;
}

#settingsModal:not([hidden]) {
  display: flex;
}

#settingsModal > div {
  background: var(--card-bg);
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-strong);
  width: 92%;
  max-width: 460px;
}

.settings-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.settings-modal-head h2 {
  margin: 0;
  font-size: 1.3rem;
}

.settings-modal-close {
  border: none;
  background: transparent;
  color: var(--midgray);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}

.settings-modal-close:hover {
  background: var(--hover-bg);
  color: var(--text);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0;
  border-top: 1px solid var(--row-border);
}

.settings-row-text {
  min-width: 0;
}

.settings-label {
  font-weight: 600;
  font-size: 1.05rem;
}

.settings-sub {
  color: var(--midgray);
  font-size: 0.9rem;
  margin-top: 2px;
}

.settings-switch-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.settings-switch-status {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--steel);
}

.scope-switch {
  position: relative;
  width: 46px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 13px;
  background: var(--softgray);
  cursor: pointer;
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.scope-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease;
}

.scope-switch[aria-checked="true"] {
  background: var(--steel);
}

.scope-switch[aria-checked="true"]::after {
  transform: translateX(20px);
}

/* ============================================================
   RESPONSIVE
============================================================ */
@media (max-width: 900px) {
  header {
    flex-direction: column;
    align-items: flex-start;
  }

  .note-grid {
    grid-template-columns: 1fr;
  }
}

.admin-row input[type="text"] {
  border: 1px solid var(--softgray);
  border-radius: 6px;
}

.admin-row input[type="color"] {
  cursor: pointer;
}

.admin-row select {
  border: 1px solid var(--softgray);
  border-radius: 6px;
}

/* ============================================================
   THE ARCHIVIST
============================================================ */
.archivist-banner {
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--danger);
  background: rgba(192, 57, 43, 0.08);
  color: var(--text);
  margin-bottom: 16px;
}

.archivist-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
}

.archivist-tab {
  padding: 12px 22px;
  border-radius: 10px;
  border: 1px solid var(--softgray);
  background: transparent;
  color: var(--text-soft);
  font-weight: 600;
  font-size: 1.02rem;
  cursor: pointer;
}

.archivist-tab:hover {
  border-color: var(--steel);
  color: var(--steel);
}

.archivist-tab.active {
  background: var(--steel);
  border-color: var(--steel);
  color: #fff;
}

.archivist-panel {
  display: none;
}

.archivist-panel.active {
  display: block;
}

.archivist-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.archivist-controls select,
.archivist-controls input[type="text"],
.archivist-controls input[type="number"] {
  padding: 12px 14px;
  border: 1px solid var(--softgray);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 1.05rem;
}

.archivist-controls input[type="text"],
.archivist-controls input[type="number"] {
  flex: 1 1 260px;
  min-width: 340px;
}

.archivist-hint {
  color: var(--midgray);
  font-size: 1rem;
}

.archivist-cta {
  padding: 14px 28px;
  font-size: 1.05rem;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  background: var(--steel);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease, opacity 0.12s ease;
}

.archivist-cta:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.24);
  transform: translateY(-1px);
}

.archivist-cta:active {
  transform: translateY(0);
}

.archivist-cta:disabled {
  opacity: 0.55;
  cursor: default;
  box-shadow: none;
  transform: none;
  filter: none;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-head .panel-title {
  margin-bottom: 0;
}

.panel-title {
  font-size: 1.55rem;
  font-weight: 700;
  margin: 0 0 14px;
  line-height: 1.2;
}

.archivist-refresh {
  padding: 9px 18px;
  border: 1px solid var(--softgray);
  border-radius: 10px;
  background: transparent;
  color: var(--text-soft);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}

.archivist-refresh:hover {
  border-color: var(--steel);
  color: var(--steel);
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.archivist-danger {
  padding: 9px 18px;
  border: 1px solid var(--danger);
  border-radius: 10px;
  background: transparent;
  color: var(--danger);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}

.archivist-danger:hover {
  background: rgba(192, 57, 43, 0.08);
}

.archivist-danger:disabled {
  opacity: 0.55;
  cursor: default;
}

.quiz-question {
  border: 1px solid var(--softgray);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 14px;
  background: var(--card-bg);
  box-shadow: var(--shadow);
}

.quiz-question h3 {
  margin: 0 0 6px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--midgray);
}

.quiz-prompt {
  margin: 0 0 12px;
  line-height: 1.5;
  font-size: 1.05rem;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.quiz-options label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border: 1px solid var(--softgray);
  border-radius: 10px;
  cursor: pointer;
  background: var(--input-bg);
  font-size: 1.02rem;
}

.quiz-options label:hover {
  border-color: var(--steel);
}

.quiz-options input[type="radio"] {
  accent-color: var(--steel);
}

.quiz-answer-input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--softgray);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  box-sizing: border-box;
  margin-bottom: 10px;
  font-size: 1.02rem;
}

.quiz-options label.quiz-correct {
  border-color: #27ae60;
  background: rgba(39, 174, 96, 0.08);
}

.quiz-options label.quiz-wrong {
  border-color: var(--danger);
  background: rgba(192, 57, 43, 0.08);
}

.quiz-answer-input.quiz-correct {
  border-color: #27ae60;
}

.quiz-answer-input.quiz-wrong {
  border-color: var(--danger);
}

.quiz-explanation {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--softgray);
  color: var(--text-soft);
  font-size: 0.92rem;
}

.quiz-explanation .correct-answer {
  font-weight: 700;
  color: #27ae60;
}

.source-link {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--steel);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}

.source-link:hover {
  text-decoration: underline;
}

.result-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-item {
  border: 1px solid var(--softgray);
  border-radius: var(--radius);
  padding: 16px 20px;
  background: var(--card-bg);
  box-shadow: var(--shadow);
}

.result-item h4 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}

.result-item h4 a {
  color: var(--text);
  text-decoration: none;
}

.result-item h4 a:hover {
  color: var(--steel);
}

.result-meta {
  font-size: 0.85rem;
  color: var(--midgray);
  margin-bottom: 6px;
}

.result-snippet {
  margin: 0 0 8px;
  line-height: 1.45;
}

.highlight {
  background: rgba(255, 213, 79, 0.35);
  border-radius: 3px;
  padding: 0 2px;
  font-weight: 600;
}

.thumbs {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.thumbs button {
  border: 1px solid var(--softgray);
  background: transparent;
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
  color: var(--text-soft);
  font-size: 0.9rem;
}

.thumbs button:hover {
  border-color: var(--steel);
  color: var(--steel);
}

.thumbs button.liked {
  border-color: #27ae60;
  color: #27ae60;
}

.thumbs button.disliked {
  border-color: var(--danger);
  color: var(--danger);
}

.concept-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 16px;
}

.concept-chip {
  border: 1px solid var(--softgray);
  background: var(--input-bg);
  border-radius: 24px;
  padding: 9px 18px;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text);
}

.concept-chip:hover {
  border-color: var(--steel);
  color: var(--steel);
}

.concept-chip.active {
  background: var(--steel);
  border-color: var(--steel);
  color: #fff;
}

.concept-chip.active:hover {
  color: #fff;
}

/* Search-to-select note picker */
.note-picker {
  position: relative;
  flex: 1 1 260px;
  min-width: 340px;
}

.note-picker input[type="text"] {
  width: 100%;
  min-width: 0;
}

.note-picker-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  display: none;
  flex-direction: column;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--softgray);
  border-radius: 10px;
  background: var(--card-bg);
  box-shadow: var(--shadow-strong);
}

.note-picker-menu.open {
  display: flex;
}

.note-picker-option {
  text-align: left;
  border: none;
  background: transparent;
  padding: 10px 14px;
  cursor: pointer;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.note-picker-option:hover {
  background: var(--softgray);
}

.note-picker-option-title {
  font-weight: 600;
}

.note-picker-option-sub {
  font-size: 0.85rem;
  color: var(--midgray);
}

.note-picker-empty {
  padding: 12px 14px;
  color: var(--midgray);
}

.note-picker-selected {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--softgray);
  border-radius: 10px;
  background: var(--input-bg);
  padding: 12px 14px;
}

.note-picker-selected .note-picker-title {
  font-weight: 600;
  flex: 1;
}

.note-picker-clear {
  border: 1px solid var(--softgray);
  background: transparent;
  border-radius: 8px;
  width: 26px;
  height: 26px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-soft);
}

.note-picker-clear:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

/* Improve (teach key phrases) dialog */
#improveDialog {
  position: fixed;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  background: var(--overlay);
  z-index: 999;
}

.improve-dialog {
  background: var(--card-bg);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-strong);
  width: 80%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
}

.improve-phrases {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.improve-phrase {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--softgray);
  background: var(--input-bg);
  border-radius: 24px;
  padding: 6px 8px 6px 16px;
  font-size: 0.95rem;
  color: var(--text);
}

.improve-unlink {
  border: 1px solid var(--softgray);
  background: transparent;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--danger);
}

.improve-unlink:hover {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}

.improve-add {
  display: flex;
  gap: 10px;
}

.improve-add input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--softgray);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 1rem;
}

.flashcard {
  perspective: 1000px;
  max-width: 720px;
  margin: 16px auto;
  cursor: pointer;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  min-height: 340px;
  transition: transform 0.4s;
  transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
  transform: rotateX(180deg);
}

.flashcard-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border: 1px solid var(--softgray);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px;
  text-align: center;
  font-size: 1.15rem;
}

.flashcard-back {
  transform: rotateX(180deg);
  color: var(--steel);
  font-weight: 700;
  flex-direction: column;
  gap: 10px;
}

.flashcard-back .flashcard-explanation {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-soft);
}

.flashcard-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}

.flashcard-controls button {
  padding: 12px 22px;
  border: 1px solid var(--softgray);
  border-radius: 10px;
  background: transparent;
  color: var(--text-soft);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.flashcard-controls button:hover {
  border-color: var(--steel);
  color: var(--steel);
}

.flashcard-controls span {
  align-self: center;
  color: var(--midgray);
  font-weight: 600;
  padding: 0 6px;
}

.archivist-actions {
  margin-top: 10px;
}

.summary-block {
  border: 1px solid var(--softgray);
  border-radius: var(--radius);
  padding: 18px 22px;
  background: var(--card-bg);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.summary-block p {
  margin: 0 0 8px;
  line-height: 1.55;
}

.archivist-notes {
  margin-top: 12px;
}

/* Archivist note viewer */
#archivistViewer {
  position: fixed;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  background: var(--overlay);
  z-index: 999;
}

#archivistViewer > div {
  background: var(--card-bg);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-strong);
  width: 80%;
  max-width: 760px;
  max-height: 85vh;
  overflow-y: auto;
}

/* ============================================================
   GUIDE PAGE
============================================================ */
main.guide {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px;
}

main.guide h2 {
  margin: 8px 0 4px;
}

.guide-lede {
  color: var(--midgray);
  margin-bottom: 20px;
  line-height: 1.55;
}

.guide-section {
  background: var(--card-bg);
  border: 1px solid var(--row-border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 0 0 14px;
  box-shadow: var(--shadow);
}

.guide-section h3 {
  margin: 0 0 8px;
}

.guide-section p {
  margin: 0 0 8px;
  line-height: 1.55;
}

.guide-section p:last-child {
  margin-bottom: 0;
}

.guide-section ol {
  margin: 0;
  padding-left: 22px;
  line-height: 1.7;
}

.got-it {
  display: block;
  margin: 8px auto 24px;
  padding: 10px 22px;
  background: var(--steel);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  cursor: pointer;
}

.got-it:hover:not(:disabled) {
  opacity: 0.9;
}

.got-it:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ============================================================
   SUGGESTIONS
============================================================ */
#suggestionForm label {
  display: block;
  margin: 10px 0 4px;
}

#suggestionForm input,
#suggestionForm select,
#suggestionForm textarea {
  width: 100%;
  box-sizing: border-box;
}

.suggestion-card {
  border: 1px solid var(--row-border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 10px;
}

.suggestion-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.suggestion-meta {
  color: var(--midgray);
  font-size: 0.85rem;
  margin: 4px 0;
}

.suggestion-body {
  margin: 4px 0 0;
  white-space: pre-wrap;
}

.suggestion-status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: bold;
  color: #fff;
  white-space: nowrap;
}

.suggestion-status-new {
  background: var(--steel);
}

.suggestion-status-acknowledged {
  background: #b8860b;
}

.suggestion-status-resolved {
  background: #2e8b57;
}

/* ============================================================
   ARCHIVIST ADVANCED (Mastery / Analytics)
============================================================ */
.mastery-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
}

.mastery-label {
  width: 190px;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.mastery-score {
  float: right;
  color: var(--midgray);
  font-weight: bold;
}

.mastery-bar,
.analytics-bar {
  flex: 1;
  height: 16px;
  background: var(--softgray);
  border-radius: 8px;
  overflow: hidden;
}

.mastery-bar-fill,
.analytics-bar-fill {
  height: 100%;
  border-radius: 6px;
  background: var(--steel);
  min-width: 2px;
}

.mastery-count {
  width: 70px;
  text-align: right;
  color: var(--midgray);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.analytics-days {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-top: 10px;
}

.analytics-day {
  flex: 1;
  min-width: 0;
}

.analytics-label {
  font-size: 0.75rem;
  color: var(--midgray);
  text-align: center;
  margin-bottom: 4px;
}

.analytics-bar {
  min-height: 90px;
  display: flex;
  align-items: flex-end;
  background: transparent;
  border-bottom: 1px solid var(--softgray);
}

.analytics-bar-fill {
  width: 100%;
  background: var(--steel);
  border-radius: 4px 4px 0 0;
}

.analytics-count {
  font-size: 0.75rem;
  color: var(--midgray);
  text-align: center;
  margin-top: 4px;
}

.analytics-type {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
}

.analytics-type-name {
  width: 170px;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-type-pct {
  width: 110px;
  text-align: right;
  color: var(--midgray);
  font-size: 0.85rem;
  flex-shrink: 0;
}


/* ============================================================
   THE ARCHIVIST — FULL-SCREEN LAYOUT & ASK CHAT
   ============================================================ */
body.page-archivist {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 14px 24px;
  overflow: hidden;
}

body.page-archivist header {
  flex-shrink: 0;
  margin-bottom: 14px;
}

body.page-archivist .archivist-tabs {
  flex-shrink: 0;
  margin: 0 0 14px;
}

body.page-archivist main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.archivist-panel.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 2px 24px;
}

.archivist-panel.active:not(.archivist-panel--chat) {
  justify-content: safe center;
  align-items: center;
}

.archivist-panel.active:not(.archivist-panel--chat) > * {
  width: 100%;
  max-width: 960px;
}

.archivist-panel--chat.active {
  overflow: hidden;
  padding: 0;
}

.ask-thread {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 12px 16px;
  flex-direction: column;
  gap: 14px;
}

.ask-chatting .ask-thread {
  display: flex;
}

.ask-hero {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 20px;
  padding: 20px;
}

.ask-chatting .ask-hero {
  display: none;
}

.ask-hero-quip {
  font-size: clamp(1.9rem, 5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.1;
}

.ask-hero-hint {
  color: var(--midgray);
  font-size: 1.15rem;
}

.ask-hero-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
}

.ask-hero .ask-chip {
  padding: 14px 26px;
  font-size: 1.1rem;
  border-width: 2px;
}

@keyframes askQuipFade {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ask-fade {
  animation: askQuipFade 0.5s ease;
}

.ask-bubble {
  max-width: min(720px, 92%);
  border-radius: 16px;
  padding: 14px 18px;
  line-height: 1.55;
}

.ask-bubble p {
  margin: 0 0 8px;
}

.ask-bubble p:last-child {
  margin-bottom: 0;
}

.ask-bubble--user {
  align-self: flex-end;
  background: var(--steel);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ask-bubble--archivist {
  align-self: flex-start;
  background: var(--card-bg);
  border: 1px solid var(--softgray);
  box-shadow: var(--shadow);
  border-bottom-left-radius: 4px;
}

.ask-bubble--archivist .summary-block {
  border: none;
  box-shadow: none;
  background: transparent;
  padding: 0;
  margin: 0;
}

.ask-greeting {
  font-weight: 700;
  font-size: 1.05rem;
}

.ask-hint {
  color: var(--midgray);
}

.ask-thinking {
  color: var(--midgray);
  font-style: italic;
}

.ask-error {
  color: var(--danger);
  font-weight: 600;
}

.ask-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.ask-chip {
  border: 1px solid var(--steel);
  background: transparent;
  color: var(--steel);
  box-shadow: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 600;
}

.ask-chip:hover {
  background: var(--hover-bg);
  transform: none;
  opacity: 1;
}

.ask-composer {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 0 4px;
}

.ask-composer textarea {
  flex: 1;
  resize: none;
  min-height: 48px;
  max-height: 120px;
  padding: 12px 14px;
  border: 1px solid var(--softgray);
  border-radius: 12px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  line-height: 1.4;
}

.ask-composer textarea:focus {
  outline: none;
  border-color: var(--steel);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.ask-composer button {
  padding: 12px 22px;
  border-radius: 12px;
  font-size: 1rem;
  border: none;
}

.ask-composer .archivist-cta {
  padding: 14px 30px;
  font-size: 1.05rem;
}

.ask-clear {
  background: transparent;
  color: var(--text-soft);
  font-weight: 600;
  border: 1px solid var(--softgray);
}

.ask-clear:hover {
  color: var(--steel);
}

.ask-clear:disabled {
  opacity: 0.5;
  cursor: default;
}

.ask-help {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ask-help-card {
  border: 1px solid var(--softgray);
  border-radius: 12px;
  background: var(--input-bg);
  padding: 12px 14px;
}

.ask-help-card h4 {
  margin: 0 0 6px;
  color: var(--steel);
}

.ask-help-card p {
  margin: 0 0 6px;
}

.ask-help-card p:last-child {
  margin-bottom: 0;
}

.ask-help-action {
  margin-top: 8px;
}

.ask-link {
  display: inline-block;
  padding: 7px 14px;
  border: 1px solid var(--steel);
  border-radius: 8px;
  color: var(--steel);
  background: transparent;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}

.ask-link:hover {
  background: var(--hover-bg);
  text-decoration: none;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.8em;
  font-weight: 700;
}

.badge-active {
  background: var(--ok);
  color: #fff;
}

.badge-pending {
  background: #e09f3e;
  color: #000;
}
