/* ============================================================
   SwishWriting — design system
   Ink navy canvas, "swish" gradient accents, Bricolage Grotesque
   for UI + Newsreader for editorial content.
   ============================================================ */

:root {
  --ink: #1b1b3a;
  --ink-2: #2a2a52;
  --bg: #f5f6fb;
  --surface: #ffffff;
  --line: #e4e6f2;
  --line-soft: #eef0f8;
  --text: #20213d;
  --muted: #6b6e8f;
  --pink: #ff4d8d;
  --violet: #8a5cff;
  --sky: #19b5fe;
  --mint: #2fd6a3;
  --amber: #f59e0b;
  --rose: #ef5b6f;
  --green: #16a34a;
  --red: #dc2626;
  --swish: linear-gradient(100deg, var(--pink), var(--violet) 40%, var(--sky) 75%, var(--mint));
  --ui: "Bricolage Grotesque", "Segoe UI", system-ui, -apple-system, sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --r-sm: 8px;
  --r: 12px;
  --r-md: 12px;
  --r-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(27, 27, 58, .06);
  --shadow: 0 1px 3px rgba(27, 27, 58, .07), 0 8px 24px rgba(32, 33, 61, .06);
  --shadow-lg: 0 18px 48px rgba(27, 27, 58, .18);
  --ring: 0 0 0 3px rgba(138, 92, 255, .18);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--ui);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin-top: 0; letter-spacing: -.01em; }
h1 { font-weight: 800; }
p { margin: 0 0 10px; }

:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }

.muted { color: var(--muted); font-size: .9rem; }
.muted-sub { color: var(--muted); font-size: .78rem; }
.error-msg { color: var(--red); font-weight: 600; margin-top: 10px; font-size: .9rem; }
.green-pill { color: var(--green); font-weight: 600; }


/* ---------- Brand ---------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: inherit;
}
.brand-mark {
  width: 36px; height: 36px;
  border-radius: 11px;
  background: var(--swish);
  display: grid; place-items: center;
  box-shadow: 0 4px 14px rgba(138, 92, 255, .35);
  flex: none;
}
.brand-mark svg { width: 21px; height: 21px; }
.brand-name {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1;
  background: var(--swish);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-name span { font-weight: 400; }


.brand-sub { color: var(--muted); font-weight: 600; font-size: .8rem; }

/* ---------- Banner (dashboard) ---------- */
.banner {
  background: var(--ink);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; height: 64px;
  position: relative; flex: none;
}
.banner::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 3px; background: var(--swish);
}
.banner .brand-name { font-size: 26px; }
.account { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--swish); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px; flex: none;
}
.username { color: #fff; font-weight: 600; margin-right: 6px; font-size: .92rem; }
.ghost-btn {
  background: transparent; border: 1px solid rgba(255, 255, 255, .28); color: #e9eaff;
  padding: 8px 15px; border-radius: 999px; cursor: pointer; font: inherit; font-size: .85rem; font-weight: 600;
  margin: 0; transition: background .15s, border-color .15s;
}
.ghost-btn:hover { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .55); }

/* ---------- Layout ---------- */
.container { max-width: 880px; margin: 0 auto; padding: 26px 18px; }
.container.wide { max-width: 1180px; }
.container.app { max-width: none; padding: 0; height: 100vh; display: flex; flex-direction: column; }

.app-shell { height: 100vh; display: grid; grid-template-rows: 64px 1fr; overflow: hidden; }
.shell { display: grid; grid-template-columns: var(--tree-w, 296px) 8px 1fr; min-height: 0; }

/* Draggable sidebar splitter */
.resizer { position: relative; cursor: col-resize; touch-action: none; }
.resizer::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 2px;
  background: transparent; transition: background .15s;
}
.resizer:hover::before, .resizer:focus-visible::before, .resizer.dragging::before { background: var(--violet); }
.resizer.dragging { cursor: col-resize; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--line);
  overflow-y: auto; padding: 18px 12px 26px;
}
.sidebar h2 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 0 10px 10px; margin: 0; }
.main { overflow-y: auto; padding: 22px 28px 44px; }

.app { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }




/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 16px;
}

/* ---------- Buttons ---------- */
button, .btn {
  font: inherit; color: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  font-size: .9rem; font-weight: 600;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, border-color .12s, background .12s;
}
button:hover, .btn:hover {
  border-color: #cfd2ea;
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(32, 33, 61, .1);
}
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
/* Icons inside buttons (template sizing) */
button svg, .btn svg { width: 16px; height: 16px; flex: none; }
/* Tab strips sit on a border; a hover lift would break the underline. */
.tab-btn:hover { transform: none; box-shadow: none; }

