/* ============================================================
   TB-S3qr — style.css
   Token system:
   Color   #0a0d0e graphite bg · #12181a panel · #1c2427 raised
           #e8a33d amber (accent/live) · #b97a26 amber-dim
           #6b7c85 cold steel (secondary text) · #e2e6e7 hi text
           #e85d5d danger · #4dd9c0 ok
   Type    display/code: system monospace stack (no external calls —
           deliberate, this is a security tool, it shouldn't phone
           out to a font CDN before you've even connected).
           body/UI: system sans stack.
   Layout  a single "console" faceplate is the signature element —
           two etched slots (TU / EI) joined by a hairline dash,
           echoing the XXX–YYY pairing that is the whole product.
   ============================================================ */

:root {
  --bg: #0a0d0e;
  --panel: #12181a;
  --raised: #1c2427;
  --line: #263033;
  --amber: #e8a33d;
  --amber-dim: #8a6425;
  --amber-ink: #e8a33d;
  --steel: #7c8a92;
  --hi: #eef1f1;
  --danger: #e8615d;
  --ok: #49d3ba;

  /* consola centrală TU/EI rămâne mereu "hardware întunecat", indiferent de temă —
     e un afișaj fizic, nu o pagină, așa că nu urmează light mode. */
  --console-bg1: #12181a;
  --console-bg2: #0d1213;
  --console-slot-bg: #0a0e0f;
  --console-line: #263033;
  --console-label: #7c8a92;
  --console-amber: #e8a33d;
  --console-amber-dim: #8a6425;

  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

:root[data-theme="light"] {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --raised: #eef0ee;
  --line: #e1e4e2;
  --amber: #e0941f;
  --amber-dim: #e3b165;
  --amber-ink: #a8660a;
  --steel: #707b80;
  --hi: #15191a;
  --danger: #cf4038;
  --ok: #0f8f6c;
}

html { transition: background-color .25s ease; }
body, .panel, button, input { transition: background-color .2s ease, color .2s ease, border-color .2s ease; }

* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--hi);
  font-family: var(--sans);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
body {
  background-image:
    radial-gradient(ellipse at 50% -10%, rgba(232,163,61,0.07), transparent 55%),
    repeating-linear-gradient(180deg, rgba(255,255,255,0.012) 0px, rgba(255,255,255,0.012) 1px, transparent 1px, transparent 3px);
}
.mono { font-family: var(--mono); letter-spacing: 0.04em; }
.hidden { display: none !important; }

/* ---------- shell / safe area ---------- */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-t);
  padding-bottom: var(--safe-b);
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
  position: sticky; top: 0; z-index: 5;
  backdrop-filter: blur(10px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
}
.brand { font-family: var(--mono); font-size: 15px; letter-spacing: 0.08em; color: var(--steel); }
.brand-mark { color: var(--hi); font-weight: 600; }
.brand-mark.accent { color: var(--amber-ink); }
.brand-dash { color: var(--amber-dim); }

/* ---------- topbar chips (lang / theme / install) ---------- */
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.chip {
  background: var(--raised); color: var(--hi); border: 1px solid var(--line);
  border-radius: 20px; padding: 7px 13px; font-size: 12px; font-weight: 700;
  letter-spacing: 0.03em; display: flex; align-items: center; gap: 6px;
}
.chip.icon-only { width: 32px; height: 32px; padding: 0; border-radius: 50%; justify-content: center; }
.chip:active { transform: scale(0.94); }
.icon-sun, .icon-moon { display: block; }
:root:not([data-theme="light"]) .icon-sun { display: none; }
:root[data-theme="light"] .icon-moon { display: none; }

