:root {
  --bg: #0b1020;
  --surface: #11182b;
  --surface-strong: #17213a;
  --surface-muted: #1d2945;
  --border: #2c3858;
  --accent: #5eead4;
  --accent-strong: #2dd4bf;
  --accent-soft: rgba(94, 234, 212, 0.14);
  --text: #eef4ff;
  --muted: #9aa8c7;
  --danger: #fb7185;
  --warning: #fbbf24;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
  --radius: 18px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(94, 234, 212, 0.16), transparent 32rem),
    radial-gradient(circle at bottom right, rgba(59, 130, 246, 0.12), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
}

button,
input,
pre,
summary {
  font: inherit;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar,
.workspace,
.url-row,
.auth-actions,
.row-heading,
.drawer-header,
.modal-header {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #60a5fa);
  color: #06111f;
  font-weight: 800;
  letter-spacing: -0.05em;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.2;
}

h2 {
  font-size: 20px;
  line-height: 1.35;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.muted,
.empty-state {
  color: var(--muted);
  line-height: 1.7;
}

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

.auth-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.status-banner,
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(17, 24, 43, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.status-banner {
  margin-bottom: 18px;
  padding: 12px 16px;
  color: var(--muted);
}

.status-banner.success {
  color: var(--accent);
  border-color: rgba(94, 234, 212, 0.38);
}

.status-banner.error {
  color: var(--danger);
  border-color: rgba(251, 113, 133, 0.38);
}

.workspace {
  align-items: stretch;
  gap: 18px;
}

.main-column {
  display: grid;
  flex: 1 1 auto;
  gap: 18px;
  min-width: 0;
}

.card {
  padding: 22px;
}

.hero-card {
  display: grid;
  gap: 16px;
}

.url-row {
  gap: 10px;
}

.url-row input,
.auth-form input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-muted);
  color: var(--text);
  outline: none;
  padding: 13px 14px;
}

.url-row input:focus,
.auth-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn,
.icon-btn {
  border: 0;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 700;
  white-space: nowrap;
}

.btn:hover:not(:disabled),
.icon-btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.btn-primary {
  background: var(--accent);
  color: #06111f;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

.btn-secondary,
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled),
.btn-ghost:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.btn-small {
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
}

.model-status {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.03);
}

.section-heading {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
}

.row-heading {
  justify-content: space-between;
  gap: 12px;
}

.history-sidebar {
  display: none;
  flex: 0 0 340px;
  max-height: calc(100vh - 146px);
  overflow: auto;
}

.history-sidebar.is-open {
  display: block;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  display: grid;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.history-item-body {
  min-width: 0;
}

.history-item strong {
  display: block;
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}

.history-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-actions .btn {
  flex: 1 1 auto;
}

.history-delete-btn {
  color: var(--danger);
}

.history-delete-btn:hover:not(:disabled) {
  border-color: rgba(251, 113, 133, 0.52);
  background: rgba(251, 113, 133, 0.12);
}

.drawer,
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  background: rgba(2, 6, 23, 0.58);
}

.drawer.is-open,
.modal.is-open {
  display: block;
}

.drawer-panel,
.modal-card {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.drawer-panel {
  width: min(440px, 92vw);
  height: 100%;
  margin-left: auto;
  padding: 22px;
}

.drawer-body {
  display: grid;
  gap: 18px;
}

.modal {
  place-items: center;
}

.modal.is-open {
  display: grid;
}

.modal-card {
  width: min(420px, calc(100vw - 32px));
  border-radius: var(--radius);
  padding: 22px;
}

.drawer-header,
.modal-header {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 22px;
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-actions {
  gap: 10px;
  margin-top: 8px;
}

.form-message {
  min-height: 22px;
  color: var(--muted);
}

.settings-grid {
  display: grid;
  gap: 8px;
}

.settings-grid label {
  color: var(--muted);
  font-weight: 700;
}

.settings-grid input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-muted);
  color: var(--text);
  outline: none;
  padding: 11px 12px;
}

.settings-grid input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.progress-track {
  width: 100%;
  height: 10px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-muted);
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #60a5fa);
  transition: width 0.2s ease;
}

.progress-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.task-status-card {
  display: grid;
  gap: 8px;
}

.task-log {
  margin-top: 8px;
}

.task-log ul {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.task-log span {
  margin-right: 8px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.summary-text {
  margin: 10px 0 16px;
  color: var(--text);
  line-height: 1.8;
}

.result-content {
  display: grid;
  gap: 14px;
}

.analysis-result,
.segment-card {
  display: grid;
  gap: 10px;
}

.segment-card {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
}

pre {
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #070b16;
  color: var(--text);
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

details {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
}

summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 800;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 920px) {
  .workspace,
  .topbar,
  .url-row {
    flex-direction: column;
    align-items: stretch;
  }

  .history-sidebar {
    flex-basis: auto;
    max-height: none;
  }

  .topbar-actions {
    justify-content: space-between;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 14px;
  }

  .brand {
    align-items: flex-start;
  }

  .card,
  .drawer-panel,
  .modal-card {
    padding: 16px;
  }

  .auth-actions,
  .topbar-actions {
    flex-direction: column;
    align-items: stretch;
  }
}
