/* TalkTimer styles. Dark by default, light via [data-theme="light"]. */

:root {
  --bg: #0b0d10;
  --surface: #15181d;
  --surface-2: #1e2229;
  --border: #2a2f38;
  --text: #f2f4f7;
  --muted: #9aa3af;
  --accent: #4f8cff;
  --accent-text: #ffffff;
  --ok: #30d158;
  --warn: #ffd60a;
  --danger: #ff453a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .25);
  --radius: 12px;
  --speed: 150ms;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  /* Display colors */
  --t-normal: #ffffff;
  --t-warn: #ffd60a;
  --t-danger: #ff453a;
  --stage-bg: #000000;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --border: #dde1e6;
  --text: #14171c;
  --muted: #5d6673;
  --accent: #2f6fec;
  --ok: #1a8f3c;
  --warn: #9a6a00;
  --danger: #d70015;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .08);
  --t-normal: #111111;
  --t-warn: #b07800;
  --t-danger: #d70015;
  --stage-bg: #ffffff;
  color-scheme: light;
}

* { 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.5;
  transition: background-color var(--speed), color var(--speed);
}
img, svg { max-width: 100%; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h2 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Buttons and inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: 44px; padding: .55em 1.1em;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background-color var(--speed), border-color var(--speed), color var(--speed), transform var(--speed), opacity var(--speed);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(.98); }
.btn:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger-text { color: var(--danger); }
.btn.small { min-height: 44px; padding: .35em .8em; font-size: .9rem; }
.btn.icon { width: 44px; padding: 0; }
.btn.wide { width: 100%; }

input[type="text"], input[type="number"], input[type="search"], textarea, select {
  width: 100%; min-height: 44px; padding: .5em .75em;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text); font: inherit;
  transition: border-color var(--speed), background-color var(--speed);
}
textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
label { cursor: pointer; }

.switch { display: flex; align-items: center; gap: .75em; min-height: 44px; }
.switch input {
  appearance: none; -webkit-appearance: none; flex: none;
  width: 46px; height: 28px; border-radius: 14px; margin: 0;
  background: var(--border); position: relative; cursor: pointer;
  transition: background-color var(--speed);
}
.switch input::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform var(--speed);
}
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(18px); }
.switch input:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Layout pieces ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px;
  transition: background-color var(--speed), border-color var(--speed);
}
.card + .card { margin-top: 16px; }
.card h2 { display: flex; align-items: center; gap: .5em; }

.topbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand {
  display: inline-flex; align-items: center; gap: .5em;
  font-weight: 800; font-size: 1.1rem; color: var(--text); text-decoration: none;
  min-height: 44px; margin-right: auto;
}
.brand svg { width: 28px; height: 28px; flex: none; }
@media (max-width: 400px) {
  body[data-page="control"] .brand { font-size: 0; gap: 0; }
  body[data-page="control"] .topbar { gap: 6px; padding: 8px 12px; }
}
.badge {
  display: inline-flex; align-items: center; gap: .3em;
  padding: .2em .65em; border-radius: 999px; font-size: .8rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
  white-space: nowrap;
}
.badge.ok { color: var(--ok); }
.badge.pro { color: var(--accent); }
.lock {
  font-size: .72rem; font-weight: 700; letter-spacing: .02em;
  color: var(--accent); border: 1px solid currentColor; border-radius: 999px;
  padding: .05em .55em; white-space: nowrap;
}

/* ---------- Controller ---------- */
.control {
  display: grid; gap: 16px; padding: 16px;
  grid-template-columns: minmax(0, 1fr);
  max-width: 1500px; margin: 0 auto;
}
@media (min-width: 1000px) {
  .control { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; padding: 24px; gap: 24px; }
}

