:root {
  --bg: #f6efe5;
  --bg-2: #efe5d5;
  --surface: rgba(255, 251, 245, 0.82);
  --surface-strong: #fffaf3;
  --line: rgba(35, 27, 18, 0.1);
  --line-strong: rgba(35, 27, 18, 0.18);
  --ink: #201710;
  --muted: #63574a;
  --accent: #155c48;
  --accent-strong: #0d4335;
  --accent-soft: rgba(21, 92, 72, 0.1);
  --danger: #8f342f;
  --shadow: 0 18px 48px rgba(78, 54, 25, 0.11);
  --radius: 24px;
  --radius-sm: 18px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Manrope', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.78), transparent 28%),
    radial-gradient(circle at top right, rgba(21, 92, 72, 0.12), transparent 24%),
    linear-gradient(180deg, #fbf6ee 0%, var(--bg) 45%, var(--bg-2) 100%);
}

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

button,
input,
textarea {
  font: inherit;
}

.hidden {
  display: none !important;
}

.shell {
  width: min(100%, 1000px);
  margin: 0 auto;
  padding: 16px;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.auth-shell {
  display: grid;
  gap: 16px;
  padding: 12px 0 24px;
}

.auth-hero,
.auth-card,
.surface-card,
.summary-card,
.detail-panel {
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.auth-hero,
.auth-card,
.surface-card,
.detail-panel {
  border-radius: var(--radius);
}

.auth-hero {
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.54), rgba(255, 255, 255, 0)),
    var(--surface);
}

.auth-hero h1,
.auth-card h2,
.panel-hero h2,
.app-brand h1,
.detail-panel h2 {
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
  letter-spacing: -0.05em;
  line-height: 0.97;
}

.auth-hero h1 {
  font-size: clamp(2.35rem, 11vw, 4.6rem);
  margin-bottom: 16px;
  max-width: 12ch;
}

.hero-copy,
.auth-copy,
.panel-hero p,
.detail-summary {
  color: var(--muted);
  line-height: 1.7;
}

.hero-points {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.hero-points span,
.summary-card,
.credit-pill,
.tab-chip {
  border-radius: 999px;
}

.hero-points span {
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.92rem;
}

.auth-card {
  padding: 22px;
}

.auth-card h2 {
  font-size: clamp(1.8rem, 6vw, 2.7rem);
  margin-bottom: 12px;
}

.auth-actions,
.panel-actions,
.detail-actions,
.header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.auth-actions {
  margin-top: 18px;
}

.auth-advanced {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.auth-advanced summary {
  cursor: pointer;
  color: var(--muted);
}

.auth-status {
  margin-top: 14px;
  font-size: 0.92rem;
  color: var(--muted);
}

.auth-result {
  margin: 12px 0 0;
  max-height: 140px;
  overflow: auto;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--line);
  white-space: pre-wrap;
  color: var(--muted);
}

.auth-links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 16px;
  color: var(--muted);
}

.app-shell {
  display: grid;
  gap: 14px;
  padding-bottom: 28px;
}

.app-header {
  display: grid;
  gap: 14px;
  padding-top: 6px;
}

.app-brand {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
}

.brand-mark {
  color: var(--accent);
}

.app-brand h1 {
  font-size: clamp(2rem, 9vw, 3.8rem);
}

.credit-pill,
.icon-btn,
.btn,
.tab-chip {
  min-height: 46px;
  border: 1px solid transparent;
}

.credit-pill,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.72);
  border-color: var(--line);
  color: var(--ink);
}

.icon-btn {
  width: 46px;
  padding: 0;
}

.workspace-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.summary-card {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid var(--line);
}

