/* ════════════════════════════════════════════════════════════════════
   ControlMT v2.3 demo — mobile-first stylesheet.

   Design principle: SINGLE COLUMN AT EVERY VIEWPORT.
   On mobile (<760px): container fills viewport, padding shrinks.
   On desktop (>=760px): container max-width 760px centered.
   No 2-column layouts → no flex-wrap battles → no @media reorgs.
   ════════════════════════════════════════════════════════════════════ */

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

html, body {
  margin: 0;
  padding: 0;
  background: #050810;
  color: #e2e8f0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  background-image:
    radial-gradient(at 10% 0%, rgba(99,102,241,0.12) 0%, transparent 40%),
    radial-gradient(at 95% 5%, rgba(168,85,247,0.10) 0%, transparent 35%),
    radial-gradient(at 50% 100%, rgba(20,184,166,0.05) 0%, transparent 40%);
  background-attachment: fixed;
}

a { color: #818cf8; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── TOP NAV (sticky) ──────────────────────────────────────────── */
.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(5, 8, 16, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-icon { font-size: 1.3rem; }
.brand-name { font-weight: 700; font-size: 1.1rem; color: #f1f5f9; }
.vbadge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(99,102,241,0.18);
  color: #c7d2fe;
  border: 1px solid rgba(99,102,241,0.3);
}
.nav-links { display: flex; gap: 4px; }
.nav-links a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 0.86rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-links a:hover {
  background: rgba(255,255,255,0.06);
  color: #f1f5f9;
  text-decoration: none;
}

/* ─── PAGE CONTAINER ───────────────────────────────────────────── */
.container {
  max-width: 1240px;            /* wide enough that 1920px windows don't have giant gutters */
  margin: 0 auto;
  padding: 20px 16px 60px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ─── TRANSLATOR GRID: stacked on mobile, side-by-side on desktop ─ */
.translator-grid {
  display: grid;
  grid-template-columns: 1fr;   /* mobile-first: single column */
  gap: 18px;
  align-items: start;           /* cards keep their natural height */
}
@media (min-width: 900px) {
  .translator-grid {
    grid-template-columns: minmax(320px, 400px) 1fr;   /* settings narrower, translate flexible */
    gap: 22px;
  }
}

/* ─── HERO ──────────────────────────────────────────────────────── */
.hero {
  padding: 28px 22px;
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(99,102,241,0.10) 0%, rgba(168,85,247,0.08) 50%, rgba(20,184,166,0.05) 100%),
    linear-gradient(180deg, rgba(15,23,41,0.6) 0%, rgba(10,15,30,0.6) 100%);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  gap: 24px;
}
.hero-content { flex: 1; min-width: 0; }
.hero-art {
  flex-shrink: 0;
  width: 220px;
  opacity: 0.95;
  display: none;        /* mobile-first: hidden by default */
}
.hero-art svg { width: 100%; height: auto; display: block; }
.hero h1 {
  margin: 0 0 14px;
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
}
.hero-title-line {
  background: linear-gradient(90deg, #818cf8, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-dash {
  color: #475569;
  font-weight: 600;
}
.hero-subline {
  background: linear-gradient(90deg, #d8b4fe, #f0abfc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-subline .arrow {
  margin: 0 4px;
  -webkit-text-fill-color: #d8b4fe;
  color: #d8b4fe;
}
.hero .subtitle {
  margin: 0 0 16px;
  color: #94a3b8;
  font-size: 0.95rem;
  max-width: 560px;
}
.hero .badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.badge svg { flex-shrink: 0; }
.badge-blue   { background: rgba(56,189,248,0.10); border-color: rgba(56,189,248,0.32); color: #7dd3fc; }
.badge-green  { background: rgba(34,197,94,0.10);  border-color: rgba(34,197,94,0.32);  color: #86efac; }
.badge-violet { background: rgba(168,85,247,0.10); border-color: rgba(168,85,247,0.32); color: #d8b4fe; }

/* ─── CARDS (the universal panel-like container) ───────────────── */
.card {
  padding: 22px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(15,23,41,0.6) 0%, rgba(10,15,30,0.6) 100%);
  border: 1px solid rgba(255,255,255,0.07);
  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 8px 24px rgba(0,0,0,0.2);
}
.card-title {
  margin: 0 0 14px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: -0.01em;
}
.card-title.with-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
}
.card + .card { margin-top: 0; }  /* gap on .container handles spacing */
.char-count {
  font-size: 0.78rem;
  font-weight: 500;
  color: #64748b;
}

/* ─── DIRECTION RADIO CARDS ────────────────────────────────────── */
.direction-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}
.dir-card {
  position: relative;
  display: block;
  padding: 14px 14px 14px 40px;
  border-radius: 14px;
  background: rgba(15,23,41,0.5);
  border: 1.5px solid rgba(255,255,255,0.08);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}
.dir-card:hover { border-color: rgba(99,102,241,0.4); }
.dir-card:active { transform: scale(0.985); }
.dir-card input[type="radio"] {
  position: absolute;
  left: 14px;
  top: 16px;
  width: 18px;
  height: 18px;
  accent-color: #818cf8;
  cursor: pointer;
  margin: 0;
}
.dir-card:has(input:checked) {
  border-color: #818cf8;
  background: rgba(99,102,241,0.10);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.18);
}
.dir-card-tag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #64748b;
  margin-bottom: 4px;
}
.dir-card:has(input:checked) .dir-card-tag { color: #818cf8; }
.dir-card-arrow {
  font-size: 1rem;
  font-weight: 700;
  color: #f1f5f9;
  margin-bottom: 2px;
}
.dir-card-desc {
  font-size: 0.78rem;
  color: #94a3b8;
}

/* ─── SETTINGS / SLIDER ────────────────────────────────────────── */
.settings-row { margin-bottom: 18px; }
.setting-label {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 6px;
}
.setting-hint {
  display: block;
  font-size: 0.74rem;
  font-weight: 500;
  color: #64748b;
  margin-top: 1px;
}
.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.slider-row input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: #818cf8;
  height: 6px;
}
.slider-row output {
  display: inline-block;
  min-width: 40px;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(99,102,241,0.14);
  border: 1px solid rgba(99,102,241,0.28);
  color: #c7d2fe;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.slider-marks {
  display: flex;
  justify-content: space-between;
  padding: 4px 0 0 4px;
  margin-right: 60px;          /* aligned with slider, not output box */
  font-size: 0.74rem;
  color: #64748b;
}

/* ─── SHARE TOGGLE ─────────────────────────────────────────────── */
.share-section {
  padding: 14px;
  border-radius: 12px;
  background: rgba(20,184,166,0.06);
  border: 1px solid rgba(20,184,166,0.18);
  margin-bottom: 16px;
}
.share-label {
  font-size: 0.86rem;
  font-weight: 700;
  color: #5eead4;
  margin-bottom: 8px;
}
.share-toggle {
  display: flex;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  align-items: flex-start;
}
.share-toggle input[type="checkbox"] {
  accent-color: #14b8a6;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  flex-shrink: 0;
  cursor: pointer;
}
.share-text {
  font-size: 0.88rem;
  color: #cbd5e1;
}
.share-hint {
  display: block;
  font-size: 0.74rem;
  color: #64748b;
  margin-top: 3px;
}

/* ─── STATUS PILL ──────────────────────────────────────────────── */
.status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(34,197,94,0.06);
  border: 1px solid rgba(34,197,94,0.20);
}
.status-ok { color: #86efac; }
.status-err  { background: rgba(239,68,68,0.06); border-color: rgba(239,68,68,0.20); color: #fca5a5; }
.status-warn { background: rgba(251,191,36,0.06); border-color: rgba(251,191,36,0.20); color: #fcd34d; }
.status-busy { background: rgba(99,102,241,0.06); border-color: rgba(99,102,241,0.20); color: #c7d2fe; }
.status-text { flex: 1; min-width: 0; }
.status-title { font-weight: 700; font-size: 0.92rem; }
.status-title .elapsed {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: rgba(199,210,254,0.12);
  color: #c7d2fe;
  letter-spacing: 0.01em;
}
.status-sub { font-size: 0.78rem; opacity: 0.85; margin-top: 1px; }
.status .spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(199,210,254,0.25);
  border-top-color: #c7d2fe;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── TEXTAREAS ────────────────────────────────────────────────── */
textarea {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(5,8,16,0.5);
  color: #e2e8f0;
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.55;
  resize: vertical;
  min-height: 110px;
  transition: border-color 0.15s, background 0.15s;
}
textarea:focus {
  outline: none;
  border-color: rgba(99,102,241,0.5);
  background: rgba(5,8,16,0.7);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
textarea[readonly] {
  background: rgba(5,8,16,0.35);
  cursor: text;
}
textarea::placeholder { color: #475569; }

/* ─── EXAMPLE CHIPS ────────────────────────────────────────────── */
.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 10px;
}
.examples-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
  margin-right: 2px;
}
.example-chip {
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(99,102,241,0.08);
  border: 1px solid rgba(99,102,241,0.22);
  color: #c7d2fe;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.example-chip:hover {
  background: rgba(99,102,241,0.18);
  border-color: rgba(99,102,241,0.4);
}
.example-chip:active { transform: scale(0.97); }

/* ─── ACTION ROW: Translate button + Rating cluster ───────────── */
.action-row {
  display: flex;
  flex-direction: column;        /* mobile: stack vertically */
  gap: 12px;
  margin-top: 14px;
  align-items: stretch;
}
@media (min-width: 640px) {
  .action-row {
    flex-direction: row;         /* desktop: side-by-side */
    align-items: center;
    gap: 16px;
  }
}

.rating-cluster {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.rating-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.01em;
}
.rating-hint {
  color: #475569;
  font-weight: 500;
}

/* ─── PRIMARY BUTTON (Translate) ──────────────────────────────── */
.btn-primary {
  width: 100%;                   /* mobile: fills the action-row */
  padding: 13px 20px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  color: white;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 6px 24px rgba(99,102,241,0.35);
  transition: transform 0.05s, box-shadow 0.15s, opacity 0.15s;
  flex-shrink: 0;
}
@media (min-width: 640px) {
  .btn-primary {
    width: auto;                 /* desktop: hugs content */
    min-width: 170px;
    align-self: stretch;         /* match the rating cluster's height */
  }
}
.btn-primary:hover { box-shadow: 0 8px 32px rgba(99,102,241,0.5); }
.btn-primary:active { transform: scale(0.985); }
.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}
.btn-primary.loading .btn-label::after {
  content: "…";
  display: inline-block;
  animation: dots 1.2s steps(4, end) infinite;
}
@keyframes dots {
  0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; }
}

/* ─── ICON BUTTON (copy) ───────────────────────────────────────── */
.title-actions { display: flex; gap: 6px; }
.icon-btn {
  padding: 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  color: #94a3b8;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: rgba(255,255,255,0.08); color: #f1f5f9; }
.icon-btn.copied { background: rgba(34,197,94,0.18); color: #86efac; }

/* ─── RATING ROW (inside .rating-cluster) ──────────────────────── */
.rating-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);   /* 4 buttons across at every size — compact pills */
  gap: 6px;
}
.rate-btn {
  padding: 9px 6px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(15,23,41,0.5);
  color: #cbd5e1;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
  font-family: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rate-btn:hover { background: rgba(15,23,41,0.8); border-color: rgba(255,255,255,0.18); }
.rate-btn:active { transform: scale(0.98); }
.rate-btn.clicked.rate-bad  { border-color: rgba(239,68,68,0.5);   background: rgba(239,68,68,0.12);   color: #fca5a5; }
.rate-btn.clicked.rate-ok   { border-color: rgba(251,191,36,0.5);  background: rgba(251,191,36,0.12);  color: #fcd34d; }
.rate-btn.clicked.rate-good { border-color: rgba(99,102,241,0.5);  background: rgba(99,102,241,0.12);  color: #c7d2fe; }
.rate-btn.clicked.rate-vg   { border-color: rgba(34,197,94,0.5);   background: rgba(34,197,94,0.12);   color: #86efac; }
.rating-ack {
  margin-top: 10px;
  font-size: 0.85rem;
  color: #86efac;
  min-height: 1.2em;
}
.rating-ack.warn { color: #fcd34d; }

/* On very narrow phones, the 4-wide grid would squeeze too much — drop to 2x2 */
@media (max-width: 380px) {
  .rating-row { grid-template-columns: repeat(2, 1fr); }
}

/* ─── USAGE NOTE ────────────────────────────────────────────────── */
.usage-note {
  padding: 14px 18px;
  border-radius: 12px;
  background: rgba(56,189,248,0.05);
  border: 1px solid rgba(56,189,248,0.18);
  font-size: 0.86rem;
  color: #cbd5e1;
}
.usage-note p { margin: 0; }
.usage-note strong { color: #7dd3fc; }

/* ─── CHALLENGE ─────────────────────────────────────────────────── */
.challenge {
  padding: 24px 22px;
  border-radius: 20px;
  background:
    linear-gradient(135deg, rgba(245,158,11,0.08) 0%, rgba(168,85,247,0.06) 100%),
    rgba(15,23,41,0.5);
  border: 1px solid rgba(245,158,11,0.18);
}
.challenge-title {
  margin: 0 0 6px;
  font-size: 1.2rem;
  font-weight: 800;
  color: #fcd34d;
}
.challenge-sub {
  margin: 0 0 16px;
  color: #cbd5e1;
  font-size: 0.92rem;
}
.challenge-sub strong { color: #fca5a5; }
.challenge-grid {
  display: grid;
  grid-template-columns: 1fr;     /* mobile-first: 1 column */
  gap: 10px;
}
.challenge-card {
  padding: 14px;
  border-radius: 12px;
  background: rgba(5,8,16,0.5);
  border: 1px solid rgba(255,255,255,0.08);
}
.challenge-card .ch-emoji { font-size: 1.5rem; margin-bottom: 4px; }
.challenge-card h3 {
  margin: 0 0 4px;
  font-size: 0.96rem;
  font-weight: 700;
  color: #f1f5f9;
}
.challenge-card p {
  margin: 0;
  font-size: 0.83rem;
  color: #94a3b8;
  line-height: 1.45;
}

/* ─── FOOTER ────────────────────────────────────────────────────── */
.footer {
  margin-top: 12px;
  text-align: center;
  font-size: 0.82rem;
  color: #64748b;
}
.footer p { margin: 0; }

/* ════════════════════════════════════════════════════════════════
   RESPONSIVE — desktop ONLY adds extras. Mobile is the default
   (the rules above already work top-to-bottom on a 320px viewport).
   ════════════════════════════════════════════════════════════════ */
@media (min-width: 640px) {
  .hero h1 { font-size: 2.1rem; }
  .hero .subtitle { font-size: 1rem; }
  .challenge-grid { grid-template-columns: 1fr 1fr; }
  /* Show hero art now that there's room beside the text */
  .hero-art { display: block; width: 200px; }
}

@media (min-width: 760px) {
  .container { padding: 28px 22px 80px; gap: 20px; }
  .topnav { padding: 14px 28px; }
  .hero-art { width: 240px; }
}

/* ════════════════════════════════════════════════════════════════
   PHONE OPTIMIZATIONS — only cosmetic shrinks, no layout changes
   (layout is already single-column at every size).
   ════════════════════════════════════════════════════════════════ */
@media (max-width: 420px) {
  .container { padding: 14px 10px 40px; gap: 14px; }
  .topnav { padding: 10px 12px; }
  .nav-links a { padding: 8px; }
  .nav-links a span { display: none; }   /* hide text labels, keep icons */
  .hero { padding: 22px 18px; }
  .hero h1 { font-size: 1.7rem; }
  .card { padding: 18px 16px; }
  .vbadge { display: none; }
  .slider-marks { margin-right: 56px; }
}