.preview {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  border-radius: 8px; overflow: hidden; background: var(--stage-bg);
  border: 1px solid var(--border);
}
.preview iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; pointer-events: none; }
.now-line { display: flex; flex-wrap: wrap; gap: .25em 1em; margin-top: 12px; }
.now-line b { font-weight: 700; }
.timer-note { margin: 8px 0 0; padding: 8px 12px; border-radius: 8px; background: var(--surface-2); white-space: pre-wrap; }

.controls { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 16px; }
.controls .btn { min-height: 56px; font-size: 1.05rem; }
.controls #btnToggle { grid-column: 1 / -1; min-height: 72px; font-size: 1.4rem; }
#btnToggle.is-running { background: var(--surface-2); border-color: var(--accent); color: var(--text); }
@media (min-width: 600px) {
  .controls { grid-template-columns: 2fr repeat(4, minmax(0, 1fr)); }
  .controls #btnToggle { grid-column: auto; min-height: 64px; }
  .controls .btn { min-height: 64px; }
}

.open-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 8px; }
.msg-presets .btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.open-row p { margin: 0; flex: 1 1 220px; }

/* Timer list */
.timer-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; max-height: 60vh; overflow-y: auto; overscroll-behavior: contain; }
@media (max-width: 999px) { .timer-list { max-height: 50vh; } }
.trow {
  display: grid; gap: 6px 8px; align-items: center;
  grid-template-columns: 44px minmax(0, 1fr) 96px 44px;
  padding: 8px; border-radius: var(--radius);
  background: var(--surface-2); border: 2px solid transparent;
  transition: border-color var(--speed), background-color var(--speed), box-shadow var(--speed);
}
@media (max-width: 440px) {
  /* Small phones: name gets the full first line, length moves next to the note. */
  .timer-list .trow { grid-template-columns: 44px 84px minmax(0, 1fr) 44px; }
  .timer-list .trow .handle { grid-column: 1; grid-row: 1; }
  .timer-list .trow .name { grid-column: 2 / 4; grid-row: 1; }
  .timer-list .trow .remove { grid-column: 4; grid-row: 1; }
  .timer-list .trow .go { grid-column: 1; grid-row: 2; }
  .timer-list .trow .len { grid-column: 2; grid-row: 2; }
  .timer-list .trow .note { grid-column: 3 / -1; grid-row: 2; }
}
.trow.current { border-color: var(--accent); }
.trow.dragging { box-shadow: var(--shadow); opacity: .9; z-index: 2; position: relative; }
.trow .handle { cursor: grab; touch-action: none; font-size: 1.2rem; letter-spacing: -2px; color: var(--muted); }
.trow .handle:active { cursor: grabbing; }
.trow .len { text-align: center; font-variant-numeric: tabular-nums; }
.trow .note { grid-column: 2 / -1; min-height: 40px; font-size: .9rem; padding: .35em .75em; }
.trow .go { grid-column: 1; grid-row: 2; font-size: .75rem; font-weight: 700; padding: 0; min-height: 40px; }
.trow.current .go { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.list-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.hidden-note { margin: 0 0 12px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); }

details.card > summary {
  list-style: none; cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: .5em;
  font-weight: 700; font-size: 1.05rem;
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "+"; margin-left: auto; font-size: 1.4rem; color: var(--muted); transition: transform var(--speed); }
details.card[open] > summary::after { transform: rotate(45deg); }
details.card[open] > summary { margin-bottom: 8px; }

.paste-preview { list-style: none; margin: 8px 0; padding: 0; font-size: .9rem; display: grid; gap: 2px; }
.paste-preview li { display: flex; justify-content: space-between; gap: 1em; padding: 4px 8px; border-radius: 6px; background: var(--surface-2); }
.paste-preview li.bad { color: var(--muted); font-style: italic; }

.msg-presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.msg-row { display: flex; gap: 8px; flex-wrap: wrap; }
.msg-row input { flex: 1 1 200px; width: auto; }
.msg-status { margin: 10px 0 0; }

