/* ============================================================
   ReX AI Assistant — Futuristic Persona UI
   Theme: Neon cyan + magenta, dark stage, living avatar
   ============================================================ */

:root {
  --bg: #05060d;
  --bg-deep: #020308;
  --surface: rgba(15, 20, 35, 0.7);
  --surface-solid: #0d1120;
  --border: rgba(100, 160, 255, 0.18);
  --border-strong: rgba(120, 200, 255, 0.35);

  --text: #e9f2ff;
  --text-muted: #8a98b5;
  --text-dim: #5a6480;

  --neon-cyan: #4fe3ff;
  --neon-blue: #4b7bff;
  --neon-purple: #b66dff;
  --neon-pink: #ff5bc7;
  --neon-glow-cyan: rgba(79, 227, 255, 0.5);
  --neon-glow-purple: rgba(182, 109, 255, 0.45);

  --success: #52e6a8;
  --danger: #ff5c7a;
  --warning: #ffb24c;

  --font-display: 'Orbitron', 'Segoe UI', sans-serif;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--bg-deep);
}

/* Logo ile uyumlu derin lacivert + kose nebula glow'lari */
body {
  background:
    radial-gradient(ellipse 55% 45% at 12% 18%, rgba(60, 140, 255, 0.22), transparent 62%),
    radial-gradient(ellipse 50% 40% at 88% 78%, rgba(178, 90, 220, 0.18), transparent 62%),
    radial-gradient(ellipse 70% 30% at 50% -8%, rgba(80, 200, 255, 0.10), transparent 70%),
    radial-gradient(ellipse at 50% 50%, #07142a 0%, #030a18 55%, #01040b 100%);
}

/* ============================================================
   Animated background (grid + particles)
   ============================================================ */
.bg-scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

/* Logoya uyumlu cok ince teknolojik grid — onceki haline gore sonuk */
.grid-layer {
  position: absolute;
  inset: -50% -50% -50% -50%;
  background-image:
    linear-gradient(rgba(79, 227, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79, 227, 255, 0.028) 1px, transparent 1px);
  background-size: 80px 80px;
  mask-image: radial-gradient(ellipse at center, black 25%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 25%, transparent 78%);
  animation: gridDrift 60s linear infinite;
}

@keyframes gridDrift {
  from { transform: translate(0, 0); }
  to   { transform: translate(80px, 80px); }
}

/* Yildiz alani — logodaki gibi cok sayida farkli boyut/parlaklikta nokta.
   3 katmanli SVG data URI: kucuk soluk + orta + buyuk parlak.  */
.particles {
  position: absolute;
  inset: 0;
  background-image:
    /* Buyuk parlak yildizlar (4-li yildiz) */
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='800' height='800' viewBox='0 0 800 800'><g fill='%23a8e6ff'><circle cx='120' cy='90'  r='1.6' opacity='0.95'/><circle cx='680' cy='160' r='1.4' opacity='0.85'/><circle cx='420' cy='720' r='1.8' opacity='0.95'/><circle cx='760' cy='560' r='1.5' opacity='0.85'/><circle cx='90'  cy='620' r='1.7' opacity='0.95'/><circle cx='300' cy='280' r='1.4' opacity='0.8'/><circle cx='540' cy='420' r='1.6' opacity='0.9'/></g></svg>"),
    /* Orta noktalar — beyaza yakin */
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='600' height='600' viewBox='0 0 600 600'><g fill='%23dff3ff'><circle cx='45'  cy='180' r='0.8' opacity='0.7'/><circle cx='220' cy='80'  r='0.9' opacity='0.75'/><circle cx='340' cy='510' r='0.9' opacity='0.75'/><circle cx='560' cy='320' r='0.8' opacity='0.7'/><circle cx='110' cy='420' r='0.9' opacity='0.75'/><circle cx='480' cy='110' r='0.8' opacity='0.7'/><circle cx='260' cy='340' r='0.8' opacity='0.6'/><circle cx='580' cy='560' r='0.9' opacity='0.8'/></g></svg>"),
    /* Kucuk uzak yildizlar — mavi tonu */
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='400' height='400' viewBox='0 0 400 400'><g fill='%2378b8ff'><circle cx='30'  cy='80'  r='0.6' opacity='0.55'/><circle cx='160' cy='30'  r='0.5' opacity='0.5'/><circle cx='220' cy='200' r='0.6' opacity='0.55'/><circle cx='320' cy='130' r='0.5' opacity='0.5'/><circle cx='90'  cy='310' r='0.6' opacity='0.55'/><circle cx='380' cy='340' r='0.5' opacity='0.5'/><circle cx='250' cy='370' r='0.6' opacity='0.55'/></g></svg>");
  background-size: 800px 800px, 600px 600px, 400px 400px;
  background-position: 0 0, 100px 50px, 250px 150px;
  animation: twinkle 6s ease-in-out infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 0.95; }
}