/* ---------- generic buttons ---------- */
button { font-family: var(--sans); cursor: pointer; border: none; -webkit-appearance: none; }
.btn-primary, .btn-accent, .btn-ghost {
  border-radius: 10px;
  padding: 13px 18px;
  font-size: 15px;
  font-weight: 600;
  transition: transform .08s ease, opacity .15s ease;
}
.btn-primary:active, .btn-accent:active, .btn-ghost:active { transform: scale(0.97); }
.btn-primary { background: var(--raised); color: var(--hi); border: 1px solid var(--line); }
.btn-accent { background: var(--amber); color: #1a1204; box-shadow: 0 6px 16px rgba(232,163,61,0.22); }
.btn-accent:disabled { background: var(--raised); color: var(--steel); }
.btn-ghost { background: transparent; color: var(--steel); border: 1px solid var(--line); }
.btn-ghost.small { padding: 8px 12px; font-size: 13px; }
.btn-danger { background: var(--danger); color: #2a0a09; }
.wide { width: 100%; }

.btn-stop {
  flex-shrink: 0;
  background: rgba(232,97,93,0.12);
  color: var(--danger);
  border: 1px solid rgba(232,97,93,0.4);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  transition: background .15s ease, transform .08s ease;
}
.btn-stop:active { transform: scale(0.95); background: rgba(232,97,93,0.28); }

/* ---------- screens ---------- */
.screens { flex: 1; display: flex; flex-direction: column; position: relative; }
.screen {
  display: none; flex: 1; flex-direction: column; padding: 8px 20px 24px;
  animation: screenIn .32s cubic-bezier(.22,.9,.34,1);
}
.screen.active { display: flex; }
@keyframes screenIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- incoming request banner ---------- */
.incoming-banner {
  background: var(--raised);
  border: 1px solid var(--amber-dim);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 18px;
  animation: bannerIn .35s cubic-bezier(.22,.9,.34,1);
}
@keyframes bannerIn {
  from { opacity: 0; transform: translateY(-14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.incoming-banner p { margin: 0 0 10px; font-size: 14px; color: var(--hi); }
.incoming-banner .row { display: flex; gap: 10px; }
.incoming-banner .row button { flex: 1; }

/* ---------- CONSOLE (signature element) ---------- */
.console-panel {
  margin: auto auto 26px;
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg, var(--console-bg1), var(--console-bg2));
  border: 1px solid var(--console-line);
  border-radius: 20px;
  padding: 26px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03), inset 0 -18px 30px rgba(0,0,0,0.35), 0 20px 40px rgba(0,0,0,0.35);
}
.console-slot {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: var(--console-slot-bg);
  border: 1px solid var(--console-line);
  border-radius: 14px;
  padding: 16px 8px;
}
.slot-label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.2em; color: var(--console-label); }
.slot-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--console-label);
  letter-spacing: 0.14em;
  transition: color .3s;
}
.console-panel.revealed .slot-value { color: var(--console-amber); text-shadow: 0 0 18px rgba(232,163,61,0.35); }
.slot-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--console-amber);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-align: center;
  font-family: var(--mono);
}
.slot-input::placeholder { color: var(--console-line); }
.console-divider { color: var(--console-amber-dim); font-size: 22px; font-family: var(--mono); }

.actions-col { display: flex; flex-direction: column; gap: 10px; max-width: 380px; width: 100%; margin: 0 auto; }
.hint { text-align: center; color: var(--steel); font-size: 12.5px; line-height: 1.5; max-width: 340px; margin: 22px auto 0; }

.install-cta { max-width: 380px; margin: 16px auto 0; }

