:root {
  color-scheme: dark;
  --bg: #050b0d;
  --bg-2: #081316;
  --panel: rgba(8, 17, 19, 0.86);
  --panel-strong: rgba(10, 20, 22, 0.94);
  --ink: #f0dfc4;
  --cream: #f4ead8;
  --muted: #c8bca9;
  --line: rgba(185, 124, 75, 0.38);
  --line-soft: rgba(123, 192, 176, 0.24);
  --gold: #f1bd69;
  --green: #a9d16e;
  --red: #ff7c55;
  --teal: #7ed6ce;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  --serif: Georgia, "Times New Roman", serif;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--cream);
  background:
    linear-gradient(180deg, rgba(5, 11, 13, 0.74), rgba(5, 11, 13, 0.98)),
    url("/assets/quiet-harbor-hero.png") center top / 1480px auto no-repeat,
    radial-gradient(circle at 50% 0%, rgba(241, 189, 105, 0.16), transparent 32%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background:
    repeating-linear-gradient(90deg, rgba(126, 214, 206, 0.05) 0 1px, transparent 1px 72px),
    repeating-linear-gradient(0deg, rgba(241, 189, 105, 0.04) 0 1px, transparent 1px 72px);
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.72), transparent 72%);
}

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

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:active {
  transform: translateY(1px);
}

.shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 32px calc(110px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 14px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 68px;
  font-weight: 700;
  line-height: 0.92;
  letter-spacing: 0;
  text-shadow: 0 10px 30px rgba(0, 0, 0, 0.54);
}

.topline {
  max-width: 720px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 21px;
  line-height: 1.35;
}

body:not([data-page="home"]) .topline {
  display: none;
}

h2 {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 46px;
  font-weight: 700;
  line-height: 1.03;
  letter-spacing: 0;
  text-shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
}

.section-copy {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}

.status {
  display: inline-flex;
  min-width: 136px;
  min-height: 56px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 650;
  text-align: center;
  background: rgba(7, 14, 16, 0.72);
  box-shadow: inset 0 1px 0 rgba(244, 234, 216, 0.06);
}

.status::before {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid var(--gold);
  border-radius: 50%;
  color: var(--gold);
  content: "⌁";
  font-size: 14px;
}

.status.ok {
  color: var(--ink);
  border-color: var(--line);
}

.status.bad {
  color: var(--gold);
}

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

.app-page {
  display: grid;
  gap: 22px;
}

.app-page[hidden] {
  display: none;
}

.home-page {
  gap: 22px;
}

.hero-card {
  position: relative;
  display: grid;
  min-height: 350px;
  align-content: center;
  overflow: hidden;
  padding: 36px 48px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background:
    linear-gradient(90deg, rgba(6, 12, 14, 0.86) 0%, rgba(6, 12, 14, 0.54) 42%, rgba(6, 12, 14, 0.08) 100%),
    linear-gradient(180deg, rgba(6, 12, 14, 0.12), rgba(6, 12, 14, 0.56)),
    url("/assets/quiet-harbor-hero.png") center / cover no-repeat;
  box-shadow: var(--shadow);
}

.hero-card::before {
  width: 168px;
  height: 2px;
  margin: 2px 0 22px;
  content: "";
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  box-shadow: 0 0 20px rgba(241, 189, 105, 0.55);
}

.hero-copy {
  display: grid;
  max-width: 560px;
  gap: 16px;
}

.hero-card p {
  margin: 0;
}

.hero-card .section-copy,
.hero-copy > p:last-child {
  color: var(--muted);
  font-size: 19px;
  line-height: 1.55;
}

.hero-note {
  position: absolute;
  right: 52px;
  bottom: 32px;
  max-width: 320px;
  color: var(--gold);
  font-family: var(--serif);
  font-size: 28px;
  font-style: italic;
  line-height: 1.1;
  text-shadow: 0 8px 26px rgba(0, 0, 0, 0.7);
}

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

.feature-grid.compact-actions {
  grid-template-columns: 1fr;
}

.feature-card {
  position: relative;
  display: grid;
  min-height: 232px;
  gap: 10px;
  align-content: start;
  justify-items: start;
  overflow: hidden;
  border: 1px solid rgba(126, 214, 206, 0.28);
  border-radius: 24px;
  padding: 22px 28px;
  color: var(--cream);
  background:
    linear-gradient(135deg, rgba(8, 18, 20, 0.94), rgba(6, 13, 15, 0.98)),
    var(--panel);
  box-shadow: var(--shadow);
  text-align: left;
}

