/* Meter generator. Colours are the SoftAscend app's design tokens (C:\dev\ascend\apps\web\lib\design\tokens.ts), the
   same as rate.softascend.xyz; the canvas design keeps its own vivid gauge colours (src/draw.js) so it reads on any video. */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('assets/fonts/Inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('assets/fonts/Inter-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('assets/fonts/SpaceGrotesk-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #070A0F;
  --surface: #0F151D;
  --surface-raised: #121A24;
  --inset: #0B1017;
  --border: #1B2733;
  --border-strong: #263646;
  --text: #F2F6FA;
  --muted: #7D8CA0;
  --accent: #38BDF8;
  --accent-strong: #0EA5E9;
  --on-accent: #000000;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --heading: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --body: 'Inter', system-ui, sans-serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(70rem 36rem at 50% -14rem, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
    var(--bg);
  color: var(--text);
  font: 400 14px/1.45 var(--body);
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
svg { display: block; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.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;
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

/* ---------- top bar ---------- */

.top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  min-height: 56px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font: 700 18px/1 var(--heading);
  letter-spacing: -0.01em;
}
.brand b { color: var(--accent); font-weight: 700; }
.brand img { width: 25px; height: 30px; }
.top-title {
  padding-left: 14px;
  border-left: 1px solid var(--border-strong);
  color: var(--muted);
  font: 600 16px/1 var(--heading);
}
.tagline { margin: 0 0 0 auto; color: var(--muted); font-size: 12.5px; }
@media (max-width: 700px) { .tagline { display: none; } }

/* ---------- tabs ---------- */

.tabs {
  display: inline-flex;
  gap: 4px;
  margin: 10px 0 16px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}
.tabs button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 700;
  transition: background-color 160ms ease-out, color 160ms ease-out, box-shadow 200ms ease-out;
}
.tabs svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected='true'] {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 8px 22px -10px color-mix(in srgb, var(--accent) 80%, transparent);
}

/* ---------- workspace ---------- */

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
@media (max-width: 860px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
}

.controls, .preview {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.9);
}
.controls { padding: 18px 16px 16px; }
.controls h1 { margin: 0; font: 700 20px/1.2 var(--heading); letter-spacing: -0.01em; }
.sub { margin: 4px 0 16px; color: var(--muted); font-size: 12.5px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin-bottom: 14px; }
.field > span { font-size: 12.5px; font-weight: 700; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.field input, .field select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background-color: var(--inset);
  outline: none;
  transition: border-color 160ms ease-out, box-shadow 160ms ease-out;
}
.field select, .size select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237D8CA0' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 16px;
  cursor: pointer;
}
.field select option, .size select option { background: var(--surface-raised); color: var(--text); }
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }

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

/* Picture presets and upload */

.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.preset-wrap { position: relative; }
.preset {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 2px solid var(--border-strong);
  border-radius: 12px;
  background: var(--inset);
  overflow: hidden;
  transition: border-color 160ms ease-out, transform 120ms ease-out, box-shadow 200ms ease-out;
}
.preset img { display: block; width: 100%; height: 100%; object-fit: cover; }
.preset:hover { border-color: var(--muted); }
.preset:active { transform: scale(0.96); }
.preset[aria-pressed='true'] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent), 0 10px 24px -10px color-mix(in srgb, var(--accent) 70%, transparent);
}
.preset-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(5, 8, 13, 0.82);
}
.preset-remove svg { width: 12px; height: 12px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; }

.upload {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 12px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 12px;
  background: var(--inset);
  font-size: 13px;
  font-weight: 700;
  transition: border-color 160ms ease-out, background-color 160ms ease-out;
}
.upload span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload svg { flex: none; width: 18px; height: 18px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.upload:hover, .upload.drag { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--inset)); }

/* ---------- preview ---------- */

.preview { padding: 14px; }
.preview-head { display: flex; justify-content: space-between; align-items: center; margin: 0 2px 10px; font-size: 13px; }
.preview-head span { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.stage {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 14px;
  background: #000;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: background-color 200ms ease-out;
}
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage.drag { box-shadow: inset 0 0 0 3px var(--accent); }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 8px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
  transition: transform 120ms ease-out, background-color 160ms ease-out, border-color 160ms ease-out, box-shadow 200ms ease-out, opacity 160ms ease-out;
}
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.btn:not(:disabled):active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; }
.btn-primary {
  border: 0;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: var(--on-accent);
  box-shadow: 0 10px 26px -12px color-mix(in srgb, var(--accent) 85%, transparent);
}
.btn-primary:not(:disabled):hover { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent), 0 12px 30px -10px color-mix(in srgb, var(--accent) 90%, transparent); }
.btn-ghost { border: 1px solid var(--border-strong); background: var(--surface-raised); }
.btn-ghost:not(:disabled):hover { border-color: var(--muted); background: var(--border); }

.size { margin-left: auto; }
.size select {
  min-height: 42px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background-color: var(--inset);
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  outline: none;
}
@media (max-width: 560px) {
  .actions .btn { flex: 1 1 auto; }
  .size { flex: 1 1 100%; margin-left: 0; }
  .size select { width: 100%; }
}

.progress { height: 4px; margin: 0 0 8px; border-radius: 4px; background: var(--border); overflow: hidden; }
.progress i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--accent-strong), var(--accent)); transition: width 120ms linear; }

.note {
  margin-top: 16px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 7%, transparent), transparent 60%),
    var(--inset);
}
.note h2 { margin: 0 0 8px; font: 700 16px/1.2 var(--heading); }
.note h2::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  margin: 0 9px 2px 0;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}
.note p { margin: 6px 0 0; font-size: 13px; }
.note .muted { color: var(--muted); }
.note .muted b { color: var(--text); }

.noscript { color: var(--muted); text-align: center; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
