/* Toirog — "B" direction: ink + neon on a soft light ground, with a night theme. */

:root {
  --bg: #F5F3FA;
  --surface: #FFFFFF;
  --surface-2: #ECE8F5;
  --line: #E0DBEE;
  --line-strong: #8E86A8;
  --text: #14101F;
  --muted: #5E5873;
  --primary-bg: #14101F;
  --primary-fg: #C6FF3D;
  --lime: #C6FF3D;
  --lime-text: #4E7A00;
  --magenta: #FF4FD8;
  --magenta-text: #B81593;
  --cyan-text: #0A7A99;
  --violet: #6D3DF5;
  --ring: #14101F;
  --live: #6BB800;
  --board: #FFFFFF;
  --dots: #DCD6EC;
  --danger: #C62828;
  --focus: #6D3DF5;
  --font: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0E0B16;
  --surface: #19152A;
  --surface-2: #2D2744;
  --line: #2D2744;
  --line-strong: #6E658F;
  --text: #F4F1FF;
  --muted: #A9A1C4;
  --primary-bg: #C6FF3D;
  --primary-fg: #0E0B16;
  --lime-text: #C6FF3D;
  --magenta-text: #FF4FD8;
  --cyan-text: #4DE1FF;
  --ring: #C6FF3D;
  --live: #C6FF3D;
  --board: #0E0B16;
  --dots: #2D2744;
  --danger: #FF6B6B;
  --focus: #C6FF3D;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1 { margin: 0; font-size: 30px; font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; overflow-wrap: anywhere; }
h2 { margin: 0; font-size: 19px; font-weight: 800; }
p { margin: 0; }

/* layout helpers */
.page { max-width: 560px; margin: 0 auto; padding: 20px 16px 110px; display: flex; flex-direction: column; gap: 12px; min-height: 100dvh; }
.page.center { align-items: center; justify-content: center; text-align: center; gap: 16px; }
.row { display: flex; align-items: center; }
.between { justify-content: space-between; gap: 10px; }
.top { align-items: flex-start; }
.baseline { align-items: baseline; }
.wrap { flex-wrap: wrap; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack-6 { display: flex; flex-direction: column; gap: 6px; }
.stack-4 { display: flex; flex-direction: column; gap: 4px; }
.stack-0 { display: flex; flex-direction: column; line-height: 1.2; }
.grow { flex-grow: 1; }
.push { margin-left: auto; }
.push-down { margin-top: auto; }
.self-start { align-self: flex-start; }

/* type */
.label { font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.label.lime { color: var(--lime-text); }
.label.magenta { color: var(--magenta-text); }
.label.cyan { color: var(--cyan-text); }
.mono { font-family: var(--mono); font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 12px; }
.wordmark { font-weight: 800; font-size: 22px; letter-spacing: -0.02em; }
.hero { display: flex; flex-direction: column; gap: 8px; padding: 18px 0 8px; }
.hero h1 { font-size: 36px; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 28px; padding: 14px; min-width: 0; }
.card.violet { background: var(--violet); border-color: var(--violet); color: #FFFFFF; }
.card-title { font-size: 16px; font-weight: 800; }
.card-q { font-size: 16px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.card-q.big { font-size: 20px; }
.card-q.small { font-size: 14px; }
.tap { text-align: left; width: 100%; }
.bento { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.bento > .stack { gap: 12px; }

/* buttons */
.btn { min-height: 44px; padding: 0 18px; border-radius: 99px; border: 1.5px solid var(--line-strong); background: transparent; color: var(--text); font-weight: 700; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.primary { min-height: 48px; border-color: var(--primary-bg); background: var(--primary-bg); color: var(--primary-fg); font-weight: 800; }
.btn.small { padding: 0 14px; font-size: 14px; }
.btn.small.primary { min-height: 44px; }
.btn.light { background: #FFFFFF; border-color: #FFFFFF; color: #14101F; font-weight: 800; }
.btn.ghost-light { border-color: rgba(255, 255, 255, 0.6); color: #FFFFFF; }
.btn.dashed { border-style: dashed; }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn:disabled { opacity: 0.6; }
.icon-btn { width: 44px; height: 44px; flex-shrink: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--text); display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.icon-btn.soft { background: var(--surface-2); border-color: transparent; }
.icon-btn.primary { background: var(--primary-bg); border-color: var(--primary-bg); color: var(--primary-fg); }
.icon-btn.small { border-color: transparent; background: transparent; color: var(--muted); }
.chip-btn { min-width: 44px; height: 44px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); font-family: var(--mono); font-weight: 700; font-size: 13px; }

/* fields */
.field { width: 100%; min-height: 48px; padding: 12px 14px; border-radius: 16px; border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--text); font-size: 16px; }
.field::placeholder { color: var(--muted); opacity: 1; }
.field.code { font-family: var(--mono); font-weight: 700; text-transform: uppercase; letter-spacing: 0.3em; text-align: center; }
.field.mono { font-size: 13px; }
textarea.field { resize: vertical; line-height: 1.35; }
.field.light { background: rgba(255, 255, 255, 0.14); border-color: rgba(255, 255, 255, 0.6); color: #FFFFFF; }
.field.light::placeholder { color: rgba(255, 255, 255, 0.82); }
.note-field { border-color: transparent; font-weight: 800; font-size: 17px; border-radius: 4px 4px 22px 4px; }
.note-field::placeholder { color: inherit; opacity: 0.7; }

/* people */
.avatar { width: 44px; height: 44px; flex-shrink: 0; border-radius: 50%; border: 2px solid var(--bg); color: #14101F; font-weight: 800; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; }
.avatar.online { box-shadow: 0 0 0 2px var(--ring); }
.avatar.small { width: 32px; height: 32px; font-size: 12px; }
.avatar.more { background: var(--surface-2); color: var(--text); }
.pill .avatar.small { border-color: var(--surface); margin-right: -6px; }
.pill .avatar.small:last-of-type { margin-right: 8px; }

/* home */
.preview { position: relative; display: block; width: 100%; height: 170px; padding: 0; border-radius: 18px; border: 1px solid var(--line); background-color: var(--board); background-image: radial-gradient(var(--dots) 1.5px, transparent 1.5px); background-size: 22px 22px; overflow: hidden; }
.preview canvas { display: block; width: 100%; height: 100%; }
#preview-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; text-align: center; }
.live { display: inline-flex; align-items: center; gap: 6px; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--live); }
[data-theme="dark"] .live i { box-shadow: 0 0 10px var(--lime); }
.dot { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid #FFFFFF; }
.dot.on { background: var(--lime); border-color: var(--lime); }
.bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar div { height: 6px; background: var(--magenta); }
.count { font-family: var(--mono); font-weight: 700; font-size: 24px; line-height: 1.2; color: var(--cyan-text); }
.count.big { font-size: 34px; }
.list-link { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 52px; padding: 0 16px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); font-weight: 700; }

/* polls + plans */
.option { position: relative; width: 100%; min-height: 46px; padding: 8px 14px; border-radius: 14px; border: 1.5px solid var(--line-strong); background: transparent; display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; overflow: hidden; }
.option .fill { position: absolute; left: 0; top: 0; bottom: 0; background: color-mix(in srgb, var(--violet) 22%, transparent); }
.option .text, .option .n { position: relative; overflow-wrap: anywhere; }
.option.on { border-color: var(--text); border-width: 2px; font-weight: 800; }
.answer { display: flex; gap: 10px; align-items: flex-start; }
.answer p { margin-top: 2px; overflow-wrap: anywhere; white-space: pre-wrap; }
.answer .avatar { border-color: var(--violet); }

/* bottom nav */
#nav { position: fixed; z-index: 20; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(528px, calc(100% - 32px)); background: var(--surface); border: 1px solid var(--line); border-radius: 99px; padding: 5px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; box-shadow: 0 8px 24px rgba(20, 16, 31, 0.1); }
#nav button { min-height: 50px; border: 0; border-radius: 99px; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: 11px; font-weight: 700; padding: 0; }
#nav button.on { background: var(--primary-bg); color: var(--primary-fg); font-weight: 800; }

/* board */
#board-view { position: fixed; inset: 0; background: var(--bg); }
.board { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none; }
.board[data-tool="move"] { cursor: grab; }
.board[data-tool="eraser"] { cursor: cell; }
.board-layer { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.board-paper { width: 2400px; height: 2400px; background-color: var(--board); background-image: radial-gradient(var(--dots) 1.5px, transparent 1.5px); background-size: 24px 24px; box-shadow: 0 0 0 1px var(--line); border-radius: 28px; }
.board-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.board-cursors { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.cursor { position: absolute; left: 0; top: 0; display: flex; align-items: flex-start; transition: transform 80ms linear; }
.cursor svg { fill: var(--c); stroke: #14101F; stroke-width: 1.5; stroke-linejoin: round; }
.cursor span { margin-top: 16px; padding: 1px 9px; border-radius: 99px; background: var(--c); color: #14101F; font-family: var(--mono); font-size: 12px; font-weight: 700; white-space: nowrap; }
.b-note { position: absolute; width: 200px; padding: 14px; border-radius: 4px 4px 22px 4px; background: var(--lime); color: #14101F; font-weight: 800; font-size: 17px; line-height: 1.25; }
.b-note[data-color="magenta"] { background: var(--magenta); }
.b-note[data-color="cyan"] { background: #4DE1FF; }
.b-note[data-color="orange"] { background: #FFB84D; }
.b-note[data-color="violet"] { background: var(--violet); color: #FFFFFF; }
.b-note p { white-space: pre-wrap; overflow-wrap: anywhere; }
.b-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; font-family: var(--mono); font-size: 12px; font-weight: 700; }
.b-meta > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-photo { position: absolute; padding: 10px 10px 4px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); color: var(--text); }
.b-photo img { display: block; width: 100%; height: auto; border-radius: 12px; background: var(--surface-2); }
.b-like { min-width: 44px; min-height: 36px; margin: -4px -6px -4px 0; padding: 0 6px; border: 0; background: transparent; color: inherit; font: inherit; display: inline-flex; align-items: center; justify-content: flex-end; gap: 4px; }
.b-like svg { fill: none; stroke: currentColor; stroke-width: 2.4; }
.b-like.on svg { fill: currentColor; }
.b-photo .b-like.on { color: var(--magenta-text); }

#board-top { position: absolute; left: 14px; right: 14px; top: calc(14px + env(safe-area-inset-top)); display: flex; align-items: center; justify-content: space-between; gap: 10px; pointer-events: none; }
.pill { pointer-events: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 99px; padding: 4px; box-shadow: 0 6px 18px rgba(20, 16, 31, 0.08); }
.pill:first-child { padding-right: 16px; }
.pill b { font-size: 16px; font-weight: 800; }
#board-hint { position: absolute; left: 50%; top: calc(80px + env(safe-area-inset-top)); transform: translateX(-50%); max-width: calc(100% - 28px); margin: 0; padding: 4px 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-family: var(--mono); font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
#board-hint:empty { display: none; }
#board-tools { position: absolute; left: 0; right: 0; bottom: calc(14px + env(safe-area-inset-bottom)); width: min(440px, calc(100% - 28px)); margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 28px; padding: 6px 10px 8px; display: flex; flex-direction: column; gap: 2px; box-shadow: 0 8px 24px rgba(20, 16, 31, 0.12); }
#board-tools > .row { gap: 0; }
.tools { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.tool { height: 46px; border: 0; border-radius: 99px; background: transparent; color: var(--text); display: flex; align-items: center; justify-content: center; padding: 0; }
.tool.on { background: var(--primary-bg); color: var(--primary-fg); }
.swatch { width: 40px; height: 44px; flex-shrink: 0; border: 0; background: transparent; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.swatch::before { content: ""; width: 26px; height: 26px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(20, 16, 31, 0.18); }
.swatch.on::before { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--text); }
.swatch.big { width: 44px; }
.swatch.big::before { width: 34px; height: 34px; }
.sheet .swatch.on::before { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--text); }
.size { width: 40px; height: 44px; border: 0; background: transparent; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.size i { border-radius: 50%; background: var(--text); }

/* sheets, toast, banner */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(14, 11, 22, 0.55); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: min(560px, 100%); max-height: 90dvh; overflow-y: auto; background: var(--surface); border-radius: 28px 28px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.sheet-body { gap: 14px; }
.sheet-photo { align-self: center; max-width: 100%; max-height: 220px; object-fit: contain; border-radius: 14px; }
.invite-code { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-radius: 18px; background: var(--surface-2); }
.invite-code b { font-size: 28px; letter-spacing: 0.2em; }
.seg { display: inline-flex; padding: 3px; border-radius: 99px; background: var(--surface-2); }
.seg button { min-height: 44px; padding: 0 16px; border: 0; border-radius: 99px; background: transparent; color: var(--muted); font-weight: 700; font-size: 14px; }
.seg button.on { background: var(--primary-bg); color: var(--primary-fg); }
#toast { position: fixed; z-index: 60; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 99px; background: var(--text); color: var(--bg); font-size: 14px; font-weight: 700; opacity: 0; pointer-events: none; transition: opacity 160ms; }
#toast.show { opacity: 1; }
#offline { position: fixed; z-index: 70; left: 0; right: 0; top: 0; padding: 6px 12px; background: var(--danger); color: #FFFFFF; text-align: center; font-size: 13px; font-weight: 700; }
[data-theme="dark"] #offline { color: #14101F; }

@media (min-width: 720px) {
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