.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: .9rem; }
.keys dt { white-space: nowrap; }
.keys dd { margin: 0; color: var(--muted); }
kbd {
  display: inline-block; padding: .05em .45em; border-radius: 6px; font: inherit; font-size: .8rem;
  border: 1px solid var(--border); background: var(--surface-2); box-shadow: 0 1px 0 var(--border);
}

.settings-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 12px; }
.field { display: grid; gap: 4px; font-size: .9rem; }
.field input[type="color"] { width: 100%; height: 44px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); cursor: pointer; }
.row-gap { display: flex; flex-wrap: wrap; gap: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: var(--radius);
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; z-index: 50;
  transition: opacity var(--speed), transform var(--speed); max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Dialog (plan) */
dialog {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 0;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
  width: min(560px, calc(100% - 32px)); max-height: calc(100% - 32px);
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dialog-body { padding: 20px; }
.dialog-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.dialog-head h2 { margin: 0 auto 0 0; }
dialog .plans { grid-template-columns: 1fr; }
dialog .plan-pro { box-shadow: none; }
.license-title, .backup-title { margin-top: 20px; }
.pro-only h3 { margin-top: 4px; }
.license-row { display: flex; gap: 8px; flex-wrap: wrap; }
.license-row input { flex: 1 1 220px; width: auto; }
.license-status { margin: 10px 0; }
.license-links { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.license-links a { min-height: 44px; display: inline-flex; align-items: center; }

/* ---------- Pricing box ---------- */
.pricing { text-align: center; }
.seg {
  display: inline-flex; padding: 4px; gap: 4px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 16px;
}
.seg button {
  min-height: 40px; padding: 0 16px; border: 0; border-radius: 9px;
  background: transparent; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer;
  transition: background-color var(--speed), color var(--speed);
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg .save { color: var(--ok); font-size: .8rem; margin-left: .3em; }
.price { font-size: 2.6rem; font-weight: 800; line-height: 1.1; }
.price span { font-size: 1rem; font-weight: 600; color: var(--muted); }
.price-sub { margin: 6px 0 16px; color: var(--muted); min-height: 1.5em; }
.plans { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); text-align: left; }
.plans ul { padding-left: 1.2em; margin: 0 0 1em; }
.plans li { margin: .3em 0; }
.plan-free, .plan-pro { display: flex; flex-direction: column; margin: 0; }
.plan-pro { border-color: var(--accent); }
.plan-free .btn, .plan-pro .btn { margin-top: auto; }

/* ---------- Landing / SEO pages ---------- */
.site-wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.hero { text-align: center; padding: 64px 0 48px; }
.hero h1 { font-size: clamp(2rem, 6vw, 3.6rem); letter-spacing: -.02em; max-width: 16ch; margin: 0 auto 16px; }
.hero p { font-size: clamp(1.05rem, 2.4vw, 1.3rem); color: var(--muted); max-width: 40ch; margin: 0 auto 28px; }
.hero .btn { min-height: 56px; padding: 0 32px; font-size: 1.15rem; }
.hero-shot {
  margin: 40px auto 0; max-width: 820px; aspect-ratio: 16 / 9; border-radius: var(--radius);
  background: #000; border: 1px solid var(--border); box-shadow: var(--shadow);
  display: grid; place-items: center; overflow: hidden; position: relative;
}
.hero-shot .shot-name { position: absolute; top: 12%; width: 100%; text-align: center; color: #aab; font-size: clamp(.9rem, 2.4vw, 1.4rem); font-weight: 600; }
.hero-shot .shot-time { color: #fff; font-weight: 800; font-size: clamp(4rem, 19vw, 11rem); font-variant-numeric: tabular-nums; letter-spacing: -.03em; line-height: 1; }
.points { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin: 16px 0 48px; }
.points .card { margin: 0; }
.points h3 { font-size: 1.1rem; }
.points p { margin: 0; color: var(--muted); }
.section { margin: 0 0 56px; }
.section > h2 { font-size: clamp(1.4rem, 3.5vw, 2rem); text-align: center; margin-bottom: 20px; }
.faq details { border-bottom: 1px solid var(--border); }
.faq summary { cursor: pointer; min-height: 52px; display: flex; align-items: center; font-weight: 600; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; margin-left: auto; padding-left: 1em; font-size: 1.4rem; color: var(--muted); transition: transform var(--speed); }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq p { color: var(--muted); }
.footer { border-top: 1px solid var(--border); padding: 24px 0 40px; color: var(--muted); font-size: .9rem; }
.footer nav { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 8px; }
.footer a { color: var(--muted); min-height: 44px; display: inline-flex; align-items: center; }
.seo-main { max-width: 760px; margin: 0 auto; padding: 48px 16px; }
.seo-main h1 { font-size: clamp(2rem, 6vw, 3rem); }
.seo-main .lead { font-size: 1.15rem; color: var(--muted); }
.seo-main .btn.primary { min-height: 56px; font-size: 1.1rem; padding: 0 28px; margin: 8px 0 32px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; }
.chips a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); text-decoration: none; color: var(--text); }
.chips a:hover { border-color: var(--accent); }

/* ---------- Display (big screen) ---------- */
body.display-page { background: var(--stage-bg); overflow: hidden; height: 100vh; height: 100dvh; }
.stage {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 3vh 3vw; background: var(--stage-bg); color: var(--t-normal); text-align: center;
  transition: background-color var(--speed), color var(--speed);
}
.d-name {
  font-size: clamp(14px, 4.2vmin, 72px); font-weight: 600; opacity: .75;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-height: 1.3em;
}
.d-time-wrap { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; width: 100%; min-height: 0; }
.d-time {
  font-weight: 800; line-height: 1; letter-spacing: -.02em; white-space: nowrap;
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum";
  font-size: 30vmin; transition: color var(--speed);
}
.stage.warn .d-time { color: var(--t-warn); }
.stage.danger .d-time { color: var(--t-danger); }
.stage.over .d-time { color: var(--t-danger); animation: over-flash 1s steps(1, end) infinite; }
@keyframes over-flash { 50% { opacity: .25; } }
.d-msg {
  width: 100%; max-width: 100%; padding: 1.5vh 3vw; border-radius: 1.5vmin;
  background: var(--t-normal); color: var(--stage-bg);
  font-weight: 800; font-size: clamp(16px, 7vmin, 140px); line-height: 1.15;
  overflow-wrap: anywhere;
}
.d-msg.flash { animation: msg-flash .5s steps(1, end) 8; }
@keyframes msg-flash { 50% { background: var(--t-danger); color: #fff; } }
.d-clock {
  position: absolute; top: 2.5vh; right: 3vw; font-size: clamp(12px, 4vmin, 64px); font-weight: 600;
  opacity: .7; font-variant-numeric: tabular-nums;
}
.d-logo {
  position: absolute; bottom: 2vh; right: 3vw; font-size: clamp(11px, 2.2vmin, 32px); opacity: .55; font-weight: 600;
}
.d-wait { position: absolute; bottom: 3vh; left: 0; right: 0; font-size: clamp(12px, 2.6vmin, 28px); opacity: .6; margin: 0; padding: 0 16px; }
.fs-btn {
  position: absolute; top: 12px; left: 12px; z-index: 5;
  background: rgba(128, 128, 128, .2); color: inherit; border-color: transparent;
  font-size: clamp(16px, 1.5vmin, 40px); min-height: 2.75em; padding: 0 1em;
  transition: opacity 300ms;
}
.idle .fs-btn, .idle .stage { cursor: none; }
.idle .fs-btn { opacity: 0; pointer-events: none; }
.preview-mode .fs-btn, .preview-mode .d-wait { display: none; }
@media (max-width: 700px) {
  body:not(.preview-mode) .stage { padding-top: 68px; }
  body:not(.preview-mode) .d-clock { top: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; }
}