button.primary, .btn.primary, .btn-primary {
  background: var(--swish); color: #fff; border-color: transparent;
  box-shadow: 0 6px 18px rgba(138, 92, 255, .28);
}
button.primary:hover, .btn.primary:hover, .btn-primary:hover { box-shadow: 0 10px 26px rgba(138, 92, 255, .4); }
button.secondary { background: var(--surface); color: var(--text); }
button.secondary:hover { border-color: var(--violet); color: var(--violet); }
/* AI assistant — violet star (template) + lift and shadow on hover */
button.ai, .btn.ai { background: var(--surface); color: var(--text); }
button.ai svg, .btn.ai svg { width: 16px; height: 16px; color: var(--violet); flex: none; }
button.ai:hover, .btn.ai:hover {
  border-color: #cfd2ea;
  color: var(--violet);
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(138, 92, 255, .22);
}
button.ai:active, .btn.ai:active { transform: translateY(0); }
button.danger { background: var(--rose); color: #fff; border-color: transparent; }
button.danger:hover { background: #dc3d52; box-shadow: 0 10px 26px rgba(239, 91, 111, .35); }
button.small, .small { padding: 6px 12px; font-size: .82rem; border-radius: 999px; }
.btn-light { background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .3); }
.btn-light:hover { background: rgba(255, 255, 255, .2); color: #fff; }

/* Toolbar */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 0 0 20px; margin: 0; background: none; border: 0; box-shadow: none;
}
.search {
  flex: 1 1 220px; min-width: 180px;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 0 14px;
}
.search svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.search input { border: 0; background: none; outline: 0; width: 100%; padding: 10px 0; font-size: .92rem; }
.search:focus-within { border-color: var(--violet); box-shadow: var(--ring); }

/* ---------- Section head ---------- */
.section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin: 6px 0 14px;
}
.section-head h1 { font-size: 22px; font-weight: 800; margin: 0; }
.section-head p { color: var(--muted); font-size: .85rem; margin: 0; }

/* ---------- Writing cards ---------- */
.write-card {
  --c: var(--violet);
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 168px;
  padding: 18px 18px 16px;
  cursor: pointer;
  text-decoration: none; color: inherit;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.write-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: var(--c);
}
.write-card:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(32, 33, 61, .1); border-color: #d8dbef; }
.write-card h3 {
  font-family: var(--serif); font-weight: 600; font-size: 20px; line-height: 1.28;
  margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.write-card .topic-line {
  color: var(--muted); font-size: .82rem;
  display: flex; align-items: center; gap: 7px;
}
.write-card .topic-line::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--c); flex: none;
}
.write-card .meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: .78rem; color: var(--muted); }
.write-card .card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }

/* Card wrapper hosts the delete control outside the card's link */
.write-card-wrap { position: relative; display: flex; }
.write-card-wrap > .write-card { flex: 1; min-width: 0; }
.card-delete {
  display: inline-grid; place-items: center;
  width: 28px; height: 28px; padding: 0; margin: 0;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--surface); color: var(--muted);
  transition: color .12s, border-color .12s, background .12s, box-shadow .12s;
}
.card-delete { position: absolute; top: 12px; right: 12px; z-index: 2; }
.card-delete svg { width: 14px; height: 14px; }
.card-delete:hover {
  color: var(--rose); border-color: rgba(239, 91, 111, .45); background: rgba(239, 91, 111, .08);
  transform: none; box-shadow: 0 6px 16px rgba(239, 91, 111, .22);
}

