/* ==========================================================================
   GSM Calculator — Main CSS (Component Layer)
   Builds on top of tokens.css — import tokens.css FIRST.
   Zero-build: plain CSS, no preprocessor.
   ========================================================================== */

/* ─── Google Fonts ────────────────────────────────────────────────────────── */
/* Note: Loaded via <link> in HTML head with preconnect. This comment documents
   the font families: Inter (400,500,600,700) + JetBrains Mono (400,600) */

/* ─── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--dur-base) var(--ease-in-out),
              color var(--dur-base) var(--ease-in-out);
}

img, svg { display: block; max-width: 100%; }
a { color: var(--color-brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ─── Typography ─────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text);
}
h1 { font-size: var(--fs-2xl); font-weight: var(--fw-bold); }
h2 { font-size: var(--fs-xl); font-weight: var(--fw-semibold); }
h3 { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
h4 { font-size: var(--fs-base); font-weight: var(--fw-semibold); }
p { margin-bottom: var(--space-4); }
p:last-child { margin-bottom: 0; }

.lead {
  font-size: var(--fs-md);
  color: var(--color-text-secondary);
  line-height: var(--lh-normal);
}

.mono { font-family: var(--font-mono); }

/* ─── Layout Primitives ──────────────────────────────────────────────────── */
.container {
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-5);
}

.container--narrow {
  max-width: var(--container-narrow);
  margin-inline: auto;
  padding-inline: var(--space-5);
}

main { flex: 1; }

/* Tool grid: 2-col input/results, collapses to 1-col at 860px */
.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
  align-items: start;
}

@media (max-width: 860px) {
  .tool-grid {
    grid-template-columns: 1fr;
  }
}

.tool-grid--wide {
  grid-template-columns: 3fr 2fr;
}

@media (max-width: 860px) {
  .tool-grid--wide { grid-template-columns: 1fr; }
}

/* ─── Header ─────────────────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  height: var(--header-h);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-xs);
  transition: background-color var(--dur-base) var(--ease-in-out);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-5);
}

.site-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--color-text);
  font-weight: var(--fw-bold);
  font-size: var(--fs-md);
  flex-shrink: 0;
  letter-spacing: var(--tracking-tight);
}

.site-logo:hover { text-decoration: none; color: var(--color-brand); }
.site-logo svg { width: 28px; height: 28px; }

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-left: var(--space-4);
  flex: 1;
}

.nav-group {
  position: relative;
}

.nav-group__trigger {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  background: none;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--color-text-secondary);
  transition: background-color var(--dur-fast), color var(--dur-fast);
  white-space: nowrap;
}

.nav-group__trigger:hover,
.nav-group:hover .nav-group__trigger {
  background-color: var(--color-surface-2);
  color: var(--color-text);
}

.nav-group__trigger svg { transition: transform var(--dur-fast); }
.nav-group:hover .nav-group__trigger svg { transform: rotate(180deg); }

.nav-dropdown {
  position: absolute;
  top: calc(100% + var(--space-1));
  left: 0;
  min-width: 200px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  z-index: var(--z-dropdown);
  padding: var(--space-2);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out),
              visibility var(--dur-fast);
}

.nav-group:hover .nav-dropdown,
.nav-group:focus-within .nav-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.nav-dropdown a {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: background-color var(--dur-fast), color var(--dur-fast);
}

.nav-dropdown a:hover {
  background-color: var(--color-surface-2);
  color: var(--color-text);
}

.nav-spacer { flex: 1; }

/* Theme toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  transition: background-color var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
  flex-shrink: 0;
}

.theme-toggle:hover {
  background-color: var(--color-surface-2);
  color: var(--color-text);
  border-color: var(--color-border-strong);
}

.theme-toggle svg { width: 18px; height: 18px; }

/* Mobile nav toggle */
.nav-mobile-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text);
  margin-left: var(--space-2);
}

@media (max-width: 768px) {
  .site-nav { display: none; }
  .nav-mobile-toggle { display: flex; }
  .site-nav.is-open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-3) var(--space-4);
    box-shadow: var(--shadow-md);
    z-index: var(--z-dropdown);
  }
  .nav-dropdown {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: none;
    padding: 0 var(--space-3);
  }
  .nav-group__trigger { width: 100%; justify-content: space-between; }
}

/* ─── Footer ─────────────────────────────────────────────────────────────── */
.site-footer {
  margin-top: var(--space-9);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: var(--space-7) 0 var(--space-5);
}

.site-footer__grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: var(--space-6);
  margin-bottom: var(--space-6);
}