/* Ag/mesh katmani — logodaki node-line gorunumu icin ince bag cizgileri.
   Tek tile bir ucgen pattern; cok yavas kayar. */
.bg-mesh {
  position: absolute;
  inset: -10% -10% -10% -10%;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'><g stroke='%234fc8ff' stroke-width='0.5' stroke-opacity='0.12' fill='none'><path d='M30 40 L130 110 L220 50 L160 180 L60 210 Z'/><path d='M30 40 L60 210'/><path d='M130 110 L160 180'/><path d='M220 50 L160 180'/></g><g fill='%2378d6ff' fill-opacity='0.4'><circle cx='30' cy='40' r='1.4'/><circle cx='130' cy='110' r='1.6'/><circle cx='220' cy='50' r='1.4'/><circle cx='160' cy='180' r='1.5'/><circle cx='60' cy='210' r='1.3'/></g></svg>");
  background-size: 320px 320px;
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 20%, transparent 80%);
  opacity: 0.55;
  animation: meshDrift 90s linear infinite;
}

@keyframes meshDrift {
  from { transform: translate(0, 0); }
  to   { transform: translate(-320px, 160px); }
}

/* ============================================================
   Top bar (minimal)
   ============================================================ */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: flex-end;        /* tum kontroller saga yaslandi */
  align-items: center;
  padding: 14px 20px;
  background: linear-gradient(180deg, rgba(5, 6, 13, 0.85), transparent);
  pointer-events: none;             /* sahnenin tikinitisini engellemesin */
}
.topbar > * { pointer-events: auto; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  backdrop-filter: blur(10px);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  box-shadow: 0 0 0 transparent;
  transition: all 0.3s;
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 8px var(--success), 0 0 20px rgba(82, 230, 168, 0.4);
}

