:root {
  --purple: #7c5cbf;
  --purple-dark: #5f43a0;
  --bg: #faf7ff;
  --card: #ffffff;
  --ink: #2b2438;
  --muted: #8a819c;
  --line: #e6def5;
  --guide: #efe9fb;
  --mine: #e3f5e9;
  --theirs: #fdf3e3;
}
* { box-sizing: border-box; }
body {
  margin: 0; padding: 16px; background: var(--bg); color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  max-width: 760px; margin-inline: auto;
}
h1 { font-size: 1.5rem; margin: 0 0 4px; }
h3 { margin: 0 0 8px; }
button { cursor: pointer; font: inherit; }
button.primary {
  background: var(--purple); color: #fff; border: none; border-radius: 10px;
  padding: 10px 16px; font-weight: 600;
}
button.primary:hover { background: var(--purple-dark); }
button.ghost { background: none; border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; color: var(--ink); }
.small-btn { padding: 2px 8px; font-size: .8rem; }
input, textarea, select {
  font: inherit; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; width: 100%;
}
label { display: block; margin: 8px 0; font-size: .92rem; }
label.check, label.radio { display: flex; gap: 8px; align-items: flex-start; font-weight: normal; }
label.check input, label.radio input { width: auto; margin-top: 3px; }
fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 14px 0; padding: 10px 14px; }
legend { font-weight: 600; padding: 0 6px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: #b3261e; background: #fdecea; border-radius: 8px; padding: 8px 10px; }
.done { text-decoration: line-through; color: var(--muted); }
.badge {
  background: var(--purple); color: #fff; font-size: .7rem; font-weight: 700;
  border-radius: 999px; padding: 2px 8px; vertical-align: middle;
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px; margin: 12px 0; box-shadow: 0 1px 3px rgba(60, 40, 120, .05);
}
.auth-card { margin-top: 6vh; }
.auth-tabs, .tabs { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.auth-tab, .tab {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 16px;
}
.auth-tab.active, .tab.active { background: var(--purple); color: #fff; border-color: var(--purple); }
.topbar { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.topbar .logo { font-weight: 700; flex: 1; }
.messages { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.msg { border-radius: 14px; padding: 10px 14px; max-width: 92%; white-space: pre-wrap; }
.msg .msg-author { font-size: .78rem; font-weight: 700; color: var(--muted); margin-bottom: 3px; }
.msg.mine { background: var(--mine); align-self: flex-end; }
.msg.theirs { background: var(--theirs); align-self: flex-start; }
.msg.guide { background: var(--guide); align-self: stretch; max-width: 100%; border: 1px dashed var(--purple); }
.composer { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; resize: vertical; }
.composer-btns { display: flex; flex-direction: column; gap: 6px; }
#scheduled-strip {
  border: 1px dashed var(--purple); background: #fffdf4; border-radius: 14px;
  padding: 10px 14px; margin: 10px 0;
}
#scheduled-strip h4 { margin: 0 0 6px; font-size: .92rem; }
.sched-row { display: flex; gap: 8px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--line); }
.sched-row:last-child { border-bottom: none; }
.sched-row .sched-body { flex: 1; white-space: pre-wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.focus-card { border-left: 5px solid var(--purple); }
.inline-form { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 140px; }
.inline-form select { width: auto; }
.stack-form label { margin: 10px 0; }
.plain-list { list-style: none; padding: 0; margin: 6px 0; }
.plain-list li { padding: 4px 0; border-bottom: 1px solid var(--line); }
.plain-list li:last-child { border-bottom: none; }
.reminder { padding: 4px 0; }
.modal {
  position: fixed; inset: 0; background: rgba(30, 20, 60, .45);
  display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 20px 10px;
}
.modal[hidden] { display: none; }
.modal-box { background: #fff; border-radius: 16px; padding: 20px; width: 100%; max-width: 620px; }
.modal-actions { display: flex; justify-content: space-between; margin-top: 14px; }
.quiz-q { margin: 10px 0; }
.quiz-q p { margin: 4px 0; }
@media (max-width: 520px) {
  body { padding: 10px; }
  .msg { max-width: 100%; }
}