@media (max-width: 860px) {
  .site-footer__grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .site-footer__grid { grid-template-columns: 1fr; }
}

.site-footer__brand p {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-3);
  line-height: var(--lh-normal);
}

.site-footer__col h4 {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

.site-footer__col a {
  display: block;
  font-size: var(--fs-sm);
  color: var(--color-text-secondary);
  padding: var(--space-1) 0;
  text-decoration: none;
  transition: color var(--dur-fast);
}

.site-footer__col a:hover { color: var(--color-brand); }

.site-footer__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-border);
}

.site-footer__bottom p {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin: 0;
}

.site-footer__disclaimer {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  text-align: center;
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--color-warning-soft);
  border-radius: var(--radius-md);
  color: var(--color-warning);
}

/* ─── Page Hero ──────────────────────────────────────────────────────────── */
.page-hero {
  padding: var(--space-7) 0 var(--space-5);
}

.page-hero h1 {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-tight);
  margin-bottom: var(--space-3);
}

@media (min-width: 860px) {
  .page-hero h1 { font-size: var(--fs-3xl); }
}

.page-hero p {
  font-size: var(--fs-md);
  color: var(--color-text-secondary);
  max-width: 60ch;
  margin-bottom: 0;
}

/* ─── Card / Panel ────────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
}

.card--inset {
  background: var(--color-surface-2);
  border-color: var(--color-border);
  box-shadow: none;
}

.card__title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

/* ─── Inputs ─────────────────────────────────────────────────────────────── */
.field-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--color-text-secondary);
}

.input,
.textarea,
.select {
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-size: var(--fs-base);
  color: var(--color-text);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.textarea {
  min-height: 180px;
  resize: vertical;
  line-height: var(--lh-normal);
  font-size: var(--fs-sm);
}

.textarea--tall { min-height: 280px; }
.textarea--mono { font-family: var(--font-mono); font-size: var(--fs-sm); }

.input:focus, .textarea:focus, .select:focus {
  border-color: var(--color-brand);
  box-shadow: var(--shadow-focus);
}

.input::placeholder, .textarea::placeholder {
  color: var(--color-text-muted);
}

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-7);
}

.input-row {
  display: flex;
  gap: var(--space-3);
}

.input-row .field-group { flex: 1; }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  line-height: 1;
  border: 1px solid transparent;
  transition: background-color var(--dur-fast), color var(--dur-fast),
              border-color var(--dur-fast), box-shadow var(--dur-fast),
              transform var(--dur-fast);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn--primary {
  background: var(--color-brand);
  color: var(--color-brand-contrast);
  border-color: var(--color-brand);
}
.btn--primary:hover {
  background: var(--color-brand-hover);
  border-color: var(--color-brand-hover);
}

.btn--ghost {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border-strong);
}
.btn--ghost:hover {
  background: var(--color-surface-2);
}

.btn--danger {
  background: var(--color-danger-soft);
  color: var(--color-danger);
  border-color: var(--color-danger);
}

.btn--sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--fs-xs);
}

.btn-row {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: var(--space-3);
}

/* ─── Stat Tiles ─────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--space-3);
}

.stat-grid--wide {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.stat-tile {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  transition: box-shadow var(--dur-fast);
}

.stat-tile:hover { box-shadow: var(--shadow-sm); }

.stat-tile__value {
  font-family: var(--font-mono);
  font-size: var(--fs-stat);
  font-weight: var(--fw-semibold);
  color: var(--color-text);
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-tile__label {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.stat-tile--accent .stat-tile__value { color: var(--color-brand); }
.stat-tile--success .stat-tile__value { color: var(--color-success); }
.stat-tile--warning .stat-tile__value { color: var(--color-warning); }
.stat-tile--danger .stat-tile__value { color: var(--color-danger); }

/* ─── Badge / Chip ───────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  line-height: 1.5;
  white-space: nowrap;
}

.badge--brand {
  background: var(--color-brand-soft);
  color: var(--color-brand);
}
.badge--success {
  background: var(--color-success-soft);
  color: var(--color-success);
}
.badge--warning {
  background: var(--color-warning-soft);
  color: var(--color-warning);
}
.badge--danger {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}
.badge--info {
  background: var(--color-info-soft);
  color: var(--color-info);
}
.badge--muted {
  background: var(--color-surface-2);
  color: var(--color-text-muted);
}

/* Disclaimer chip */
.disclaimer-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-warning-soft);
  color: var(--color-warning);
  border-radius: var(--radius-md);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  margin-top: var(--space-3);
  line-height: var(--lh-snug);
}

/* ─── Segmented Tabs ─────────────────────────────────────────────────────── */
.tabs {
  display: inline-flex;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
}