.status-pill {
  font-size: .72rem; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  background: var(--line-soft); color: var(--muted);
}
.status-pill.finished { background: rgba(47, 214, 163, .16); color: #0f9b74; }
.status-pill.timeout { background: rgba(245, 158, 11, .16); color: #b45309; }
.status-pill.writing { background: rgba(138, 92, 255, .15); color: #6d3fe0; }
.status-pill.draft { background: var(--line-soft); color: var(--muted); }
.score-chip {
  font-size: .72rem; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  background: rgba(138, 92, 255, .14); color: #6d3fe0;
}
.score-chip.high { background: rgba(47, 214, 163, .16); color: #0f9b74; }
.score-chip.low { background: rgba(239, 91, 111, .16); color: #c02a45; }
.empty-state {
  grid-column: 1 / -1;
  text-align: center; color: var(--muted);
  padding: 54px 20px; font-size: .95rem;
}
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 48px 0; }

/* ---------- Tree ---------- */
.tree-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px 12px; margin: 0 0 8px;
  border-bottom: 1px solid var(--line);
}
.tree-header h2 { margin: 0; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
#tree { flex: 1; min-height: 0; overflow-y: auto; }
.tree, .tree ul { list-style: none; padding: 0; margin: 0; }
.tree-year { margin-bottom: 6px; }
.tree-toggle {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left;
  padding: 7px 10px; border-radius: var(--r-sm);
  font-size: .9rem; font-weight: 500;
  cursor: pointer; color: var(--text);
  background: none; border: 0; margin: 0;
  box-shadow: none;
}
.tree-toggle:hover { background: var(--bg); }
.tree-toggle .tree-caret {
  width: 14px; height: 14px; flex: none;
  color: var(--muted); transition: transform .15s;
}
.tree-toggle.open .tree-caret { transform: rotate(90deg); }
.tree-toggle .tree-count {
  margin-left: auto; font-size: .72rem; font-weight: 600;
  color: var(--muted); background: var(--bg);
  padding: 1px 8px; border-radius: 999px;
}
.tree-body { display: none; margin-left: 12px; padding-left: 10px; border-left: 1px solid var(--line); }
.tree-toggle.open + .tree-body { display: block; }
.tree-month > .tree-toggle { color: var(--muted); font-size: .84rem; font-weight: 600; }
.tree-article { position: relative; margin: 1px 0; display: flex; align-items: center; gap: 4px; }
/* Leaf rows follow swishwriting.html: colour dot, title, day on the right,
   then a vertical three-dot menu button. The row is a button (it selects the
   entry) rather than a link. */
.leaf-open {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: var(--r-sm);
  border: 1px solid transparent; background: transparent;
  color: var(--text); text-align: left; font-size: .85rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tree-article .leaf-dot {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--c, var(--violet)); opacity: .85;
}
.leaf-open:hover { background: var(--bg); }
.tree-article .leaf-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-article .leaf-when { flex: none; font-size: .74rem; color: var(--muted); }

/* Selected entry: tinted row in the sidebar… */
.tree-article.selected .leaf-open {
  background: color-mix(in srgb, var(--c, var(--violet)) 13%, white);
  border-color: color-mix(in srgb, var(--c, var(--violet)) 32%, transparent);
  font-weight: 600;
}
body[data-theme="dark"] .tree-article.selected .leaf-open {
  background: color-mix(in srgb, var(--c, var(--violet)) 24%, #14152b);
}
body[data-theme="sepia"] .tree-article.selected .leaf-open {
  background: color-mix(in srgb, var(--c, var(--violet)) 16%, var(--surface));
}
/* …and a matching highlight on its card. */
.write-card.selected {
  border-color: var(--c, var(--violet));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c, var(--violet)) 22%, transparent);
}

.leaf-menu-btn {
  flex: none;
  width: 24px; height: 24px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; background: transparent;
  color: var(--muted); border-radius: var(--r-sm);
  opacity: 0; transition: opacity .12s, background .12s, color .12s;
}
.leaf-menu-btn svg { width: 15px; height: 15px; }
.tree-article:hover .leaf-menu-btn,
.leaf-menu-btn:focus-visible,
.leaf-menu-btn[aria-expanded="true"] { opacity: 1; }
.leaf-menu-btn:hover { background: var(--bg); color: var(--ink); border-color: var(--line); }
body[data-theme="dark"] .leaf-menu-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }

/* Row context menu (Edit / Delete) */
.ctx-menu {
  position: fixed; z-index: 90;
  min-width: 156px; padding: 5px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--shadow);
  animation: swishIn .12s ease-out;
}
/* `button.ctx-item` (not `.ctx-item`) so these items fully override the global
   `button.danger` rule — otherwise the Delete item rendered as a solid red
   button while Edit stayed flat. Both items now share one style. */
button.ctx-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 8px 10px;
  border: 0; background: transparent; box-shadow: none;
  font-size: .85rem; text-align: left; border-radius: var(--r-sm);
}
.ctx-item svg { width: 15px; height: 15px; flex: none; }
.ctx-item:hover { background: var(--bg); }
.ctx-item.danger { color: var(--pink); }
.ctx-item.danger:hover { background: rgba(255, 77, 141, .1); }
/* Both menu items use the same chip: white by default with a coloured icon,
   filling with that colour while the row is hovered. */
.ctx-item .ctx-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  flex: none;
  background: #fff; color: var(--violet);
  box-shadow: inset 0 0 0 1px var(--line);
}
.ctx-item .ctx-icon svg { width: 13px; height: 13px; }
.ctx-item:hover .ctx-icon { background: var(--violet); color: #fff; box-shadow: none; }
.ctx-item .ctx-icon.danger-chip { color: var(--pink); }
.ctx-item.danger:hover .ctx-icon.danger-chip {
  background: var(--pink); color: #fff; box-shadow: none;
}


.tree-empty { color: var(--muted); font-size: .88rem; padding: 22px 12px; text-align: center; }

/* ---------- Search ---------- */

#assistantPanel, #settingsModal {
  margin-bottom: 18px;
  animation: swishIn .18s ease-out;
}
@keyframes swishIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }


/* ---------- Assistant ---------- */
.assist-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.assist-col { min-width: 0; }
.pane-title {
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin-bottom: 10px;
}
.asst-chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.assist-recents { list-style: none; margin: 8px 0 0; padding: 0; }
.assist-recents li { padding: 8px 4px; border-bottom: 1px solid var(--line-soft); font-size: .88rem; }
.assist-recents li:last-child { border-bottom: none; }
.ai-cell { font-size: .78rem; color: var(--muted); margin-top: 4px; line-height: 1.4; }


