/* ============================================================
   Tweakspace Recorder — design tokens
   ============================================================ */
:root {
  --bg:        #0E0F14;
  --bg-2:      #15161E;
  --panel:     #1B1C25;
  --panel-2:   #22232E;
  --border:    rgba(255,255,255,0.08);
  --border-2:  rgba(255,255,255,0.14);

  --text:      #F2F3F7;
  --text-dim:  #C7C9D6;
  --muted:     #8A8CA0;

  --accent:    #4DE8C2;
  --accent-dim:#2E7C6C;
  --accent-ink:#06231C;

  --rec:       #FF4D5E;
  --amber:     #FFB454;

  --font-display: 'Space Grotesk', sans-serif;
  --font-body:    'Inter', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  --radius:    16px;
  --radius-sm: 10px;
  --shadow-card: 0 30px 80px -20px rgba(0,0,0,0.65), 0 2px 0 rgba(255,255,255,0.02) inset;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
}

/* Ambient backdrop: a soft mint glow drifting behind the card, like a status LED bleeding light */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(600px 400px at 20% 15%, rgba(77,232,194,0.10), transparent 60%),
    radial-gradient(700px 500px at 85% 85%, rgba(77,232,194,0.06), transparent 60%),
    var(--bg);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 460px;
  padding: 32px 20px;
}

/* ============================================================
   Card shell + signature status strip
   ============================================================ */
.card {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

/* The signature element: a thin indicator strip that reads like a hardware status LED.
   Its color/animation state communicates app state across every screen. */
.status-strip {
  height: 3px;
  width: 100%;
  background: var(--border-2);
}
.status-strip[data-state="idle"]   { background: var(--border-2); }
.status-strip[data-state="countdown"] {
  background: var(--amber);
  animation: strip-pulse 0.9s ease-in-out infinite;
}
.status-strip[data-state="recording"] {
  background: var(--rec);
  animation: strip-pulse 1.6s ease-in-out infinite;
}
.status-strip[data-state="paused"] { background: var(--amber); }
.status-strip[data-state="done"]   { background: var(--accent); }

@keyframes strip-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

.card-header {
  padding: 28px 28px 4px;
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.wordmark.small { font-size: 17px; }
.wordmark-light { color: var(--muted); font-weight: 500; }
.wordmark-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px 2px rgba(77,232,194,0.5);
  flex: none;
}
.logo {
  height: 22px;
  width: auto;
  display: block;
}
.wordmark-divider {
  width: 1px;
  height: 16px;
  background: var(--border-2);
  flex: none;
}

.subtitle {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.card-body {
  padding: 20px 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ============================================================
   Form fields
   ============================================================ */
.field { display: flex; flex-direction: column; gap: 8px; }
.field-pair { display: flex; gap: 14px; }
.field-pair .field { flex: 1; }

label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

input[type="text"], select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s ease;
  width: 100%;
}
input[type="text"]:focus, select:focus {
  border-color: var(--accent);
}
select { appearance: none; cursor: pointer; }

.field-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

/* Toggle chips (screen / mic / camera) */
.toggle {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel-2);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  transition: all 0.15s ease;
  position: relative;
}
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-box {
  width: 14px; height: 14px;
  border-radius: 4px;
  border: 1.5px solid var(--border-2);
  flex: none;
  position: relative;
}
.toggle input:checked ~ .toggle-box {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle input:checked ~ .toggle-box::after {
  content: "";
  position: absolute;
  left: 3.5px; top: 0.5px;
  width: 4px; height: 8px;
  border: solid var(--accent-ink);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.toggle:has(input:checked) {
  border-color: var(--accent-dim);
  color: var(--text);
  background: rgba(77,232,194,0.07);
}
.toggle:has(input:disabled) { cursor: default; opacity: 0.85; }

.check-row { display: flex; gap: 18px; margin-top: 2px; }
.check {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 400; color: var(--muted);
  text-transform: none; letter-spacing: 0; cursor: pointer;
}
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check-box {
  width: 14px; height: 14px;
  border-radius: 4px;
  border: 1.5px solid var(--border-2);
  position: relative; flex: none;
}
.check input:checked ~ .check-box {
  background: var(--accent);
  border-color: var(--accent);
}
.check input:checked ~ .check-box::after {
  content: "";
  position: absolute;
  left: 3.5px; top: 0.5px;
  width: 4px; height: 8px;
  border: solid var(--accent-ink);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.hint {
  margin: -6px 0 0;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  padding: 15px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  box-shadow: 0 8px 24px -8px rgba(77,232,194,0.45);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 28px -8px rgba(77,232,194,0.55); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 14px;
  padding: 13px;
  cursor: pointer;
}
.btn-secondary:hover { border-color: var(--muted); }

.permission-note {
  margin: 0;
  font-size: 11.5px;
  color: var(--muted);
  text-align: center;
}

.rec-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent-ink);
  flex: none;
}
.rec-dot.pulsing {
  background: var(--rec);
  animation: dot-pulse 1.2s ease-in-out infinite;
}
@keyframes dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.85); }
}

