@font-face { font-family: "Vazirmatn"; src: url("fonts/vazirmatn.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Archivo"; src: url("fonts/archivo.woff2") format("woff2"); font-weight: 100 900; font-stretch: 62% 125%; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("fonts/jetbrains-mono.woff2") format("woff2"); font-weight: 100 800; font-display: swap; }

:root {
  --oxblood: #793C38;
  --oxblood-hi: #A4544E;
  --oxblood-deep: #5A2926;
  --bone: #F2EFE8;
  --stone: #B9B4A8;
  --ink: #8C887E;
  --night: #121311;
  --night-2: #191A18;
  --line: rgba(242, 239, 232, .12);
  --glass: rgba(24, 25, 23, .86);
  --glass-hi: rgba(242, 239, 232, .06);
  --danger: #D2574C;
  --live: #7FB08A;
  --level: 0;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--night);
  color: var(--bone);
  font-family: "Vazirmatn", system-ui, sans-serif;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; color: inherit; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; letter-spacing: .08em; }

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
}

.aura {
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(42% 30% at 50% 44%, rgba(121, 60, 56, calc(.42 + var(--level) * .4)) 0%, rgba(121, 60, 56, 0) 70%),
    radial-gradient(80% 60% at 50% 110%, rgba(121, 60, 56, .18) 0%, rgba(18, 19, 17, 0) 70%),
    var(--night);
  transition: background .2s;
}

.grain {
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: url("pattern-stone.svg");
  background-size: 220px;
  opacity: .05;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, .4) 30%, transparent 60%);
  mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, .4) 30%, transparent 60%);
  pointer-events: none;
}

.hud {
  position: absolute;
  top: 0;
  inset-inline: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + var(--safe-t)) 20px 0;
}

.mark { display: flex; align-items: baseline; gap: 10px; }
.mark .fa { font-weight: 800; font-size: 22px; color: var(--bone); }
.mark .en {
  font-family: "Archivo", sans-serif;
  font-stretch: 125%;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: .42em;
  color: var(--stone);
}

.pills { display: flex; gap: 8px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--glass-hi);
  backdrop-filter: blur(10px);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: .1em;
  color: var(--stone);
  cursor: pointer;
}
.led { width: 6px; height: 6px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 0 transparent; }
.led.ok { background: var(--live); box-shadow: 0 0 10px var(--live); }
.led.bad { background: var(--danger); box-shadow: 0 0 12px var(--danger); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .25; } }

.stage { position: absolute; inset: 0; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }

.state {
  position: absolute;
  top: calc(66px + var(--safe-t));
  inset-inline: 0;
  display: flex;
  justify-content: center;
  gap: 10px;
  font-size: 12px;
  color: var(--stone);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .3s, transform .3s;
  pointer-events: none;
}
.state.on { opacity: 1; transform: none; }
.state .mono { color: var(--oxblood-hi); font-size: 10.5px; }

.captions {
  position: absolute;
  inset-inline: 0;
  bottom: calc(124px + var(--safe-b));
  z-index: 2;
  padding: 0 28px;
  text-align: center;
  pointer-events: none;
}
.heard {
  margin: 0 auto 8px;
  max-width: 560px;
  font-size: 14px;
  color: var(--ink);
  min-height: 1.4em;
}
.said {
  margin: 0 auto;
  max-width: 600px;
  font-size: clamp(18px, 4.6vw, 24px);
  font-weight: 500;
  line-height: 1.75;
  color: var(--bone);
  max-height: 24vh;
  overflow: hidden;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .55);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.said .w { opacity: 0; filter: blur(6px); transition: opacity .35s, filter .35s; }
.said .w.in { opacity: 1; filter: none; }

.dock {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 34px;
  padding: 0 24px calc(26px + var(--safe-b));
}

