/* ==========================================================================
   CATO — Design System
   Warm editorial minimalism. Instrument Serif + Figtree + JetBrains Mono.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Custom Properties
   -------------------------------------------------------------------------- */

:root {
  /* Palette — warm stone */
  --bg: #F7F7F5;
  --surface: #FFFFFF;
  --surface-hover: #FAFAF8;
  --border: #E8E5DF;
  --border-light: #F0EDE8;

  /* Text */
  --text: #1A1918;
  --text-secondary: #706D66;
  --text-muted: #A9A69F;

  /* Accent — warm amber, used sparingly */
  --accent: #D97706;
  --accent-hover: #B45309;
  --accent-soft: #FFFBEB;

  /* Interactive — near-black */
  --interactive: #1A1918;
  --interactive-hover: #3D3B37;

  /* Status */
  --status-pending-bg: #FEF7ED;
  --status-pending: #92600E;
  --status-provisioning-bg: #EFF6FF;
  --status-provisioning: #1E40AF;
  --status-running-bg: #ECFDF5;
  --status-running: #065F46;
  --status-completed-bg: #F0FDF4;
  --status-completed: #166534;
  --status-failed-bg: #FEF2F2;
  --status-failed: #991B1B;
  --status-cancelled-bg: #F5F5F4;
  --status-cancelled: #57534E;

  /* Feedback */
  --success-bg: #F0FDF4;
  --success: #166534;
  --success-border: #BBF7D0;
  --error-bg: #FEF2F2;
  --error: #991B1B;
  --error-border: #FECACA;

  /* Event types */
  --event-assistant: #7C3AED;
  --event-tool_use: #2563EB;
  --event-tool_result: #059669;
  --event-result: #166534;
  --event-error: #DC2626;
  --event-system: #78716C;

  /* Layout */
  --sidebar-w: 240px;
  --content-max-w: 960px;
  --form-max-w: 480px;
  --auth-card-w: 400px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Transitions */
  --speed: 150ms;
  --ease: ease;
}


/* --------------------------------------------------------------------------
   2. Reset & Base
   -------------------------------------------------------------------------- */

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: "Figtree", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--text);
  text-decoration: none;
  transition: color var(--speed) var(--ease);
}

a:hover {
  color: var(--text-secondary);
}

img, svg {
  display: inline-block;
  vertical-align: middle;
}

ul, ol {
  list-style: none;
}

code {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.9em;
  background: var(--border-light);
  padding: 2px 6px;
  border-radius: 4px;
}

::selection {
  background: var(--accent);
  color: white;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}


/* --------------------------------------------------------------------------
   3. Typography
   -------------------------------------------------------------------------- */

h1, h2, h3 {
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-title-sub {
  font-weight: 400;
  color: var(--text-secondary);
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
}

.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-error { color: var(--error); }


/* --------------------------------------------------------------------------
   4. Layout — App Shell (authenticated)
   -------------------------------------------------------------------------- */

.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.main-content {
  padding: 40px 48px;
  max-width: calc(var(--content-max-w) + 96px);
  width: 100%;
  animation: fadeIn 0.2s ease-out;
}

.sidebar-toggle {
  display: none;
}


/* --------------------------------------------------------------------------
   5. Layout — Auth (unauthenticated)
   -------------------------------------------------------------------------- */

.auth-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 20px;
  background: var(--bg);
}

.auth-container {
  width: 100%;
  max-width: var(--auth-card-w);
  animation: fadeIn 0.3s ease-out;
}

.auth-brand {
  text-align: center;
  margin-bottom: 40px;
}

.auth-brand-link {
  text-decoration: none;
}

.auth-brand-link:hover {
  color: var(--text);
}

.auth-brand-name {
  font-family: "Instrument Serif", Georgia, serif;
  font-style: italic;
  font-size: 32px;
  color: var(--text);
  letter-spacing: -0.02em;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
}

.auth-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 24px;
  text-align: center;
}

.auth-subtitle {
  color: var(--text-secondary);
  text-align: center;
  margin-top: -16px;
  margin-bottom: 24px;
  font-size: 14px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 24px 0;
  color: var(--text-muted);
  font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-legal {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 12px;
  line-height: 1.5;
}

.auth-legal a {
  color: var(--text-secondary);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 2px;
}

.auth-legal a:hover {
  color: var(--text);
  text-decoration-color: var(--text-muted);
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-footer a {
  color: var(--text-secondary);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
}

.auth-footer a:hover {
  color: var(--text);
  text-decoration-color: var(--text-muted);
}


/* --------------------------------------------------------------------------
   6. Layout — Onboarding
   -------------------------------------------------------------------------- */

.onboarding-layout {
  max-width: 520px;
  margin: 0 auto;
  padding: 60px 20px;
  animation: fadeIn 0.3s ease-out;
}

.onboarding-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 40px;
}

.onboarding-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color var(--speed) var(--ease);
}