/* ============================================================
   Countdown overlay
   ============================================================ */
.countdown-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(6,7,10,0.94);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.countdown-number {
  font-family: var(--font-display);
  font-size: 140px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  text-shadow: 0 0 60px rgba(77,232,194,0.5);
  animation: countdown-pop 1s ease-in-out;
}
@keyframes countdown-pop {
  0%   { transform: scale(0.6); opacity: 0; }
  30%  { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.countdown-label {
  font-size: 14px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* ============================================================
   Self-share warning overlay
   ============================================================ */
.warning-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(6,7,10,0.96);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 40px 24px;
  text-align: center;
}
.warning-icon {
  font-size: 40px;
  color: var(--amber);
}
.warning-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}
.warning-body {
  font-size: 14px;
  color: var(--muted);
  max-width: 420px;
  line-height: 1.6;
  margin: 0;
}
.warning-body em { color: var(--text-dim); font-style: normal; font-weight: 600; }
.warning-actions {
  display: flex;
  gap: 12px;
  margin-top: 10px;
}
.warning-actions .btn-primary,
.warning-actions .btn-secondary {
  padding: 12px 20px;
  font-size: 13px;
}

/* ============================================================
   Recording screen
   ============================================================ */
.record-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.preview-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000;
}
#preview-canvas {
  max-width: 100%;
  max-height: 100%;
  cursor: grab;
}
#preview-canvas:active { cursor: grabbing; }

.toolbar {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(27,28,37,0.92);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-2);
  border-radius: 999px;
  padding: 8px 14px;
  box-shadow: 0 20px 50px -12px rgba(0,0,0,0.6);
  z-index: 60;
}
.toolbar-drag-handle {
  cursor: grab;
  color: var(--muted);
  font-size: 14px;
  padding: 0 2px;
  user-select: none;
}
.toolbar-rec {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--rec);
  letter-spacing: 0.04em;
}
.toolbar-timer {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  min-width: 78px;
}
.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border-2);
}
.tb-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px; height: 36px;
  border-radius: 50%;
  font-size: 15px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s ease, transform 0.1s ease;
}
.tb-btn:hover { background: var(--panel); transform: translateY(-1px); }
.tb-btn.off { opacity: 0.4; }
.tb-btn-stop {
  background: var(--rec);
  border-color: var(--rec);
}
.tb-btn-stop:hover { background: #e6404f; }

.screenshot-flash {
  position: fixed;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 55;
}
.screenshot-flash.flash { animation: flash-anim 0.35s ease-out; }
@keyframes flash-anim {
  0%   { opacity: 0.7; }
  100% { opacity: 0; }
}

.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--border-2);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 60;
  box-shadow: 0 10px 30px -8px rgba(0,0,0,0.6);
}

/* ============================================================
   Finished screen
   ============================================================ */
#preview-video {
  width: 100%;
  border-radius: var(--radius-sm);
  background: #000;
  display: block;
}

/* ============================================================
   Utility
   ============================================================ */
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .status-strip, .rec-dot.pulsing, .countdown-number { animation: none !important; }
}

@media (max-width: 480px) {
  .countdown-number { font-size: 96px; }
  .toolbar { flex-wrap: wrap; justify-content: center; padding: 8px 12px; }
}
