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

:root, [data-theme="dark"] {
  --bg: #0a0a0a;
  --surface: #151515;
  --border: #2a2a2a;
  --text: #e5e5e5;
  --text-muted: #a0a0a0;
  --accent: #5ba3ff;
  --accent-hover: #78b4ff;
  --success: #34d399;
  --error: #f87171;
  --warning: #fbbf24;
  --focus: #5ba3ff;
  --topbar-bg: #000;
  --footer-bg: #000;
  --terminal-bg: #050505;
  --status-connected-bg: #091a09;
  --status-connected-border: #1a3a1a;
  --status-disconnected-bg: #1a0909;
  --status-disconnected-border: #3a1a1a;
}

[data-theme="light"] {
  --bg: #f5f5f5;
  --surface: #fff;
  --border: #d4d4d4;
  --text: #1a1a1a;
  --text-muted: #555;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --success: #16a34a;
  --error: #dc2626;
  --warning: #d97706;
  --focus: #2563eb;
  --topbar-bg: #fff;
  --footer-bg: #fff;
  --terminal-bg: #fff;
  --status-connected-bg: #dcfce7;
  --status-connected-border: #bbf7d0;
  --status-disconnected-bg: #fee2e2;
  --status-disconnected-border: #fecaca;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  height: 2.75rem;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
}

.logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  overflow: hidden;
}
.logo:hover { opacity: 0.8; text-decoration: none; }

.logo-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  animation: logo-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.logo-text {
  display: inline-block;
  animation: logo-slide 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}

@keyframes logo-pop {
  from { transform: scale(0) rotate(-20deg); opacity: 0; }
  to { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes logo-slide {
  from { transform: translateX(-1rem); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.topbar-right svg { opacity: 0.7; transition: opacity 0.15s; }
.topbar-right a:hover svg { opacity: 1; }

#theme-select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.2rem 0.4rem;
  font-size: 0.75rem;
  cursor: pointer;
  outline: none;
}
#theme-select:focus-visible { border-color: var(--focus); }

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.content {
  max-width: 40rem;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  width: 100%;
}

h1 { font-size: 1.75rem; margin-bottom: 0.5rem; color: var(--text); }
h2 { font-size: 1.1rem; margin: 1.75rem 0 0.5rem; color: var(--text); }

p { color: var(--text-muted); line-height: 1.6; margin-bottom: 1rem; }

pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  color: var(--text);
}

code { font-family: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace; }

.code-block { position: relative; }
.code-block pre { margin-bottom: 1rem; padding-right: 3rem; }
.copy-btn {
  position: absolute; top: 0.5rem; right: 0.5rem;
  background: var(--border); border: none; border-radius: 4px;
  color: var(--text-muted); cursor: pointer; padding: 0.35rem 0.5rem;
  font-size: 0.75rem; line-height: 1;
  display: flex; align-items: center; gap: 0.3rem;
}
.copy-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.copy-btn:hover { color: var(--text); background: var(--accent); }
p code { background: var(--surface); border: 1px solid var(--border); border-radius: 3px; padding: 0.15rem 0.35rem; font-size: 0.85em; }
kbd { background: var(--surface); border: 1px solid var(--border); border-radius: 3px; padding: 0.1rem 0.4rem; font-size: 0.85em; font-family: inherit; }

.steps { display: flex; flex-direction: column; gap: 0.75rem; margin: 0.75rem 0 1rem; }
.step { display: flex; align-items: flex-start; gap: 0.75rem; }
.step-num {
  flex-shrink: 0;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.1rem;
}
.step div { color: var(--text-muted); line-height: 1.5; }
.step strong { color: var(--text); }

.warning {
  background: var(--surface);
  border: 1px solid var(--warning);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  color: var(--text);
}

form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

label {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

input[type="text"] {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.6rem 0.75rem;
  color: var(--text);
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s;
}

input[type="text"]::placeholder {
  color: #666;
}

input[type="text"]:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 1px var(--focus);
}

button[type="submit"] {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0.6rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  align-self: flex-end;
  margin-top: 0.75rem;
  transition: background 0.15s;
}

button[type="submit"]:hover { background: var(--accent-hover); }
button[type="submit"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

#terminal-view {
  display: flex;
  flex-direction: column;
  padding: 0;
  gap: 0;
  flex: 1;
  overflow: hidden;
}

#terminal-row {
  display: flex;
  flex: 1;
  gap: 0;
  overflow: hidden;
  background: var(--terminal-bg);
}

#terminal {
  padding: 0.5rem;
  background: var(--terminal-bg);
  flex: 1;
  min-width: 0;
  overflow: auto;
}

#bottombar {
  border-top: 1px solid var(--border);
}