.onboarding-step.current {
  color: var(--text);
}

.onboarding-step.completed {
  color: var(--accent);
}

.onboarding-step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  transition: all var(--speed) var(--ease);
}

.onboarding-step.current .onboarding-step-number {
  border-color: var(--text);
  color: var(--text);
  background: var(--surface);
}

.onboarding-step.completed .onboarding-step-number {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.onboarding-step-separator {
  width: 32px;
  height: 1px;
  background: var(--border);
}

.onboarding-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  text-align: center;
}

.onboarding-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 12px;
}

.onboarding-description {
  color: var(--text-secondary);
  margin-bottom: 28px;
  line-height: 1.6;
  font-size: 14px;
}

.onboarding-empty {
  color: var(--text-muted);
  font-size: 14px;
  padding: 20px 0;
}


/* --------------------------------------------------------------------------
   7. Sidebar
   -------------------------------------------------------------------------- */

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 0 8px;
  margin-bottom: 32px;
}

.sidebar-brand-link {
  text-decoration: none;
}

.sidebar-brand-link:hover {
  color: var(--text);
}

.sidebar-brand-name {
  font-family: "Instrument Serif", Georgia, serif;
  font-style: italic;
  font-size: 22px;
  color: var(--text);
  letter-spacing: -0.02em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 450;
  color: var(--text-secondary);
  transition: all var(--speed) var(--ease);
  text-decoration: none;
  position: relative;
}

.sidebar-link:hover {
  color: var(--text);
  background: var(--border-light);
}

.sidebar-link.active {
  color: var(--text);
  background: var(--border-light);
  font-weight: 550;
}

.sidebar-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 16px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.sidebar-link svg {
  opacity: 0.6;
  flex-shrink: 0;
}

.sidebar-link.active svg,
.sidebar-link:hover svg {
  opacity: 1;
}

.sidebar-footer {
  padding: 16px 12px 0;
  border-top: 1px solid var(--border-light);
  margin-top: auto;
}

.sidebar-user-email {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-logout {
  font-size: 13px;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  transition: color var(--speed) var(--ease);
}

.sidebar-logout:hover {
  color: var(--text);
}

.sidebar-overlay {
  display: none;
}


/* --------------------------------------------------------------------------
   8. Components — Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--interactive);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 550;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--speed) var(--ease);
  text-decoration: none;
  line-height: 1.4;
}

.btn:hover {
  background: var(--interactive-hover);
  color: white;
}

.btn:active {
  transform: scale(0.98);
}

.btn-full {
  width: 100%;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--text-muted);
}

.btn-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 10px 20px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--speed) var(--ease);
}

.btn-google:hover {
  background: var(--surface-hover);
  border-color: var(--text-muted);
}

.btn-google:active {
  transform: scale(0.98);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
  transition: color var(--speed) var(--ease);
}

.btn-ghost:hover {
  color: var(--text);
  text-decoration-color: var(--text-muted);
}

.btn-danger-text {
  color: var(--error);
  text-decoration-color: var(--error-border);
}

.btn-danger-text:hover {
  color: var(--error);
  text-decoration-color: var(--error);
}


/* --------------------------------------------------------------------------
   9. Components — Forms
   -------------------------------------------------------------------------- */

.form-narrow {
  max-width: var(--form-max-w);
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 550;
  margin-bottom: 6px;
  color: var(--text);
}

.form-input,
.form-select,
.form-textarea {
  display: block;
  width: 100%;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  transition: border-color var(--speed) var(--ease),
              box-shadow var(--speed) var(--ease);
  -webkit-appearance: none;
  appearance: none;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' fill='none' stroke='%23706D66' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.6;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-hint {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}

.form-errors {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.5;
}

.form-errors p {
  margin: 0;
}

.form-errors p + p {
  margin-top: 4px;
}

.form-errors ul {
  margin: 0;
  padding-left: 18px;
}

.form-errors li {
  list-style: disc;
}

.form-errors li + li {
  margin-top: 4px;
}

.form-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex-shrink: 0;
  margin-top: 2px;
}

.auth-method-options {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.auth-method-option {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--speed) var(--ease);
}

.auth-method-option:hover {
  border-color: var(--text-muted);
}

.auth-method-option:has(input:checked) {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-soft);
}

.auth-method-option input[type="radio"] {
  accent-color: var(--accent);
  margin: 0;
}


/* --------------------------------------------------------------------------
   10. Components — Tables
   -------------------------------------------------------------------------- */

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

.table th {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-align: left;
  padding: 8px 16px 12px 0;
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 14px 16px 14px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
  vertical-align: middle;
}

.table tbody tr {
  transition: background var(--speed) var(--ease);
}

.table tbody tr:hover {
  background: var(--surface-hover);
}