.status-dot.error {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

.topbar-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.topbar-btn:hover {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  box-shadow: 0 0 16px var(--neon-glow-cyan);
}

/* Active (on) — goz acik / detaylar gorunuyor */
.topbar-btn.active {
  background: rgba(79, 227, 255, 0.15);
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  box-shadow: 0 0 12px var(--neon-glow-cyan);
}

/* ============================================================
   Main stage — ReX kisi gibi ortada
   ============================================================ */
.stage {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px 180px;
  overflow: hidden;
  transition: padding 0.4s cubic-bezier(0.16, 1, 0.3, 1), justify-content 0.4s ease;
}

/* Chat active durumunda: avatar kucul, yukari kay, response alani genislesin */
.stage.active {
  justify-content: flex-start;
  padding: 70px 24px 120px;
}

/* Avatar + rings */
.avatar-wrap {
  position: relative;
  width: 320px;
  height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.avatar {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #0a1428 0%, #050811 100%);
  box-shadow:
    inset 0 0 30px rgba(79, 227, 255, 0.2),
    0 0 40px rgba(79, 227, 255, 0.3),
    0 0 80px rgba(182, 109, 255, 0.2);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 3;
  transition: all 0.4s;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  transition: filter 0.5s ease, transform 0.4s ease;
  will-change: transform, filter;
}

/* Animated concentric rings */
.ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid;
  pointer-events: none;
}

.ring-outer {
  width: 100%;
  height: 100%;
  border-color: rgba(79, 227, 255, 0.25);
  border-top-color: var(--neon-cyan);
  animation: rotate 8s linear infinite;
  box-shadow: 0 0 20px rgba(79, 227, 255, 0.15);
}

.ring-middle {
  width: 85%;
  height: 85%;
  border-color: rgba(182, 109, 255, 0.2);
  border-right-color: var(--neon-purple);
  animation: rotateReverse 6s linear infinite;
}

.ring-inner {
  width: 74%;
  height: 74%;
  border-color: rgba(75, 123, 255, 0.3);
  border-bottom-color: var(--neon-blue);
  animation: rotate 4s linear infinite;
  box-shadow: inset 0 0 10px rgba(75, 123, 255, 0.2);
}

@keyframes rotate {
  to { transform: rotate(360deg); }
}
@keyframes rotateReverse {
  to { transform: rotate(-360deg); }
}

/* IDLE: yavas breathing + logo hafif glow nabzi */
.avatar-wrap.idle .avatar {
  animation: breathe 4s ease-in-out infinite;
}
.avatar-wrap.idle .avatar img {
  animation: logoIdleGlow 5s ease-in-out infinite;
}

@keyframes logoIdleGlow {
  0%, 100% { filter: brightness(1) drop-shadow(0 0 6px rgba(79, 227, 255, 0.35)); }
  50%      { filter: brightness(1.08) drop-shadow(0 0 14px rgba(79, 227, 255, 0.6)); }
}

@keyframes breathe {
  0%, 100% { transform: scale(1); box-shadow:
    inset 0 0 30px rgba(79, 227, 255, 0.2),
    0 0 40px rgba(79, 227, 255, 0.3),
    0 0 80px rgba(182, 109, 255, 0.2); }
  50% { transform: scale(1.02); box-shadow:
    inset 0 0 40px rgba(79, 227, 255, 0.3),
    0 0 60px rgba(79, 227, 255, 0.5),
    0 0 120px rgba(182, 109, 255, 0.3); }
}

/* THINKING: halkalar hizlanir + glow artar + logo subtle hue oynama */
.avatar-wrap.thinking .ring-outer { animation-duration: 2s; }
.avatar-wrap.thinking .ring-middle { animation-duration: 1.5s; }
.avatar-wrap.thinking .ring-inner { animation-duration: 1s; }
.avatar-wrap.thinking .avatar {
  box-shadow:
    inset 0 0 40px rgba(255, 91, 199, 0.3),
    0 0 60px rgba(255, 91, 199, 0.4),
    0 0 120px rgba(79, 227, 255, 0.3);
}
.avatar-wrap.thinking .avatar img {
  animation: logoThink 2.4s ease-in-out infinite;
}

@keyframes logoThink {
  0%, 100% { filter: brightness(1)    hue-rotate(0deg)   drop-shadow(0 0 10px rgba(255, 91, 199, 0.45)); }
  50%      { filter: brightness(1.15) hue-rotate(-22deg) drop-shadow(0 0 22px rgba(255, 91, 199, 0.75)); }
}

/* SPEAKING: wave bars gorunur + logo nabiz gibi atar (konusma ritmine yakin) */
.avatar-wrap.speaking .wave-bars { opacity: 1; }
.avatar-wrap.speaking .avatar {
  box-shadow:
    inset 0 0 50px rgba(82, 230, 168, 0.3),
    0 0 80px rgba(82, 230, 168, 0.4),
    0 0 140px rgba(79, 227, 255, 0.4);
}
.avatar-wrap.speaking .avatar img {
  animation: logoSpeak 0.65s ease-in-out infinite;
}

@keyframes logoSpeak {
  0%, 100% { transform: scale(1);     filter: brightness(1.05) drop-shadow(0 0 12px rgba(82, 230, 168, 0.55)); }
  50%      { transform: scale(1.045); filter: brightness(1.25) drop-shadow(0 0 24px rgba(82, 230, 168, 0.85)); }
}

/* ERROR: kirmizimsi titreme */
.avatar-wrap.error .avatar img {
  animation: logoError 0.18s ease-in-out 4;
}

@keyframes logoError {
  0%, 100% { transform: translateX(0);    filter: brightness(0.9) drop-shadow(0 0 14px rgba(255, 80, 80, 0.7)); }
  25%      { transform: translateX(-3px); }
  75%      { transform: translateX(3px); }
}

/* Voice wave bars — speaking halinde aktif */
.wave-bars {
  position: absolute;
  bottom: -50px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 40px;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 2;
}

.wave-bars span {
  display: inline-block;
  width: 4px;
  background: linear-gradient(180deg, var(--neon-cyan), var(--neon-purple));
  border-radius: 2px;
  box-shadow: 0 0 8px var(--neon-glow-cyan);
  animation: waveBar 1s ease-in-out infinite;
}

.wave-bars span:nth-child(1) { animation-delay: 0.0s; }
.wave-bars span:nth-child(2) { animation-delay: 0.1s; }
.wave-bars span:nth-child(3) { animation-delay: 0.2s; }
.wave-bars span:nth-child(4) { animation-delay: 0.3s; }
.wave-bars span:nth-child(5) { animation-delay: 0.4s; }
.wave-bars span:nth-child(6) { animation-delay: 0.3s; }
.wave-bars span:nth-child(7) { animation-delay: 0.2s; }
.wave-bars span:nth-child(8) { animation-delay: 0.1s; }
.wave-bars span:nth-child(9) { animation-delay: 0.15s; }
.wave-bars span:nth-child(10) { animation-delay: 0.25s; }

@keyframes waveBar {
  0%, 100% { height: 6px; }
  50% { height: 32px; }
}

/* ============================================================
   State text (avatar altinda durum)
   ============================================================ */
.state-text {
  margin-top: 72px;
  font-family: var(--font-display);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px var(--neon-glow-cyan);
  min-height: 20px;
  text-align: center;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Response preview — ReX'in soyledigi buyuk ve prominent
   ============================================================ */
.response-preview {
  margin-top: 20px;
  max-width: 820px;
  width: 100%;
  min-height: 0;
  max-height: 62vh;
  overflow-y: auto;
  padding: 8px 24px;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  text-align: left;
  font-weight: 300;
  letter-spacing: 0.2px;
  animation: fadeIn 0.3s ease;
}

.response-preview:empty { display: none; }

.response-preview p { margin-bottom: 12px; }
.response-preview p:last-child { margin-bottom: 0; }

.response-preview strong {
  color: var(--neon-cyan);
  font-weight: 600;
  text-shadow: 0 0 8px var(--neon-glow-cyan);
}

.response-preview em {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.9em;
}

.response-preview code {
  background: rgba(79, 227, 255, 0.1);
  color: var(--neon-cyan);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.92em;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
}

.response-preview pre {
  background: rgba(5, 10, 20, 0.7);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 8px;
  text-align: left;
  font-size: 12px;
  overflow-x: auto;
  margin: 12px 0;
}
.response-preview pre code {
  background: none;
  color: var(--text);
  padding: 0;
}

.response-preview h1, .response-preview h2, .response-preview h3 {
  color: var(--neon-cyan);
  margin: 16px 0 8px;
  font-family: var(--font-display);
  letter-spacing: 1px;
}

.response-preview ul, .response-preview ol {
  text-align: left;
  margin: 10px auto;
  display: inline-block;
  padding-left: 20px;
}

.response-preview li { margin-bottom: 6px; }

.response-preview .cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--neon-cyan);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: blink 0.8s step-end infinite;
  box-shadow: 0 0 6px var(--neon-glow-cyan);
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* ============================================================
   Tool activity chips (avatar altinda ne yapiyor)
   ============================================================ */
.tool-activity {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
  max-width: 720px;
}

.tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(79, 227, 255, 0.08);
  border: 1px solid rgba(79, 227, 255, 0.25);
  border-radius: 20px;
  font-size: 11px;
  color: var(--neon-cyan);
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  animation: fadeIn 0.2s ease;
}