.feature-card::before {
  position: absolute;
  inset: 0;
  content: "";
  opacity: 0.22;
  background:
    linear-gradient(135deg, transparent 0 52%, currentColor 52.5% 53.3%, transparent 54% 100%),
    repeating-linear-gradient(90deg, currentColor 0 1px, transparent 1px 20px);
  mask-image: linear-gradient(135deg, transparent 0 22%, #000 45%, transparent 80%);
}

.feature-card::after {
  position: absolute;
  right: -34px;
  bottom: -34px;
  width: 176px;
  height: 176px;
  content: "";
  border: 1px solid currentColor;
  border-radius: 50%;
  opacity: 0.12;
}

.deals-card {
  color: var(--green);
  border-color: rgba(169, 209, 110, 0.34);
  background:
    linear-gradient(135deg, rgba(13, 30, 18, 0.94), rgba(5, 14, 13, 0.98)),
    var(--panel);
}

.sos-card {
  color: var(--red);
  border-color: rgba(255, 124, 85, 0.38);
  background:
    linear-gradient(135deg, rgba(31, 17, 15, 0.94), rgba(8, 12, 14, 0.98)),
    var(--panel);
}

.rule-card {
  color: var(--teal);
  border-color: rgba(126, 214, 206, 0.36);
  background:
    linear-gradient(135deg, rgba(10, 31, 33, 0.94), rgba(5, 13, 17, 0.98)),
    var(--panel);
}

.feature-icon {
  position: relative;
  z-index: 1;
  display: grid;
  width: 62px;
  height: 62px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  color: currentColor;
  background: rgba(244, 234, 216, 0.04);
  font-size: 26px;
  font-weight: 850;
  box-shadow: 0 0 34px rgba(241, 189, 105, 0.12);
}

.feature-card strong {
  position: relative;
  z-index: 1;
  color: currentColor;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.08;
}

.feature-card small {
  position: relative;
  z-index: 1;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.45;
}

.open-row {
  position: relative;
  z-index: 1;
  display: flex;
  width: min(250px, 100%);
  min-height: 40px;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding: 0 28px;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: currentColor;
  font-size: 16px;
  font-weight: 750;
}

.section {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(11, 22, 25, 0.94), rgba(7, 14, 16, 0.98)),
    var(--panel-strong);
  box-shadow: var(--shadow);
}

.section.compact {
  padding: 12px;
}

.summary-panel[hidden] {
  display: none;
}

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

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

.result-only {
  display: none;
}

body[data-mode="result"] .result-only {
  display: grid;
}

body[data-mode="result"] .plan-only {
  display: none;
}

.field {
  display: grid;
  gap: 7px;
}

.field span,
.section-title span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 11px 13px;
  color: var(--cream);
  background: rgba(3, 9, 10, 0.74);
  outline: none;
  box-shadow: inset 0 1px 0 rgba(244, 234, 216, 0.04);
}

input::placeholder,
textarea::placeholder {
  color: rgba(200, 188, 169, 0.62);
}

textarea {
  resize: vertical;
  line-height: 1.35;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(241, 189, 105, 0.14), inset 0 1px 0 rgba(244, 234, 216, 0.04);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.outcome-switch {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.segmented label {
  min-width: 0;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  min-height: 48px;
  place-items: center;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(3, 9, 10, 0.64);
  font-weight: 800;
  text-align: center;
}

.segmented input:checked + span {
  border-color: var(--gold);
  color: #14100a;
  background: var(--gold);
}

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

.icon-button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  color: #14100a;
  background: var(--gold);
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}

.icon-button.ghost {
  align-self: end;
  border: 1px solid var(--line-soft);
  color: var(--muted);
  background: rgba(3, 9, 10, 0.66);
}

.takes {
  display: grid;
  gap: 10px;
}

.take-row {
  display: grid;
  grid-template-columns: 1fr 1fr 40px;
  gap: 8px;
  align-items: end;
}

.trade-card {
  display: grid;
  gap: 6px;
  padding: 13px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  color: var(--muted);
  background: rgba(3, 9, 10, 0.58);
  font-size: 13px;
  line-height: 1.35;
}

.trade-card strong {
  color: var(--cream);
}

.assistant-response {
  white-space: pre-wrap;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  color: var(--cream);
  background: rgba(3, 9, 10, 0.62);
  font-size: 15px;
  line-height: 1.45;
}

.sos-chat {
  display: grid;
  gap: 10px;
  white-space: normal;
  background: rgba(3, 9, 10, 0.5);
}

.chat-message {
  display: grid;
  gap: 4px;
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.42;
}

.chat-message strong {
  font-size: 12px;
  color: var(--muted);
}

.chat-message span {
  overflow-wrap: anywhere;
}

.chat-message.user {
  justify-self: end;
  color: #14100a;
  background: var(--gold);
}

.chat-message.user strong {
  color: rgba(20, 16, 10, 0.68);
}

.chat-message.assistant {
  justify-self: start;
  background: rgba(244, 234, 216, 0.06);
  border: 1px solid var(--line-soft);
}

.assistant-response[hidden],
.inline-panel[hidden] {
  display: none;
}

.inline-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: rgba(3, 9, 10, 0.54);
}

