:root {
  --bg: #070b12; --bg2: #0d1320; --card: #131b2b;
  --accent: #7c3aed; --accent2: #a78bfa; --blue: #38bdf8; --cyan: #22d3ee;
  --green: #22c55e; --amber: #f59e0b; --red: #ef4444;
  --text: #e8eef6; --dim: #7d8aa0; --border: #1d2840;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background:
    radial-gradient(900px 600px at 50% -8%, #1b2540 0%, transparent 60%),
    radial-gradient(700px 500px at 100% 100%, #14203a 0%, transparent 55%),
    var(--bg);
  color: var(--text); font-family: 'Inter', system-ui, sans-serif; overflow: hidden;
}
.app { display: flex; flex-direction: column; height: 100dvh; max-width: 860px; margin: 0 auto; position: relative; }

/* ── Topbar ── */
.topbar { display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border); background: rgba(13,19,32,.6); backdrop-filter: blur(12px); z-index: 10; }
.title { flex: 1; display: flex; flex-direction: column; line-height: 1.15; }
.brand { font-weight: 700; font-size: 1rem; letter-spacing: .2px; display: flex; align-items: center; gap: 0.45rem; }
.brand .logo { width: 20px; height: 20px; border-radius: 6px; background: linear-gradient(135deg, var(--accent), var(--blue)); box-shadow: 0 0 12px var(--accent); }
.status { font-size: 0.7rem; color: var(--dim); font-family: 'Consolas', monospace; display: flex; align-items: center; gap: 0.4rem; margin-top: 2px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); transition: all .3s; }
.status-dot.online { background: var(--green); box-shadow: 0 0 9px rgba(34,197,94,.7); }
.status-dot.thinking { background: var(--amber); box-shadow: 0 0 9px rgba(245,158,11,.7); }
.icon-btn { background: var(--bg2); border: 1px solid var(--border); color: var(--text); border-radius: 11px; width: 40px; height: 40px; font-size: 1.05rem; cursor: pointer; transition: all .15s; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon-btn:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn.big { width: 46px; height: 46px; font-size: 1.15rem; }
.icon-btn.muted { background: var(--red); border-color: var(--red); }

/* ── Stage ── */
.stage { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.7rem; padding: 0.9rem; min-height: 0; }
.orb-wrap { position: relative; width: 156px; height: 156px; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.orb { width: 96px; height: 96px; border-radius: 50%; background: radial-gradient(circle at 32% 28%, var(--accent2), var(--accent) 52%, #4c1d95 100%); box-shadow: 0 0 48px var(--accent), 0 0 90px rgba(124,58,237,.4), inset 0 0 28px rgba(255,255,255,.18); transition: transform .08s ease-out, box-shadow .3s, background .4s, filter .3s; }
.orb.listening { background: radial-gradient(circle at 32% 28%, #a5f3fc, var(--cyan) 50%, #0e7490 100%); box-shadow: 0 0 48px var(--cyan), 0 0 90px rgba(34,211,238,.4), inset 0 0 28px rgba(255,255,255,.2); }
.orb.speaking { background: radial-gradient(circle at 32% 28%, #86efac, var(--green) 52%, #15803d 100%); box-shadow: 0 0 56px var(--green), 0 0 100px rgba(34,197,94,.4), inset 0 0 28px rgba(255,255,255,.22); }
.orb.thinking { background: radial-gradient(circle at 32% 28%, #fcd34d, var(--amber) 52%, #b45309 100%); box-shadow: 0 0 52px var(--amber), 0 0 90px rgba(245,158,11,.4); }
.orb.muted { filter: grayscale(.65) brightness(.65); }
.ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(124,58,237,.25); opacity: 0; }
.ring.pulse { animation: pulse 2.2s infinite; }
@keyframes pulse { 0% { transform: scale(.52); opacity: .6; } 100% { transform: scale(1.18); opacity: 0; } }
.viz { position: absolute; inset: 0; }
.viz .bar { position: absolute; left: 50%; top: 50%; width: 3px; height: 12px; border-radius: 3px; background: linear-gradient(var(--accent2), var(--cyan)); transform-origin: 50% 0; opacity: .55; transition: height .07s ease-out; }
.hint { font-size: 0.82rem; color: var(--dim); min-height: 1.2em; text-align: center; }
.hint b { color: var(--accent2); }

/* ── Transcript ── */
.transcripts { width: 100%; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 0.55rem; padding: 0.3rem; -webkit-overflow-scrolling: touch; }
.empty { text-align: center; color: var(--dim); padding: 1.2rem; font-size: 0.85rem; }
.msg { padding: 0.55rem 0.8rem; border-radius: 16px; line-height: 1.5; font-size: 0.92rem; max-width: 86%; word-wrap: break-word; position: relative; animation: rise .18s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg .label { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 3px; opacity: .85; }
.msg .time { font-size: 0.6rem; color: var(--dim); margin-top: 4px; text-align: right; opacity: .7; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, rgba(124,58,237,.22), rgba(56,189,248,.14)); border: 1px solid rgba(124,58,237,.32); border-bottom-right-radius: 5px; }
.msg.user .label { color: var(--accent2); }
.msg.ai { align-self: flex-start; background: rgba(255,255,255,.045); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.msg.ai .label { color: var(--cyan); }
.msg.agent { align-self: flex-start; background: rgba(34,197,94,.07); border: 1px solid rgba(34,197,94,.22); border-bottom-left-radius: 5px; max-width: 94%; }
.msg.agent .label { color: var(--green); }
.msg.tool { align-self: center; background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3); font-size: 0.76rem; color: #fcd34d; max-width: 94%; }
.msg.err { align-self: center; background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.35); color: #fca5a5; font-size: 0.82rem; }
.msg.think { align-self: flex-start; background: rgba(167,139,250,.08); border: 1px solid rgba(167,139,250,.25); color: var(--accent2); font-size: 0.82rem; display: flex; align-items: center; gap: 0.5rem; }
.dots span { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--accent2); margin: 0 1px; animation: blink 1.2s infinite; }
.dots span:nth-child(2) { animation-delay: .2s; } .dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

/* Markdown */
.md p { margin: 0.3rem 0; } .md h2,.md h3,.md h4 { margin: 0.5rem 0 0.3rem; line-height: 1.3; }
.md h2 { font-size: 1.05rem; } .md h3 { font-size: .98rem; } .md h4 { font-size: .9rem; color: var(--accent2); }
.md ul { margin: 0.3rem 0 0.3rem 1.1rem; } .md li { margin: 0.15rem 0; }
.md a { color: var(--blue); }
.md code { background: rgba(255,255,255,.08); padding: 0.1rem 0.35rem; border-radius: 5px; font-family: 'Consolas', monospace; font-size: .85em; }
.md .code { position: relative; margin: 0.5rem 0; }
.md .code pre { background: #05080e; border: 1px solid var(--border); border-radius: 10px; padding: 0.7rem 0.8rem; overflow-x: auto; }
.md .code pre code { background: none; padding: 0; font-size: .82rem; line-height: 1.45; color: #cdd9e5; }
.md .code .copy { position: absolute; top: 6px; right: 6px; background: var(--bg2); border: 1px solid var(--border); color: var(--dim); font-size: .68rem; padding: 0.15rem 0.5rem; border-radius: 6px; cursor: pointer; }
.md .code .copy:hover { color: var(--text); border-color: var(--accent); }

/* ── Mode bar (giriş modu) ── */
.modebar { display: flex; justify-content: center; padding: 0.3rem 0.9rem; }
.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.seg button { border: 0; background: transparent; color: var(--dim); padding: 0.5rem 0.85rem; font: inherit; font-size: 0.8rem; font-weight: 600; cursor: pointer; transition: all .15s; }
.seg button.active { background: linear-gradient(135deg, var(--accent), #6d28d9); color: #fff; }

/* ── Input bar ── */
.inputbar { display: flex; align-items: center; gap: 0.5rem; padding: 0.6rem 0.9rem 0.8rem; border-top: 1px solid var(--border); background: rgba(13,19,32,.8); backdrop-filter: blur(12px); }
.pill { border: 0; border-radius: 13px; padding: 0 1.05rem; height: 46px; font: inherit; font-weight: 700; font-size: 0.9rem; cursor: pointer; transition: transform .12s, box-shadow .2s; white-space: nowrap; flex-shrink: 0; }
.pill:active { transform: scale(.96); }
.pill-start { background: linear-gradient(135deg, var(--accent), #6d28d9); color: #fff; box-shadow: 0 4px 18px var(--accent); }
.pill-stop { background: var(--red); color: #fff; box-shadow: 0 4px 14px rgba(239,68,68,.4); }
#textInput { flex: 1; background: var(--bg2); border: 1px solid var(--border); color: var(--text); border-radius: 13px; padding: 0 0.95rem; height: 46px; font: inherit; font-size: 0.9rem; min-width: 0; }
#textInput:focus { outline: none; border-color: var(--accent); }
.ptt { flex: 1; height: 46px; border-radius: 13px; border: 1px solid var(--border); background: var(--bg2); color: var(--text); font: inherit; font-weight: 700; font-size: 0.9rem; cursor: pointer; user-select: none; touch-action: none; transition: all .12s; }
.ptt.active { background: linear-gradient(135deg, var(--cyan), var(--blue)); color: #04121a; box-shadow: 0 0 26px rgba(34,211,238,.6); transform: scale(1.02); }

/* Giriş moduna göre kontrol görünürlüğü */
.for-live, .for-ptt, .for-text { display: none; }
.app[data-input="live"] .for-live { display: inline-flex; }
.app[data-input="ptt"]  .for-ptt  { display: inline-flex; }
.app[data-input="text"] .for-text { display: inline-flex; }

/* ── Drawer / Sheet ortak ── */
.drawer { position: fixed; top: 0; left: 0; bottom: 0; width: 320px; max-width: 85vw; background: var(--bg2); border-right: 1px solid var(--border); transform: translateX(-105%); transition: transform .28s ease; z-index: 40; display: flex; flex-direction: column; visibility: hidden; }
.drawer.open { transform: translateX(0); visibility: visible; box-shadow: 22px 0 60px rgba(0,0,0,.55); }
.drawer header { display: flex; align-items: center; justify-content: space-between; padding: 0.8rem; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 0.9rem; }
.history-list { flex: 1; overflow-y: auto; padding: 0.5rem; display: flex; flex-direction: column; gap: 0.4rem; }
.hi { background: var(--card); border: 1px solid var(--border); border-radius: 11px; padding: 0.6rem 0.7rem; cursor: pointer; transition: border-color .15s; }
.hi:hover { border-color: var(--accent); }
.hi .t { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hi .m { font-size: 0.66rem; color: var(--dim); margin-top: 4px; display: flex; gap: 0.5rem; align-items: center; }
.hi .badge { background: rgba(124,58,237,.2); color: var(--accent2); border-radius: 5px; padding: 0 0.4rem; }

.sheet { position: fixed; left: 50%; bottom: 0; transform: translate(-50%, 110%); width: 100%; max-width: 460px; background: var(--bg2); border: 1px solid var(--border); border-bottom: 0; border-radius: 18px 18px 0 0; transition: transform .28s ease; z-index: 40; padding-bottom: 0.5rem; }
.sheet.open { transform: translate(-50%, 0); box-shadow: 0 -22px 60px rgba(0,0,0,.55); }
.sheet header { display: flex; align-items: center; justify-content: space-between; padding: 0.9rem; border-bottom: 1px solid var(--border); font-weight: 700; }
.sheet .row { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; padding: 0.7rem 0.9rem; }
.sheet .row > span { font-size: 0.85rem; color: var(--dim); }
.sheet select { background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 9px; padding: 0.45rem 0.5rem; font: inherit; font-size: 0.82rem; }
.sheet input[type=range] { width: 130px; accent-color: var(--accent); }

.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); opacity: 0; pointer-events: none; transition: opacity .28s; z-index: 35; }
.scrim.show { opacity: 1; pointer-events: auto; }

/* ── Log ── */
.logbox { border-top: 1px solid var(--border); background: #05080e; }
.logbox summary { padding: 0.35rem 0.9rem; font-size: 0.7rem; color: var(--dim); cursor: pointer; font-family: 'Consolas', monospace; }
.log { height: 90px; overflow-y: auto; padding: 0 0.9rem 0.5rem; font-family: 'Consolas', monospace; font-size: 0.68rem; color: var(--dim); }
.log div { margin-bottom: 2px; }

/* ── Responsive ── */
@media (max-width: 560px) {
  .orb-wrap { width: 124px; height: 124px; } .orb { width: 78px; height: 78px; }
  .brand { font-size: 0.95rem; }
}
@media (min-width: 900px) {
  .orb-wrap { width: 170px; height: 170px; } .orb { width: 104px; height: 104px; }
  .msg { font-size: 0.95rem; } .stage { padding: 1.2rem; gap: 0.9rem; }
}