.tool-chip .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--neon-cyan);
  box-shadow: 0 0 6px var(--neon-cyan);
  animation: pulseDot 1s ease-in-out infinite;
}

.tool-chip.done {
  background: rgba(82, 230, 168, 0.08);
  border-color: rgba(82, 230, 168, 0.3);
  color: var(--success);
}

.tool-chip.done .dot {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
  animation: none;
}

.tool-chip.error {
  background: rgba(255, 92, 122, 0.08);
  border-color: rgba(255, 92, 122, 0.3);
  color: var(--danger);
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

/* ============================================================
   Suggestion chips (welcome)
   ============================================================ */
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 28px;
  max-width: 640px;
  animation: fadeIn 0.6s ease;
}

.chip {
  padding: 9px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 30px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.25s;
  font-family: var(--font-ui);
  letter-spacing: 0.3px;
  backdrop-filter: blur(8px);
}

.chip:hover {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  box-shadow: 0 0 16px var(--neon-glow-cyan);
  transform: translateY(-2px);
}

.suggestions.hidden {
  display: none;
}

/* ============================================================
   Sliding history panel (Konusma gecmisi)
   ============================================================ */
.history-panel {
  position: fixed;
  top: 0;
  right: -440px;
  width: 420px;
  max-width: 90vw;
  height: 100vh;
  background: var(--surface-solid);
  border-left: 1px solid var(--border-strong);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.5);
  z-index: 20;
  transition: right 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.history-panel.open {
  right: 0;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.history-header h3 {
  font-family: var(--font-display);
  letter-spacing: 2px;
  font-size: 14px;
  color: var(--neon-cyan);
  text-transform: uppercase;
}

.history-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.history-content:empty::before {
  content: 'Henuz konusma yok.';
  color: var(--text-dim);
  font-size: 13px;
  display: block;
  text-align: center;
  padding: 40px 0;
}

.msg-entry {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(100, 160, 255, 0.08);
  animation: fadeIn 0.3s ease;
}

.msg-entry:last-child {
  border-bottom: none;
}

.msg-role {
  font-family: var(--font-display);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 6px;
  opacity: 0.7;
}

.msg-entry.user .msg-role { color: var(--neon-purple); }
.msg-entry.assistant .msg-role { color: var(--neon-cyan); }

.msg-text {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  word-break: break-word;
}

/* ============================================================
   Agenda panel (ders programi + hatirlatici + notlar)
   Panel kabugu .history-panel sinifini yeniden kullanir.
   ============================================================ */
.agenda-content:empty::before {
  content: 'Ajanda bos.';
}

.agenda-section { margin-bottom: 24px; }

.agenda-section h4 {
  font-family: var(--font-display);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--neon-purple);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(182, 109, 255, 0.15);
}