.sub-badge { padding: 4px 11px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.sub-badge.ok { background: rgba(47, 214, 163, .16); color: #0f9b74; }
.sub-badge.off { background: var(--line-soft); color: var(--muted); }
.plan-box {
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 15px; margin-top: 10px; background: var(--bg);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}

/* ---------- Forms ---------- */
label { display: block; margin: 14px 0 5px; font-weight: 600; font-size: .86rem; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .92rem;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--violet); box-shadow: var(--ring); }
/* The search field's own wrapper already shows the focus ring (:focus-within). */
.search input:focus { box-shadow: none; border-color: transparent; }
input[type="search"] { -webkit-appearance: none; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6e8f' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 15px;
  padding-right: 32px;
}
hr { margin: 22px 0; border: none; border-top: 1px solid var(--line); }

/* ---------- Chips / topic picker ---------- */
.topic-mode { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; margin: 0;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text);
  font-size: .82rem; font-weight: 500; cursor: pointer;
  transition: border-color .12s, background .12s, color .12s;
}
.chip:hover { border-color: var(--violet); color: var(--violet); }
.chip.selected, .chip.active {
  background: var(--swish); color: #fff; border-color: transparent; font-weight: 600;
  box-shadow: 0 4px 14px rgba(138, 92, 255, .3);
}
.chips-scroll { max-height: 250px; overflow-y: auto; padding-right: 4px; }
.topic-group { margin-bottom: 10px; }
.topic-group-label {
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); margin-bottom: 4px;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(27, 27, 58, .5);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 28px 16px; overflow-y: auto;
}
.modal-popup {
  max-width: 580px; width: 100%; max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: swishIn .2s ease-out;
}
/* Dialog title bar — same ink + swish stripe as the app banner */
.modal-head {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: -20px -20px 18px;
  padding: 15px 20px 16px;
  background: var(--ink);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  overflow: hidden;
}
.modal-head::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 3px; background: var(--swish);
}
.modal-head h3 {
  margin: 0; color: #fff; font-size: 1.05rem; font-weight: 700; letter-spacing: -.01em;
}
.modal-close {
  background: transparent; border: 1px solid rgba(255, 255, 255, .28); color: #e9eaff;
  width: 30px; height: 30px; min-width: 30px; padding: 0; margin: 0;
  border-radius: 50%; display: inline-grid; place-items: center;
  font-size: 20px; line-height: 1; flex: none;
}
.modal-close:hover {
  background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .55);
  color: #fff; transform: none; box-shadow: 0 6px 16px rgba(0, 0, 0, .28);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translate(-50%, 20px);
  opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff;
  padding: 11px 20px; border-radius: 999px;
  font-size: .88rem; font-weight: 600;
  box-shadow: var(--shadow-lg);
  transition: opacity .2s, transform .2s;
  z-index: 90;
  max-width: min(560px, 92vw);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--rose); }