#status-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 1rem;
  font-size: 0.75rem;
  gap: 1.5rem;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
}

#status-bar .status-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

#status-bar .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

#status-bar { background: var(--surface); border-top: 1px solid var(--border); }

.footer-links {
  display: flex;
  justify-content: center;
  padding: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--footer-bg);
}

#toast-container {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 1000;
  max-width: 24rem;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--text);
  animation: toast-in 0.2s ease;
  cursor: pointer;
}

.toast:hover { opacity: 0.8; }

#live-sessions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.session-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}

.session-card:hover {
  border-color: var(--accent);
  background: var(--bg);
  text-decoration: none;
}

.session-name {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.25rem;
  color: var(--accent);
}

.session-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
}

.no-sessions {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
}

#live-count {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 400;
}

.hero {
  text-align: center;
  margin-bottom: 1.5rem;
}

.hero-logo-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.hero-icon {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  animation: hero-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -1px;
  font-family: 'Inter', 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
  animation: hero-slide 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.25s both;
}

.hero-tagline {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 32rem;
  margin: 0 auto 1rem;
  animation: hero-fade 0.6s ease 0.5s both;
}

@keyframes hero-pop {
  from { transform: scale(0) rotate(-20deg); opacity: 0; }
  to { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes hero-slide {
  from { transform: translateX(-1.5rem); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes hero-fade {
  from { transform: translateY(0.5rem); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

.feature-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
}

.feature-list li {
  color: var(--text-muted);
  line-height: 1.5;
  padding-left: 1.25rem;
  position: relative;
}

.feature-list li::before {
  content: "\2713";
  position: absolute;
  left: 0;
  color: var(--success);
  font-weight: 700;
}

.learn-more {
  text-align: center;
  margin-top: 1rem;
}

.callout {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-top: 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

#chat-bar {
  display: none;
  width: 320px;
  min-width: 320px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
#chat-bar:hover { color: var(--text); }
#chat-bar svg { width: 16px; height: 16px; flex-shrink: 0; }

#chat-badge {
  background: var(--error);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  margin-left: 0.25rem;
}

#chat-sidebar {
  width: 320px;
  min-width: 320px;
  flex-shrink: 0;
  background: var(--bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.chat-minimize {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
}
.chat-minimize:hover { color: var(--text); }

#chat-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-weight: 600;
  font-size: 0.9rem;
}

#chat-header span:first-child { flex-shrink: 0; }

#chat-name {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--accent);
  font-size: 0.8rem;
  padding: 0.2rem 0.4rem;
  text-align: right;
  outline: none;
  font-family: inherit;
}
#chat-name:hover { border-color: var(--border); }
#chat-name:focus { border-color: var(--accent); }

#chat-header button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
}
#chat-header button:hover { color: var(--text); }

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-msg {
  max-width: 85%;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  line-height: 1.4;
  word-break: break-word;
}

.chat-sender {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.15rem;
}

.chat-text { color: var(--text); }

.chat-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.chat-msg.self {
  align-self: flex-end;
  border-color: var(--accent);
}
.chat-msg.self .chat-sender { color: var(--success); }

.chat-system {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 0.25rem 0;
}

#chat-form {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  align-items: center;
}

#chat-input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
}
#chat-input:focus { border-color: var(--accent); }

#chat-form button[type="submit"] {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  align-self: auto;
  margin-top: 0;
}
#chat-form button[type="submit"] svg { width: 16px; height: 16px; }
#chat-form button[type="submit"]:hover { background: var(--accent-hover); }

.disclaimer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1.5rem;
  font-style: italic;
}

#session-banner {
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  flex-shrink: 0;
}
#session-banner.ended {
  background: var(--status-disconnected-bg);
  border-bottom: 1px solid var(--status-disconnected-border);
  color: var(--error);
}
#session-banner.waiting {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--warning);
}
#session-banner.connected {
  background: var(--status-connected-bg);
  border-bottom: 1px solid var(--status-connected-border);
  color: var(--success);
}

@media (max-width: 768px) {
  #terminal-view { flex-direction: column; }
  #terminal { max-width: 100vw; overflow: hidden; }
  #chat-sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    height: 50vh;
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
    z-index: 100;
    animation: chat-slide-up 0.2s ease;
  }
  #chat-sidebar[style*="display: none"] ~ #chat-bar { display: flex; }

  @keyframes chat-slide-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  #chat-bar {
    position: fixed;
    width: 100%;
    min-width: 100%;
    left: 0;
    bottom: 0;
    border-radius: 0;
    border: none;
    border-top: 1px solid var(--border);
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    justify-content: center;
    z-index: 99;
  }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(0.5rem); }
  to { opacity: 1; transform: translateY(0); }
}