.table td:last-child,
.table th:last-child {
  padding-right: 0;
}

.table td a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.table td a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}


/* --------------------------------------------------------------------------
   11. Components — Badges
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.4;
}

.badge-pending {
  background: var(--status-pending-bg);
  color: var(--status-pending);
}

.badge-provisioning {
  background: var(--status-provisioning-bg);
  color: var(--status-provisioning);
}

.badge-running {
  background: var(--status-running-bg);
  color: var(--status-running);
}

.badge-completed {
  background: var(--status-completed-bg);
  color: var(--status-completed);
}

.badge-failed {
  background: var(--status-failed-bg);
  color: var(--status-failed);
}

.badge-cancelled {
  background: var(--status-cancelled-bg);
  color: var(--status-cancelled);
}

.badge-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 2s ease-in-out infinite;
}


/* --------------------------------------------------------------------------
   12. Components — Toast Notifications
   -------------------------------------------------------------------------- */

.toast-container {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: min(420px, calc(100vw - 40px));
}

.toast {
  position: relative;
  padding: 14px 40px 14px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  pointer-events: auto;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  opacity: 0;
  transform: translateX(-24px);
  transition: none;
}

.toast-visible {
  animation: toast-enter 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.toast-exit {
  animation: toast-leave 0.25s ease-in forwards;
}

@keyframes toast-enter {
  from {
    opacity: 0;
    transform: translateX(-24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toast-leave {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(-24px);
  }
}

/* Progress bar — animates the remaining time */
.toast::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 100%;
  transform-origin: left;
  animation: toast-progress var(--toast-duration, 5000ms) linear forwards;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

@keyframes toast-progress {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

.toast-notice {
  background: var(--surface);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.toast-notice::after {
  background: var(--success);
}

.toast-alert {
  background: var(--surface);
  color: var(--error);
  border: 1px solid var(--error-border);
}

.toast-alert::after {
  background: var(--error);
}

.toast-close {
  position: absolute;
  top: 0;
  right: 0;
  width: 36px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: inherit;
  opacity: 0.5;
  cursor: pointer;
  padding: 0;
  transition: opacity 0.15s;
}

.toast-close:hover {
  opacity: 1;
}


/* --------------------------------------------------------------------------
   13. Page Header
   -------------------------------------------------------------------------- */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 32px;
}

.page-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header-left #session_status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-stop {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error-border);
  font-size: 13px;
  padding: 6px 14px;
}

.btn-stop:hover {
  background: var(--error);
  color: white;
  border-color: var(--error);
}

.page-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  transition: color var(--speed) var(--ease);
}

.page-back:hover {
  color: var(--text);
}

.page-back svg {
  flex-shrink: 0;
}


/* --------------------------------------------------------------------------
   14. Page — Sessions List
   -------------------------------------------------------------------------- */

.session-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.session-card {
  display: block;
  padding: 16px 20px;
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  transition: background var(--speed) var(--ease);
}

.session-card:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.session-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.session-card-header .badge {
  margin-left: auto;
  flex-shrink: 0;
}

.session-card-title {
  font-size: 14px;
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.session-card-issue-title {
  font-weight: 400;
  color: var(--text-secondary);
}

.session-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.session-card-time {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.session-card-activity {
  margin-top: 8px;
  font-size: 12px;
  font-family: "JetBrains Mono", monospace;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state-icon {
  color: var(--text-muted);
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state p {
  margin-bottom: 24px;
  font-size: 14px;
}


/* --------------------------------------------------------------------------
   15. Page — Session Detail
   -------------------------------------------------------------------------- */

.session-meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 32px;
}

.session-meta-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
}

.session-meta-value {
  font-size: 14px;
  color: var(--text);
}

.session-meta-value a {
  color: var(--accent);
  font-weight: 500;
}

.session-meta-value a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.session-prompt {
  margin-bottom: 32px;
}

.session-prompt-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  color: var(--text-secondary);
}


/* --------------------------------------------------------------------------
   16. Events Feed
   -------------------------------------------------------------------------- */

.events-section {
  margin-top: 8px;
}

.events-container {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-height: 600px;
  overflow-y: auto;
  background: var(--surface);
}

.events-empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.events-container:has(.event) .events-empty {
  display: none;
}

.event {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-light);
  animation: eventSlideIn 0.25s ease-out;
}

.event:last-child {
  border-bottom: none;
}

.event-indicator {
  width: 3px;
  flex-shrink: 0;
  border-radius: 0;
}

.event-indicator-assistant { background: var(--event-assistant); }
.event-indicator-tool_use  { background: var(--event-tool_use); }
.event-indicator-tool_result { background: var(--event-tool_result); }
.event-indicator-result    { background: var(--event-result); }
.event-indicator-error     { background: var(--event-error); }
.event-indicator-system    { background: var(--event-system); }

.event-body {
  flex: 1;
  padding: 8px 14px;
  min-width: 0;
}

.event-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.event-type {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.event-time {
  font-size: 12px;
  color: var(--text-muted);
  font-family: "JetBrains Mono", monospace;
  font-variant-numeric: tabular-nums;
}

.event-content {
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

.events-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 8px 16px;
  background: var(--border-light);
  border: none;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}

.events-toggle[hidden] {
  display: none;
}

.events-toggle:hover {
  background: var(--border);
  color: var(--text-secondary);
}

.events-toggle [data-role="icon"] {
  font-size: 9px;
}

.event[hidden] {
  display: none;
}


/* --------------------------------------------------------------------------
   17. Page — Settings
   -------------------------------------------------------------------------- */

.settings-section {
  margin-bottom: 40px;
}

.settings-section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 8px;
}

.settings-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  gap: 16px;
}

.settings-item + .settings-item {
  border-top: 1px solid var(--border-light);
}

.settings-item-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-item-icon {
  flex-shrink: 0;
  color: var(--text-muted);
}

.settings-item-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.settings-item-value {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.settings-item-action {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
  flex-shrink: 0;
  transition: color var(--speed) var(--ease);
}

.settings-item-action:hover {
  color: var(--text);
  text-decoration-color: var(--text-muted);
}


/* --------------------------------------------------------------------------
   18. Devices & Sessions
   -------------------------------------------------------------------------- */

.sessions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.device-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
}

.device-agent {
  font-size: 13px;
  color: var(--text);
  word-break: break-all;
}

.device-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}