.glass-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--glass-hi);
  backdrop-filter: blur(14px);
  display: grid;
  place-items: center;
  color: var(--stone);
  cursor: pointer;
  transition: background .2s, color .2s;
}
.glass-btn:hover { background: rgba(242, 239, 232, .1); color: var(--bone); }
.glass-btn.small { width: 38px; height: 38px; }
.glass-btn svg, .mic svg, .send svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mic {
  position: relative;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 0;
  background: radial-gradient(circle at 50% 35%, var(--oxblood-hi), var(--oxblood) 60%, var(--oxblood-deep));
  color: var(--bone);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(242, 239, 232, .14) inset, 0 12px 40px rgba(121, 60, 56, .55);
  transition: transform .15s;
}
.mic:active { transform: scale(.96); }
.mic svg { width: 28px; height: 28px; }
.mic-ring {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 1px solid rgba(164, 84, 78, .5);
  transform: scale(calc(1 + var(--level) * .45));
  opacity: calc(.35 + var(--level));
  transition: transform .08s linear;
}
.mic.rec { background: radial-gradient(circle at 50% 35%, #E06A5F, var(--danger) 60%, #8E3029); }
.mic.rec .mic-ring { border-color: rgba(210, 87, 76, .8); }

.typebar {
  position: absolute;
  inset-inline: 14px;
  bottom: calc(18px + var(--safe-b));
  z-index: 4;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(20px);
  max-width: 640px;
  margin-inline: auto;
  animation: up .25s ease-out;
}
.typebar[hidden] { display: none; }
.typebar textarea {
  flex: 1;
  resize: none;
  max-height: 130px;
  border: 0;
  background: transparent;
  padding: 9px 12px;
  line-height: 1.7;
  outline: none;
  color: var(--bone);
}
.typebar textarea::placeholder { color: var(--ink); }
.send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 0;
  background: var(--oxblood);
  color: var(--bone);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.send svg { transform: scaleX(-1); }
#app.typing .dock { opacity: 0; pointer-events: none; }

.cards {
  position: absolute;
  inset-inline: 14px;
  bottom: calc(134px + var(--cap-h, 0px) + var(--safe-b));
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 520px;
  margin-inline: auto;
}

.card {
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(22px);
  padding: 14px 16px;
  font-size: 13.5px;
  animation: up .35s ease-out;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.card .kicker { font-family: "JetBrains Mono", monospace; font-size: 10.5px; letter-spacing: .16em; color: var(--oxblood-hi); margin-bottom: 8px; }
.card dl { margin: 0 0 10px; display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; color: var(--stone); }
.card dt { color: var(--ink); }
.card dd { margin: 0; direction: ltr; text-align: right; overflow-wrap: anywhere; }
.card .body { text-align: start; white-space: pre-wrap; line-height: 1.75; background: rgba(0, 0, 0, .22); border-radius: 14px; padding: 9px 12px; max-height: 120px; overflow: auto; color: var(--bone); }
.card .row { display: flex; gap: 8px; margin-top: 12px; }
.card .state-line { margin-top: 10px; color: var(--stone); font-size: 12.5px; }

.cta {
  border: 0;
  border-radius: 999px;
  padding: 14px 26px;
  background: var(--oxblood);
  color: var(--bone);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 34px rgba(121, 60, 56, .5);
}
.cta:disabled { opacity: .5; }
.ghost {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  padding: 11px 20px;
  color: var(--stone);
  cursor: pointer;
}

.login {
  position: absolute;
  inset-inline: 0;
  bottom: calc(40px + var(--safe-b));
  z-index: 4;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
}
.login form { display: flex; gap: 8px; }
.login form[hidden] { display: none; }
.login input {
  width: 200px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(16px);
  padding: 13px 18px;
  font-family: "JetBrains Mono", monospace;
  font-size: 20px;
  letter-spacing: .4em;
  text-align: center;
  color: var(--bone);
  outline: none;
}
.hint { margin: 0; font-size: 13px; color: var(--ink); min-height: 1.4em; }

#app[data-view="login"] .login { display: flex; }
#app[data-view="login"] .dock,
#app[data-view="login"] .cards,
#app[data-view="loading"] .dock { display: none; }
#app[data-view="login"] .captions { bottom: calc(170px + var(--safe-b)); }

.sheet {
  position: absolute;
  inset: 0;
  z-index: 6;
  background: rgba(8, 8, 7, .45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet[hidden] { display: none; }
.panel {
  width: min(640px, 100%);
  max-height: 78dvh;
  display: flex;
  flex-direction: column;
  border-radius: 28px 28px 0 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: rgba(22, 23, 21, .9);
  backdrop-filter: blur(28px);
  padding: 14px 16px calc(18px + var(--safe-b));
  animation: up .3s ease-out;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--glass-hi); }
.tab { border: 0; background: transparent; padding: 7px 16px; border-radius: 999px; color: var(--stone); cursor: pointer; }
.tab.on { background: var(--oxblood); color: var(--bone); }
.tab-body { overflow-y: auto; min-height: 0; }
.tab-body[hidden] { display: none; }
.tab-body pre {
  font-family: inherit;
  white-space: pre-wrap;
  line-height: 1.9;
  background: var(--glass-hi);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px 14px;
  margin: 0 0 10px;
  color: var(--stone);
}

.log { display: flex; flex-direction: column; gap: 8px; padding-bottom: 6px; }
.msg { max-width: 84%; padding: 9px 14px; border-radius: 18px; line-height: 1.8; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.msg.me { align-self: flex-end; background: var(--oxblood); border-end-end-radius: 6px; }
.msg.vash { align-self: flex-start; background: var(--glass-hi); border: 1px solid var(--line); border-end-start-radius: 6px; }
.msg.note { align-self: center; color: var(--ink); font-size: 12.5px; }
.msg.alert { align-self: center; color: #F0B3AC; background: rgba(210, 87, 76, .12); border: 1px solid rgba(210, 87, 76, .3); }
.msg .tier { display: block; font-family: "JetBrains Mono", monospace; font-size: 10px; letter-spacing: .12em; color: var(--ink); margin-top: 3px; }
.log .card { animation: none; box-shadow: none; background: var(--glass-hi); }

.banner {
  position: absolute;
  top: calc(56px + var(--safe-t));
  inset-inline: 14px;
  z-index: 5;
  max-width: 560px;
  margin-inline: auto;
  padding: 12px 16px;
  border-radius: 18px;
  border: 1px solid rgba(210, 87, 76, .45);
  background: rgba(60, 22, 20, .72);
  backdrop-filter: blur(18px);
  color: #F6CFCA;
  font-size: 13.5px;
  overflow: hidden;
  animation: up .3s ease-out;
}
.banner[hidden] { display: none; }
.banner::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .12), transparent);
  transform: translateX(-100%);
  animation: scan 2.2s ease-in-out infinite;
}
@keyframes scan { to { transform: translateX(100%); } }
@keyframes up { from { opacity: 0; transform: translateY(12px); } }

@media (min-width: 900px) {
  .captions { bottom: calc(150px + var(--safe-b)); }
  .cards { inset-inline-start: auto; inset-inline-end: 28px; bottom: 140px; width: 400px; margin: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
