/* Cyber-Kitsune: same look and flow as the original Streamlit app, as a real web page. No inline styles (CSP). */
:root {
  --bg: #0A0807; --black: #000; --side: #050403; --card: #030202; --msg: #050403;
  --ember: #FF7A00; --ember-rgb: 255, 122, 0; --accent: var(--ember); --accent-rgb: var(--ember-rgb);
  --text: #E4E4E7; --strong: #fff; --muted: #A1A1AA; --danger: #FF0033; --ok: #00FF66;
  --line: rgba(var(--accent-rgb), .4); --line-soft: rgba(var(--accent-rgb), .15); --line-faint: rgba(var(--accent-rgb), .1);
  --font: 'Inter', -apple-system, 'Segoe UI', system-ui, sans-serif;
  --ease: cubic-bezier(.16, 1, .3, 1); --status: var(--ember); --status-rgb: 255, 122, 0;
}
body.theme-a { --accent: #FF1493; --accent-rgb: 255, 20, 147; }
body.theme-b { --accent: #8A2BE2; --accent-rgb: 138, 43, 226; }
body.theme-admin { --accent: #FF3344; --accent-rgb: 255, 51, 68; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 1rem; line-height: 1.6; -webkit-font-smoothing: antialiased; min-height: 100vh; }
h1, h2, h3, h4 { color: var(--strong); font-weight: 300; letter-spacing: -.02em; margin: 0 0 .6rem; line-height: 1.2; }
h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); } h2 { font-size: 1.7rem; } h3 { font-size: 1.3rem; } h4 { font-size: 1.05rem; font-weight: 400; }
p { margin: 0 0 1em; }
a { color: var(--strong); text-decoration-color: var(--accent); text-underline-offset: 3px; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.hide { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: fixed; left: 12px; top: -60px; z-index: 200; background: var(--accent); color: #000; padding: .6rem 1rem; border-radius: 4px; transition: top .2s; }
.skip:focus { top: 12px; }
.muted { color: var(--muted); } .accent { color: var(--accent); }
hr { border: 0; border-top: 1px solid var(--line-soft); margin: 1.5rem 0; }
.noscript { padding: 2rem; text-align: center; }

/* atmosphere (rotating glow + rising ashes) */
.atmosphere { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.glow { position: absolute; left: -50%; top: -50%; width: 200%; height: 200%; background: radial-gradient(circle at 50% 50%, rgba(var(--accent-rgb), .08), transparent 60%); animation: rotateGlow 30s linear infinite; }
.ashes { position: absolute; inset: 0; opacity: .4; background-image: radial-gradient(circle at 15% 50%, rgba(var(--accent-rgb), .8) 1px, transparent 2px), radial-gradient(circle at 85% 30%, rgba(var(--accent-rgb), .5) 1.5px, transparent 2px); background-size: 113px 131px, 89px 97px; animation: risingAshes 24s linear infinite; }
@keyframes rotateGlow { to { transform: rotate(360deg); } }
@keyframes risingAshes { 0% { transform: translate(0, 0); } 50% { transform: translate(15px, -25%); } 100% { transform: translate(0, -50%); } }

/* gate */
.gate { position: relative; z-index: 5; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; }
.gate-inner { width: 100%; max-width: 440px; text-align: center; animation: fadeIn 1s var(--ease) both; }
.reactor { font-size: 7rem; line-height: 1; display: block; margin-bottom: .6rem; }
.reactor.sleeping { filter: grayscale(80%) drop-shadow(0 0 5px rgba(var(--ember-rgb), .1)); animation: breathe 3s infinite ease-in-out; }
.reactor.waking { animation: bloom 1.5s forwards ease-in-out; }
.reactor.heart { filter: drop-shadow(0 0 20px rgba(255, 20, 147, .8)); animation: heartbeat 1.5s infinite; }
.reactor.devil { filter: drop-shadow(0 0 20px rgba(138, 43, 226, .8)); animation: devil 2s infinite alternate ease-in-out; }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.03); filter: grayscale(50%) drop-shadow(0 0 15px rgba(var(--ember-rgb), .3)); } }
@keyframes bloom { 0% { transform: scale(1); opacity: 0; } 15% { opacity: 1; } 100% { transform: scale(1.15); filter: drop-shadow(0 0 60px rgba(var(--ember-rgb), 1)); opacity: 1; } }
@keyframes heartbeat { 0%, 30%, 100% { transform: scale(1); } 15%, 45% { transform: scale(1.15); } }
@keyframes devil { 0% { transform: scale(1); } 100% { transform: scale(1.1); filter: drop-shadow(0 0 35px rgba(220, 20, 60, .9)); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fadeIn 1s var(--ease) both; }
.gate h2 { font-size: 1.9rem; margin-bottom: 1rem; }
.glow-red { color: #FF2222; font-weight: 700; letter-spacing: 1px; text-shadow: 0 0 10px rgba(255, 0, 0, .6); animation: pulseText 1s infinite alternate; }
.glow-green { color: var(--ok); font-weight: 600; text-shadow: 0 0 10px rgba(0, 255, 0, .6); animation: pulseText 1s infinite alternate; }
.glow-accent { color: var(--accent); text-shadow: 0 0 12px rgba(var(--accent-rgb), .6); }
@keyframes pulseText { from { opacity: .75; } to { opacity: 1; } }
.gate form { display: flex; flex-direction: column; gap: .75rem; margin-top: 1rem; }
.gate-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.gate .err { min-height: 1.4em; }
.gate details { margin-top: 1.5rem; text-align: left; }
.gate summary { cursor: pointer; color: var(--muted); min-height: 44px; display: flex; align-items: center; }

/* controls */
.field, .textarea { width: 100%; min-height: 44px; background: var(--black); color: var(--text); border: 1px solid rgba(var(--accent-rgb), .3); border-radius: 6px; padding: .65rem .9rem; transition: border-color .2s, box-shadow .2s; }
.textarea { resize: vertical; line-height: 1.5; }
.field:hover, .textarea:hover { border-color: var(--line); }
.field:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 10px rgba(var(--accent-rgb), .25); }
.field::placeholder, .textarea::placeholder { color: #71717A; }
.field.error, .textarea.error { border-color: var(--danger); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 44px; padding: .55rem 1rem; background: var(--side); color: var(--strong); border: 1px solid #3F2314; border-radius: 4px; font-weight: 500; cursor: pointer; transition: border-color .2s, color .2s, box-shadow .2s, transform .1s; text-decoration: none; width: 100%; text-align: center; }
.btn:hover { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 10px rgba(var(--accent-rgb), .2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0A0807; }
.btn.primary:hover { filter: brightness(1.1); color: #0A0807; }
.btn.auto { width: auto; }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.err { color: var(--danger); font-size: .92rem; margin: .4rem 0 0; min-height: 1.3em; }
.ok { color: #22C55E; }

/* shell */
.app { position: relative; z-index: 5; display: flex; min-height: 100vh; }
.sidebar { width: 300px; flex: 0 0 300px; position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--side); border-right: 1px solid rgba(var(--accent-rgb), .2); padding: 1.5rem 1.25rem; animation: slideRight .8s var(--ease) both; }
@keyframes slideRight { from { opacity: 0; transform: translateX(-40px); } to { opacity: 1; transform: none; } }
.sidebar h2 { font-size: 1.6rem; margin-bottom: .2rem; }
.sidebar .caption { color: var(--muted); font-size: .9rem; margin: 0 0 .5rem; }
.sidebar h3 { font-size: 1.1rem; margin: 0 0 .6rem; }
.status { margin: 10px 0 15px; padding: 12px; background: #050200; border-radius: 6px; border: 1px solid rgba(var(--status-rgb), .4); box-shadow: 0 0 15px rgba(var(--status-rgb), .15), inset 0 0 10px rgba(var(--status-rgb), .05); }
.status.root { background: #1A0505; --status-rgb: 255, 0, 0; --status: #FF0000; }
.status.theme-a { background: #1A050D; --status-rgb: 255, 20, 147; --status: #FF1493; }
.status.theme-b { background: #10051A; --status-rgb: 138, 43, 226; --status: #8A2BE2; }
.status-row { display: flex; align-items: center; margin-bottom: 4px; }
.status-text { font-size: .9rem; color: #F8FAFC; font-weight: 600; text-shadow: 0 0 8px rgba(var(--status-rgb), .6); }
.status-sub { font-size: .8rem; color: var(--muted); margin-left: 18px; }
.pulse { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--status); margin-right: 8px; animation: pulseDot 1.8s infinite; }
@keyframes pulseDot { 0% { transform: scale(.95); box-shadow: 0 0 0 0 rgba(var(--status-rgb), .7); } 70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(var(--status-rgb), 0); } 100% { transform: scale(.95); box-shadow: 0 0 0 0 rgba(var(--status-rgb), 0); } }
.badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badge { background: var(--side); border: 1px solid #3F2314; padding: 4px 10px; border-radius: 4px; font-size: .78rem; font-weight: 500; }
.socials { display: flex; gap: 10px; }
.social { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 48px; color: var(--muted); background: var(--side); border: 1px solid var(--line-soft); border-radius: 6px; transition: all .3s; }
.social svg { width: 24px; height: 24px; fill: currentColor; }
.social:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 0 10px rgba(var(--accent-rgb), .15); }
.sidebar details { border: 1px solid var(--line-soft); border-radius: 6px; padding: 0 .8rem; margin-bottom: .8rem; }
.sidebar summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--text); }
.sidebar details[open] { padding-bottom: .8rem; }
.sidebar details form { display: flex; flex-direction: column; gap: .6rem; }

.block { flex: 1; min-width: 0; max-width: 1050px; margin: 3rem auto 4rem; padding: 3rem; background: var(--black); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 0 30px rgba(0, 0, 0, .9), 0 0 15px rgba(var(--accent-rgb), .05); animation: blockIn 1.2s var(--ease) both; outline: none; }
@keyframes blockIn { from { opacity: 0; transform: translateY(40px); filter: blur(10px); } to { opacity: 1; transform: none; filter: none; } }
.block h1 { margin-bottom: .5rem; }
.meta { margin-bottom: 1rem; }
.meta b { color: var(--strong); font-weight: 600; }
.radar-wrap { max-width: 520px; margin: 0 auto; min-height: 120px; }
.radar-wrap svg { width: 100%; height: auto; overflow: visible; }
.radar-wrap .loading { text-align: center; color: var(--muted); padding: 3rem 0; }
.radar .grid { fill: none; stroke: rgba(255, 255, 255, .06); }
.radar .spoke { stroke: rgba(255, 255, 255, .06); }
.radar .shape { fill: rgba(var(--accent-rgb), .2); stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.radar .dot { fill: var(--accent); }
.projects { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 1.25rem; margin: .75rem 0 1.25rem; }
.projects .loading { color: var(--muted); }
.project { display: flex; flex-direction: column; min-width: 0; background: var(--card); border: 1px solid var(--line-soft); border-radius: 10px; overflow: hidden; transition: border-color .3s, box-shadow .3s, transform .3s var(--ease); }
.project:hover { border-color: var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, .6), 0 0 18px rgba(var(--accent-rgb), .12); transform: translateY(-3px); }
.project-cover { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; background: #111; border-bottom: 1px solid var(--line-soft); }
.project-cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .6s var(--ease); }
.project:hover .project-cover img { transform: scale(1.04); }
.project-cover::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(3, 2, 2, .85)); pointer-events: none; }
.project-lang { position: absolute; left: .8rem; bottom: .7rem; z-index: 1; font-size: .75rem; font-weight: 600; color: var(--strong); background: rgba(0, 0, 0, .55); border: 1px solid var(--line); border-radius: 999px; padding: .15rem .6rem; }
.project-body { display: flex; flex-direction: column; gap: .75rem; padding: 1.2rem 1.3rem 1.3rem; flex: 1; }
.project-role { margin: 0; font-size: .78rem; letter-spacing: .02em; color: var(--accent); }
.project h4 { margin: 0; font-size: 1.2rem; line-height: 1.3; overflow-wrap: anywhere; }
.project h4 a { color: var(--strong); text-decoration: none; }
.project h4 a:hover { color: var(--accent); }
.project p.tagline { margin: 0; color: var(--text); font-size: .92rem; line-height: 1.55; }
.project-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: .5rem; margin: .1rem 0; }
.project-stats div { background: #0A0504; border: 1px solid var(--line-faint); border-radius: 6px; padding: .55rem .6rem; }
.project-stats b { display: block; font-size: 1.35rem; font-weight: 700; color: var(--accent); line-height: 1.1; text-shadow: 0 0 12px rgba(var(--accent-rgb), .35); }
.project-stats span { display: block; font-size: .72rem; color: var(--muted); line-height: 1.3; margin-top: .2rem; }
.project-foot { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding-top: .3rem; }
.project-foot .meta-line { flex: 1 1 100%; font-size: .78rem; color: var(--muted); }
.project-foot .btn { width: auto; flex: 1 1 auto; min-height: 40px; font-size: .88rem; }
.project-foot .btn svg { width: 16px; height: 16px; fill: currentColor; }
.radar text { fill: var(--muted); font-size: 11px; font-family: var(--font); }

/* tabs */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line-soft); overflow-x: auto; margin-bottom: 1.25rem; scrollbar-width: thin; }
.tab { background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: .8rem 1.1rem; min-height: 48px; cursor: pointer; white-space: nowrap; font-weight: 500; transition: color .3s, border-color .3s, text-shadow .3s; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); text-shadow: 0 0 10px rgba(var(--accent-rgb), .5); }

/* chat */
.trails { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.trails .btn { height: 100%; }
.log { height: 500px; overflow-y: auto; border: 1px solid var(--line-soft); border-radius: 8px; padding: 1rem; background: var(--card); display: flex; flex-direction: column; gap: .6rem; scroll-behavior: smooth; }
.log.short { height: 400px; }
.msg { display: flex; gap: .75rem; align-items: flex-start; background: var(--msg); border: 1px solid var(--line-faint); border-radius: 8px; padding: 10px 15px; }
.msg .av { flex: none; font-size: 1.4rem; line-height: 1.5; }
.msg .body { min-width: 0; overflow-wrap: anywhere; }
.msg .body > :last-child { margin-bottom: 0; }
.msg .who { display: block; font-size: .78rem; color: var(--muted); margin-bottom: 2px; }
.body ul, .body ol { margin: 0 0 1em; padding-left: 1.3rem; }
.body h3, .body h4 { font-size: 1.05rem; font-weight: 600; margin: .8rem 0 .3rem; }
.body code { background: #111; padding: .1em .35em; border-radius: 3px; font-size: .9em; }
.body strong { color: var(--strong); }
.typing { display: inline-flex; gap: 4px; padding: .4rem 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: blink 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
.composer { display: flex; gap: .6rem; margin-top: .9rem; }
.composer .field { flex: 1; } .composer .btn { width: auto; }
.empty { text-align: center; color: var(--muted); margin: 150px 0 0; }
.output { border: 1px solid var(--line-soft); border-radius: 8px; padding: 1rem; margin: 1rem 0; background: var(--card); }
.output .body { white-space: pre-wrap; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .6rem; margin: .8rem 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.stat { background: #0A0504; border: 1px solid var(--line-soft); border-radius: 8px; padding: 1rem; }
.stat b { display: block; font-size: 2rem; font-weight: 300; color: var(--strong); line-height: 1.1; }
.stat span { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.pills { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.pill { border: 1px solid #3F2314; border-radius: 999px; padding: .25rem .8rem; font-size: .85rem; background: var(--side); }
.acc { border: 1px solid var(--line-soft); border-radius: 8px; margin-bottom: .6rem; background: var(--card); }
.acc summary { cursor: pointer; padding: .8rem 1rem; min-height: 44px; }
.acc .inner { max-height: 350px; overflow-y: auto; padding: 0 1rem 1rem; }
.logitem { background: #000; border: 1px solid #333; border-radius: 6px; padding: 12px; margin-bottom: 10px; font-size: .88rem; overflow-wrap: anywhere; }
.logitem .t { color: var(--muted); font-size: .75rem; margin-bottom: 6px; }
.logitem b.u { color: var(--accent); }
.cfg { display: grid; gap: 1rem; margin-bottom: 1rem; }
@media (min-width: 800px) { .cfg { grid-template-columns: 1fr 1fr; } .cfg .wide { grid-column: 1 / -1; } }
.cfg label, label.lbl { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .3rem; }
.check { display: flex; align-items: center; gap: .6rem; min-height: 44px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.check label { margin: 0; color: var(--text); }
.brain { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: .85rem; min-height: 360px; }
.divider { margin: 1.5rem 0; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: var(--black); border: 1px solid var(--line); padding: .7rem 1.1rem; border-radius: 6px; opacity: 0; pointer-events: none; transition: all .3s var(--ease); z-index: 95; font-size: .92rem; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* mobile / tablet: sidebar becomes a drawer */
.menu-btn, .scrim { display: none; }
@media (max-width: 900px) {
  .menu-btn { display: flex; align-items: center; justify-content: center; position: fixed; top: 10px; left: 10px; z-index: 60; width: 48px; height: 48px; background: var(--side); border: 1px solid var(--line); border-radius: 8px; color: var(--strong); font-size: 1.4rem; cursor: pointer; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 70; width: min(320px, 86vw); transform: translateX(-105%); transition: transform .3s var(--ease); animation: none; }
  .app.open .sidebar { transform: none; }
  .app.open .scrim { display: block; position: fixed; inset: 0; z-index: 65; background: rgba(0, 0, 0, .6); }
  .block { margin: 66px 12px 2rem; padding: 1.25rem; }
  .log { height: 60vh; min-height: 320px; }
  .reactor { font-size: 5.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .ashes, .glow { animation: none !important; }
}

/* Profile Sync (admin) */
[hidden] { display: none !important; }
.hint { color: var(--muted); font-size: .85rem; margin: .2rem 0 .6rem; }
.drafts { display: grid; gap: 1rem; margin: 1rem 0; }
.draft { border: 1px solid var(--line-soft); border-radius: 8px; padding: .4rem 1rem 1rem; background: var(--card); }
.draft .was { color: var(--muted); font-size: .85rem; margin: 0 0 .5rem; white-space: pre-wrap; overflow-wrap: anywhere; }
pre.preview { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .8rem; margin: 0; }

.gate-note { margin-top: 1rem; font-size: .85rem; }
.sidebar .btn + .btn { margin-top: .5rem; }
@media (max-width: 520px) { .tab { flex: 1 1 0; white-space: normal; padding: .6rem .4rem; font-size: .9rem; line-height: 1.25; text-align: center; } }