/* --------------------------------------------------------------------------
   19. Repositories (onboarding)
   -------------------------------------------------------------------------- */

.repo-list-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
}

.repo-list-action-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--speed) var(--ease);
}

.repo-list-action-btn:hover {
  color: var(--text);
}

.repo-list {
  text-align: left;
  margin-bottom: 24px;
}

.repo-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: color var(--speed) var(--ease);
}

.repo-item:last-child {
  border-bottom: none;
}

.repo-item:hover {
  color: var(--text);
}

.repo-description {
  display: block;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 2px;
}


/* --------------------------------------------------------------------------
   20. Landing Page
   -------------------------------------------------------------------------- */

.landing {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 20px;
  background: var(--bg);
}

.landing-content {
  text-align: center;
  animation: fadeIn 0.4s ease-out;
}

.landing-brand {
  font-family: "Instrument Serif", Georgia, serif;
  font-style: italic;
  font-size: 72px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 16px;
}

.landing-tagline {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 40px;
  line-height: 1.5;
}

.landing-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.landing-footer {
  position: absolute;
  bottom: 32px;
  font-size: 13px;
}

.landing-footer a {
  color: var(--text-muted);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
}

.landing-footer a:hover {
  color: var(--text-secondary);
  text-decoration-color: var(--text-muted);
}

@media (max-width: 480px) {
  .landing-brand {
    font-size: 56px;
  }

  .landing-actions {
    flex-direction: column;
  }
}


/* --------------------------------------------------------------------------
   21. Prose (long-form pages)
   -------------------------------------------------------------------------- */

.prose-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 20px 80px;
  animation: fadeIn 0.3s ease-out;
}

.prose-header {
  margin-bottom: 48px;
}

.prose-brand {
  text-decoration: none;
}

.prose-brand:hover {
  color: var(--text);
}

.prose h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.prose-updated {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 40px;
}

.prose h2 {
  font-size: 16px;
  font-weight: 600;
  margin-top: 32px;
  margin-bottom: 4px;
}

.prose p {
  font-size: 14px;
  line-height: 1.75;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.prose ul {
  margin: 0 0 16px;
  padding-left: 20px;
}

.prose li {
  font-size: 14px;
  line-height: 1.75;
  color: var(--text-secondary);
  list-style: disc;
  margin-bottom: 6px;
}

.prose strong {
  color: var(--text);
  font-weight: 600;
}

.prose-license {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}


/* --------------------------------------------------------------------------
   22. Animations
   -------------------------------------------------------------------------- */

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

@keyframes eventSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}


/* --------------------------------------------------------------------------
   23. Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.08);
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.2);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .sidebar-overlay.visible {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    margin-bottom: 24px;
    transition: color var(--speed) var(--ease);
  }

  .sidebar-toggle:hover {
    color: var(--text);
  }

  .main-content {
    padding: 24px 20px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .session-meta {
    grid-template-columns: 1fr 1fr;
  }

  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .auth-card {
    padding: 24px;
  }

  .onboarding-card {
    padding: 28px 20px;
  }
}

@media (max-width: 480px) {
  .session-meta {
    grid-template-columns: 1fr;
  }

  .device-card {
    flex-direction: column;
    align-items: flex-start;
  }
}
