/* RoyalDS Speedtest – brand styles.
   Palette: bg #120c04, accent #c8a227. Font Inter (fallback for Gilroy). */

:root {
  --bg: #120c04;
  --bg-elev: #1c150a;
  --bg-elev-2: #261c0e;
  --line: #3a2c14;
  --text: #f3ead7;
  --text-dim: #b9a378;
  --text-muted: #7d6b46;
  --accent: #c8a227;
  --accent-hover: #d9b540;
  --ok: #6fbf73;
  --warn: #d9a441;
  --fail: #d9534f;
  --radius: 10px;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: 'Inter', 'Gilroy', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: var(--text);
}

.brand-mark {
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
  font-size: 1.05rem;
}

.brand-divider {
  color: var(--text-muted);
}

.brand-tagline {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.lang-switch select {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 0.85rem;
}

.app-main {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.hero {
  text-align: center;
}

.hero-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
}

.hero-sub {
  color: var(--text-dim);
  margin: 0 0 28px;
}

.cta {
  background: var(--accent);
  color: #120c04;
  border: none;
  border-radius: var(--radius);
  padding: 14px 32px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 120ms ease;
}

.cta:hover:not(:disabled),
.cta:focus-visible:not(:disabled) {
  background: var(--accent-hover);
  outline: none;
}

.cta:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cta.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.cta.secondary:hover:not(:disabled),
.cta.secondary:focus-visible:not(:disabled) {
  background: rgba(200, 162, 39, 0.1);
}

.link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}

.link:hover,
.link:focus-visible {
  text-decoration: underline;
}

.progress {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  margin-bottom: 10px;
}

.progress-phase {
  color: var(--text);
  font-weight: 500;
}

.progress-pct {
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}

.progress-bar {
  height: 4px;
  background: var(--bg-elev-2);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 18px;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 200ms ease;
}

.progress-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.progress-steps li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-steps .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
  flex-shrink: 0;
}

.progress-steps li.active {
  color: var(--text);
}

.progress-steps li.active .dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(200, 162, 39, 0.2);
}

.progress-steps li.done {
  color: var(--text-dim);
}

.progress-steps li.done .dot {
  background: var(--ok);
}

.result {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge-ok {
  background: rgba(111, 191, 115, 0.15);
  color: var(--ok);
  border: 1px solid rgba(111, 191, 115, 0.4);
}

.badge-warn {
  background: rgba(217, 164, 65, 0.15);
  color: var(--warn);
  border: 1px solid rgba(217, 164, 65, 0.4);
}

.badge-fail {
  background: rgba(217, 83, 79, 0.15);
  color: var(--fail);
  border: 1px solid rgba(217, 83, 79, 0.4);
}

.result-id {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.result-id a {
  color: var(--accent);
  text-decoration: none;
  font-family: var(--mono);
}

.result-md {
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--text);
  margin: 0 0 14px;
  white-space: pre;
  overflow-x: auto;
}

.result-actions {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.toast {
  margin-top: 10px;
  color: var(--ok);
  font-size: 0.85rem;
}

.error {
  background: rgba(217, 83, 79, 0.08);
  border: 1px solid rgba(217, 83, 79, 0.3);
  border-radius: var(--radius);
  padding: 14px 18px;
  color: var(--fail);
  font-size: 0.95rem;
}

.app-footer {
  border-top: 1px solid var(--line);
  padding: 14px 24px;
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-family: var(--mono);
}

.dim {
  color: var(--text-muted);
}

.hidden {
  display: none !important;
}

@media (max-width: 520px) {
  .app-header {
    padding: 14px 16px;
  }
  .app-main {
    padding: 28px 16px 24px;
  }
  .hero-title {
    font-size: 1.5rem;
  }
  .result-md {
    font-size: 0.78rem;
  }
}

/* Recent tests block on the landing page. */
.recent {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 22px 14px;
}

.recent-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.recent-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text);
}

.recent-refresh {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease;
}

.recent-refresh:hover,
.recent-refresh:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
  outline: none;
}

.recent-hint {
  margin: 2px 0 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.recent-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.recent-list {
  border-top: 1px solid var(--line);
}

.recent-row {
  display: grid;
  grid-template-columns: minmax(120px, auto) 1fr auto;
  align-items: center;
  column-gap: 16px;
  padding: 10px 6px;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--text-dim);
  transition: background 100ms ease;
}

.recent-row:last-child {
  border-bottom: none;
}

.recent-row:hover {
  background: var(--bg-elev-2);
}

.recent-rating {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.recent-rating-num {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  min-width: 2.2ch;
  text-align: right;
}

.recent-rating-num.is-empty {
  color: var(--text-muted);
}

.stars {
  display: inline-flex;
  gap: 2px;
  font-size: 0.9rem;
  line-height: 1;
}

.stars.is-empty {
  opacity: 0.45;
}

.star {
  display: inline-block;
  color: var(--line);
}

.star.star-full {
  color: var(--accent);
}

.star.star-half {
  background: linear-gradient(to right, var(--accent) 50%, var(--line) 50%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.recent-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}

.recent-time {
  font-family: var(--mono);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.recent-loc {
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}

.recent-isp {
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.recent-sep {
  color: var(--text-muted);
  flex-shrink: 0;
}

.recent-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.82rem;
  white-space: nowrap;
}

.recent-link:hover,
.recent-link:focus-visible {
  text-decoration: underline;
}

.recent-empty {
  margin: 12px 0 4px;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

@media (max-width: 640px) {
  .recent-row {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      'rating link'
      'meta meta';
    column-gap: 12px;
    row-gap: 4px;
    padding: 10px 4px;
  }
  .recent-rating { grid-area: rating; }
  .recent-meta { grid-area: meta; flex-wrap: wrap; }
  .recent-link { grid-area: link; justify-self: end; }
}

/* Detail view (/r/:id) reuses the same shell with a slightly different layout. */
.detail {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}

.detail h2 {
  margin: 0 0 16px;
  font-size: 1.2rem;
  color: var(--text);
}

.detail dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 18px;
  margin: 0 0 18px;
  font-size: 0.9rem;
}

.detail dt {
  color: var(--text-muted);
}

.detail dd {
  margin: 0;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.85rem;
  word-break: break-word;
}

.detail-section {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 16px;
}
