/* TPK shared design system: tokens, type, buttons, fields, notices.
   Used by every TPK app page. Wrap page markup in <div class="tpk">. */
.tpk { --bg:#0f1115; --bg-deep:#08090b; --surface:#181b21; --line:#2a2f38; --line-strong:#3a404a; --fg:#f5f6f7; --fg-soft:#c9cdd3; --muted:#9aa0a8; --accent:#d7ff3f; --ink:#0f1115; --danger:#ff9a8a; --danger-bg:#2a1614; --ok-bg:#1e2a0e;
    --display:'Instrument Serif','Iowan Old Style',Georgia,serif; --ui:'Geist',system-ui,-apple-system,'Segoe UI',sans-serif;
    position:relative; width:100vw; margin-left:calc(50% - 50vw); margin-right:calc(50% - 50vw); min-height:100vh; min-height:100dvh;
    background:var(--bg); color:var(--fg); font-family:var(--ui); font-size:16px; line-height:1.5; text-align:left; -webkit-font-smoothing:antialiased; color-scheme:dark; }
html, body { background:#0f1115 !important; overflow-x:clip; }
.tpk *, .tpk *::before, .tpk *::after { box-sizing:border-box; }
.tpk h1, .tpk h2, .tpk p { margin:0; }
.tpk a { color:var(--fg); text-underline-offset:3px; }
.tpk a:hover { color:var(--accent); }
.tpk em { font-style:italic; color:var(--accent); }
.tpk :focus-visible { outline:2px solid var(--accent); outline-offset:2px; border-radius:4px; }
.tpk [hidden] { display:none !important; }
.tpk-top { display:flex; align-items:center; justify-content:space-between; gap:12px; padding-top:8px; }
.tpk-logo { display:inline-flex; align-items:center; gap:10px; text-decoration:none; color:var(--fg); }
.tpk-logo span { font-family:var(--display); font-style:italic; font-size:28px; line-height:1; }
.tpk-view { display:flex; flex-direction:column; gap:18px; animation:tpkRise .4s ease both; }
@keyframes tpkRise { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }
.tpk-title { font-family:var(--display); font-weight:400; font-size:clamp(44px,12vw,60px); line-height:.98; letter-spacing:-.02em; text-wrap:balance; overflow-wrap:anywhere; }
.tpk-lead { color:var(--muted); }
.tpk-lead strong { color:var(--fg); font-weight:500; overflow-wrap:anywhere; }
.tpk-form { display:flex; flex-direction:column; gap:16px; }
.tpk-field { display:flex; flex-direction:column; gap:6px; }
.tpk-field label { font-size:13px; font-weight:500; color:var(--fg-soft); }
.tpk-field input, .tpk-field textarea { width:100%; font:inherit; font-size:16px; color:var(--fg); background:var(--bg-deep); border:1px solid var(--line-strong); border-radius:12px; padding:14px 16px; min-height:50px; transition:border-color .15s, box-shadow .15s; }
.tpk-field textarea { resize:vertical; min-height:110px; }
.tpk-field input::placeholder, .tpk-field textarea::placeholder { color:#6f757e; }
.tpk-field input:focus, .tpk-field textarea:focus { outline:none; border-color:var(--accent); box-shadow:0 0 0 3px rgba(215,255,63,.18); }
.tpk-field input[aria-invalid="true"] { border-color:var(--danger); }
.tpk-pw { position:relative; }
.tpk-pw input { padding-right:72px; }
.tpk-pw button { position:absolute; right:6px; top:50%; transform:translateY(-50%); min-height:38px; padding:0 12px; font:inherit; font-size:13px; font-weight:500; color:var(--muted); background:transparent; border:0; border-radius:8px; cursor:pointer; }
.tpk-pw button:hover { color:var(--fg); }
.tpk-hint { font-size:13px; color:var(--muted); }
.tpk-hint.is-error { color:var(--danger); }
.tpk-hint.is-ok { color:var(--accent); }
.tpk-row { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.tpk-check { display:inline-flex; align-items:flex-start; gap:10px; font-size:14px; color:var(--fg-soft); cursor:pointer; }
.tpk-check input { width:18px; height:18px; margin:2px 0 0; accent-color:var(--accent); flex:none; }
.tpk-quiet { font-size:14px; color:var(--muted) !important; }
.tpk-fine { font-size:13px; color:var(--muted); }
.tpk-btn { display:inline-flex; align-items:center; justify-content:center; gap:10px; min-height:50px; padding:0 22px; font:inherit; font-size:15px; font-weight:600; border-radius:12px; border:1px solid transparent; cursor:pointer; text-decoration:none; transition:transform .12s, background-color .15s, border-color .15s, opacity .15s; }
.tpk-btn:active:not(:disabled) { transform:scale(.985); }
.tpk-btn:disabled { opacity:.55; cursor:not-allowed; }
.tpk-primary { background:var(--accent); color:var(--ink) !important; }
.tpk-primary:hover:not(:disabled) { background:#e3ff6e; }
.tpk-ghost { background:transparent; color:var(--fg); border-color:var(--line-strong); }
.tpk-ghost:hover:not(:disabled) { border-color:#6a7280; background:#14171c; }
.tpk-text { background:transparent; color:var(--muted); min-height:44px; }
.tpk-text:hover { color:var(--fg); }
.tpk-small { min-height:40px; padding:0 16px; font-size:14px; }
.tpk-mark { width:22px; height:22px; border-radius:50%; display:grid; place-items:center; background:var(--fg); color:var(--bg); font-size:13px; font-weight:700; line-height:1; }
.tpk-spin { width:16px; height:16px; border-radius:50%; border:2px solid currentColor; border-right-color:transparent; animation:tpkSpin .7s linear infinite; }
@keyframes tpkSpin { to { transform:rotate(360deg); } }
.tpk-stack { display:flex; flex-direction:column; gap:10px; }
.tpk-divider { display:flex; align-items:center; gap:14px; color:var(--muted); font-size:12px; letter-spacing:.14em; text-transform:uppercase; }
.tpk-divider::before, .tpk-divider::after { content:""; flex:1; height:1px; background:var(--line); }
.tpk-notice { border-radius:12px; padding:12px 14px; font-size:14px; border:1px solid transparent; animation:tpkRise .25s ease both; }
.tpk-notice.error { background:var(--danger-bg); border-color:#5a2a24; color:var(--danger); }
.tpk-notice.success { background:var(--ok-bg); border-color:#3b5215; color:var(--accent); }
.tpk-notice.info { background:#151a22; border-color:var(--line-strong); color:var(--fg-soft); }
.tpk-eyebrow { color:var(--accent); font-size:13px; font-weight:500; letter-spacing:.2em; text-transform:uppercase; }
.tpk-card { background:var(--surface); border:1px solid var(--line); border-radius:20px; padding:24px; }
.tpk-avatar { width:56px; height:56px; border-radius:50%; object-fit:cover; background:var(--line); flex:none; display:grid; place-items:center; font-family:var(--display); font-size:28px; color:var(--accent); }
.tpk-loading { min-height:60vh; display:grid; place-items:center; }
.tpk-ball { width:36px; height:36px; border-radius:50%; background:var(--accent); animation:tpkBounce .9s cubic-bezier(.3,0,.7,1) infinite alternate; }
@keyframes tpkBounce { from { transform:translateY(-14px); } to { transform:translateY(14px) scale(1.06,.94); } }
@media (prefers-reduced-motion:reduce) { .tpk *, .tpk *::before, .tpk *::after { animation-duration:.001ms !important; animation-iteration-count:1 !important; transition-duration:.001ms !important; } }

/* ---------- Light mode (first version) ----------
   Tapok is drawn dark. Light mode flips light and dark for the whole page and keeps every colour's hue.
   Photos, videos and avatars are flipped back so they keep their real colours (very vivid colours come out a
   little softer: a limit of this method). Lime buttons become deep green with light text, which reads better on white. */
html[data-theme="light"] { filter:invert(1) hue-rotate(180deg); }
/* Pop-ups are drawn above the page, outside the flipped area, so each one is flipped on its own. */
html[data-theme="light"] dialog { filter:invert(1) hue-rotate(180deg); }
html[data-theme="light"] dialog::backdrop { background:rgba(225,227,231,.72); }
html[data-theme="light"] :where(img, video, canvas, .av, .chat-item-avatar, .keep-colour) { filter:invert(1) hue-rotate(180deg); }
/* Inside a part that is already flipped back, pictures are left alone (flipping them again would undo it). */
html[data-theme="light"] .keep-colour :where(img, video, canvas, .av) { filter:none; }
html[data-theme="light"] .tpk { color-scheme:light; }
