:root {
  --blue: #295bb7;
  --blue-deep: #1d4592;
  --navy: #0b1b34;
  --bg: #eef3fb;
  --card: #ffffff;
  --line: #d4def1;
  --ink: #0b1b34;
  --muted: #5a6780;
  --coral: #e4573d;
  --ok: #1e8e5a;
  --warn: #b5611d;
  --code-bg: #0b1b34;
  --code-ink: #cfe0ff;
  --display: "Baloo Bhaijaan 2", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --body: "IBM Plex Sans Arabic", system-ui, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --blue: #6b97ec;
    --blue-deep: #4d7fdc;
    --bg: #081222;
    --card: #0f1d33;
    --line: #1f3252;
    --ink: #e6eefb;
    --muted: #93a3bd;
    --coral: #f07a60;
    --ok: #52c48a;
    --warn: #eea062;
    --code-bg: #050c18;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--body); }
button, input { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #ffd166; outline-offset: 3px; border-radius: 8px; }

/* Hero */
.hero { position: relative; min-height: min(92vh, 820px); color: #fff; display: flex; flex-direction: column; overflow: hidden; background: var(--navy); }
.hero-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 60% 40%; }
.hero-shade { position: absolute; inset: 0; background:
  linear-gradient(180deg, rgba(11,27,52,.55) 0%, rgba(11,27,52,.25) 30%, rgba(11,27,52,.72) 70%, rgba(11,27,52,.92) 100%),
  linear-gradient(90deg, rgba(11,27,52,.65) 0%, rgba(11,27,52,0) 65%); }
[dir=rtl] .hero-shade { background:
  linear-gradient(180deg, rgba(11,27,52,.55) 0%, rgba(11,27,52,.25) 30%, rgba(11,27,52,.72) 70%, rgba(11,27,52,.92) 100%),
  linear-gradient(270deg, rgba(11,27,52,.65) 0%, rgba(11,27,52,0) 65%); }

.topbar { position: relative; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 20px clamp(16px, 4vw, 48px); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-chip { background: #fff; border-radius: 14px; padding: 6px 10px; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.brand-chip img { height: 40px; width: auto; }
.pilot { font: 600 .8rem/1 var(--display); letter-spacing: .04em; text-transform: uppercase; padding: 8px 12px; border: 1px solid rgba(255,255,255,.35); border-radius: 999px; backdrop-filter: blur(6px); }
[dir=rtl] .pilot { letter-spacing: 0; text-transform: none; font-size: .9rem; }
.top-actions { display: flex; gap: 8px; }
.top-btn { display: inline-flex; align-items: center; gap: 8px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.3); color: #fff; padding: 9px 16px; border-radius: 999px; cursor: pointer; font-weight: 500; backdrop-filter: blur(6px); transition: background .2s; }
.top-btn:hover { background: rgba(255,255,255,.22); }
.key-dot { width: 9px; height: 9px; border-radius: 50%; background: #ffb84d; box-shadow: 0 0 0 3px rgba(255,184,77,.25); }
.key-dot.ok { background: #4ade80; box-shadow: 0 0 0 3px rgba(74,222,128,.25); }

.hero-body { position: relative; z-index: 2; flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 24px clamp(16px, 6vw, 88px) 150px; max-width: 900px; }
h1 { font: 800 clamp(2.4rem, 6.2vw, 4.6rem)/1.02 var(--display); margin: 0 0 18px; letter-spacing: -.02em; text-wrap: balance; }
[dir=rtl] h1 { letter-spacing: 0; line-height: 1.2; }
.lede { font-size: clamp(1.05rem, 1.8vw, 1.25rem); max-width: 34em; margin: 0 0 40px; color: rgba(255,255,255,.88); }

.mic-wrap { display: flex; align-items: center; gap: 24px; }
.mic { position: relative; flex: none; width: 104px; height: 104px; border-radius: 50%; border: 0; background: #fff; color: var(--blue); cursor: pointer; display: grid; place-items: center; box-shadow: 0 14px 40px rgba(0,0,0,.35); transition: transform .2s, background .2s, color .2s; }
.mic:hover { transform: scale(1.04); }
.mic:disabled { cursor: progress; transform: none; }
.mic svg { width: 44px; height: 44px; fill: currentColor; }
.mic .icon-stop, .mic .icon-wait { display: none; }
.mic-ring { position: absolute; inset: -10px; border-radius: 50%; border: 2px solid rgba(255,255,255,.55); transform: scale(var(--level, 1)); transition: transform 80ms linear; pointer-events: none; }
.mic.recording { background: var(--coral); color: #fff; }
.mic.recording .mic-ring { border-color: rgba(228,87,61,.7); }
.mic.recording .icon-mic { display: none; }
.mic.recording .icon-stop { display: block; }
.mic.busy .icon-mic { display: none; }
.mic.busy .icon-wait { display: block; animation: spin 1s linear infinite; }
.mic.busy .mic-ring { opacity: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

.mic-text { display: flex; flex-direction: column; gap: 2px; }
.mic-text strong { font: 700 1.5rem/1.2 var(--display); }
.mic-text > span { color: rgba(255,255,255,.75); font-variant-numeric: tabular-nums; }
.upload { margin-top: 8px; color: #fff; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; text-decoration-color: rgba(255,255,255,.45); width: fit-content; }
.upload:hover { text-decoration-color: #fff; }
.upload input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload:focus-within { outline: 3px solid #ffd166; outline-offset: 3px; border-radius: 4px; }

.sea { position: absolute; left: 0; right: 0; bottom: -1px; width: 100%; height: 130px; z-index: 1; }

/* Main */
main { max-width: 1040px; margin: 0 auto; padding: 8px clamp(16px, 4vw, 32px) 40px; }
h2 { font: 700 clamp(1.5rem, 3vw, 2rem)/1.2 var(--display); margin: 0 0 20px; }

/* Result */
.result { margin: 8px 0 56px; }
.steps { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 0; margin: 0 0 24px; counter-reset: s; }
.steps li { position: relative; display: flex; flex-direction: column; gap: 8px; font-size: .9rem; color: var(--muted); padding-top: 4px; }
.steps li::before { content: ""; position: absolute; top: 12px; inset-inline-start: 26px; inset-inline-end: -8px; height: 2px; background: var(--line); }
.steps li:last-child::before { display: none; }
.step-dot { position: relative; z-index: 1; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); background: var(--bg); }
.steps li.active { color: var(--ink); font-weight: 600; }
.steps li.active .step-dot { border-color: var(--blue); box-shadow: 0 0 0 5px color-mix(in srgb, var(--blue) 22%, transparent); animation: pulse 1.2s ease-in-out infinite; }
.steps li.done { color: var(--ink); }
.steps li.done .step-dot { background: var(--blue); border-color: var(--blue); }
.steps li.done::before { background: var(--blue); }
.steps li.failed .step-dot { background: var(--coral); border-color: var(--coral); }
@keyframes pulse { 50% { box-shadow: 0 0 0 9px color-mix(in srgb, var(--blue) 8%, transparent); } }

.said { margin: 0 0 20px; padding: 22px 26px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); border-inline-start: 6px solid var(--blue); }
.said figcaption { font-size: .85rem; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.said blockquote { margin: 0; font: 600 clamp(1.2rem, 2.6vw, 1.6rem)/1.5 var(--display); }

.outcome { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: 0 18px 50px -24px rgba(11,27,52,.35); }
.outcome-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding: 22px 26px; background: linear-gradient(120deg, var(--blue), var(--blue-deep)); color: #fff; }
.outcome-head h3 { margin: 0; font: 700 1.6rem/1.2 var(--display); }
.badge { font: 600 .8rem/1 var(--display); padding: 7px 12px; border-radius: 999px; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.35); white-space: nowrap; }
.outcome-head.warn { background: linear-gradient(120deg, #c9661f, #a44d12); }

.lines { width: 100%; border-collapse: collapse; }
.lines th { text-align: start; font-size: .78rem; font-weight: 600; color: var(--muted); padding: 14px 26px 8px; text-transform: uppercase; letter-spacing: .05em; }
[dir=rtl] .lines th { text-transform: none; letter-spacing: 0; font-size: .85rem; }
.lines td { padding: 14px 26px; border-top: 1px solid var(--line); vertical-align: middle; }
.lines .num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fish-name, .fish-alt { display: block; width: fit-content; }
.fish-name { font: 700 1.2rem/1.2 var(--display); }
.fish-alt { font-size: .85rem; color: var(--muted); }
.lines tfoot td { font-weight: 700; background: color-mix(in srgb, var(--blue) 7%, var(--card)); }
.next { display: flex; gap: 12px; align-items: flex-start; margin: 0; padding: 18px 26px; border-top: 1px solid var(--line); color: var(--muted); }
.next svg { flex: none; width: 22px; height: 22px; fill: var(--blue); margin-top: 2px; }

.outcome-body { padding: 22px 26px; }
.outcome-body p { margin: 0 0 14px; }
.tips { margin: 0 0 20px; padding-inline-start: 20px; }
.tips li { margin-bottom: 4px; }
.btn { border: 0; border-radius: 999px; padding: 11px 22px; font-weight: 600; cursor: pointer; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-deep); }
.btn-quiet { background: transparent; color: var(--ink); border: 1px solid var(--line); }

.tech { border-top: 1px solid var(--line); }
.tech summary { cursor: pointer; padding: 16px 26px; color: var(--muted); font-weight: 600; font-size: .92rem; }
.tech summary:hover { color: var(--ink); }
.tech-inner { padding: 0 26px 22px; }
.tech-inner p { margin: 0 0 12px; font-size: .9rem; color: var(--muted); }
.code-wrap { position: relative; }
.tech pre { margin: 0; background: var(--code-bg); color: var(--code-ink); padding: 18px; border-radius: 12px; overflow-x: auto; font: .82rem/1.55 var(--mono); direction: ltr; text-align: left; }
.copy { position: absolute; top: 10px; inset-inline-end: 10px; background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.25); border-radius: 8px; padding: 4px 10px; font-size: .8rem; cursor: pointer; }

/* Examples */
.examples { margin-top: 24px; }
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.card img { width: 100%; aspect-ratio: 16 / 8; object-fit: cover; }
.card-body { padding: 20px 22px 24px; }
.card h3 { font: 700 1.4rem/1.2 var(--display); margin: 10px 0 4px; }
.card-note { margin: 0 0 16px; color: var(--muted); }
.tag { display: inline-block; font: 600 .78rem/1 var(--display); padding: 6px 10px; border-radius: 999px; }
.tag-buyer { background: color-mix(in srgb, var(--blue) 14%, transparent); color: var(--blue); }
.tag-seller { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.phrase { font: 600 1.25rem/1.5 var(--display); margin: 0; padding: 12px 16px; background: var(--bg); border-radius: 12px; }
.phrase-tr { margin: 8px 0 0; font-size: .9rem; color: var(--muted); font-style: italic; }
[dir=rtl] .phrase-tr { display: none; }

/* Footer */
.foot { max-width: 1040px; margin: 0 auto; padding: 32px clamp(16px, 4vw, 32px) 48px; display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; align-items: center; color: var(--muted); font-size: .88rem; border-top: 1px solid var(--line); }
.foot-logo { grid-row: span 2; height: 44px; width: auto; }
.foot p { margin: 0; }
.credit { font-size: .8rem; }

/* Settings dialog */
dialog { width: min(500px, calc(100% - 32px)); border: 1px solid var(--line); border-radius: 22px; padding: 28px; background: var(--card); color: var(--ink); box-shadow: 0 30px 80px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(11,27,52,.55); backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 8px; }
.dlg-intro { margin: 0 0 8px; color: var(--muted); font-size: .95rem; }
dialog label { display: block; font-weight: 600; margin: 16px 0 6px; }
dialog input { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); direction: ltr; }
dialog input:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
.advanced { margin-top: 16px; }
.advanced summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 12px 20px; border-radius: 999px; box-shadow: 0 10px 30px rgba(0,0,0,.3); z-index: 10; font-weight: 500; }

@media (max-width: 720px) {
  .pilot { display: none; }
  .hero { min-height: auto; }
  .hero-body { padding-top: 32px; padding-bottom: 130px; }
  .mic { width: 88px; height: 88px; }
  .mic svg { width: 38px; height: 38px; }
  .mic-wrap { gap: 18px; }
  .cards { grid-template-columns: 1fr; }
  .steps { grid-template-columns: repeat(2, 1fr); row-gap: 14px; }
  .steps li::before { display: none; }
  .lines th, .lines td { padding-inline: 16px; }
  .outcome-head, .outcome-body, .next, .said { padding-inline: 18px; }
  .top-btn { padding: 8px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