.inline-panel.nested {
  padding: 0;
  border: 0;
  background: transparent;
}

.actions {
  display: grid;
  gap: 10px;
  padding: 4px 0 0;
}

.primary {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 999px;
  color: #14100a;
  background: linear-gradient(180deg, #ffd27a, var(--gold));
  font-weight: 900;
  box-shadow: 0 12px 34px rgba(241, 189, 105, 0.18);
}

.primary:disabled {
  opacity: 0.62;
}

.secondary {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(3, 9, 10, 0.58);
  font-weight: 850;
}

.secondary:disabled {
  opacity: 0.62;
}

.outcome-switch button {
  min-height: 48px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(3, 9, 10, 0.62);
  font-weight: 850;
}

.outcome-switch button:active {
  border-color: var(--gold);
  color: #14100a;
  background: var(--gold);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 20;
  display: grid;
  width: min(1120px, calc(100% - 64px));
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(6, 13, 15, 0.88);
  box-shadow: 0 18px 64px rgba(0, 0, 0, 0.46);
  transform: translateX(-50%);
  backdrop-filter: blur(16px);
}

.bottom-nav button {
  display: flex;
  min-width: 0;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 0;
  border-radius: 999px;
  color: rgba(240, 223, 196, 0.68);
  background: transparent;
  font-size: 18px;
  font-weight: 650;
}

.nav-icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
}

.bottom-nav button.active {
  color: var(--gold);
  text-shadow: 0 0 18px rgba(241, 189, 105, 0.28);
}

.bottom-nav button.active .nav-icon {
  color: #14100a;
  background: var(--gold);
  box-shadow: 0 0 28px rgba(241, 189, 105, 0.36);
}

.message {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.message.error {
  color: var(--red);
}

.message.success {
  color: var(--teal);
}

@media (max-width: 900px) {
  .shell {
    padding-inline: 18px;
  }

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

  .feature-card {
    min-height: 220px;
  }

  .bottom-nav {
    width: min(720px, calc(100% - 28px));
  }

  .bottom-nav button {
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
  }
}

@media (max-width: 560px) {
  .shell {
    padding: max(18px, env(safe-area-inset-top)) 12px calc(102px + env(safe-area-inset-bottom));
  }

  .topbar {
    margin-bottom: 18px;
  }

  h1 {
    font-size: 46px;
  }

  .topline {
    margin-top: 12px;
    font-size: 17px;
  }

  h2 {
    font-size: 32px;
  }

  .status {
    min-width: 104px;
    min-height: 46px;
    padding: 10px 12px;
    font-size: 14px;
  }

  .status::before {
    width: 20px;
    height: 20px;
  }

  .hero-card {
    min-height: 370px;
    padding: 24px 24px;
    border-radius: 20px;
    background:
      linear-gradient(90deg, rgba(6, 12, 14, 0.92) 0%, rgba(6, 12, 14, 0.62) 54%, rgba(6, 12, 14, 0.22) 100%),
      linear-gradient(180deg, rgba(6, 12, 14, 0.12), rgba(6, 12, 14, 0.68)),
      url("/assets/quiet-harbor-hero.png") 74% center / cover no-repeat;
  }

  .hero-card::before {
    width: 118px;
    margin-bottom: 20px;
  }

  .hero-copy {
    max-width: 330px;
  }

  .hero-copy > p:last-child {
    font-size: 16px;
  }

  .hero-note {
    right: 24px;
    bottom: 24px;
    max-width: 210px;
    font-size: 20px;
  }

  .feature-card {
    min-height: 188px;
    padding: 24px;
    border-radius: 20px;
  }

  .feature-icon {
    width: 60px;
    height: 60px;
    font-size: 24px;
  }

  .feature-card strong {
    font-size: 29px;
  }

  .feature-card small {
    font-size: 16px;
  }

  .grid,
  .grid.two {
    grid-template-columns: 1fr;
  }

  .take-row {
    grid-template-columns: 1fr 1fr 40px;
  }

  .outcome-switch {
    grid-template-columns: 1fr;
  }

  .bottom-nav {
    bottom: max(12px, env(safe-area-inset-bottom));
    gap: 4px;
    padding: 10px;
    border-radius: 20px;
  }

  .bottom-nav button {
    min-height: 52px;
    font-size: 11px;
  }

  .nav-icon {
    width: 30px;
    height: 30px;
    font-size: 18px;
  }
}