.agenda-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: rgba(79, 227, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  animation: fadeIn 0.3s ease;
}

.agenda-item .when {
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 12px;
  color: var(--neon-cyan);
  white-space: nowrap;
  min-width: 52px;
}

.agenda-item.event .when { color: var(--warning); }
.agenda-item .what { color: var(--text); flex: 1; word-break: break-word; }
.agenda-item .meta { color: var(--text-dim); font-size: 11px; }

.agenda-empty {
  color: var(--text-dim);
  font-size: 12px;
  font-style: italic;
  padding: 4px 10px;
}

/* ============================================================
   Proaktif hatirlatma toast'lari (ReX kendisi hatirlatir)
   ============================================================ */
.reminder-stack {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(440px, calc(100vw - 32px));
  pointer-events: none;
}

.reminder-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(20, 16, 40, 0.96), rgba(12, 18, 36, 0.96));
  border: 1px solid var(--neon-purple);
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 26px var(--neon-glow-purple);
  backdrop-filter: blur(14px);
  animation: reminderIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.reminder-toast.closing { animation: reminderOut 0.3s ease forwards; }

@keyframes reminderIn {
  from { opacity: 0; transform: translateY(-14px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes reminderOut {
  to { opacity: 0; transform: translateY(-14px) scale(0.96); }
}

.reminder-toast .bell {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(182, 109, 255, 0.15);
  color: var(--neon-purple);
  animation: bellRing 1.2s ease-in-out infinite;
}

@keyframes bellRing {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-14deg); }
  40% { transform: rotate(11deg); }
  60% { transform: rotate(-7deg); }
  80% { transform: rotate(4deg); }
}

.reminder-toast .r-body { flex: 1; min-width: 0; }

.reminder-toast .r-label {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--neon-purple);
  margin-bottom: 4px;
}

