:root {
  --text: #f4f6ff;
  --muted: rgba(226, 231, 255, 0.62);
  --faint: rgba(226, 231, 255, 0.38);
  --line: rgba(255, 255, 255, 0.11);
  --glass: rgba(8, 10, 26, 0.66);
  --glass-strong: rgba(6, 8, 20, 0.78);
  --ok: #2ee59d;
  --warn: #ffb547;
  --bad: #ff5c7a;
  --accent: #6aa8ff;
  --accent2: #9b30ff;
  --radius: 20px;
  color-scheme: dark;
}
body.theme-main { --accent: #3d8bff; --accent2: #9b30ff; background: #070b22; }
body.theme-hanko { --accent: #00b4ff; --accent2: #0066ff; background: #050a14; }
body.theme-magno { --accent: #c77dff; --accent2: #9b30ff; background: #0a0a0a; }
body.theme-pitx { --accent: #4a95ff; --accent2: #2e79f9; background: #03060d; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--text);
  font: 15px/1.5 "Inter", system-ui, -apple-system, Segoe UI, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, .display { font-family: "Sora", "Inter", sans-serif; letter-spacing: -0.02em; margin: 0; }
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }

/* animated background */
.shader-layer { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.shader-layer canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.shader-layer.no-webgl { background: radial-gradient(120% 90% at 10% 100%, var(--accent2), transparent 60%), radial-gradient(90% 80% at 100% 0%, var(--accent), transparent 55%); opacity: 0.55; }
.shader-layer::after { /* keeps text legible over the bright bands */
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(3, 5, 16, 0.35), rgba(3, 5, 16, 0.15) 40%, rgba(3, 5, 16, 0.45));
}

.wrap { position: relative; z-index: 1; max-width: 1260px; margin: 0 auto; padding: 22px 16px 72px; }
@media (min-width: 720px) { .wrap { padding: 28px 28px 80px; } }

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  /* no backdrop-filter on purpose: re-blurring every panel on every frame of
     the animated background is expensive on laptops; the waves are soft anyway */
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* top bar */
.topbar { display: flex; align-items: center; gap: 14px; justify-content: space-between; margin-bottom: 26px; flex-wrap: wrap; }
.brandmark { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brandmark .logo-dot { width: 38px; height: 38px; border-radius: 12px; background: linear-gradient(135deg, var(--accent), var(--accent2)); display: grid; place-items: center; font: 700 15px "Sora"; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); }
img.logo-dot { object-fit: cover; }
.brandmark b { display: block; font: 700 17px "Sora"; }
.brandmark small { color: var(--muted); font-size: 12.5px; }
.topbar .right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 12px; padding: 10px 16px; font-weight: 600; font-size: 14px; cursor: pointer; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); text-decoration: none; transition: transform 0.12s ease, background 0.2s ease, border-color 0.2s ease; white-space: nowrap; }
.btn:hover { background: rgba(255, 255, 255, 0.11); border-color: rgba(255, 255, 255, 0.2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { border: 0; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35); }
.btn-primary:hover { filter: brightness(1.08); background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.btn-danger { color: #ffd0d9; border-color: rgba(255, 92, 122, 0.35); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }

/* status pill */
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line); white-space: nowrap; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.pill.ok .dot { background: var(--ok); box-shadow: 0 0 0 4px rgba(46, 229, 157, 0.18); }
.pill.warn .dot { background: var(--warn); box-shadow: 0 0 0 4px rgba(255, 181, 71, 0.18); }
.pill.bad .dot { background: var(--bad); box-shadow: 0 0 0 4px rgba(255, 92, 122, 0.18); }
.pill.live .dot { animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(46, 229, 157, 0); } }

/* on/off switch */
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; background: none; border: 0; padding: 0; }
.switch .track { width: 58px; height: 32px; border-radius: 999px; background: rgba(255, 255, 255, 0.13); border: 1px solid var(--line); position: relative; transition: background 0.25s; flex: none; }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4); transition: transform 0.25s; }
.switch[aria-checked="true"] .track { background: linear-gradient(135deg, #20c98a, #2ee59d); border-color: transparent; }
.switch[aria-checked="true"] .knob { transform: translateX(26px); }
.switch .lbl { font-weight: 700; font-size: 14px; text-align: left; }
.switch .lbl small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.switch:disabled { opacity: 0.55; cursor: wait; }

/* key/value tiles */
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.kv > div { background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; min-width: 0; }
.kv label { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); margin-bottom: 4px; }
.kv b { font: 600 17px "Sora"; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv b.small { font-size: 14px; }
@media (min-width: 560px) { .kv.four { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.section-title { font: 600 13px "Inter"; text-transform: uppercase; letter-spacing: 0.1em; color: var(--faint); margin: 0 0 12px; }

/* status chips for revisions */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
.chip.queued, .chip.working { background: rgba(106, 168, 255, 0.16); color: #bcd6ff; }
.chip.needs_info { background: rgba(255, 181, 71, 0.16); color: #ffd79c; }
.chip.testing { background: rgba(199, 125, 255, 0.18); color: #e6c8ff; }
.chip.live { background: rgba(46, 229, 157, 0.16); color: #9ff2cc; }
.chip.failed { background: rgba(255, 92, 122, 0.16); color: #ffb3c1; }
.chip.blocked { background: rgba(255, 181, 71, 0.16); color: #ffd79c; }
.chip.closed, .chip.discarded { color: var(--muted); }
.spin { width: 11px; height: 11px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* toast */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--glass-strong); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 14px; padding: 12px 14px; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45); animation: rise 0.25s ease; font-size: 14px; }
.toast.ok { border-left-color: var(--ok); }
.toast.bad { border-left-color: var(--bad); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* ---------- main dashboard ---------- */
.hero { display: grid; gap: 18px; align-items: center; grid-template-columns: 1fr; margin-bottom: 26px; padding: 26px; overflow: hidden; position: relative; }
.hero h1 { font-size: clamp(30px, 5vw, 50px); line-height: 1.05; }
.hero h1 span { background: linear-gradient(90deg, #4aa3ff, #b56bff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.theme-pitx .hero h1 span { background-image: linear-gradient(90deg, #8fc1ff, #2e79f9); }
.hero p { color: var(--muted); max-width: 520px; margin: 12px 0 0; }
.hero .stats { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.hero .duo { display: flex; justify-content: center; align-items: flex-end; gap: 0; min-height: 230px; }
.hero .duo img { height: 250px; width: auto; filter: drop-shadow(0 22px 30px rgba(0, 0, 0, 0.55)); animation: bob 5s ease-in-out infinite; }
.hero .duo img + img { margin-left: -14px; animation-delay: -2.5s; }
.hero .duo img.pitx { height: 150px; align-self: center; margin-left: 18px; } /* the X mark is wide, not a tall mascot */
@keyframes bob { 50% { transform: translateY(-8px); } }
@media (min-width: 900px) { .hero { grid-template-columns: 1.15fr 1fr; padding: 34px 40px; } .hero .duo img { height: 300px; } }

.bots { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 980px) { .bots { grid-template-columns: 1fr 1fr; } }
/* one-bot view (PITX): the card takes the full row, its four numbers side by side */
@media (min-width: 980px) { .bots.solo { grid-template-columns: 1fr; } .bots.solo .kv { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.botcard { padding: 22px; position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 16px; }
.botcard::before { content: ""; position: absolute; inset: -40% -20% auto auto; width: 70%; height: 90%; background: radial-gradient(closest-side, var(--glow), transparent); opacity: 0.35; pointer-events: none; }
.botcard.hanko { --glow: #0066ff; --accent: #00b4ff; --accent2: #0066ff; }
.botcard.magno { --glow: #9b30ff; --accent: #c77dff; --accent2: #9b30ff; }
.botcard.pitx { --glow: #2e79f9; --accent: #4a95ff; --accent2: #2e79f9; }
.botcard.pitx .head .mascot, .status-hero .mascot.pitx { object-position: center; }
.botcard .head { display: flex; gap: 16px; align-items: center; position: relative; }
.botcard .head .mascot { width: 92px; height: 120px; object-fit: contain; object-position: bottom; flex: none; filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.5)); }
.botcard .head .logo { height: 30px; width: auto; display: block; margin-bottom: 8px; }
.botcard .head .meta { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.botcard .controls { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; position: relative; }
.lastrev { background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); border-radius: 14px; padding: 14px; position: relative; }
.lastrev .t { font-weight: 600; margin: 4px 0; overflow-wrap: anywhere; }
.lastrev .m { font-size: 12.5px; color: var(--muted); }
.waiting { display: flex; align-items: center; gap: 10px; font-size: 13.5px; padding: 10px 14px; border-radius: 12px; background: rgba(199, 125, 255, 0.12); border: 1px solid rgba(199, 125, 255, 0.3); }

.feed { margin-top: 22px; padding: 22px; }
.feed ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.feed li { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: start; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.feed li:first-child { border-top: 0; }
.feed .ic { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; font-size: 13px; background: rgba(255, 255, 255, 0.07); }
.feed .when { color: var(--faint); font-size: 12px; white-space: nowrap; }
.feed .txt { overflow-wrap: anywhere; }

/* ---------- bot workspace ---------- */
.botbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.botbar .logo { height: 34px; width: auto; }
.status-hero { display: grid; gap: 20px; padding: 22px; margin-bottom: 20px; grid-template-columns: 1fr; align-items: center; position: relative; overflow: hidden; }
.status-hero .mascot { height: 210px; width: auto; justify-self: center; filter: drop-shadow(0 18px 26px rgba(0, 0, 0, 0.55)); animation: bob 5s ease-in-out infinite; }
.status-hero .side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.status-hero .row { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
@media (min-width: 860px) { .status-hero { grid-template-columns: 200px 1fr; padding: 24px 30px; } .status-hero .mascot { height: 230px; } }

.banner { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 16px 20px; margin-bottom: 20px; border-color: rgba(199, 125, 255, 0.35); background: linear-gradient(135deg, rgba(155, 48, 255, 0.22), rgba(0, 102, 255, 0.16)); }
.banner .actions { display: flex; gap: 10px; flex-wrap: wrap; }

.columns { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 1040px) { .columns { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); } }

/* revision chat */
.revchat { display: flex; flex-direction: column; height: 680px; max-height: 82vh; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-head h3 { font-size: 17px; }
.panel-head .sub { font-size: 12.5px; color: var(--muted); }
.thread { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth; }
.msg { display: flex; gap: 10px; max-width: 88%; }
.msg .av { width: 34px; height: 34px; border-radius: 50%; flex: none; overflow: hidden; background: rgba(255, 255, 255, 0.08); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.msg .av img { width: 100%; height: 100%; object-fit: cover; }
.msg .bubble { padding: 10px 14px; border-radius: 16px; background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; }
.msg .who { font-size: 11.5px; color: var(--faint); margin-bottom: 3px; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.user .bubble { background: linear-gradient(135deg, var(--accent2), color-mix(in srgb, var(--accent2) 60%, #000)); border-color: transparent; border-bottom-right-radius: 6px; }
.msg.user .who { text-align: right; }
.msg.engineer .bubble { border-bottom-left-radius: 6px; }
.msg.engineer.testing .bubble, .msg.engineer.live .bubble { border-color: rgba(46, 229, 157, 0.4); background: rgba(46, 229, 157, 0.09); }
.msg.engineer.needs_info .bubble { border-color: rgba(255, 181, 71, 0.45); background: rgba(255, 181, 71, 0.08); }
.msg.engineer.blocked .bubble { border-color: rgba(255, 181, 71, 0.45); background: rgba(255, 181, 71, 0.08); }
.msg.engineer.failed .bubble { border-color: rgba(255, 92, 122, 0.45); background: rgba(255, 92, 122, 0.08); }
.msg .bubble img { display: block; max-width: 240px; border-radius: 10px; margin-top: 8px; }
.sysline { align-self: center; display: inline-flex; gap: 8px; align-items: center; font-size: 13px; color: #cfe0ff; padding: 7px 14px; border-radius: 999px; background: rgba(106, 168, 255, 0.12); border: 1px solid rgba(106, 168, 255, 0.25); text-align: center; max-width: 92%; }
.empty { margin: auto; text-align: center; color: var(--muted); max-width: 340px; font-size: 14px; }
.empty img { width: 92px; display: block; margin: 0 auto 10px; }

.composer { border-top: 1px solid var(--line); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; background: rgba(0, 0, 0, 0.18); }
.composer .row { display: flex; gap: 10px; align-items: center; }
.field { width: 100%; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; outline: none; transition: border-color 0.2s; }
.field:focus { border-color: var(--accent); }
textarea.field { resize: none; min-height: 72px; max-height: 200px; }
.attach-list { display: flex; gap: 8px; flex-wrap: wrap; }
.attach-list .a { position: relative; }
.attach-list img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.attach-list .a.pdf { display: flex; align-items: center; height: 56px; max-width: 240px; padding: 0 30px 0 12px; border-radius: 8px; border: 1px solid var(--line); font-size: 12.5px; font-weight: 600; }
.attach-list .a.pdf span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filechip { display: inline-flex; align-items: center; margin: 8px 6px 0 0; padding: 7px 11px; border-radius: 8px; border: 1px solid var(--line); font-size: 12.5px; font-weight: 600; color: inherit; text-decoration: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filechip:hover { border-color: currentColor; }
.attach-list button { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: #000; cursor: pointer; font-size: 12px; line-height: 20px; padding: 0; }

/* test chat widget (LiveChat look) */
.tester { display: flex; flex-direction: column; height: 680px; max-height: 82vh; overflow: hidden; }
.tester .whead { padding: 14px 18px; display: flex; align-items: center; gap: 12px; background: linear-gradient(135deg, color-mix(in srgb, var(--accent2) 85%, #000), color-mix(in srgb, var(--accent) 55%, #000)); }
.tester .whead img { width: 42px; height: 42px; border-radius: 50%; background: rgba(0, 0, 0, 0.25); object-fit: cover; }
.tester .whead b { display: block; font-family: "Sora"; }
.tester .whead small { opacity: 0.85; font-size: 12.5px; }
.tester .whead .grow { flex: 1; min-width: 0; }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 9px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted); }
.seg button.on { background: rgba(255, 255, 255, 0.14); color: var(--text); }
.tester .tools { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tester .msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: rgba(0, 0, 0, 0.12); }
.bmsg { max-width: 86%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; }
.bmsg.bot { background: rgba(255, 255, 255, 0.09); border-bottom-left-radius: 6px; align-self: flex-start; }
.bmsg.me { background: linear-gradient(135deg, var(--accent2), color-mix(in srgb, var(--accent2) 65%, #000)); border-bottom-right-radius: 6px; align-self: flex-end; }
.bmsg.img { padding: 4px; background: rgba(255, 255, 255, 0.09); }
.bmsg.img img { display: block; max-width: 100%; max-height: 300px; border-radius: 12px; }
.bmsg.sys { align-self: center; font-size: 12.5px; color: #ffe0a8; background: rgba(255, 181, 71, 0.1); border: 1px dashed rgba(255, 181, 71, 0.35); text-align: center; }
.typing { align-self: flex-start; display: inline-flex; gap: 4px; padding: 12px 14px; border-radius: 16px; background: rgba(255, 255, 255, 0.09); }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 50% { opacity: 0.25; transform: translateY(-2px); } }
.tester form { display: flex; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); }

.history { margin-top: 20px; padding: 20px 22px; }
.history table { width: 100%; border-collapse: collapse; font-size: 14px; }
.history td { padding: 10px 8px; border-top: 1px solid var(--line); vertical-align: top; }
.history tr:first-child td { border-top: 0; }
.history td.v { font: 600 14px "Sora"; white-space: nowrap; }
.history td.w { color: var(--faint); font-size: 12.5px; white-space: nowrap; }
@media (max-width: 640px) { .history td.w, .history td.n { display: none; } }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; position: relative; z-index: 1; }
.login .card { width: min(420px, 100%); padding: 30px; text-align: center; }
.login .duo { display: flex; justify-content: center; margin: -6px 0 6px; }
.login .duo img { height: 150px; width: auto; filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.5)); }
.login .duo img + img { margin-left: -10px; }
.login .duo img.pitx { height: 104px; margin: 18px 0 10px; } /* the X mark is wide, not a tall mascot */
.login h1 { font-size: 26px; margin: 8px 0 6px; }
.login form { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.login .err { color: #ffb3c1; font-size: 13.5px; min-height: 20px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