.summary-card span,
.info-list span,
.detail-grid span {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.summary-card strong,
.info-list strong,
.detail-grid strong {
  font-size: 0.98rem;
}

.tab-bar {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.tab-chip {
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.6);
  border-color: var(--line);
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.tab-chip.active {
  background: var(--ink);
  color: #fff9f1;
}

.tab-panels {
  display: grid;
}

.tab-panel {
  display: none;
  gap: 14px;
}

.tab-panel.active {
  display: grid;
}

.panel-hero {
  display: grid;
  gap: 8px;
}

.panel-hero.compact h2 {
  font-size: clamp(1.25rem, 5vw, 1.8rem);
}

.panel-hero h2 {
  font-size: clamp(1.55rem, 7vw, 2.6rem);
}

.surface-card {
  padding: 18px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field span {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  padding: 13px 14px;
  outline: none;
}

select {
  min-height: 54px;
  font-weight: 700;
}

textarea {
  resize: vertical;
  min-height: 150px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(21, 92, 72, 0.44);
  box-shadow: 0 0 0 4px rgba(21, 92, 72, 0.08);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  cursor: pointer;
  padding: 0 18px;
  font-weight: 700;
}

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

.btn-secondary {
  background: rgba(255, 255, 255, 0.7);
  border-color: var(--line);
  color: var(--ink);
}

.btn-tertiary {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.panel-actions-inline {
  margin-top: -4px;
}

.panel-meta {
  color: var(--muted);
  font-size: 0.95rem;
}

.card-list,
.ledger-list,
.detail-grid,
.info-list,
.onboarding-list,
.home-grid,
.checkbox-list {
  display: grid;
  gap: 12px;
}

.result-log {
  margin: 12px 0 0;
  max-height: 220px;
  overflow: auto;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}

.result-card,
.ledger-item {
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.6);
}

.result-card-header,
.ledger-item-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.result-card h3 {
  margin: 0 0 8px;
  font-size: 1.15rem;
}

.result-meta,
.result-tags,
.card-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 700;
}

.result-summary {
  margin: 12px 0;
  color: var(--muted);
  line-height: 1.65;
}

.card-actions-row {
  margin-top: 14px;
}

.card-actions-row .btn {
  flex: 1 1 140px;
}

.empty-state {
  padding: 20px;
  border-radius: 20px;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.45);
}

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

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

.surface-card h3 {
  margin: 0 0 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.35rem;
  letter-spacing: -0.04em;
}

.surface-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.field-checkbox {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.checkbox-list {
  grid-template-columns: 1fr;
}

.checkbox-chip {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.56);
  color: var(--ink);
}

.checkbox-chip input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.field-checkbox input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.onboarding-step {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.52);
}

.onboarding-step.is-active {
  border-color: rgba(21, 92, 72, 0.34);
  background: rgba(21, 92, 72, 0.08);
}

.onboarding-step-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.onboarding-step-title {
  font-weight: 800;
  font-size: 1rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 84px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-pill.done {
  background: rgba(21, 92, 72, 0.12);
  color: var(--accent-strong);
}

.status-pill.skipped {
  background: rgba(99, 87, 74, 0.12);
}

.stat-card strong {
  font-size: 1.5rem;
}

.ledger-item span {
  color: var(--muted);
}

.link-stack {
  display: grid;
  gap: 12px;
}

.action-link {
  display: block;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--line);
  font-weight: 700;
}

.action-link strong {
  display: block;
  margin-bottom: 6px;
}

.action-link span {
  display: block;
  color: var(--muted);
  font-weight: 500;
  line-height: 1.6;
}

.action-link.compact {
  padding: 12px 14px;
}

.action-link.is-disabled {
  opacity: 0.6;
  pointer-events: none;
}

.message-detail-card {
  gap: 16px;
}

.detail-attachment-list,
.mail-composer-grid {
  display: grid;
  gap: 12px;
}

.composer-card {
  padding: 16px;
  background: rgba(255, 255, 255, 0.46);
  box-shadow: none;
}

.detail-sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 12, 8, 0.42);
}

.detail-panel {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(100%, 420px);
  padding: 22px;
  overflow-y: auto;
  background: rgba(255, 249, 241, 0.96);
}

.close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
  cursor: pointer;
}

.detail-panel h2 {
  margin-top: 16px;
  font-size: 2rem;
}

.detail-actions {
  margin-top: 18px;
}

.toast-stack {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 80;
  display: grid;
  gap: 10px;
}

.toast {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(24, 19, 15, 0.92);
  color: #fffaf2;
  box-shadow: 0 18px 40px rgba(16, 11, 7, 0.22);
}

.toast.error {
  background: rgba(143, 52, 47, 0.94);
}

@media (min-width: 900px) {
  .shell {
    padding: 22px;
  }

  .auth-shell {
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
    align-items: stretch;
    padding-top: 24px;
  }

  .auth-card {
    align-self: end;
  }

  .app-header {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

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

  .tab-panels {
    margin-top: 6px;
  }

  .card-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .shell {
    padding: 12px;
  }

  .workspace-summary,
  .credits-grid {
    grid-template-columns: 1fr;
  }

  .auth-actions .btn,
  .panel-actions .btn,
  .header-actions .credit-pill {
    width: 100%;
  }

  .header-actions {
    display: grid;
    grid-template-columns: 1fr auto auto;
  }

  .result-card-header,
  .ledger-item-top {
    flex-direction: column;
  }

  .detail-panel {
    top: auto;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 88vh;
    border-top-left-radius: 28px;
    border-top-right-radius: 28px;
  }
}
