:root {
  --color-primary: #6366f1;
  --color-primary-2: #4f46e5;
  --color-bg: #ffffff;
  --color-surface: #f8fafc;
  --color-surface-2: #ffffff;
  --color-text: #0f172a;
  --color-text-secondary: #475569;
  --color-border: #e2e8f0;
  --color-danger: #ef4444;
  --color-success: #16a34a;
  --radius: 0.75rem;
  --shadow: 0 1px 3px rgba(0,0,0,0.12);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.12);
}

[data-theme="dark"] {
  --color-bg: #0b1220;
  --color-surface: #111c33;
  --color-surface-2: #0f172a;
  --color-text: #f1f5f9;
  --color-text-secondary: #a3b3c7;
  --color-border: #22314f;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--color-bg);
  color: var(--color-text);
}

a { color: inherit; text-decoration: none; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-2));
  box-shadow: var(--shadow);
}

.brand-title {
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}

.main {
  padding-top: 72px; /* topbar height */
  padding-bottom: 72px; /* bottombar height */
}

.bottombar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--color-surface-2);
  border-top: 1px solid var(--color-border);
}

.bottombar-inner {
  display: flex;
  justify-content: space-around;
  gap: 0.5rem;
  padding: 0.5rem;
}

.navlink {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-width: 72px;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  transition: all 0.15s ease;
  color: var(--color-text-secondary);
}

.navlink:hover { background: rgba(99, 102, 241, 0.10); color: var(--color-text); }
.navlink.active { background: rgba(99, 102, 241, 0.16); color: var(--color-text); border: 1px solid rgba(99, 102, 241, 0.25); }

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 900px) {
  .grid { grid-template-columns: 1.2fr 0.8fr; }
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.card h2 {
  margin: 0 0 0.25rem 0;
  font-size: 1.25rem;
}

.muted { color: var(--color-text-secondary); }
.small { font-size: 0.875rem; }

.row { display: flex; gap: 0.75rem; flex-wrap: wrap; }

.btn {
  appearance: none;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  border-radius: 14px;
  padding: 0.75rem 1rem;
  min-height: 44px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow);
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.btn:active { transform: translateY(0px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: var(--shadow); }

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-2));
  border-color: rgba(255,255,255,0.15);
  color: white;
}

.btn-danger { border-color: rgba(239,68,68,0.35); color: var(--color-danger); }

.input, select, textarea {
  width: 100%;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
  min-height: 44px;
  outline: none;
  transition: all 0.15s ease;
}

.input:focus, select:focus, textarea:focus {
  border-color: rgba(99,102,241,0.55);
  box-shadow: 0 0 0 4px rgba(99,102,241,0.18);
}

label { display: block; font-size: 0.875rem; color: var(--color-text-secondary); margin-bottom: 0.35rem; }

.hr { height: 1px; background: var(--color-border); margin: 1rem 0; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  font-size: 0.875rem;
}

.pill.good { border-color: rgba(22,163,74,0.35); }
.pill.warn { border-color: rgba(239,68,68,0.35); }

.kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.8rem;
  padding: 0.15rem 0.35rem;
  border: 1px solid var(--color-border);
  border-bottom-width: 2px;
  border-radius: 8px;
  background: var(--color-surface-2);
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid rgba(148,163,184,0.35);
  border-top-color: var(--color-primary);
  animation: spin 0.8s linear infinite;
}

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

.toast-wrap {
  position: fixed;
  right: 12px;
  top: 84px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  width: min(360px, calc(100vw - 24px));
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 0.75rem 0.9rem;
}

.toast-title { font-weight: 700; margin-bottom: 0.2rem; }

.video {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: #000;
}

.preview-img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  display: block;
}

.chat {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 360px;
  overflow: auto;
  padding-right: 0.25rem;
}

.bubble {
  max-width: 92%;
  padding: 0.65rem 0.75rem;
  border-radius: 14px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
}

.bubble.user { margin-left: auto; border-color: rgba(99,102,241,0.35); }
.bubble.assistant { margin-right: auto; }

.typing {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th, .table td {
  text-align: left;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.95rem;
}

.table th { color: var(--color-text-secondary); font-weight: 600; }

.notice {
  border-left: 4px solid rgba(99,102,241,0.7);
  padding: 0.75rem 0.9rem;
  background: rgba(99,102,241,0.08);
  border-radius: 12px;
}

.danger {
  border-left: 4px solid rgba(239,68,68,0.7);
  background: rgba(239,68,68,0.08);
}

.success {
  border-left: 4px solid rgba(22,163,74,0.7);
  background: rgba(22,163,74,0.08);
}