.reminder-toast .r-text {
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  word-break: break-word;
}

.reminder-toast .r-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 2px 4px;
  flex-shrink: 0;
}
.reminder-toast .r-close:hover { color: var(--neon-pink); }

@media (max-width: 720px) {
  .reminder-stack { top: 60px; }
}

/* ============================================================
   Bottom command bar
   ============================================================ */
.command-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 40px;
  backdrop-filter: blur(20px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 30px rgba(79, 227, 255, 0.08);
  max-width: calc(100vw - 40px);
  width: 720px;
}

.cmd-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cmd-btn:hover {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  box-shadow: 0 0 16px var(--neon-glow-cyan);
}

.cmd-btn.active {
  background: var(--neon-cyan);
  border-color: var(--neon-cyan);
  color: var(--bg-deep);
  box-shadow: 0 0 20px var(--neon-glow-cyan);
}

.cmd-btn.recording {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
  animation: pulseRed 1s ease-in-out infinite;
}

@keyframes pulseRed {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 92, 122, 0.6); }
  50% { box-shadow: 0 0 0 12px rgba(255, 92, 122, 0); }
}

.cmd-send {
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-blue));
  border-color: transparent;
  color: var(--bg-deep);
  box-shadow: 0 0 20px var(--neon-glow-cyan);
}

/* STOP butonu — ReX konusurken gosterilir */
.cmd-stop {
  background: linear-gradient(135deg, var(--neon-pink), var(--danger));
  border-color: transparent;
  color: white;
  box-shadow: 0 0 20px rgba(255, 92, 122, 0.5);
  animation: pulseStop 1.2s ease-in-out infinite;
}

@keyframes pulseStop {
  0%, 100% { box-shadow: 0 0 20px rgba(255, 92, 122, 0.5); }
  50% { box-shadow: 0 0 30px rgba(255, 92, 122, 0.9), 0 0 50px rgba(182, 109, 255, 0.5); }
}

/* Conversation mode butonu — aktifken nabız efektli */
#convoBtn.active {
  background: var(--neon-purple);
  border-color: var(--neon-purple);
  color: var(--bg-deep);
  box-shadow: 0 0 20px var(--neon-glow-purple);
  animation: pulseConvo 2s ease-in-out infinite;
}

@keyframes pulseConvo {
  0%, 100% { box-shadow: 0 0 20px var(--neon-glow-purple); }
  50% { box-shadow: 0 0 35px var(--neon-glow-purple), 0 0 60px rgba(79, 227, 255, 0.3); }
}

/* TTS Backend Badge (ElevenLabs / edge-tts gosterir) */
.tts-badge {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  backdrop-filter: blur(10px);
  color: var(--text-muted);
  margin-left: auto;
  margin-right: 10px;
  display: none;
}

.tts-badge.elevenlabs {
  display: inline-block;
  color: var(--neon-purple);
  border-color: rgba(182, 109, 255, 0.4);
  box-shadow: 0 0 10px rgba(182, 109, 255, 0.15);
}

.tts-badge.edge {
  display: inline-block;
  color: var(--neon-cyan);
  border-color: rgba(79, 227, 255, 0.3);
}

/* ============================================================
   Language toggle (TR / EN)
   ============================================================ */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  backdrop-filter: blur(10px);
  cursor: pointer;
  margin-right: 8px;
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 1.2px;
  user-select: none;
}

