:root {
  --bg: #0b1512;
  --surface: #12211c;
  --surface-2: #19302a;
  --line: #264238;
  --text: #f1f6f3;
  --muted: #a9bdb4;
  --accent: #35c08e;
  --accent-ink: #062018;
  --gold: #e3c170;
  --danger: #e5484d;
  --danger-deep: #b3262b;
  --radius: 22px;
  --touch: 72px;
}
:root[data-theme="light"] {
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-2: #e8efeb;
  --line: #cfdcd5;
  --text: #0e1f19;
  --muted: #4c6359;
  --accent: #0f8f63;
  --accent-ink: #ffffff;
  --gold: #8a6510;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Tajawal, "Segoe UI", Tahoma, sans-serif;
  font-size: clamp(18px, 1.5vw + 12px, 26px);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }

.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px clamp(16px, 3vw, 40px); border-bottom: 1px solid var(--line); background: var(--surface); }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-name { font-weight: 800; font-size: 1.25em; }
.brand-site { color: var(--gold); font-weight: 700; padding: 2px 14px; border: 1px solid var(--line); border-radius: 999px; }
.net { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); flex: none; }
.net.off { background: var(--danger); }
.tabs { display: flex; gap: 8px; }
.tab { min-height: var(--touch); padding: 0 clamp(16px, 2.2vw, 34px); border-radius: 999px; background: var(--surface-2); font-weight: 700; }
.tab.is-on { background: var(--accent); color: var(--accent-ink); }

.langbar { display: flex; gap: 10px; padding: 12px clamp(16px, 3vw, 40px); overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); }
.langbar::-webkit-scrollbar { display: none; }
.lang { flex: none; min-height: 64px; min-width: 104px; padding: 0 20px; border-radius: 16px; background: var(--surface); border: 2px solid var(--line); font-weight: 700; }
.lang.is-on { border-color: var(--accent); background: var(--surface-2); color: var(--accent); }

main { flex: 1; min-height: 0; overflow-y: auto; padding: clamp(16px, 2.5vw, 36px) clamp(16px, 3vw, 40px) 40px; }
.view { max-width: 1500px; margin: 0 auto; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 16px; }
.tile { min-height: 150px; padding: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 12px; text-align: start; font-weight: 700; font-size: 1.1em; }
.tile:active { background: var(--surface-2); }
.tile-icon { font-size: 1.9em; line-height: 1; }

