:root {
  color-scheme: light;
  --bg: #f4efe7;
  --bg-accent: #d8e2dc;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-strong: #fffaf4;
  --text: #1f2933;
  --muted: #58636f;
  --line: rgba(31, 41, 51, 0.1);
  --primary: #0f766e;
  --primary-dark: #115e59;
  --danger: #b42318;
  --shadow: 0 20px 60px rgba(31, 41, 51, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.18), transparent 28%),
    radial-gradient(circle at right, rgba(201, 162, 39, 0.18), transparent 24%),
    linear-gradient(135deg, var(--bg) 0%, #eef6f3 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.22) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.22) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.35), transparent 75%);
}

.shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 40px 0 56px;
}

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

.hero-card,
.dashboard-frame {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 28px;
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.hero-card {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
  overflow: hidden;
}

.hero-copy {
  padding: 56px;
  background:
    linear-gradient(160deg, rgba(15, 118, 110, 0.95), rgba(17, 94, 89, 0.82)),
    var(--bg-accent);
  color: white;
}

.eyebrow {
  margin: 0 0 12px;
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.74;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(2.6rem, 5vw, 4.8rem);
  line-height: 0.96;
  letter-spacing: -0.05em;
  margin-bottom: 18px;
}

h2 {
  font-size: 1.55rem;
  margin-bottom: 8px;
}

.lede,
.subtle,
.project-meta dd,
.empty-state {
  color: var(--muted);
}

.hero-copy .lede {
  color: rgba(255, 255, 255, 0.82);
  max-width: 32rem;
  font-size: 1.02rem;
}

.auth-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  background: rgba(255, 250, 244, 0.9);
}

label,
dt {
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  font: inherit;
  background: rgba(255, 255, 255, 0.86);
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 14px 16px;
  font: inherit;
  resize: vertical;
  min-height: 120px;
  background: rgba(255, 255, 255, 0.86);
}

input:focus {
  outline: 2px solid rgba(15, 118, 110, 0.2);
  border-color: rgba(15, 118, 110, 0.45);
}

textarea:focus {
  outline: 2px solid rgba(15, 118, 110, 0.2);
  border-color: rgba(15, 118, 110, 0.45);
}

button,
.logout-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  padding: 0 22px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
}

button {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

button:hover,
button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(15, 118, 110, 0.22);
}

.alert,
.toast {
  border-radius: 18px;
  padding: 14px 16px;
  font-weight: 500;
}

.alert {
  color: var(--danger);
  background: rgba(180, 35, 24, 0.08);
}

.toast {
  margin-bottom: 22px;
  color: var(--primary-dark);
  background: rgba(15, 118, 110, 0.08);
}

.hidden {
  display: none;
}

.dashboard-frame {
  padding: 32px;
}

.dashboard-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.dashboard-header h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
  margin-bottom: 10px;
}

.logout-link {
  background: rgba(31, 41, 51, 0.06);
  color: var(--text);
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.chat-frame {
  padding: 28px;
}

.chat-header {
  margin-bottom: 22px;
}

.header-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.chat-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 22px;
}

.chat-sidebar,
.chat-panel {
  border-radius: 24px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 244, 0.76);
}

.chat-sidebar {
  padding: 24px;
}

.sidebar-metric {
  display: grid;
  gap: 6px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.sidebar-metric span {
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.chat-panel {
  display: grid;
  grid-template-rows: minmax(320px, 1fr) auto;
  overflow: hidden;
}

.history-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
}

.history-link {
  color: var(--primary-dark);
  font-weight: 700;
  text-decoration: none;
}

.history-link-disabled {
  pointer-events: none;
  opacity: 0.35;
}

.history-page {
  color: var(--muted);
  font-size: 0.92rem;
}

.chat-stream {
  padding: 24px;
  display: grid;
  gap: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.48), rgba(216, 226, 220, 0.34)),
    rgba(255, 255, 255, 0.4);
}

.chat-bubble {
  max-width: 780px;
  padding: 18px;
  border-radius: 22px;
  background: white;
  border: 1px solid rgba(15, 118, 110, 0.08);
  box-shadow: 0 12px 24px rgba(31, 41, 51, 0.06);
}

.chat-bubble p {
  margin-bottom: 0;
  white-space: pre-wrap;
}

.chat-bubble-pending {
  border-style: dashed;
  background: rgba(255, 255, 255, 0.82);
}

.cli-response {
  margin: 0;
  white-space: pre-wrap;
  overflow-x: auto;
  padding: 14px;
  border-radius: 16px;
  background: #10261f;
  color: #ebfff7;
  font: 0.95rem/1.45 "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.pending-response {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(15, 118, 110, 0.2);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
  box-shadow: none;
}

.chat-bubble-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.attachment-card {
  margin: 0;
  overflow: hidden;
  border-radius: 18px;
  background: rgba(244, 239, 231, 0.92);
  border: 1px solid var(--line);
}

.attachment-card img {
  display: block;
  width: 100%;
  height: 150px;
  object-fit: cover;
}

.attachment-card figcaption {
  padding: 10px 12px 12px;
  font-size: 0.9rem;
  color: var(--muted);
}

.chat-form {
  display: grid;
  gap: 12px;
  padding: 22px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
}

.voice-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.voice-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border-radius: 999px;
  padding: 0 18px;
  font: inherit;
  font-weight: 700;
}

.voice-button {
  border: 0;
}

.voice-status {
  margin: 0;
  color: var(--primary-dark);
  font-weight: 500;
}

.dropzone {
  display: grid;
  place-items: center;
  gap: 4px;
  min-height: 120px;
  padding: 18px;
  border: 2px dashed rgba(15, 118, 110, 0.24);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.06), rgba(201, 162, 39, 0.08)),
    rgba(255, 250, 244, 0.8);
  text-align: center;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.dropzone-active {
  border-color: var(--primary);
  transform: scale(1.01);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), rgba(201, 162, 39, 0.12)),
    rgba(255, 250, 244, 0.92);
}

.dropzone-title,
.dropzone-copy,
.file-list {
  margin: 0;
}

.dropzone-title {
  font-weight: 700;
}

.dropzone-copy,
.file-list {
  color: var(--muted);
}

.project-card {
  padding: 22px;
  border-radius: 24px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

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

.project-id {
  margin-bottom: 8px;
  color: var(--primary-dark);
  font-weight: 700;
}

.usage-pill {
  white-space: nowrap;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.1);
  color: var(--primary-dark);
  font-size: 0.9rem;
  font-weight: 700;
}

.project-meta {
  margin: 0 0 20px;
}

.project-meta dd {
  margin: 6px 0 0;
  word-break: break-word;
}

.empty-state {
  margin: 0;
  padding: 28px;
  border-radius: 20px;
  background: rgba(255, 250, 244, 0.72);
  border: 1px dashed var(--line);
}

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

@media (max-width: 860px) {
  .hero-card {
    grid-template-columns: 1fr;
  }

  .hero-copy,
  .auth-card {
    padding: 28px;
  }

  .dashboard-header {
    align-items: start;
    flex-direction: column;
  }

  .chat-layout {
    grid-template-columns: 1fr;
  }
}
