:root {
  --brand: #1f4e5f;
  --ink: #1c2430;
  --muted: #5e6b7a;
  --line: #dde3ea;
  --bg: #f5f7f9;
  --card: #ffffff;
  --warn-bg: #fff6e0;
  --warn-line: #f0d48a;
  --danger: #b3261e;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
h1 { font-size: 1.5rem; margin: 0 0 4px; line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
p { margin: 0 0 12px; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-inner { max-width: 960px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--brand); margin-right: auto; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--ink); font-weight: 500; }
.nav a.active { background: color-mix(in srgb, var(--brand) 12%, white); color: var(--brand); }
main { max-width: 960px; margin: 0 auto; padding: 24px 16px 96px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1 1 220px; min-width: 0; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }

label { display: block; font-weight: 600; font-size: 0.875rem; margin-bottom: 4px; }
label .opt { font-weight: 400; color: var(--muted); }
input[type="text"], input[type="email"], input[type="url"], input[type="date"], input[type="number"], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid #c5ced8; border-radius: 8px; font: inherit; color: inherit; background: #fff;
}
textarea { resize: vertical; min-height: 84px; }
textarea.transcript { min-height: 260px; }
input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 45%, white); outline-offset: 1px; }
input[type="color"] { width: 52px; height: 42px; padding: 2px; border: 1px solid #c5ced8; border-radius: 8px; background: #fff; }

button, .btn {
  font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 8px; border: 1px solid #c5ced8; background: #fff; color: var(--ink);
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
}
button.primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.ghost { border-color: transparent; background: transparent; color: var(--brand); padding: 8px 10px; }
button.danger { color: var(--danger); }
button.sm { min-height: 36px; padding: 6px 10px; font-size: 0.875rem; }
button:disabled { opacity: 0.55; cursor: default; }

.login { max-width: 400px; margin: 12vh auto 0; padding: 0 16px; }
.login h1 { color: var(--brand); }
.code-input { font-size: 1.5rem; letter-spacing: 0.3em; text-align: center; }

.list a.item { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 14px 4px; border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
.list a.item:first-child { border-top: 0; }
.list a.item:hover strong { color: var(--brand); }

.banner { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.banner ul { margin: 6px 0 0; padding-left: 20px; }
.demo-warning { border-left: 4px solid #a45e00; }
.block { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; background: #fbfcfd; }
.block-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.thumb { width: 132px; }
.thumb img { width: 132px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #fff; display: block; }
.thumb-missing { width: 132px; min-height: 96px; padding: 8px; border: 1px solid var(--warn-line); border-radius: 8px; background: var(--warn-bg); font-size: 0.8rem; }
.thumb input { margin-top: 4px; padding: 6px 8px; font-size: 0.8rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.grid .tile { border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: #fff; text-align: left; display: block; min-height: 0; font-weight: 400; }
.grid .tile img { width: 100%; height: 100px; object-fit: contain; background: #f2f4f6; border-radius: 6px; display: block; margin-bottom: 6px; }
.grid .tile .t { font-size: 0.8rem; line-height: 1.3; display: block; overflow-wrap: anywhere; }

.actionbar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); z-index: 6; }
.actionbar-inner { max-width: 960px; margin: 0 auto; padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.actionbar-inner .danger { margin-right: auto; }
.editor { padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
@media (max-width: 520px) {
  .actionbar-inner { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .actionbar-inner .danger { margin-right: 0; }
}

.modal-back { position: fixed; inset: 0; background: rgba(20, 28, 38, 0.5); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: #fff; width: 100%; max-width: 720px; max-height: 88vh; overflow: auto; border-radius: 14px 14px 0 0; padding: 20px; }
@media (min-width: 720px) { .modal-back { align-items: center; } .modal { border-radius: 14px; } }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: none; min-height: 40px; }
.tabs button.on { border-bottom-color: var(--brand); color: var(--brand); }

.spinner { width: 18px; height: 18px; border: 3px solid rgba(255, 255, 255, 0.4); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 30; max-width: 90vw; }
#toast.show { opacity: 1; }
@media (max-width: 520px) { #toast { bottom: calc(124px + env(safe-area-inset-bottom, 0px)); } }

.flags { padding: 10px 14px; }
.flags summary { font-weight: 600; cursor: pointer; }
.flags li { font-size: 0.9rem; margin-bottom: 4px; }
.review-search { align-items: end; }
.review-option { width: 100%; display: flex; flex-direction: column; align-items: flex-start; text-align: left; font-weight: 400; overflow-wrap: anywhere; }
.review-option:hover { border-color: var(--brand); }
.review-quote { font-style: italic; overflow-wrap: anywhere; }
.review-selected .review-quote { margin: 8px 0; }
.review-selected p.small { margin-bottom: 4px; }
.review-results:empty, .review-card [role="status"]:empty { display: none; }

.live-pt-results:empty, .live-pt-preview:empty, .live-pt-selected:empty, .live-pt-card [role="status"]:empty { display: none; }
.live-pt-option { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left; font-weight: 400; overflow-wrap: anywhere; }
.live-pt-option:hover { border-color: var(--brand); }
.live-pt-program, .live-pt-selected { overflow-wrap: anywhere; }
.live-pt-program label, .live-pt-confirm { display: flex; gap: 8px; align-items: flex-start; font-size: 1rem; }
.live-pt-exercises { margin: 8px 0 0; padding-left: 24px; }
.live-pt-exercises li { margin: 0 0 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.live-pt-exercises li:last-child { margin-bottom: 0; }
.live-pt-details { white-space: pre-wrap; }


.preview-notice {
  display:flex; align-items:center; justify-content:center; gap:10px; padding:10px 18px;
  background:#fff4d6; color:#654a00; border-bottom:1px solid #f0c86b; font-size:13px; text-align:center;
}
.preview-notice strong { letter-spacing:.08em; font-size:12px; }
@media (max-width: 560px) { .preview-notice { align-items:flex-start; flex-direction:column; gap:3px; text-align:left; } }