#view-ask { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; min-height: 100%; }
.heard { font-size: 1.5em; font-weight: 700; margin: 12px 0 0; min-height: 2.4em; max-width: 30ch; }
.heard.live { color: var(--accent); }
.heard.small { font-size: 1.05em; min-height: 0; color: var(--muted); max-width: none; margin: 0 0 12px; }
.example { color: var(--muted); margin: 0; }
.mic-note { color: var(--gold); margin: 0; }
.mic { margin-top: auto; width: 190px; height: 190px; border-radius: 50%; background: var(--danger); color: #fff; font-weight: 800; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; box-shadow: 0 0 0 10px color-mix(in srgb, var(--danger) 22%, transparent); touch-action: none; }
.mic.is-on { background: var(--danger-deep); box-shadow: 0 0 0 22px color-mix(in srgb, var(--danger) 30%, transparent); }
.mic:disabled { background: var(--surface-2); color: var(--muted); box-shadow: none; }
.mic-wave { display: flex; gap: 6px; align-items: center; height: 44px; }
.mic-wave i { width: 7px; height: 12px; border-radius: 4px; background: #fff; }
.mic.is-on .mic-wave i { animation: wave 0.9s ease-in-out infinite; }
.mic.is-on .mic-wave i:nth-child(2) { animation-delay: 0.12s; }
.mic.is-on .mic-wave i:nth-child(3) { animation-delay: 0.24s; }
.mic.is-on .mic-wave i:nth-child(4) { animation-delay: 0.36s; }
.mic.is-on .mic-wave i:nth-child(5) { animation-delay: 0.48s; }
@keyframes wave { 0%, 100% { height: 12px; } 50% { height: 44px; } }
@media (prefers-reduced-motion: reduce) { .mic.is-on .mic-wave i { animation: none; height: 28px; } }
.typed { display: flex; gap: 10px; width: min(100%, 760px); }
.typed input { flex: 1; min-width: 0; min-height: 64px; border-radius: 16px; border: 2px solid var(--line); background: var(--surface); color: var(--text); font: inherit; padding: 0 18px; user-select: text; }
.typed button { min-height: 64px; padding: 0 28px; border-radius: 16px; background: var(--accent); color: var(--accent-ink); font-weight: 800; }

.soon { min-height: 50vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; }
.soon-title { font-size: 1.6em; font-weight: 800; }
.soon-text { font-size: 2.4em; font-weight: 800; color: var(--gold); }
.soon-tag { color: var(--muted); border: 1px dashed var(--line); border-radius: 999px; padding: 6px 20px; }

.result-head { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.result-head h2 { margin: 0; font-size: 1.4em; }
.back { min-height: 64px; padding: 0 26px; border-radius: 16px; background: var(--surface-2); font-weight: 700; flex: none; }
.notice { background: var(--surface); border: 1px solid var(--line); border-inline-start: 6px solid var(--gold); border-radius: 14px; padding: 12px 18px; margin: 0 0 12px; }
.notice.none { border-inline-start-color: var(--danger); font-weight: 700; font-size: 1.15em; }
.alternates { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.alt { min-height: 64px; padding: 0 22px; border-radius: 16px; background: var(--surface); border: 2px solid var(--line); font-weight: 700; }
.sub { margin: 26px 0 12px; color: var(--gold); font-size: 1.15em; }

.quote { margin: 0 0 16px; padding: 18px 22px; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); font-size: 1.15em; user-select: text; overflow-wrap: anywhere; }
.quote cite { display: block; margin-top: 10px; color: var(--muted); font-size: 0.8em; font-style: normal; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; grid-template-columns: 1fr; gap: 14px; min-width: 0; }
.card-top { display: flex; gap: 16px; min-width: 0; }
.cover { flex: none; width: 118px; aspect-ratio: 987 / 1400; border-radius: 12px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 2.4em; overflow: hidden; position: relative; }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card-meta { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.badge { align-self: flex-start; font-size: 0.72em; font-weight: 700; padding: 2px 12px; border-radius: 999px; background: var(--surface-2); color: var(--accent); }
.card-title { font-weight: 800; font-size: 1.1em; line-height: 1.4; overflow-wrap: anywhere; }
.card-origin, .card-source { color: var(--muted); font-size: 0.82em; overflow-wrap: anywhere; }
.card-text { margin: 0; padding: 12px 16px; background: var(--surface-2); border-radius: 14px; font-size: 0.92em; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.card-text-label { color: var(--muted); font-size: 0.72em; }
.card-bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.qr { width: 220px; height: 220px; background: #fff; border-radius: 14px; padding: 6px; flex: none; }
.qr img { width: 100%; height: 100%; display: block; }
.qr-side { display: flex; flex-direction: column; gap: 10px; flex: 1; min-width: 150px; }
.qr-hint { color: var(--muted); font-size: 0.82em; }
.listen { min-height: 64px; padding: 0 22px; border-radius: 16px; background: var(--accent); color: var(--accent-ink); font-weight: 800; }
.book { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 18px; margin-bottom: 10px; display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.book .qr { width: 150px; height: 150px; }

.foot { padding: 8px clamp(16px, 3vw, 40px); font-size: 0.68em; color: var(--muted); border-top: 1px solid var(--line); text-align: center; }
.foot b { color: var(--gold); }

@media (max-width: 720px) {
  .top { justify-content: center; }
  .tab { min-height: 64px; }
  .qr { width: 200px; height: 200px; margin-inline: auto; }
  .cover { width: 92px; }
}
