/* Same family as bls.saderra.com and sand.saderra.com: midnight surfaces, warm amber accent. */
:root {
  color-scheme: dark;
  --page: #0b0d12;
  --panel: #12151c;
  --raised: #1a1e27;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);
  --ink: #f3efe8;
  --muted: #b4b9c7;
  --accent: #f2b56b;
  --accent-soft: rgba(242, 181, 107, 0.14);
  --accent-ink: #1d1408;
  --danger: #e2735a;
  --ok: #7fd4a0;
  --radius: 16px;
  --sans: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  font-family: var(--sans);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { color: var(--ink); background: var(--page); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Buttons and small parts ------------------------------------------- */
.btn {
  font: inherit; font-size: 15px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: transparent; color: var(--ink); padding: 8px 14px; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.24); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: #f6c486; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #1c0c08; font-weight: 600; }
.btn.danger:hover { background: #e98a74; border-color: #e98a74; }
.btn.big { font-size: 18px; padding: 14px 32px; }
.btn:disabled { opacity: 0.5; cursor: default; }
a.btn { display: inline-block; text-decoration: none; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; box-shadow: 0 0 8px currentColor; color: var(--accent); }
.dot.on { background: var(--ok); color: var(--ok); }
.dot.off { background: var(--danger); color: var(--danger); }
.status { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; color: var(--muted); white-space: nowrap; }

.seg { display: inline-flex; gap: 3px; padding: 3px; background: var(--raised); border-radius: 11px; }
.seg button {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 14px; padding: 7px 12px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed=true] { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px rgba(242, 181, 107, 0.35); }
.seg svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

input[type=text], input[type=search], input[type=email] {
  font: inherit; font-size: 15px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--raised); color: var(--ink); width: 100%;
}
input::placeholder { color: var(--muted); }
/* iOS zooms into fields under 16px. */
@media (pointer: coarse) { input[type=text], input[type=search], input[type=email] { font-size: 16px; } }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; color: var(--muted); white-space: nowrap; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  position: relative; width: 40px; height: 22px; border-radius: 999px; flex: none;
  background: var(--raised); box-shadow: inset 0 0 0 1px var(--line-strong); transition: background 0.2s;
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--muted); transition: transform 0.2s, background 0.2s;
}
.switch input:checked + .switch-track { background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(242, 181, 107, 0.5); }
.switch input:checked + .switch-track::after { transform: translateX(18px); background: var(--accent); }
.switch input:checked ~ span:last-child { color: var(--ink); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

.hint { font-size: 14px; color: var(--muted); line-height: 1.5; }
.error { color: var(--danger); font-size: 14px; }

/* ---- Dialogs ------------------------------------------------------------ */
.modal {
  position: fixed; width: min(520px, calc(100vw - 32px)); padding: 28px; border-radius: 20px;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line-strong);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.modal::backdrop { background: rgba(5, 6, 9, 0.7); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal-title { font-family: var(--serif); font-weight: 300; font-size: 28px; margin: 0 0 8px; }
.modal .hint { font-size: 15px; margin: 0 0 22px; }
.modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.modal-close-form { position: absolute; top: 14px; right: 14px; margin: 0; }
.modal-close {
  width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer;
  background: transparent; color: var(--muted); font-size: 22px; line-height: 1;
}
.modal-close:hover { background: var(--raised); color: var(--ink); }
.link-row { display: flex; gap: 8px; }
.link-row input { flex: 1; min-width: 0; font-family: ui-monospace, Menlo, monospace; color: var(--accent); }

/* ---- Home page ---------------------------------------------------------- */
body.home-page {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(242, 181, 107, 0.10), transparent 70%) no-repeat fixed,
    var(--page);
}
.home { max-width: 720px; margin: 0 auto; padding: 12vh 16px 48px; text-align: center; }
.home h1.logo { margin: 40px 0 36px; line-height: 0; }
.home h1.logo img { width: min(330px, 100%); height: auto; }
.home .lead { color: var(--muted); font-size: 18px; line-height: 1.6; margin: 0 auto 32px; max-width: 560px; }
.home .error { margin-top: 12px; }
.home-art { display: block; margin: 0 auto; width: 260px; height: 64px; overflow: visible; }
.home-art .doodle { fill: none; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.home-art .art-note { filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.4)); }
.home-points { list-style: none; padding: 0; margin: 48px auto 0; max-width: 560px; text-align: left; display: grid; gap: 12px; }
.home-points li { color: var(--muted); font-size: 15px; line-height: 1.5; padding-left: 22px; position: relative; }
.home-points li::before { content: ""; position: absolute; left: 4px; top: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.home-points strong { color: var(--ink); font-weight: 500; }
/* Links to the other Saderra tools on the home page */
.sister-heading { margin: 48px 0 12px; }
.sister-sites { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 560px; margin: 0 auto; }
@media (max-width: 520px) { .sister-sites { grid-template-columns: 1fr; } }
.sister-site {
  display: block; padding: 20px; text-decoration: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.sister-site:hover { border-color: var(--accent); background: var(--accent-soft); }
.sister-label { display: block; font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.sister-site img { display: block; margin: 0 auto; width: auto; height: 20px; }
.sister-desc { display: block; margin-top: 12px; font-size: 14px; line-height: 1.5; color: var(--muted); }
.home-foot { margin-top: 48px; font-size: 13px; color: var(--muted); }
.home-foot a { color: var(--muted); }

/* ---- The board app ------------------------------------------------------ */
body.app { height: 100dvh; overflow: hidden; display: grid; grid-template-rows: auto 1fr; }
.bar {
  display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.bar .brand { line-height: 0; margin-right: auto; }
.bar .brand img { height: 22px; width: auto; }
.bar-actions { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }

.stage { display: grid; grid-template-rows: auto auto 1fr; min-width: 0; min-height: 0; }
.tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.tools .spacer { flex: 1; }
.tools .seg button { padding: 7px 9px; }
.tools .seg svg { width: 18px; height: 18px; }
.seg button:disabled { opacity: 0.35; cursor: default; }
.seg-gap { width: 1px; align-self: stretch; margin: 5px 3px; background: var(--line-strong); }

/* The row under the tools: colors and sizes, or what's selected. */
.opts { display: flex; align-items: center; min-height: 52px; padding: 7px 16px; border-bottom: 1px solid var(--line); }
.tool-opts { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; }
.opts .hint { font-size: 14px; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25), 0 0 0 1px var(--line-strong);
}
.swatch[aria-pressed=true] { box-shadow: 0 0 0 2px var(--page), 0 0 0 4px var(--accent); }
.sizes button { width: 36px; height: 30px; justify-content: center; padding: 0; }
.sizes i { display: block; width: var(--d); height: var(--d); border-radius: 50%; background: currentColor; }
.sel-bar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 3px 3px 3px 12px; border-radius: 11px; background: var(--raised); }
.sel-bar .sel-name { font-size: 14px; color: var(--ink); margin-right: 6px; white-space: nowrap; }
.sel-bar .swatches { margin-right: 8px; }
.sel-bar .swatch { width: 22px; height: 22px; }
.sel-bar button:not(.swatch) { font: inherit; font-size: 14px; padding: 6px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.sel-bar button:not(.swatch):hover { color: var(--ink); background: rgba(255, 255, 255, 0.06); }
.sel-bar .remove:hover { color: var(--danger); }
@media (pointer: coarse) { .swatch { width: 32px; height: 32px; } .sel-bar .swatch { width: 28px; height: 28px; } }

/* The board keeps a 16:10 shape and fills the space it has. */
.board-wrap { container-type: size; display: grid; place-items: center; padding: 20px 20px 34px; min-height: 0; }
.board {
  position: relative; width: min(100cqw - 4px, (100cqh - 4px) * 1.6); aspect-ratio: 16 / 10; overflow: hidden;
  border-radius: 8px; touch-action: none; user-select: none; -webkit-user-select: none; cursor: crosshair;
  background: #fdfcfa; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 24px 60px rgba(0, 0, 0, 0.55);
}
.board[data-tool=select] { cursor: default; }
.board[data-tool=text] { cursor: text; }
.board[data-tool=eraser] { cursor: none; }
.board canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#over, #cursors { position: absolute; inset: 0; pointer-events: none; }
#cursors { z-index: 2; }
body.read-only .board { cursor: default; }

.sel-box { position: absolute; left: 0; top: 0; border: 1.5px dashed #3b82f6; border-radius: 4px; }
.handle {
  position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 2px solid #3b82f6; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  pointer-events: auto; touch-action: none; cursor: nwse-resize;
}
.handle[data-h=p1], .handle[data-h=p2] { cursor: move; }
@media (pointer: coarse) { .handle { width: 28px; height: 28px; left: -14px; top: -14px; } }
.eraser-ring { position: absolute; left: 0; top: 0; border-radius: 50%; border: 1.5px solid rgba(0, 0, 0, 0.55); background: rgba(255, 255, 255, 0.45); }

/* Typing into text or a sticky note. */
.editor {
  position: absolute; left: 0; top: 0; margin: 0; padding: 0; border: 0; border-radius: 0; pointer-events: auto;
  background: transparent; color: #2b2a28; resize: none; overflow: hidden;
  font-family: var(--sans); font-weight: 500; line-height: 1.25; white-space: pre;
  outline: 1.5px dashed rgba(59, 130, 246, 0.8); outline-offset: 6px; caret-color: #3b82f6;
}
.editor.note { white-space: pre-wrap; overflow-wrap: break-word; outline: 0; }

.cursor { position: absolute; left: 0; top: 0; transition: transform 0.1s linear; }
.cursor::before {
  content: ""; position: absolute; left: -7px; top: -7px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--c); box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35);
}
.cursor span {
  position: absolute; left: 10px; top: 8px; padding: 2px 8px; border-radius: 6px;
  background: var(--c); color: #111; font-size: 12px; font-weight: 600; white-space: nowrap;
}

.board-note {
  position: absolute; left: 50%; top: 16px; transform: translateX(-50%); z-index: 4;
  padding: 10px 18px; border-radius: 12px; background: rgba(11, 13, 18, 0.82); color: var(--ink);
  font-size: 15px; white-space: nowrap; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
body.read-only .tools .seg, body.read-only .opts, body.read-only #bgBtn { opacity: 0.4; pointer-events: none; }

/* ---- Backgrounds -------------------------------------------------------- */
.bg-modal { width: min(660px, calc(100vw - 32px)); }
.bg-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.bg-choice {
  display: flex; flex-direction: column; gap: 8px; padding: 8px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--raised); color: var(--ink); font: inherit; font-size: 14px; text-align: left;
}
.bg-choice canvas { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; border-radius: 6px; }
.bg-choice:hover { border-color: rgba(242, 181, 107, 0.5); }
.bg-choice[aria-pressed=true] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.flash {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  padding: 10px 18px; border-radius: 12px; background: #2a5a3f; color: #fff; font-size: 15px;
}

/* ---- Accounts (home page) ------------------------------------------------ */
/* The same sign-in panel as bls.saderra.com. */
.check { display: flex; justify-content: flex-start; align-items: center; gap: 10px; font-size: 15px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.modal-label { display: block; font-size: 14px; color: var(--muted); margin: 0 0 8px; }
.home-signin {
  position: absolute; top: max(16px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right));
  background: none; border: 1px solid var(--line-strong); border-radius: 999px; padding: 8px 18px;
  font: inherit; font-size: 14px; font-weight: 500; color: var(--ink); cursor: pointer;
}
.home-signin:hover { border-color: var(--accent); color: var(--accent); }
.home-signin[hidden] { display: none; }
.account { margin-top: 36px; }
.account-panel {
  margin: 0 auto; max-width: 540px; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px;
}
.account-panel h2 { font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); margin: 0 0 8px; font-weight: 600; }
.account-panel h2 .free { color: #fff; font-weight: 700; }
.home .account-panel .hint { margin: 0 0 18px; max-width: none; font-size: 15px; }
.account-row { display: flex; gap: 10px; }
.account-row > input { flex: 1; min-width: 0; }
.account-row .btn { flex: none; white-space: nowrap; }
@media (max-width: 480px) { .account-row { flex-direction: column; } .account-panel { padding: 20px; } }
#loginCode { font-family: ui-monospace, Menlo, monospace; letter-spacing: 0.2em; }
.account-links { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px; }
.account-links:not(:has(:not([hidden]))) { display: none; }
.text-btn { background: none; border: 0; padding: 0; font: inherit; font-size: 13px; color: var(--muted); text-decoration: underline; cursor: pointer; }
.text-btn:hover { color: var(--ink); }
.text-btn:disabled { opacity: 0.6; cursor: default; }
.my-link { margin: 4px 0 18px; font-family: ui-monospace, Menlo, monospace; font-size: 17px; }
.my-link a { color: var(--ink); text-decoration: none; letter-spacing: 0.02em; }
.my-link a:hover { color: var(--accent); }
#readyStep .btn.big { width: 100%; }
.home .account-panel .error, .home #accountNote { margin: 14px 0 0; }
.account-foot {
  display: flex; gap: 6px 16px; flex-wrap: wrap; align-items: baseline;
  margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted);
}
.account-foot .signed-in { margin-right: auto; }
.home .updates-check { font-size: 14px; color: var(--muted); margin-top: 14px; }
.account-foot .updates-check { flex-basis: 100%; font-size: 13px; margin-top: 4px; }
.account-foot strong { color: var(--ink); font-weight: 500; }
.code-field {
  flex: 1; min-width: 0; display: flex; align-items: center;
  background: var(--raised); border: 1px solid var(--line-strong); border-radius: 10px; padding: 0 4px 0 16px;
}
.code-field:focus-within { border-color: var(--accent); }
.code-prefix { color: var(--muted); font-size: 15px; white-space: nowrap; }
.code-field input[type=text] {
  border: 0; background: transparent; padding: 10px 8px 10px 0; border-radius: 0; min-width: 0;
  font-family: ui-monospace, Menlo, monospace; color: var(--accent); outline: none;
}
@media (max-width: 420px) { .code-prefix { display: none; } .code-field input[type=text] { padding-left: 0; } }

/* ---- Saved boards (therapist's board) ------------------------------------- */
.boards-modal { width: min(600px, calc(100vw - 32px)); }
.boards-modal .link-row input { font-family: inherit; color: var(--ink); }
.boards-modal .board-replace { margin: 10px 0 0; font-size: 14px; }
.boards-modal .board-warning { margin: 12px 0 0; font-size: 13px; }
.boards-modal .board-warning strong { color: var(--ink); font-weight: 500; }
.boards-modal .error { margin-top: 14px; }
#boardsEmpty { margin: 20px 0 0; }
.board-list { list-style: none; margin: 20px 0 0; padding: 0; max-height: min(420px, 50vh); overflow-y: auto; }
.board-list:empty { display: none; }
.board-list li { display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-top: 1px solid var(--line); border-radius: 8px; transition: background 1.2s; }
.board-list li:last-child { border-bottom: 1px solid var(--line); }
.board-list li.just-saved { background: var(--accent-soft); }
.board-thumb { flex: none; width: 96px; height: 60px; border-radius: 6px; object-fit: cover; background: var(--raised); }
.board-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.board-name { font-size: 15px; overflow-wrap: anywhere; }
.board-date { font-size: 13px; color: var(--muted); }
.board-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.board-actions .btn { padding: 6px 14px; font-size: 14px; }
.board-actions .text-btn { margin-left: 4px; }
@media (max-width: 480px) {
  .board-list li { flex-wrap: wrap; }
  .board-actions { width: 100%; padding-left: 108px; }
}

/* ---- Cookie policy ------------------------------------------------------ */
.policy { max-width: 640px; margin: 0 auto; padding: 8vh 20px 64px; line-height: 1.65; }
.policy .back { color: var(--muted); font-size: 14px; text-decoration: none; }
.policy .back:hover { color: var(--ink); }
.policy h1 { font-family: var(--serif); font-size: clamp(30px, 5vw, 44px); font-weight: 300; line-height: 1.1; margin: 28px 0 8px; }
.policy h1 em { color: var(--accent); font-style: italic; }
.policy .updated { color: var(--muted); font-size: 14px; margin: 0 0 32px; }
.policy h2 { font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 36px 0 10px; font-weight: 600; }
.policy p, .policy li { font-size: 16px; }
.policy ul { padding-left: 20px; }
.policy li + li { margin-top: 6px; }
.policy a:not(.back) { color: var(--accent); }

/* Shown when the session ends. */
.ended {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 24px; text-align: center;
  background: rgba(11, 13, 18, 0.9); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.ended h1 { font-family: var(--serif); font-weight: 300; font-size: clamp(28px, 5vw, 44px); margin: 0 0 12px; }
.ended p { margin: 0 auto 24px; max-width: 420px; color: var(--muted); font-size: 18px; line-height: 1.5; }
.ended .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* Narrow screens: the bars wrap and the board gets as much room as it can. */
@media (max-width: 819px) {
  .bar { padding: 8px 12px; }
  .bar-actions { width: 100%; }
  .tools, .opts { padding-left: 12px; padding-right: 12px; }
  .board-wrap { padding: 12px; }
}
