/* Personal agent: mobile-first (iPhone 16 portrait), dark, no camera image anywhere. */
:root {
  --bg: #0b0f14;
  --surface: #141a22;
  --surface-2: #1c2430;
  --fg: #eef2f6;
  --muted: #9aa7b4;
  --accent: #19c3a6;
  --accent-ink: #04201b;
  --danger: #ff5d6c;
  --warn: #ffb020;
  --radius: 22px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Tahoma, "Vazirmatn", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tk-accent: var(--accent);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f6f8; --surface: #ffffff; --surface-2: #eef1f4; --fg: #141a22; --muted: #5c6670;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.6 var(--font);
  overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  overflow: hidden;
}
button, a { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; padding: calc(var(--safe-t) + 16px) 16px calc(var(--safe-b) + 16px); }

/* ---------- start ---------- */
.start { align-items: center; justify-content: center; text-align: center; gap: 12px; overflow-y: auto; }
.start h1 { margin: 8px 0 0; font-size: 30px; letter-spacing: -0.01em; }
.start > p { margin: 0; max-width: 34ch; }
.orb { width: 120px; height: 120px; border-radius: 50%; position: relative; margin-bottom: 8px;
  background: radial-gradient(circle at 35% 30%, #7af0dc, var(--accent) 45%, #0b5d52 100%);
  box-shadow: 0 0 60px rgba(25, 195, 166, 0.45); animation: breathe 3.2s ease-in-out infinite; }
.orb span { position: absolute; inset: 34%; border-radius: 50%; border: 3px solid rgba(255,255,255,.85); }
@keyframes breathe { 50% { transform: scale(1.06); box-shadow: 0 0 90px rgba(25, 195, 166, 0.6); } }

.primary { position: relative; overflow: hidden; border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: 18px; padding: 16px 40px; min-width: 220px; min-height: 56px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; }
.primary.small { font-size: 16px; padding: 10px 22px; min-width: 0; min-height: 46px; }
.primary:disabled { background: var(--surface-2); color: var(--muted); }
.primary .bar { position: absolute; inset: auto 0 0 0; height: 3px; background: transparent; }
.primary .bar i { display: block; height: 100%; width: var(--p, 0%); background: var(--accent); transition: width .3s; }
.primary:not(:disabled) .bar { display: none; }
.ghost { border: 1px solid rgba(255,255,255,.18); background: transparent; border-radius: 999px; padding: 10px 20px; min-height: 46px; cursor: pointer; }
:root[data-theme="light"] .ghost { border-color: rgba(0,0,0,.15); }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 8px; }
.error { color: var(--danger); max-width: 36ch; margin: 0; font-size: 15px; }
.privacy { font-size: 13px; color: var(--muted); max-width: 36ch; margin-top: 8px !important; }
.guide { list-style: none; margin: 0; padding: 12px 14px; background: var(--surface); border-radius: 16px; text-align: start; font-size: 15px; max-width: 360px; width: 100%; }
.guide li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,.06); }
.guide li:last-child { border-bottom: 0; }
.guide li b { font-weight: 600; white-space: nowrap; }

