:root {
  color-scheme: dark;
  --bg: oklch(0.16 0.018 255);
  --bg-soft: oklch(0.2 0.02 255);
  --panel: color-mix(in oklch, var(--bg-soft) 86%, white 3%);
  --panel-strong: color-mix(in oklch, var(--bg) 70%, oklch(0.72 0.06 80) 9%);
  --line: oklch(0.35 0.024 250);
  --line-strong: oklch(0.68 0.08 82);
  --text: oklch(0.93 0.015 92);
  --muted: oklch(0.73 0.024 84);
  --accent: oklch(0.78 0.11 82);
  --accent-soft: oklch(0.42 0.06 82);
  --danger: oklch(0.66 0.18 25);
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.34);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(214, 170, 79, 0.16), transparent 28%),
    radial-gradient(circle at top right, rgba(91, 122, 173, 0.2), transparent 30%),
    linear-gradient(180deg, oklch(0.18 0.02 255), var(--bg));
  color: var(--text);
  font-family: "Manrope", sans-serif;
}

body {
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 28px;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.018)),
    rgba(8, 11, 18, 0.88);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 0 0 22px;
  font-size: clamp(2rem, 8vw, 3.5rem);
  line-height: 1;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-form label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.form-message {
  min-height: 1.3em;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.app-shell {
  width: min(1180px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.hero {
  display: grid;
  gap: 18px;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 30px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.015)),
    rgba(11, 16, 25, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.eyebrow,
.panel-kicker {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.7rem;
  color: var(--muted);
}

.hero h1,
.panel-head h2 {
  margin: 0;
  line-height: 1;
}

.hero h1 {
  font-size: clamp(2.1rem, 7vw, 4.5rem);
  letter-spacing: -0.05em;
  font-weight: 800;
}

.subtitle {
  max-width: 54ch;
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.98rem;
}

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

.hero-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status-chip {
  width: fit-content;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(217, 173, 83, 0.16);
  border: 1px solid rgba(217, 173, 83, 0.3);
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 700;
}

.status-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.status-grid span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.status-grid strong {
  font-size: 1rem;
  line-height: 1.4;
}

.layout {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.panel {
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02)),
    rgba(8, 11, 18, 0.82);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 18px 12px;
}

.console-actions,
.session-actions,
.composer-actions,
.project-actions,
.project-add {
  display: flex;
  gap: 10px;
}

.session-actions {
  padding: 0 18px 12px;
}

.list-wrap {
  display: grid;
  gap: 10px;
  padding: 0 14px 14px;
  max-height: 34vh;
  overflow: auto;
}

.list-wrap.compact {
  max-height: none;
}

.list-item {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  text-align: left;
  color: inherit;
  display: grid;
  gap: 8px;
  min-height: 56px;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease;
}

.list-item-project {
  grid-template-columns: minmax(0, 1fr);
}

.project-main {
  width: 100%;
  display: grid;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.project-actions {
  justify-content: flex-end;
}

.list-item:active {
  transform: scale(0.99);
}

.list-item.selected {
  border-color: rgba(217, 173, 83, 0.54);
  background: rgba(217, 173, 83, 0.12);
}

.list-title {
  font-weight: 700;
  line-height: 1.35;
}

.list-meta {
  color: var(--muted);
  font-size: 0.84rem;
  word-break: break-all;
}

.terminal-frame {
  margin: 0 14px;
  min-height: 34vh;
  max-height: 46vh;
  overflow: auto;
  border-radius: var(--radius-lg);
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(222, 180, 84, 0.05), transparent 22%),
    rgba(7, 10, 14, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.terminal {
  min-height: calc(34vh - 36px);
  padding: 8px;
  color: oklch(0.9 0.012 95);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.88rem;
}

.terminal .xterm-viewport {
  overflow-y: auto !important;
}

.composer {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.composer textarea {
  width: 100%;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 16px;
  min-height: 92px;
  resize: vertical;
}

.project-add {
  align-items: center;
  padding: 0 14px 14px;
}

.project-add select {
  min-width: 0;
  flex: 1;
}

.composer textarea,
.login-form input,
.project-add select {
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.login-form input,
.project-add select {
  min-height: 46px;
  padding: 0 14px;
}

.composer textarea:focus,
.login-form input:focus,
.project-add select:focus {
  outline: 2px solid rgba(217, 173, 83, 0.42);
  outline-offset: 2px;
}

.primary-button,
.ghost-button {
  min-height: 46px;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0 18px;
  font-weight: 700;
}

.compact-button {
  min-height: 38px;
  padding: 0 14px;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), oklch(0.68 0.09 64));
  color: oklch(0.19 0.015 250);
}

.ghost-button {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.ghost-button.danger {
  color: oklch(0.8 0.08 25);
  border-color: rgba(227, 94, 94, 0.28);
}

.text-button {
  min-height: 32px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 700;
}

.text-button.danger {
  color: oklch(0.8 0.08 25);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (min-width: 980px) {
  .layout {
    grid-template-columns: 1.05fr 1.45fr 0.9fr;
    align-items: start;
  }

  .panel-sessions,
  .panel-projects {
    min-height: 72vh;
  }

  .panel-console {
    min-height: 72vh;
  }

  .terminal-frame {
    min-height: 48vh;
    max-height: 52vh;
  }

  .terminal {
    min-height: calc(48vh - 36px);
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: calc(100vw - 16px);
    padding-top: 8px;
  }

  .hero,
  .panel {
    border-radius: 24px;
  }

  .panel-head,
  .session-actions,
  .composer-actions,
  .project-add {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .status-grid {
    grid-template-columns: 1fr;
  }

  .terminal-frame {
    min-height: 38vh;
    max-height: 42vh;
  }

  .terminal {
    min-height: calc(38vh - 36px);
    font-size: 0.82rem;
  }

  .composer {
    position: sticky;
    bottom: 0;
    background:
      linear-gradient(180deg, rgba(8, 11, 18, 0), rgba(8, 11, 18, 0.98) 18%),
      rgba(8, 11, 18, 0.9);
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }

  .primary-button,
  .ghost-button,
  .list-item {
    min-height: 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto;
    transition: none !important;
  }
}