.lang-toggle .lang-opt {
  padding: 5px 10px;
  border-radius: 16px;
  color: var(--text-dim);
  transition: all 0.2s;
}

.lang-toggle .lang-opt.active {
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-blue));
  color: var(--bg-deep);
  box-shadow: 0 0 12px var(--neon-glow-cyan);
  font-weight: 600;
}

.lang-toggle:hover { border-color: var(--neon-cyan); }

.cmd-send:hover {
  transform: scale(1.05);
  box-shadow: 0 0 30px var(--neon-glow-cyan), 0 0 60px var(--neon-glow-purple);
  color: var(--bg-deep);
}

.cmd-send:disabled {
  background: var(--border);
  color: var(--text-dim);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 12px;
}

#input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  resize: none;
  max-height: 120px;
  min-height: 24px;
  padding: 10px 4px;
  line-height: 1.4;
}

#input::placeholder {
  color: var(--text-dim);
  font-style: italic;
}

/* Focus glow on bar */
.command-bar:focus-within {
  border-color: var(--neon-cyan);
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.5),
    0 0 40px rgba(79, 227, 255, 0.25);
}

/* ============================================================
   Footer status text
   ============================================================ */
.footer-info {
  position: fixed;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  z-index: 14;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-family: var(--font-display);
}

/* ============================================================
   Error states
   ============================================================ */
.error-banner {
  background: rgba(255, 92, 122, 0.1);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin: 10px 0;
}

/* ============================================================
   Custom scrollbar
   ============================================================ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(79, 227, 255, 0.2);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(79, 227, 255, 0.4);
}

/* ============================================================
   Responsive (mobile / small screens)
   ============================================================ */
@media (max-width: 720px) {
  /* Topbar daha kompakt — kucuk ekranlarda ikonlar daralir */
  .topbar { padding: 10px 12px; }
  .topbar-actions { gap: 6px; }
  .topbar-btn, .status { width: 34px; height: 34px; }
  .lang-toggle { padding: 4px 6px; gap: 4px; font-size: 11px; }

  .stage {
    padding: 72px 16px 140px;
  }
  .avatar-wrap {
    width: 220px;
    height: 220px;
  }
  .avatar {
    width: 150px;
    height: 150px;
  }
  .state-text {
    font-size: 12px;
    letter-spacing: 2px;
    margin-top: 48px;
  }
  .response-preview {
    font-size: 15px;
    max-height: 58vh;
    padding: 8px 14px;
  }
  .stage.active .response-preview { max-height: none; }
  .stage.active .avatar-wrap { width: 140px; height: 140px; }
  .stage.active .avatar-wrap .avatar { width: 95px; height: 95px; }
  .command-bar {
    bottom: 16px;
    width: calc(100vw - 20px);
    padding: 8px;
    gap: 6px;
  }
  .cmd-btn {
    width: 40px;
    height: 40px;
  }
  #input { font-size: 14px; }
  .history-panel { width: 100vw; right: -100vw; }
  .history-panel.open { right: 0; }
  .suggestions { gap: 6px; margin-top: 20px; }
  .chip { padding: 7px 14px; font-size: 12px; }
}

/* Avatar chat active iken daha kucuk + yukarida, preview alani buyusun */
.stage.active .avatar-wrap {
  width: 180px;
  height: 180px;
  margin-bottom: 0;
}
.stage.active .avatar-wrap .avatar {
  width: 120px;
  height: 120px;
}
.stage.active .wave-bars {
  bottom: -30px;
  height: 26px;
}
.stage.active .wave-bars span { width: 3px; }
.stage.active .state-text {
  margin-top: 44px;
  font-size: 12px;
  letter-spacing: 2px;
}
.stage.active .response-preview {
  flex: 1;
  max-height: none;
  margin-top: 16px;
}
.stage.active .tool-activity {
  margin-top: 10px;
  order: -1;  /* tool chips response'un ustunde dursun */
}