.tab-btn {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--color-text-secondary);
  background: none;
  border: none;
  transition: background-color var(--dur-fast), color var(--dur-fast),
              box-shadow var(--dur-fast);
  cursor: pointer;
}

.tab-btn.active,
.tab-btn[aria-selected="true"] {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-xs);
}

/* ─── Char Highlights (SMS segment preview) ──────────────────────────────── */
.char-preview {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.8;
  word-break: break-all;
  padding: var(--space-4);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  min-height: 80px;
}

.char-preview span { border-radius: 2px; padding: 0 1px; }

.char-ext {
  background: var(--hl-ext-bg);
  color: var(--hl-ext-text);
  font-weight: var(--fw-semibold);
}

.char-ucs2 {
  background: var(--hl-ucs2-bg);
  color: var(--hl-ucs2-text);
  font-weight: var(--fw-semibold);
}

.char-astral {
  background: var(--hl-ucs2-bg);
  color: var(--hl-ucs2-text);
  font-weight: var(--fw-semibold);
  outline: 1px dashed var(--color-warning);
}

/* Legend chips */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--fs-xs);
  color: var(--color-text-secondary);
}

.legend-dot {
  width: 10px; height: 10px;
  border-radius: 2px;
}
.legend-dot--ext { background: var(--hl-ext-bg); }
.legend-dot--ucs2 { background: var(--hl-ucs2-bg); }

/* ─── Toast ──────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--color-text);
  color: var(--color-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  pointer-events: auto;
  animation: toastIn var(--dur-base) var(--ease-out) forwards,
             toastOut var(--dur-base) var(--ease-in-out) forwards 2s;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ─── Table ──────────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.data-table th {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-2);
}

.data-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--color-surface-2); }

.data-table td.num {
  font-family: var(--font-mono);
  text-align: right;
}

/* ─── Breakdown bar ─────────────────────────────────────────────────────── */
.breakdown-bar {
  height: 12px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-3);
  overflow: hidden;
  display: flex;
}

.breakdown-bar__segment {
  height: 100%;
  transition: width var(--dur-slow) var(--ease-out);
}

/* ─── Slider ─────────────────────────────────────────────────────────────── */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--color-surface-3);
  border-radius: var(--radius-pill);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--color-brand);
  border: 2px solid var(--color-surface);
  box-shadow: var(--shadow-sm);
  transition: background-color var(--dur-fast);
}

input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--color-brand);
  border: 2px solid var(--color-surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

input[type="range"]:focus::-webkit-slider-thumb {
  box-shadow: var(--shadow-focus);
}

/* ─── Toggle Switch ─────────────────────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) 0;
  gap: var(--space-3);
}

.toggle-label {
  font-size: var(--fs-sm);
  color: var(--color-text);
}

.toggle-switch {
  position: relative;
  width: 44px; height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0; height: 0;
  position: absolute;
}

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--color-surface-3);
  border-radius: var(--radius-pill);
  transition: background-color var(--dur-fast);
  cursor: pointer;
}

.toggle-track::after {
  content: '';
  position: absolute;
  left: 2px; top: 2px;
  width: 20px; height: 20px;
  background: var(--color-surface);
  border-radius: 50%;
  transition: transform var(--dur-fast) var(--ease-out);
  box-shadow: var(--shadow-xs);
}

.toggle-switch input:checked + .toggle-track {
  background: var(--color-brand);
}

.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(20px);
}

.toggle-switch input:focus-visible + .toggle-track {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
}

/* ─── Related Tools Strip ───────────────────────────────────────────────── */
.related-tools {
  margin: var(--space-7) 0 var(--space-5);
  padding: var(--space-5);
  background: var(--color-surface-2);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
}

.related-tools h3 {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

.related-tools__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.related-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: background-color var(--dur-fast), color var(--dur-fast),
              border-color var(--dur-fast), transform var(--dur-fast);
}

.related-link:hover {
  background: var(--color-brand-soft);
  color: var(--color-brand);
  border-color: var(--color-brand);
  transform: translateY(-1px);
  text-decoration: none;
}

/* ─── FAQ Section ────────────────────────────────────────────────────────── */
.faq-section {
  margin: var(--space-8) 0;
}

.faq-section h2 {
  font-size: var(--fs-xl);
  margin-bottom: var(--space-5);
}

.faq-item {
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-4) 0;
}

.faq-item:last-child { border-bottom: none; }

.faq-item summary {
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
}

.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: '+';
  font-size: var(--fs-xl);
  color: var(--color-text-muted);
  transition: transform var(--dur-fast);
  flex-shrink: 0;
}

