/* Components (tokens are set per-theme in themes.css) */
:root {
  color-scheme: dark;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --duration: 360ms;
  --success: #16a36a;
  --danger: #e74c3c;
  --font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  /* Fallbacks (overridden by themes) */
  --page: #101216; --canvas: #15181e; --surface: #20242b; --surface-2: #292e37;
  --text: #f5f6f8; --muted: #a5abb5; --faint: #7d8591;
  --accent: #8b78f6; --accent-hover: #7661ee; --accent-soft: rgba(139,120,246,.12);
  --button-bg: #8b78f6; --button-hover: #7661ee; --button-text: #fff; --button-border: transparent;
  --progress-start: #8b78f6; --progress-end: #b2a6ff; --progress-track: rgba(255,255,255,.12);
  --border: rgba(255,255,255,.10); --focus: rgba(139,120,246,.42);
  --shadow: 0 28px 80px rgba(0,0,0,.36);
  --card-radius: 24px; --button-radius: 14px; --sheet-radius: 26px;
}

*, *::before, *::after { box-sizing: border-box; }
html { min-height: 100%; background: var(--page); }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  color: var(--text); background: var(--page); font-family: var(--font-family);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  transition: background-color var(--duration) var(--ease), color var(--duration) var(--ease);
}
button, select { font: inherit; }
button:focus-visible, select:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
button { -webkit-tap-highlight-color: transparent; }

/* Shell & Controls */
.app-shell { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 24px 0 36px; }
.site-header { display: flex; align-items: center; justify-content: space-between; padding-bottom: 22px; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 12px; color: var(--accent); background: var(--accent-soft); font-weight: 800; }
.brand-name { font-size: 14px; font-weight: 700; }
.brand-caption { margin-top: 3px; color: var(--muted); font-size: 11px; }

.control-panel {
  display: grid; grid-template-columns: minmax(180px, 1.3fr) auto auto; gap: 12px;
  padding: 13px; border: 1px solid var(--border); border-radius: 17px; background: var(--surface); margin-top: 20px;
}
.control-group { display: flex; flex-direction: column; gap: 6px; }
.control-label { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.control-select { height: 38px; padding: 0 11px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); background: var(--surface-2); cursor: pointer; }
.segmented { display: flex; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.segmented button { min-width: 70px; padding: 0 12px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 600; cursor: pointer; transition: all 180ms var(--ease); }
.segmented button[aria-pressed="true"] { color: var(--text); background: var(--surface); box-shadow: 0 1px 4px rgba(0,0,0,.10); }
.segmented button:disabled { opacity: 0.35; cursor: not-allowed; }

.stage-controls { display: flex; align-items: center; gap: 7px; margin-top: 11px; padding: 11px 13px; border: 1px solid var(--border); border-radius: 15px; background: var(--surface); flex-wrap: wrap; }
.stage-controls-label { margin-right: 4px; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.stage-button, .utility-button { min-height: 32px; padding: 0 11px; border: 1px solid var(--border); border-radius: 9px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 600; cursor: pointer; transition: all 180ms var(--ease); }
.stage-button:hover, .utility-button:hover { color: var(--text); background: var(--surface-2); }
.stage-button[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.utility-button.primary-utility { color: var(--button-text); background: var(--button-bg); border-color: transparent; }

/* Preview */
.preview-area { display: grid; place-items: center; min-height: 520px; margin-top: 18px; padding: 34px 20px; border: 1px solid var(--border); border-radius: 22px; background: var(--canvas); transition: all 240ms var(--ease); }
.preview-device { display: grid; place-items: center; width: 100%; min-height: 450px; transition: width 240ms var(--ease); }
.preview-area[data-viewport="mobile"] { min-height: 700px; padding: 20px; }
.preview-area[data-viewport="mobile"] .preview-device { width: min(100%, 390px); min-height: 640px; border: 1px solid var(--border); border-radius: 30px; background: var(--page); box-shadow: 0 24px 60px rgba(0,0,0,.15); }
.preview-area[data-viewport="mobile"] .flow-card { width: calc(100% - 32px); border-radius: var(--card-radius); border: 1px solid var(--border); box-shadow: var(--shadow); }

/* Card */
.flow-card { width: min(100%, 400px); min-height: 260px; padding: 24px; border: 1px solid var(--border); border-radius: var(--card-radius); background: var(--surface); box-shadow: var(--shadow); backdrop-filter: blur(22px); display: flex; flex-direction: column; }
.card-meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.step-name { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.step-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.step-count { color: var(--faint); font-size: 10px; font-weight: 700; }

/* Screens */
.screen { display: flex; flex-direction: column; flex: 1; animation: screen-enter 420ms var(--ease) both; }
.screen[hidden] { display: none; }
.eyebrow { margin: 0 0 8px; color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.04em; line-height: 1.2; }
.description { max-width: 320px; margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

/* Progress */
.progress-block { margin-top: 20px; margin-bottom: 8px; }
.progress-meta { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 11px; font-weight: 700; }
.progress-value { color: var(--muted); }
.progress-track { height: 4px; overflow: hidden; border-radius: 999px; background: var(--progress-track); }
.progress-fill { width: 0%; height: 100%; background: linear-gradient(90deg, var(--progress-start), var(--progress-end)); transition: width 90ms linear; }
.status-line { margin: 12px 0 0; color: var(--faint); font-size: 10px; }

/* Button */
.action-button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; min-height: 48px; margin-top: 24px;
  border: 1px solid var(--button-border); border-radius: var(--button-radius);
  color: var(--button-text); background: var(--button-bg);
  font-size: 13px; font-weight: 700; cursor: pointer;
  transition: all 200ms var(--ease);
}
.action-button:hover { background: var(--button-hover); }
.action-button:active { transform: scale(.985); }

/* TronLink-specific typographic overrides */
[data-wallet="tronlink"] h1 { font-weight: 600; letter-spacing: -0.02em; }
[data-wallet="tronlink"] .action-button { font-weight: 500; }
[data-wallet="tronlink"] .step-name,
[data-wallet="tronlink"] .eyebrow { font-weight: 600; }
[data-wallet="tronlink"] .progress-meta { font-weight: 500; }

/* Icons */
.state-symbol { display: flex; align-items: center; justify-content: center; width: 56px; height: 56px; margin: 0 0 20px; }
.state-symbol circle { stroke: var(--border); }
.success-symbol { color: var(--success); }
.success-symbol path { stroke: var(--success); stroke-dasharray: 52; stroke-dashoffset: 52; animation: draw-check 700ms 100ms var(--ease) forwards; }
.error-symbol { color: var(--danger); }
.error-symbol path { stroke: var(--danger); stroke-dasharray: 52; stroke-dashoffset: 52; animation: draw-check 700ms 100ms var(--ease) forwards; }

@keyframes screen-enter { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: translateY(0); } }
@keyframes draw-check { to { stroke-dashoffset: 0; } }

@media (max-width: 760px) {
  .control-panel { grid-template-columns: 1fr 1fr; }
  .control-group:first-child { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