/* ---------- waiting screen ---------- */
.waiting-box { margin: auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.spinner {
  width: 46px; height: 46px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--amber);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.waiting-box p { color: var(--hi); font-size: 15px; }
.accent { color: var(--amber-ink); }

/* ---------- chat screen ---------- */
.chat-screen { padding: 8px 0 0; }
.chat-header {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 16px 12px;
  border-bottom: 1px solid var(--line);
}
.chat-ids { font-size: 15px; color: var(--hi); display: flex; align-items: center; gap: 8px; }
.chat-ids .dash { color: var(--amber-ink); margin: 0 4px; }
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(73,211,186,0.5);
  animation: livePulse 2s infinite;
}
@keyframes livePulse {
  0%   { box-shadow: 0 0 0 0 rgba(73,211,186,0.5); }
  70%  { box-shadow: 0 0 0 6px rgba(73,211,186,0); }
  100% { box-shadow: 0 0 0 0 rgba(73,211,186,0); }
}
.timer-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
#timer { font-family: var(--mono); font-size: 16px; color: var(--ok); }
#timer.warn { color: var(--amber-ink); }
#timer.danger { color: var(--danger); }
.timer-track { width: 100%; max-width: 160px; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.timer-bar { height: 100%; width: 100%; background: var(--ok); transition: width 1s linear, background .4s; }
#timer.warn ~ .timer-track .timer-bar, .timer-wrap:has(#timer.warn) .timer-bar { background: var(--amber); }
.timer-wrap:has(#timer.danger) .timer-bar { background: var(--danger); }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}
.msg {
  max-width: 78%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.4;
  word-break: break-word;
  white-space: pre-wrap;
  animation: msgIn .28s cubic-bezier(.22,.9,.34,1);
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.msg.theirs { align-self: flex-start; background: var(--raised); color: var(--hi); border-bottom-left-radius: 4px; }
.msg.mine { align-self: flex-end; background: var(--amber); color: #1a1204; border-bottom-right-radius: 4px; }
.msg.broken { opacity: 0.5; font-style: italic; }
.msg-image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 260px;
  border-radius: 10px;
  cursor: zoom-in;
}
/* Pe ecrane late (desktop), bula de mesaj se poate întinde mult;
   plafonăm explicit thumbnail-ul ca să rămână "poză de chat", nu fullscreen. */
@media (min-width: 560px) {
  .msg-image { max-width: 260px; }
}
.msg audio { max-width: 220px; }

.record-indicator {
  text-align: center;
  color: var(--danger);
  font-size: 12.5px;
  padding: 6px 0;
  animation: pulse 1s infinite;
}

.composer {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px calc(10px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.icon-btn {
  background: var(--raised); color: var(--hi);
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex-shrink: 0;
}
.icon-btn.send { background: var(--amber); color: #1a1204; }
.icon-btn.recording { background: var(--danger); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.6; } }
.text-input {
  flex: 1; background: var(--raised); border: 1px solid var(--line);
  border-radius: 20px; padding: 10px 16px; color: var(--hi); font-size: 15px; outline: none;
}

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,0.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 20px;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 24px; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; max-width: 340px; }
.modal-box h3 { margin: 0 0 10px; }
.modal-box p { color: var(--steel); font-size: 14px; line-height: 1.5; }
.modal-box .row { display: flex; gap: 10px; margin-top: 16px; }
.modal-box { position: relative; }
.modal { animation: fadeIn .2s ease; backdrop-filter: blur(3px); }
.modal-box { animation: modalIn .28s cubic-bezier(.22,.9,.34,1); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-x {
  position: absolute; top: 14px; right: 14px;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--raised); border: 1px solid var(--line); color: var(--steel);
  display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.modal-x:active { transform: scale(0.9); }

/* ---------- image popup ---------- */
.drop-zone {
  border: 1.5px dashed var(--line);
  border-radius: 14px;
  padding: 30px 14px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  color: var(--steel);
  margin-top: 6px;
}
.drop-zone svg { opacity: 0.7; }
.drop-zone span { font-size: 13.5px; font-weight: 600; }
.drop-zone:active { border-color: var(--amber-dim); color: var(--amber-ink); }
.image-preview { width: 100%; max-height: 220px; object-fit: cover; border-radius: 12px; margin-top: 12px; }

/* ---------- audio popup ---------- */
.audio-record-area { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 18px 0 6px; }
.record-orb {
  width: 74px; height: 74px; border-radius: 50%;
  background: var(--raised); border: 2px solid var(--line); color: var(--hi);
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, border-color .2s, transform .15s;
}
.record-orb:active { transform: scale(0.94); }
.record-orb.recording {
  background: var(--danger); border-color: var(--danger); color: #fff;
  animation: orbPulse 1.2s infinite;
}
@keyframes orbPulse {
  0%   { box-shadow: 0 0 0 0 rgba(232,97,93,0.45); }
  70%  { box-shadow: 0 0 0 18px rgba(232,97,93,0); }
  100% { box-shadow: 0 0 0 0 rgba(232,97,93,0); }
}
.audio-timer { font-size: 16px; color: var(--hi); }
.audio-hint { font-size: 12.5px; color: var(--steel); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; top: calc(var(--safe-t) + 14px);
  transform: translate(-50%, -140%);
  background: var(--raised); color: var(--hi);
  border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 10px; font-size: 13.5px;
  z-index: 80; transition: transform .25s ease; max-width: 86vw; text-align: center;
}
.toast.show { transform: translate(-50%, 0); }
.toast.error { border-color: var(--danger); color: #ffd7d5; }

/* ---------- misc ---------- */
@media (min-width: 560px) {
  .screen { padding-left: 40px; padding-right: 40px; }
}
