:root {
  --bg: #0d080f; --bg2: #1a111c; --card: #211623; --line: #382840; --ink: #f6ece8; --muted: #b9a5ae;
  --accent: #a8326a; --accent2: #d9a0e6; --plum: #74418f; --ok: #6fcf97; --err: #ff7b7b; --amber: #f2c46b;
  --r: 14px; --serif: 'Fraunces', Georgia, serif; --sans: 'Inter', system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent2); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0 0 .4em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; width: 100%; min-height: 44px; }
textarea { min-height: 160px; resize: vertical; line-height: 1.45; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent2); outline-offset: 2px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: 600 14px var(--sans);
  cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--plum)); border: 0; color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--err); border-color: #5a2a30; }
.linkbtn { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 8px; min-height: 44px; text-decoration: underline; text-underline-offset: 3px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > input { flex: 1; min-width: 140px; }

.flashes { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 50; width: min(520px, calc(100% - 32px)); display: grid; gap: 8px; }
.flash { padding: 10px 14px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); }
.flash.ok { border-color: #2f5a41; } .flash.error { border-color: #6a2d33; color: #ffc9c9; }

/* ------------------------------------------------------------ talk page */
.talkbody { min-height: 100dvh; background:
  radial-gradient(120% 70% at 50% 15%, #2e1636 0%, transparent 60%), radial-gradient(80% 50% at 50% 110%, #22122a 0%, transparent 70%), var(--bg); }
.talk { min-height: 100dvh; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; padding: 0 16px; }
.ttop { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; }
.brand { font-family: var(--serif); font-size: 20px; letter-spacing: .01em; }
.tfoot { text-align: center; padding: 16px 0 calc(16px + env(safe-area-inset-bottom)); }
.gate { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 6px; }
.gate h1 { font-size: clamp(34px, 9vw, 52px); }
.gateform { display: flex; gap: 10px; width: 100%; max-width: 380px; margin: 14px 0 6px; }
.gateform input { flex: 1; text-align: center; font-size: 17px; }

.stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 10px 0 20px; }
.orb { position: relative; width: min(64vw, 260px); aspect-ratio: 1; display: grid; place-items: center; margin-bottom: 8px; }
.orb .core { width: 46%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #f0c6de, #b5609a 35%, #7d3a8f 70%, #2e1238);
  box-shadow: 0 0 60px rgba(168, 50, 106, .45); transition: transform .4s ease; }
.orb i { position: absolute; inset: 0; border-radius: 50%; border: 1px solid rgba(181, 96, 154, .4); opacity: 0; }
.orb.listen i, .orb.hear i, .orb.talk i, .orb.think i { animation: ripple 2.6s ease-out infinite; }
.orb i:nth-child(2) { animation-delay: .85s !important; } .orb i:nth-child(3) { animation-delay: 1.7s !important; }
.orb.talk .core { animation: talk 0.5s ease-in-out infinite alternate; }
.orb.hear .core { transform: scale(1.08); }
.orb.think .core { animation: breathe 1.4s ease-in-out infinite alternate; }
.orb.idle .core { animation: breathe 4s ease-in-out infinite alternate; opacity: .85; }
.orb.talk i { animation-duration: 1.4s; }
@keyframes ripple { 0% { transform: scale(.45); opacity: .7; } 100% { transform: scale(1); opacity: 0; } }
@keyframes talk { from { transform: scale(1); } to { transform: scale(1.14); } }
@keyframes breathe { from { transform: scale(.96); } to { transform: scale(1.04); } }
@media (prefers-reduced-motion: reduce) { .orb *, .orb.talk .core { animation: none !important; } }
.state { font-family: var(--serif); font-size: 22px; margin: 0; min-height: 1.4em; max-width: 30ch; }
.timer { margin: -6px 0 0; font-variant-numeric: tabular-nums; }
.controls { display: flex; align-items: center; gap: 18px; margin-top: 6px; }
.callbtn { width: 78px; height: 78px; border-radius: 50%; border: 0; cursor: pointer; color: #1a0d12;
  background: linear-gradient(135deg, var(--ok), #9fe3b8); box-shadow: 0 10px 30px rgba(111, 207, 151, .3); transition: transform .15s; }
.callbtn:active { transform: scale(.95); }
.callbtn.end { background: linear-gradient(135deg, #ff5a6a, #ff8a7a); box-shadow: 0 10px 30px rgba(255, 90, 106, .35); }
.callbtn.end svg { transform: rotate(135deg); }
.callbtn:disabled { opacity: .4; cursor: not-allowed; }
.roundbtn { width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.roundbtn.on { background: var(--ink); color: var(--bg); }
.hint { max-width: 32ch; }
.trans { width: 100%; max-height: 34vh; overflow-y: auto; display: grid; gap: 8px; padding: 12px; background: rgba(0,0,0,.25); border: 1px solid var(--line); border-radius: var(--r); text-align: left; }
.tb { padding: 8px 12px; border-radius: 12px; max-width: 85%; }
.tb.ai { background: var(--card); justify-self: start; }
.tb.me { background: #3a2240; justify-self: end; }
.tb.sys { color: var(--muted); font-size: 13px; justify-self: center; }
.mepanel { position: fixed; top: 60px; right: 16px; left: 16px; max-width: 340px; margin-left: auto; z-index: 20; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: grid; gap: 10px; box-shadow: 0 20px 50px rgba(0,0,0,.5); }
.mepanel p { margin: 0; }

/* ------------------------------------------------------------ admin */
.adminbody { background: var(--bg); }
.awrap { display: grid; grid-template-columns: 220px 1fr; min-height: 100dvh; }
.aside { background: var(--bg2); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100dvh; }
.aside .brand { padding: 4px 10px 14px; }
.amark { height: 46px; width: auto; align-self: flex-start; margin: 2px 10px 16px; }
.aside a { color: var(--ink); text-decoration: none; padding: 10px 12px; border-radius: 10px; min-height: 44px; display: flex; align-items: center; }
.aside a:hover { background: var(--card); }
.aside a.on { background: var(--card); color: var(--accent2); }
.aside .foot { margin-top: auto; }
.amain { padding: 26px clamp(16px, 4vw, 40px) 60px; max-width: 980px; width: 100%; min-width: 0; }
.amain h1 { font-size: 30px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin: 0 0 16px; }
.card h2 { font-size: 20px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.stat b { display: block; font: 600 26px var(--serif); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-weight: 600; font-size: 13px; }
.field small { color: var(--muted); }
.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 14px; }
.check input { width: 20px; min-height: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); }
.pill.ok { color: var(--ok); border-color: #2f5a41; } .pill.no { color: var(--amber); border-color: #5a4a2a; }
.engine { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; cursor: pointer; }
.engine input { width: 20px; min-height: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); }
.engine:has(input:checked) { border-color: var(--accent); background: rgba(168,50,106,.08); }
.sticky { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 40%); }
pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-x: auto; white-space: pre-wrap; font-size: 13px; }
code { background: var(--bg); padding: 1px 6px; border-radius: 6px; font-size: 13px; }
table.list { width: 100%; border-collapse: collapse; }
table.list td, table.list th { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.list th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.callers { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.ccard { display: block; color: var(--ink); text-decoration: none; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.ccard:hover { border-color: var(--muted); }
.ccard p { margin: 6px 0 0; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tag { padding: 3px 10px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.tag button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 2px; font-size: 14px; line-height: 1; }
.amber { color: var(--amber); }
details.call { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; background: var(--bg2); }
details.call summary { cursor: pointer; list-style: none; }
details.call summary::-webkit-details-marker { display: none; }
.lines { display: grid; gap: 6px; margin-top: 12px; }
.lines div { padding: 6px 10px; border-radius: 10px; background: var(--card); }
.lines div.caller { background: #3a2240; }
.lines b { font-size: 12px; color: var(--muted); margin-right: 6px; }
.loginbox { max-width: 380px; margin: 12vh auto; padding: 0 16px; }

/* ------------------------------------------------------------ 1.0.1: logo, badge, text chat */
.mark { height: 46px; width: auto; display: block; }
.gate .logo { width: min(300px, 78vw); height: auto; margin-bottom: 4px; }
.badge { display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 8px 14px; border-radius: 999px;
  background: rgba(242,196,107,.1); border: 1px solid #5a4a2a; color: var(--amber); font-size: 13px; }
.spacer { width: 52px; }
.pillbtn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px; margin-top: 4px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--ink); font: 600 14px var(--sans); cursor: pointer; }
.pillbtn:hover { border-color: var(--muted); }
.talk.chatting { padding: 0; max-width: none; }
.chat { --col: 720px; --side: max(14px, calc((100% - var(--col)) / 2)); position: fixed; inset: 0; z-index: 5; display: flex; flex-direction: column; overflow: hidden;
  background: radial-gradient(120% 50% at 50% 0%, #2e1636 0%, var(--bg) 60%); }
.chat[hidden] { display: none !important; }
.chathead { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: env(safe-area-inset-top) var(--side) 0; padding-left: max(6px, calc(var(--side) - 8px));
  background: rgba(13, 8, 15, .72); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid rgba(255,255,255,.06); position: relative; z-index: 2; }
.iconbtn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: none; color: var(--ink); display: grid; place-items: center; cursor: pointer; flex-shrink: 0; }
.iconbtn:hover { background: rgba(255,255,255,.06); }
.iconbtn.ring { background: linear-gradient(135deg, var(--ok), #9fe3b8); color: #10241a; width: 40px; height: 40px; }
.chathead .av { width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; background: radial-gradient(circle at 35% 30%, #f0c6de, #b5609a 35%, #7d3a8f 70%, #2e1238);
  box-shadow: 0 0 0 2px rgba(181, 96, 154, .25); }
.chathead .who { flex: 1; display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.chathead .who b { font-size: 16px; font-weight: 600; }
.chathead .who small { color: #9fe3b8; font-size: 12px; }

.msgs { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding: 18px var(--side) 12px; font-size: 15px; line-height: 1.42;
  scrollbar-width: thin; scrollbar-color: #3a2a40 transparent; overscroll-behavior: contain; }
.msgs::-webkit-scrollbar { width: 8px; } .msgs::-webkit-scrollbar-thumb { background: #3a2a40; border-radius: 8px; } .msgs::-webkit-scrollbar-track { background: transparent; }
.msgs > :first-child { margin-top: auto; }
.m { max-width: min(78%, 520px); padding: 9px 14px; white-space: pre-wrap; overflow-wrap: anywhere; border-radius: 20px; }
.m.ai { align-self: flex-start; background: #221825; color: var(--ink); }
.m.me { align-self: flex-end; background: linear-gradient(135deg, #9a2e63, #6b3a88); color: #fff; }
.m.ai + .m.me, .m.me + .m.ai { margin-top: 10px; }
.m.ai:has(+ .m.ai) { border-bottom-left-radius: 6px; } .m.ai + .m.ai { border-top-left-radius: 6px; }
.m.me:has(+ .m.me) { border-bottom-right-radius: 6px; } .m.me + .m.me { border-top-right-radius: 6px; }
.m.me { display: flex; align-items: flex-end; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.m .tx { white-space: pre-wrap; }
.tk { display: inline-flex; align-items: center; margin: 0 -4px -1px auto; color: rgba(255, 255, 255, .5); transition: color .3s; }
.tk.seen { color: #8fe3ff; }
.m.sys { align-self: center; color: var(--muted); font-size: 13px; padding: 6px; background: none; }
.day { align-self: center; color: var(--muted); font-size: 12px; margin: 0 0 8px; }
.m.dots { display: flex; gap: 4px; padding: 14px 16px; }
.m.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent2); animation: dot 1.2s infinite; }
.m.dots i:nth-child(2) { animation-delay: .2s; } .m.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.chathead, .composer { flex-shrink: 0; }
.composer { padding: 8px var(--side) calc(14px + env(safe-area-inset-bottom)); }
.cbox { display: flex; align-items: flex-end; gap: 8px; background: #1a111c; border: 1px solid #33243a; border-radius: 26px; padding: 5px 5px 5px 18px; transition: border-color .15s; }
.cbox:focus-within { border-color: #7d4a8f; box-shadow: 0 0 0 3px rgba(125, 74, 143, .2); }
.composer textarea { flex: 1; min-height: 40px; height: 40px; max-height: 140px; border: 0; background: transparent; border-radius: 0; padding: 9px 0; line-height: 22px;
  font-size: 16px; resize: none; overflow-y: hidden; outline: none; scrollbar-width: thin; scrollbar-color: #3a2a40 transparent; }
.composer textarea:focus-visible { outline: none; }
.composer textarea.scroll { overflow-y: auto; }
.composer textarea::placeholder { color: #8f7d88; }
.sendbtn { width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%; border: 0; background: linear-gradient(135deg, #c8437f, #8a52b0); color: #fff; display: grid; place-items: center; cursor: pointer; transition: opacity .15s, transform .1s; }
.sendbtn:active { transform: scale(.94); }
.cbox.empty .sendbtn { opacity: .45; }

@media (max-width: 760px) {
  .awrap { grid-template-columns: 1fr; }
  .aside { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .aside .brand { width: 100%; padding: 4px 8px 6px; }
  .aside .foot { margin-top: 0; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .gateform { flex-direction: column; }
}