.toast-ok { background: #12996f; }

/* ---------- Auth pages ---------- */
.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 34px 30px;
  box-shadow: var(--shadow);
}
.auth-brand { text-align: center; margin-bottom: 10px; display: flex; justify-content: center; }
.auth-tabs {
  display: flex; gap: 4px; margin-top: 20px; padding: 5px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px;
}
.auth-tabs button {
  flex: 1; padding: 9px 12px; border: 0; border-radius: 999px;
  background: transparent; color: var(--muted); font-weight: 600; box-shadow: none;
}
.auth-tabs button:not(.active):hover { background: var(--surface); color: var(--text); }
.auth-tabs button.active { background: var(--swish); color: #fff; box-shadow: 0 4px 14px rgba(138, 92, 255, .3); }
#loginForm, #registerForm, #forgotForm { margin-top: 18px; }
.auth-submit { width: 100%; margin-top: 20px; }
.auth-link-row { text-align: center; margin: 14px 0 0; }
.auth-link-row a { color: var(--violet); font-size: .85rem; text-decoration: none; font-weight: 600; }
.auth-link-row a:hover { text-decoration: underline; }


/* ---------- Subscription ---------- */
.upgrade-card {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 18px; padding: 16px 20px;
  border-radius: var(--r-lg);
  background: linear-gradient(100deg, rgba(138, 92, 255, .12), rgba(25, 181, 254, .1));
  border: 1px solid rgba(138, 92, 255, .28);
}
.upgrade-card .upgrade-text strong { font-family: var(--ui); font-size: 1rem; }
.upgrade-card .muted { font-size: .85rem; margin-top: 2px; }

.sub-settings {
  padding: 16px 18px; margin-bottom: 18px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--bg);
}
.sub-settings h4 { margin: 0 0 6px; font-family: var(--ui); font-size: .95rem; }
.plan-list {
  display: grid; gap: 10px; margin-top: 12px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.plan-list .plan-box { margin: 0; }
#subActions { margin-top: 12px; }
#subActions:empty { display: none; }

/* ---------- Practice Typing ---------- */
/* Opened from the toolbar, the typing view takes over the whole screen: the
   dashboard toolbar, sidebar and recent-writing cards step aside. */
body.practice-mode .toolbar,
body.practice-mode .sidebar,
body.practice-mode #treeResizer,
body.practice-mode .section-head,
body.practice-mode #recentSection,
body.practice-mode #upgradeCard { display: none !important; }
body.practice-mode .shell { grid-template-columns: 1fr; }
body.practice-mode .main { max-width: 940px; margin: 0 auto; padding-top: 22px; }
body.practice-mode #practicePanel { display: block !important; }

.practice-panel { padding: 0 0 22px; }
.practice-head {
  margin: 0; padding: 18px 22px;
  background: var(--ink); color: #fff;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  border-bottom: 3px solid transparent;
  border-image: var(--swish) 1;
}
.practice-head h2 { margin: 0; font-size: 1.12rem; }
.practice-head > div { flex: 1; min-width: 0; }
.practice-head .muted { color: #c3c6e6; }
.practice-head button {
  background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .3);
}
.practice-head button:hover { background: rgba(255, 255, 255, .22); box-shadow: none; }
.practice-head button.back-btn {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  margin-right: 14px;
}
.practice-head button.back-btn svg { width: 14px; height: 14px; }
/* The AI button keeps its violet identity inside the dark header. */
.practice-head button.ai {
  background: linear-gradient(100deg, var(--violet), var(--sky));
  color: #fff; border-color: transparent;
  display: inline-flex; align-items: center; gap: 6px;
}
.practice-head button.ai svg { width: 14px; height: 14px; }
.practice-head button.ai:hover { background: linear-gradient(100deg, var(--violet), var(--sky)); box-shadow: 0 8px 20px rgba(138, 92, 255, .45); }
.practice-head button.ai:disabled { opacity: .65; }

.practice-meta {
  display: flex; align-items: baseline; gap: 10px;
  padding: 16px 22px 6px;
}
.practice-meta .pane-title { font-size: .95rem; }

.practice-text { padding: 0 22px; }
.practice-passage {
  margin: 0; padding: 16px 18px;
  font-family: var(--serif); font-size: 1.22rem; line-height: 2;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.practice-passage .pw { border-radius: 4px; padding: 1px 3px; transition: color .12s, background .12s; }
.practice-passage .pw.todo { color: var(--muted); }
.practice-passage .pw.current {
  color: var(--ink); background: color-mix(in srgb, var(--violet) 16%, transparent);
  box-shadow: inset 0 -2px 0 var(--violet);
}
.practice-passage .pw.ok { color: var(--mint); font-weight: 600; }
.practice-passage .pw.bad { color: var(--crimson, #a4262c); font-weight: 600; text-decoration: underline; text-decoration-thickness: 2px; }

.practice-input {
  margin: 16px 22px 0; width: calc(100% - 44px);
  padding: 14px 16px;
  font-size: 1.1rem; letter-spacing: .01em;
}
.practice-input.is-correct { border-color: var(--mint); box-shadow: 0 0 0 3px rgba(47, 214, 163, .18); }
.practice-input.is-prefix { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(25, 181, 254, .16); }
.practice-input.is-wrong { border-color: #ef5b6f; box-shadow: 0 0 0 3px rgba(239, 91, 111, .18); color: #b3384a; }

.practice-hint { margin: 8px 22px 0; min-height: 1.1rem; font-size: .82rem; }
.practice-hint.ok { color: var(--mint); }
.practice-hint.tip { color: var(--muted); }
.practice-hint.warn { color: #b3384a; }
.practice-hint b { color: var(--ink); background: rgba(239, 91, 111, .12); border-radius: 3px; padding: 0 3px; }

.practice-meter { margin: 18px 22px 0; }
.practice-meter-top {
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: .85rem; margin-bottom: 6px;
}
.practice-meter-top b { font-size: 1.1rem; font-family: var(--ui); color: var(--violet); }
.meter-track {
  height: 12px; border-radius: 999px; overflow: hidden;
  background: var(--bg); border: 1px solid var(--line);
}
.meter-fill {
  height: 100%; width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--sky), var(--violet));
  transition: width .25s ease, background .25s ease;
}
.meter-fill[data-zone="fast"] { background: linear-gradient(90deg, var(--mint), var(--violet)); }
.meter-fill[data-zone="slow"] { background: linear-gradient(90deg, var(--sky), var(--mint)); }

.practice-stats {
  display: grid; gap: 10px; margin: 18px 22px 0;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}
.stat-tile {
  padding: 12px 14px; text-align: center;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-md);
}
.stat-tile b {
  display: block; font-family: var(--ui); font-size: 1.35rem; line-height: 1.2;
  color: var(--ink);
}
.stat-tile span { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

.practice-result { margin: 18px 22px 0; padding: 16px; border-radius: var(--r-md); background: var(--bg); border: 1px dashed var(--line); }
.result-row { display: flex; justify-content: space-around; gap: 12px; text-align: center; }
.result-stat b { display: block; font-family: var(--ui); font-size: 1.6rem; color: var(--violet); }
.result-stat span { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

body[data-theme="dark"] .practice-passage { background: #10112a; }
body[data-theme="dark"] .stat-tile b, body[data-theme="dark"] .practice-passage .pw.current { color: #fff; }
body[data-theme="dark"] .meter-track,
body[data-theme="dark"] .stat-tile,
body[data-theme="dark"] .practice-result { background: #10112a; }
body[data-theme="dark"] .practice-input.is-wrong { color: #ff9aa8; }
body[data-theme="sepia"] .practice-passage { background: #fbf3e4; }

/* ---------- Diary ---------- */
button.diary {
  background: linear-gradient(100deg, var(--violet), var(--sky));
  color: #fff; border-color: transparent;
  box-shadow: 0 6px 18px rgba(138, 92, 255, .3);
}
button.diary:hover { box-shadow: 0 10px 26px rgba(138, 92, 255, .42); }

.diary-chip {
  display: inline-block;
  margin-bottom: 8px;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--swish);
  color: #fff;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.link-btn {
  background: none; border: 0; padding: 0;
  color: var(--violet); font-size: .82rem; font-weight: 700;
  text-decoration: underline; cursor: pointer;
}
.link-btn:hover { color: var(--pink); }

.status-pill.diary { background: rgba(138, 92, 255, .12); color: var(--violet); }
.write-card.diary-card h3 { font-family: var(--ui); letter-spacing: .01em; }

/* Sidebar: two parallel sections (Timed Writing / Diary) */
.tree-section + .tree-section { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line); }
.tree-section-head {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 8px; padding: 0 8px;
  font-family: var(--ui); font-size: .74rem; font-weight: 800;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink);
}
.tree-section.diary-section .tree-section-head { color: var(--violet); }
.tree-section-sub {
  font-weight: 500; letter-spacing: .04em; text-transform: none;
  font-size: .7rem; color: var(--muted);
}
.tree-year.diary-tree .tree-toggle strong { color: var(--violet); }

/* Diary rows share the leaf pattern; only the accent colour differs. */
.tree-year.diary-tree .tree-toggle strong { color: var(--violet); }
.tree-year.diary-tree { margin-top: 0; }

.polish-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding-bottom: 14px; margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

/* ---------- Editor ---------- */
/* Header card: only the title line sits on the dark bar; topic + tabs stay light. */
.editor-head { padding: 0; margin-bottom: 18px; overflow: hidden; }
.editor-title-bar {
  position: relative;
  background: var(--ink);
  padding: 13px 20px 14px;
}
.editor-title-bar::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 3px; background: var(--swish);
}
.editor-head-body { padding: 14px 20px 0; }
.editor-title-bar .art-title-input { margin: 0; color: #fff; }
.editor-title-bar .art-title-input::placeholder { color: rgba(255, 255, 255, .45); }
.editor-title-bar .art-title-input:hover { border-color: rgba(255, 255, 255, .28); }
.editor-title-bar .art-title-input:focus {
  background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .4);
  box-shadow: 0 0 0 3px rgba(138, 92, 255, .28);
}

/* Themed action buttons (editor side panel) */
button.finish {
  background: linear-gradient(100deg, #2fd6a3, #19b5fe);
  color: #fff; border-color: transparent;
  box-shadow: 0 6px 18px rgba(47, 214, 163, .3);
}
button.finish:hover { box-shadow: 0 10px 26px rgba(47, 214, 163, .42); }
button.ghost-dark {
  background: transparent; color: var(--violet); border-color: rgba(138, 92, 255, .4);
}
button.ghost-dark:hover {
  background: rgba(138, 92, 255, .1); border-color: var(--violet);
  box-shadow: 0 8px 20px rgba(138, 92, 255, .22);
}
.editor-side button { width: 100%; }

.editor-layout { display: flex; gap: 18px; align-items: flex-start; }
.editor-main { flex: 1; min-width: 0; }
.editor-side { width: 230px; flex-shrink: 0; display: flex; flex-direction: column; gap: 14px; }
.editor-side button { width: 100%; }
.editor-tabs {
  display: flex; gap: 4px; margin-bottom: 14px;
  border-bottom: 1px solid var(--line); flex-wrap: nowrap;
}
.tab-btn {
  background: transparent; color: var(--muted);
  border: 0; border-bottom: 3px solid transparent;
  padding: 10px 16px; margin-bottom: -1px;
  border-radius: 0; font-weight: 600; box-shadow: none;
}
.tab-btn:hover { color: var(--violet); background: none; }
.tab-btn.active { color: var(--violet); border-bottom-color: var(--violet); background: none; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

#editor {
  font-family: var(--editor-font-family, var(--serif));
  font-size: var(--editor-font-size, 18px);
  line-height: var(--editor-line-height, 1.65);
  min-height: 60vh;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px 20px;
}
#editor:focus { outline: none; border-color: var(--violet); box-shadow: var(--ring); }
.editor .extra, #editor.extra { color: var(--muted); }
.art-title-input {
  font-family: var(--serif); font-size: 1.6rem; font-weight: 600;
  letter-spacing: -.01em;
  background: transparent; border: 1px solid transparent; color: inherit;
  border-radius: var(--r-sm); padding: 6px 10px; margin: -6px -10px 4px;
}
.art-title-input:hover { border-color: var(--line); }
.art-title-input:focus { outline: none; border-color: var(--violet); background: var(--surface); box-shadow: var(--ring); }

.timer { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; text-align: center; letter-spacing: -.02em; }
.timer-bar-wrap {
  position: relative; width: 30px; height: 260px; margin: 8px auto;
  border-radius: 15px; overflow: hidden;
  background: var(--line-soft); border: 1px solid var(--line);
}
.timer-bar-fill {
  position: absolute; inset: auto 0 0 0; height: 100%;
  background: linear-gradient(to bottom, var(--mint) 0%, var(--amber) 55%, var(--rose) 100%);
  transition: height 1s linear;
}
.timer-bar-wrap.flash { animation: timerFlash .9s infinite; }
@keyframes timerFlash { 50% { opacity: .2; } }

/* ---------- Versions ---------- */
.versions-layout { display: flex; gap: 18px; align-items: flex-start; }
.version-list { width: 190px; flex-shrink: 0; }
.version-item {
  padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--r);
  margin-bottom: 9px; cursor: pointer; font-size: .85rem; background: var(--surface);
  transition: border-color .12s, box-shadow .12s;
}
.version-item:hover { border-color: #cfd2ea; }
.version-item.active { border-color: var(--violet); box-shadow: var(--ring); background: var(--surface); }
.version-item .v-name { font-weight: 700; }
.version-item .v-tag { font-size: .72rem; color: var(--muted); display: block; margin-top: 2px; }
.versions-editor { flex: 1; min-width: 0; }
.version-note { font-style: normal; }

/* ---------- Split pane / AI review ---------- */
.split-pane { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: flex-start; }
.split-pane .pane { min-width: 0; }
.original-pane { color: inherit; }
.score-panel {
  display: flex; gap: 18px; align-items: center;
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px; margin: 12px 0; background: var(--bg);
}
.score-total { text-align: center; min-width: 96px; }
.score-num { display: block; font-size: 2.3rem; font-weight: 800; letter-spacing: -.03em; background: var(--swish); -webkit-background-clip: text; background-clip: text; color: transparent; }
.score-detail { flex: 1; }
.score-row { display: flex; align-items: center; gap: 10px; margin: 4px 0; font-size: .82rem; }
.score-row > span:first-child { width: 92px; color: var(--muted); }
.score-bar { flex: 1; background: var(--line-soft); border-radius: 999px; height: 8px; overflow: hidden; }
.score-bar i { display: block; height: 100%; border-radius: 999px; background: var(--swish); }
.score-val { width: 28px; text-align: right; font-weight: 700; }
.issue-group { margin: 12px 0; }
.issue-label { font-weight: 700; font-size: .85rem; color: var(--rose); margin-bottom: 5px; }
.issue-item {
  border-left: 3px solid var(--amber); background: rgba(245, 158, 11, .08);
  padding: 8px 12px; margin: 5px 0; border-radius: 0 var(--r-sm) var(--r-sm) 0; font-size: .86rem;
}
.issue-explain { margin-top: 3px; }
.summary-block { margin-top: 14px; }
.summary-strengths, .summary-improve { margin-bottom: 10px; }
.summary-block ul { margin: 5px 0; padding-left: 20px; }
.overall-text {
  background: rgba(138, 92, 255, .07); border-radius: var(--r);
  padding: 12px 15px; font-size: .92rem;
}

/* ---------- Report ---------- */
.report-page { font-family: var(--serif); line-height: 1.65; }
.report-header { text-align: center; margin-bottom: 26px; border-bottom: 2px solid var(--line); padding-bottom: 18px; }
.report-header h2 { margin: 0 0 6px; font-family: var(--serif); font-size: 1.9rem; }
.report-stats { font-size: .9rem; color: var(--muted); margin: 10px 0 0; }
.report-section { margin-bottom: 26px; page-break-inside: avoid; }
.report-section h3 { border-bottom: 1px solid var(--line); padding-bottom: 7px; margin-bottom: 12px; color: var(--violet); font-family: var(--serif); }
.report-text {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; white-space: pre-wrap; font-size: .96rem;
}
.report-review { font-size: .9rem; }
.report-scores { margin-bottom: 14px; flex-wrap: wrap; display: flex; gap: 10px; }

/* ---------- Admin ---------- */
.filter-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar input { flex: 1; min-width: 200px; }
.filter-bar select { width: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .87rem; }
.admin-table th {
  text-align: left; font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
  border-bottom: 1px solid var(--line); padding: 9px 8px;
}
.admin-table td { border-bottom: 1px solid var(--line-soft); padding: 10px 8px; vertical-align: middle; }
.admin-table tr:hover td { background: var(--bg); }
.role-select { width: auto; padding: 5px 8px; font-size: .82rem; }
.pager { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.detail-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 10px; margin-top: 14px; }
.stat-box { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; text-align: center; }
.stat-num { font-size: 1.25rem; font-weight: 800; }
.grant-box { background: var(--bg); border-color: var(--line); }
.grant-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.grant-row input { width: auto; }
.grant-row input[type="number"] { width: 110px; }
.grant-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 2px; border-bottom: 1px solid var(--line-soft); font-size: .84rem;
}
.log-action { font-size: .74rem; background: var(--bg); padding: 3px 7px; border-radius: 999px; border: 1px solid var(--line); }

/* ---------- Themes ---------- */
body[data-theme="dark"] {
  --bg: #14152b; --surface: #1e1f3d; --line: #2f3160; --line-soft: #272952;
  --text: #e9eaff; --muted: #a0a3c8;
  background: var(--bg); color: var(--text);
}
body[data-theme="dark"] .card,
body[data-theme="dark"] .sidebar,
body[data-theme="dark"] .modal-popup { background: var(--surface); border-color: var(--line); }
body[data-theme="dark"] .banner { background: #0f1024; }
body[data-theme="dark"] .editor-title-bar { background: #10112a; }
body[data-theme="dark"] .muted { color: var(--muted); }
body[data-theme="dark"] .tree-toggle:hover,
body[data-theme="dark"] .leaf-open:hover,
body[data-theme="dark"] .admin-table tr:hover td,
body[data-theme="dark"] .version-item:hover { background: var(--line-soft); }
body[data-theme="dark"] .tree-body,
body[data-theme="dark"] .score-bar { border-color: var(--line); }
body[data-theme="dark"] input,
body[data-theme="dark"] select,
body[data-theme="dark"] textarea { background: var(--bg); color: var(--text); border-color: var(--line); }
body[data-theme="dark"] select { background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a0a3c8' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); }
body[data-theme="dark"] .write-card:hover { box-shadow: 0 10px 26px rgba(0, 0, 0, .45); }
body[data-theme="dark"] .art-title-input:focus,
body[data-theme="dark"] #editor:focus { background: var(--bg); }
body[data-theme="dark"] .auth-tabs { background: var(--bg); border-color: var(--line); }
body[data-theme="dark"] .auth-tabs button:not(.active):hover { background: var(--line-soft); color: var(--text); }
body[data-theme="dark"] .timer-bar-wrap { background: var(--bg); border-color: var(--line); }
body[data-theme="dark"] .report-text,
body[data-theme="dark"] .score-panel,
body[data-theme="dark"] .plan-box,
body[data-theme="dark"] .stat-box,
body[data-theme="dark"] .grant-box { background: var(--bg); border-color: var(--line); }
body[data-theme="dark"] .search input,
body[data-theme="dark"] .search { background: var(--bg); border-color: var(--line); }
body[data-theme="dark"] .search input { border: 0; }
body[data-theme="dark"] .overall-text { background: rgba(138, 92, 255, .12); }

body[data-theme="sepia"] {
  --bg: #f6efe0; --surface: #fdf8ee; --line: #e5d8bd; --line-soft: #f0e6d2;
  --text: #3c3225; --muted: #7d6f5c;
  background: var(--bg); color: var(--text);
}
body[data-theme="sepia"] .write-card::before { background: linear-gradient(100deg, #b07d2a, #c99a3f); }
body[data-theme="sepia"] .write-card:hover { box-shadow: 0 10px 26px rgba(90, 70, 40, .14); }
body[data-theme="sepia"] .btn.primary,
body[data-theme="sepia"] button.primary,
body[data-theme="sepia"] .btn-primary,
body[data-theme="sepia"] .chip.selected,
body[data-theme="sepia"] .chip.active,
body[data-theme="sepia"] .auth-tabs button.active { background: linear-gradient(100deg, #b07d2a, #c99a3f); box-shadow: 0 6px 18px rgba(176, 125, 42, .3); }
body[data-theme="sepia"] button:hover { border-color: #c9ab74; }
body[data-theme="sepia"] .tree-toggle:hover { background: var(--line-soft); }
body[data-theme="sepia"] input,
body[data-theme="sepia"] select,
body[data-theme="sepia"] textarea { background: #fffaf0; color: #3c3225; border-color: var(--line); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .resizer { display: none; }
  .app-shell { grid-template-rows: 64px auto; overflow: auto; }
  .app { height: auto; overflow: visible; }
  .sidebar { max-height: 300px; border-right: 0; border-bottom: 1px solid var(--line); }
  .username { display: none; }
  .banner { padding: 0 14px; }
  .assist-grid { grid-template-columns: 1fr; }
  .editor-layout { flex-direction: column; }
  .editor-side { width: 100%; }
  .versions-layout { flex-direction: column; }
  .version-list { width: 100%; display: flex; gap: 10px; overflow-x: auto; }
  .split-pane { grid-template-columns: 1fr; }
  .filter-bar input { min-width: 0; }
}
@media (max-width: 560px) {
  .cards { grid-template-columns: 1fr; }
  .admin-table { display: block; overflow-x: auto; white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Print ---------- */
@media print {
  body { background: #fff !important; color: #000; }
  .banner, .editor-head, .editor-tabs, #reportToolbar, .tab-btn, .editor-side,
  .toolbar, .sidebar, .toast { display: none !important; }
  .container, .main { max-width: 100% !important; padding: 0 !important; overflow: visible !important; height: auto !important; }
  .card { box-shadow: none !important; border: none !important; padding: 0 !important; background: #fff !important; }
  /* Only the report reaches paper. Un-blocking every .tab-panel (the old rule)
     also printed the writing, improve and review tabs — the raw textarea and
     private notes alongside the report. Everything else stays display:none. */
  .tab-panel { display: none !important; }
  #tab-report { display: block !important; }
  .report-page { padding: 20px; }
  .report-section { page-break-inside: avoid; }
  .report-text { border: 1px solid #ccc; background: #fff; }
}