details[open] summary::after { content: '−'; }

.faq-item .faq-answer {
  margin-top: var(--space-3);
  color: var(--color-text-secondary);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
}

/* ─── Section dividers ───────────────────────────────────────────────────── */
.section-divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-7) 0;
}

/* ─── Case converter cards ──────────────────────────────────────────────── */
.case-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-4);
}

.case-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--dur-fast), border-color var(--dur-fast);
}

.case-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--color-border-strong);
}

.case-card__label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.case-card__value {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--color-text);
  word-break: break-all;
  min-height: 40px;
  line-height: var(--lh-normal);
  margin-bottom: var(--space-3);
}

/* ─── Cost breakdown ─────────────────────────────────────────────────────── */
.cost-breakdown {
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  font-size: var(--fs-sm);
}

.cost-breakdown__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border);
}

.cost-breakdown__row:last-child { border-bottom: none; }
.cost-breakdown__row.total {
  font-weight: var(--fw-bold);
  font-size: var(--fs-md);
  color: var(--color-text);
}

.cost-breakdown__label { color: var(--color-text-secondary); }
.cost-breakdown__value { font-family: var(--font-mono); color: var(--color-text); }

/* ─── Platform remaining counter ────────────────────────────────────────── */
.platform-counter {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  margin-top: var(--space-3);
}

.platform-counter__num {
  font-family: var(--font-mono);
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  line-height: 1;
}

.platform-counter__num.over-limit { color: var(--color-danger); }

.platform-counter__label {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}

/* ─── Age calculator output ─────────────────────────────────────────────── */
.age-primary {
  font-family: var(--font-mono);
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: var(--fw-bold);
  color: var(--color-brand);
  line-height: 1.2;
  margin-bottom: var(--space-4);
}

/* ─── Util classes ─────────────────────────────────────────────────────────*/
.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;
}

.text-muted { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-center { text-align: center; }
.text-mono { font-family: var(--font-mono); }

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }

.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.wrap { flex-wrap: wrap; }

/* ─── 404 page ───────────────────────────────────────────────────────────── */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  padding: var(--space-8);
}

.error-page__code {
  font-family: var(--font-mono);
  font-size: 6rem;
  font-weight: var(--fw-bold);
  color: var(--color-brand);
  line-height: 1;
  margin-bottom: var(--space-4);
}

/* ─── Widget page ────────────────────────────────────────────────────────── */
.widget-body {
  padding: var(--space-4);
  background: transparent;
}

/* ─── Encoding badge ─────────────────────────────────────────────────────── */
.encoding-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
}

.encoding-badge--gsm7 {
  background: var(--color-success-soft);
  color: var(--color-success);
}
.encoding-badge--ucs2 {
  background: var(--color-warning-soft);
  color: var(--color-warning);
}

/* ─── SMS parts explainer (collapsible details) ──────────────────────────── */
.sms-parts-explainer summary { user-select: none; }
.sms-parts-explainer summary::-webkit-details-marker { display: none; }
.sms-parts-explainer[open] .sms-parts-explainer__arrow { content: '▲'; transform: rotate(180deg); display: inline-block; }

/* ─── Scrollbar (webkit) ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* ─── Ad Slot (.ad-slot) ─────────────────────────────────────────────────── */
/*
 * Wrapper for the Adsterra native banner. Sits between the tool content and
 * the related-tools / footer region — never between input and live results.
 *
 * The ::before pseudo-element renders an "Advertisement" disclosure label
 * above the ad at all times, even before the JS injects the ad container.
 * This satisfies FTC/IAB honest-advertising requirements and keeps the slot
 * visually distinct from tool UI.
 *
 * min-height reserves space to prevent layout shift when the ad loads async.
 */
.ad-slot {
  display: block;
  margin: var(--space-4) auto var(--space-5);
  max-width: 728px;
  width: 100%;
  min-height: 180px;          /* reserve space → prevents CLS when ad loads  */
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4) var(--space-4);
  box-sizing: border-box;
  text-align: center;
  overflow: hidden;           /* clip any oversized ad creatives              */
}

/* "Advertisement" disclosure label — always visible, above the ad */
.ad-slot::before {
  content: "Advertisement";
  display: block;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
  text-align: center;
  line-height: 1;
}

/* Responsive: prevent overflow on narrow viewports */
@media (max-width: 768px) {
  .ad-slot {
    max-width: 100%;
    min-height: 140px;
    padding: var(--space-2) var(--space-3) var(--space-3);
    margin: var(--space-4) auto var(--space-4);
  }
}