/* ---------- app ---------- */
.app { padding-inline: 0; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 0 16px; min-height: 44px; }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.status i { width: 10px; height: 10px; border-radius: 50%; background: #5c6670; transition: background .2s, box-shadow .2s; }
.status[data-s="hand"] i { background: #2bd96b; box-shadow: 0 0 0 5px rgba(43, 217, 107, .18); }
.status[data-s="nohand"] i { background: var(--warn); }
.status[data-s="paused"] i { background: #8a939c; }
.status[data-s="loading"] i { background: var(--accent); animation: blink 1s infinite; }
.status[data-s="error"] i { background: var(--danger); }
@keyframes blink { 50% { opacity: .3; } }

.top-mid { display: inline-flex; align-items: center; gap: 10px; }
.mic { font-size: 15px; opacity: .8; animation: blink 2.4s infinite; }
.status.wake i { animation: wake .6s ease-out 2; }
@keyframes wake { 50% { transform: scale(2.2); box-shadow: 0 0 0 10px rgba(25,195,166,.35); } }
.counter { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--surface); font-size: 20px; cursor: pointer; }

.deck { flex: 1; position: relative; margin: 8px 0; touch-action: pan-y; }
.card { position: absolute; inset: 0 16px; border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column;
  justify-content: flex-end; padding: 24px; cursor: pointer; border: 0; text-align: start; color: #fff;
  background: linear-gradient(150deg, var(--c1), var(--c2));
  box-shadow: 0 20px 50px rgba(0,0,0,.45);
  transition: transform .45s cubic-bezier(.2,.8,.2,1), opacity .45s; will-change: transform; }
.card::before { content: ""; position: absolute; inset: 0; background:
  radial-gradient(circle at 80% 15%, rgba(255,255,255,.28), transparent 45%),
  linear-gradient(to top, rgba(0,0,0,.55), transparent 55%); pointer-events: none; }
.card .icon { position: absolute; top: 28%; inset-inline: 0; text-align: center; font-size: 96px; line-height: 1; filter: drop-shadow(0 10px 25px rgba(0,0,0,.35)); }
.card h2 { position: relative; margin: 0; font-size: 28px; line-height: 1.25; }
.card p { position: relative; margin: 6px 0 0; opacity: .9; font-size: 16px; }
.card .hint { position: relative; margin-top: 14px; font-size: 13px; opacity: .7; }
.card[data-pos="0"] { transform: none; opacity: 1; z-index: 3; }
.card[data-pos="1"] { transform: translateX(-88%) scale(.86); opacity: .35; z-index: 2; }
.card[data-pos="-1"] { transform: translateX(88%) scale(.86); opacity: .35; z-index: 2; }
.card[data-pos="far"] { transform: scale(.7); opacity: 0; z-index: 1; pointer-events: none; }
.dots { display: flex; justify-content: center; gap: 7px; padding-bottom: 6px; }
.dots span { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.22); transition: width .3s, background .3s; }
.dots span.on { width: 22px; border-radius: 4px; background: var(--accent); }

/* ---------- sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: flex; flex-direction: column;
  animation: rise .35s cubic-bezier(.2,.8,.2,1); }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }
.sheet-art { flex: none; height: 34vh; display: grid; place-items: center; font-size: 110px;
  background: linear-gradient(150deg, var(--c1, #333), var(--c2, #111)); padding-top: var(--safe-t); }
.sheet-body { flex: 1; overflow-y: auto; padding: 22px 20px calc(var(--safe-b) + 22px); -webkit-user-select: text; user-select: text; }
.sheet-body h2 { margin: 0; font-size: 26px; }
.sheet-body p { margin: 8px 0; }
.points { padding: 0; list-style: none; margin: 14px 0; display: grid; gap: 8px; }
.points li { background: var(--surface); border-radius: 14px; padding: 12px 14px; }
.points li::before { content: "✦ "; color: var(--accent); }
.sheet-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.settings .sheet-body { padding-top: calc(var(--safe-t) + 22px); }
.settings label { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 14px 0; }
.settings input[type="range"] { width: 48%; accent-color: var(--accent); }
.settings label.check { justify-content: flex-start; }
.settings h3 { margin: 22px 0 8px; font-size: 17px; }

/* ---------- draw ---------- */
.draw { position: fixed; inset: 0; z-index: 15; background: #fbfaf7; }
.draw canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.draw-bar { position: absolute; inset-inline: 12px; bottom: calc(var(--safe-b) + 12px); display: flex; gap: 8px; align-items: center;
  justify-content: center; flex-wrap: wrap; background: rgba(20,26,34,.88); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 8px; border-radius: 999px; }
.draw-bar button { width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(255,255,255,.1); color: #fff; font-size: 20px; cursor: pointer; }
.swatches { display: flex; gap: 6px; }
.swatch { width: 34px !important; height: 34px !important; border: 3px solid transparent !important; padding: 0; }
.swatch[aria-pressed="true"] { border-color: #fff !important; }

/* ---------- toast ---------- */
.toast { position: fixed; z-index: 40; left: 50%; bottom: calc(var(--safe-b) + 34px); transform: translateX(-50%);
  background: rgba(20,26,34,.92); color: #fff; border-radius: 999px; padding: 10px 20px; font-size: 15px; font-weight: 600;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); white-space: nowrap; max-width: calc(100vw - 32px);
  overflow: hidden; text-overflow: ellipsis; animation: pop .2s ease-out; pointer-events: none; }
.toast[data-kind="warn"] { background: rgba(120, 80, 0, .92); white-space: normal; text-align: center; border-radius: 18px; }
@keyframes pop { from { transform: translate(-50%, 8px); opacity: 0; } }

/* ---------- calibration ---------- */
.calib { position: fixed; inset: 0; z-index: 30; background: var(--bg); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 14px; text-align: center; padding: calc(var(--safe-t) + 20px) 20px calc(var(--safe-b) + 20px); }
.calib h2 { margin: 0; font-size: 24px; }
.calib p { margin: 0; max-width: 34ch; color: var(--muted); }
.calib-box { position: relative; width: min(78vw, 340px); aspect-ratio: 3 / 4; border-radius: 22px; border: 2px dashed rgba(255,255,255,.18); }
.calib-box .c { position: absolute; width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); transition: background .25s, box-shadow .25s; }
.calib-box .c.on { background: var(--accent); box-shadow: 0 0 0 8px rgba(25,195,166,.22); }
.calib-box .tl { top: 10px; left: 10px; } .calib-box .tr { top: 10px; right: 10px; }
.calib-box .bl { bottom: 10px; left: 10px; } .calib-box .br { bottom: 10px; right: 10px; }
.calib-dot { position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 12px rgba(255,255,255,.7); left: 50%; top: 50%; opacity: 0; transition: opacity .2s; }
.calib-dot.on { opacity: 1; }
.calib-bar { width: min(78vw, 340px); height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.calib-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s linear; }
body.calibrating .tk-cursor { display: none; }

/* cursor is bigger on a phone */
.tk-cursor { width: 40px; height: 40px; margin: -20px 0 0 -20px; }

/* ---------- mobile profile: bigger touch and gesture targets ---------- */
.mobile .draw-bar button { width: 54px; height: 54px; font-size: 22px; }
.mobile .swatch { width: 42px !important; height: 42px !important; }
.mobile .icon-btn { width: 50px; height: 50px; }
.mobile .ghost, .mobile .primary.small { min-height: 52px; padding-inline: 24px; }
.mobile .tk-cursor { width: 48px; height: 48px; margin: -24px 0 0 -24px; }

@media (min-width: 700px) {
  .card { inset: 0 18%; }
  .sheet-body { max-width: 680px; margin: 0 auto; width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .card, .orb { transition: none; animation: none; } }
