:root {
  color-scheme: light;
  --ink: #16221d;
  --muted: #66736d;
  --paper: #f4f5ef;
  --surface: #ffffff;
  --line: #dfe4dc;
  --forest: #245a45;
  --forest-dark: #163f30;
  --mint: #c9eadc;
  --mint-light: #eaf7f1;
  --coral: #df6b50;
  --coral-light: #fff0eb;
  --gold: #e7b854;
  --danger: #a43e35;
  --shadow: 0 18px 50px rgba(22, 34, 29, 0.09);
  --radius: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body { min-height: 100vh; margin: 0; color: var(--ink); background: var(--paper); }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid rgba(36, 90, 69, 0.3); outline-offset: 2px; }
a { color: inherit; }
p { line-height: 1.6; }
[hidden] { display: none !important; }

.landing-shell { min-height: 100vh; display: flex; flex-direction: column; padding: 24px clamp(20px, 5vw, 72px); overflow: hidden; position: relative; }
.landing-shell::before { content: ""; position: fixed; width: 680px; height: 680px; border-radius: 50%; background: radial-gradient(circle, rgba(201, 234, 220, 0.72), rgba(201, 234, 220, 0)); top: -300px; left: -230px; pointer-events: none; }
.landing-shell::after { content: ""; position: fixed; width: 560px; height: 560px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 205, 188, 0.6), rgba(255, 205, 188, 0)); bottom: -300px; right: -180px; pointer-events: none; }
.landing-header, .landing-footer { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; }
.landing-footer { color: var(--muted); font-size: 0.78rem; padding-top: 24px; }
.landing-grid { position: relative; z-index: 1; width: min(1120px, 100%); margin: auto; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(330px, 0.75fr); gap: clamp(40px, 8vw, 110px); align-items: center; padding: 64px 0; }
.hero-copy h1 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: clamp(3rem, 6.5vw, 6.2rem); line-height: 0.98; letter-spacing: -0.055em; max-width: 780px; margin: 24px 0; }
.hero-copy > p { max-width: 650px; font-size: clamp(1.05rem, 1.7vw, 1.35rem); color: #44524c; }
.promise-pill { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 10px 16px; font-weight: 650; font-size: 0.86rem; box-shadow: 0 6px 20px rgba(22, 34, 29, 0.05); }
.how-it-works { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 34px; color: var(--forest); font-weight: 750; }
.how-it-works span { background: rgba(255, 255, 255, 0.7); padding: 8px 12px; border-radius: 12px; }
.how-it-works i { color: var(--coral); font-style: normal; }

.brand { display: inline-flex; gap: 10px; align-items: center; text-decoration: none; }
.brand img { border-radius: 11px; box-shadow: 0 6px 16px rgba(36, 90, 69, 0.14); }
.brand > span { display: flex; flex-direction: column; line-height: 1.15; }
.brand strong { font-size: 1.08rem; letter-spacing: -0.02em; }
.brand small { color: var(--muted); font-size: 0.72rem; margin-top: 3px; }
.locale-select { width: auto; min-width: 64px; max-width: 72px; flex: 0 0 auto; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.76); border-radius: 12px; padding: 9px 10px; font-weight: 750; }

.auth-card { background: rgba(255, 255, 255, 0.9); border: 1px solid rgba(255, 255, 255, 0.9); border-radius: 28px; padding: 22px; box-shadow: var(--shadow); backdrop-filter: blur(16px); }
.segmented { display: grid; grid-template-columns: 1fr 1fr; background: #eef0eb; border-radius: 14px; padding: 4px; margin-bottom: 24px; }
.segmented button { border: 0; background: transparent; padding: 10px; border-radius: 11px; cursor: pointer; color: var(--muted); font-weight: 700; }
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: 0 2px 8px rgba(22, 34, 29, 0.08); }
label { display: grid; gap: 7px; font-weight: 700; font-size: 0.87rem; }
label + label, form > label + fieldset, fieldset + fieldset { margin-top: 16px; }
input, textarea, select { width: 100%; border: 1px solid #cfd6ce; border-radius: 12px; padding: 12px 13px; background: var(--surface); color: var(--ink); }
textarea { resize: vertical; }
label small, fieldset small, .terms-note { font-weight: 450; color: var(--muted); line-height: 1.45; }
.terms-note { display: block; text-align: center; margin: 14px 4px 2px; }
.form-error { min-height: 22px; color: var(--danger); font-size: 0.85rem; margin: 12px 0 0; }
.terms-check { grid-template-columns: auto 1fr; align-items: start; font-weight: 500; line-height: 1.45; }
.terms-check input, .inline-check input { width: auto; margin-top: 3px; }
.access-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 14px; margin-top: 17px; }
.access-links button { border: 0; background: transparent; color: var(--forest); text-decoration: underline; cursor: pointer; }
.recovery-shell { justify-content: space-between; }
.recovery-card { position: relative; z-index: 1; width: min(560px, 100%); margin: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 28px; padding: clamp(24px, 5vw, 42px); box-shadow: var(--shadow); }
.recovery-card h1 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: clamp(2.2rem, 7vw, 3.7rem); margin: 8px 0 16px; }
.recovery-code { display: block; margin: 24px 0 8px; padding: 18px; border-radius: 14px; background: #eef1ed; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: clamp(0.92rem, 3vw, 1.2rem); font-weight: 800; overflow-wrap: anywhere; text-align: center; }

.button { border: 0; border-radius: 13px; padding: 11px 16px; font-weight: 750; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform 120ms ease, background 120ms ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: 0.5; cursor: wait; transform: none; }
.button.primary { background: var(--forest); color: white; box-shadow: 0 8px 18px rgba(36, 90, 69, 0.2); }
.button.primary:hover { background: var(--forest-dark); }
.button.secondary { background: #eef1ed; color: var(--ink); }
.button.quiet { background: transparent; border: 1px solid var(--line); padding: 9px 12px; }
.button.full { width: 100%; margin-top: 16px; }
.danger-button { background: var(--danger); color: white; }

.app-shell { min-height: 100vh; }
.app-header { height: 72px; position: fixed; z-index: 20; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 max(20px, calc((100vw - 1180px) / 2)); background: rgba(244, 245, 239, 0.89); border-bottom: 1px solid rgba(205, 214, 205, 0.7); backdrop-filter: blur(18px); }
.header-actions { display: flex; align-items: center; gap: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--coral); color: white; font-weight: 800; cursor: pointer; }
.app-main { min-height: 100vh; padding: 108px max(20px, calc((100vw - 1180px) / 2)) 110px; }
.page { width: 100%; }
.page-heading { margin-bottom: 32px; max-width: 780px; }
.page-heading.split { max-width: none; display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.page-heading h1 { margin: 2px 0 8px; font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: clamp(2.35rem, 5vw, 4.4rem); line-height: 1; letter-spacing: -0.045em; }
.page-heading p:not(.eyebrow) { margin: 8px 0 0; color: var(--muted); max-width: 680px; }
.eyebrow { margin: 0 0 8px; color: var(--coral); text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.72rem; font-weight: 850; }

.primary-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.intent-card { min-height: 210px; position: relative; overflow: hidden; border: 0; border-radius: 28px; padding: 26px; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end; text-align: left; cursor: pointer; box-shadow: var(--shadow); }
.intent-card::after { content: ""; position: absolute; width: 180px; height: 180px; border-radius: 50%; top: -70px; right: -30px; background: rgba(255, 255, 255, 0.35); }
.intent-card.wish { background: var(--mint); }
.intent-card.need { background: #ffd4c7; }
.intent-card strong { font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.8rem, 3vw, 2.5rem); font-weight: 500; letter-spacing: -0.03em; }
.intent-card small { margin-top: 8px; font-size: 0.92rem; max-width: 390px; color: #3d5148; }
.action-icon { position: absolute; top: 24px; left: 25px; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: rgba(255, 255, 255, 0.62); font-size: 1.4rem; }
.secondary-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.secondary-actions button { border: 1px solid var(--line); background: var(--surface); border-radius: 18px; padding: 17px 18px; display: flex; flex-direction: column; align-items: flex-start; text-align: left; cursor: pointer; }
.secondary-actions span { color: var(--muted); font-size: 0.82rem; margin-top: 4px; }
.section-block { margin-top: 44px; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.section-title h2 { margin: 0; font-size: 1.15rem; }
.match-notice { width: 100%; margin-top: 24px; display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; border: 0; border-radius: 18px; padding: 17px 20px; background: var(--forest); color: white; text-align: left; cursor: pointer; }

.entry-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.entry-grid.logbook-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.entry-card { position: relative; border: 1px solid var(--line); background: var(--surface); border-radius: 20px; padding: 20px; min-width: 0; }
.entry-card.compact { min-height: 150px; }
.entry-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 0.76rem; }
.entry-card h3 { margin: 16px 0 8px; font-size: 1.08rem; }
.entry-card p { color: var(--muted); font-size: 0.88rem; margin: 0 0 14px; white-space: pre-wrap; }
.kind-badge { display: inline-flex; border-radius: 999px; padding: 6px 9px; font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink); }
.kind-badge.merit { background: #e9e1ff; }
.kind-badge.outcome { background: #fff0bd; }
.kind-badge.wish { background: var(--mint); }
.kind-badge.need { background: #ffd4c7; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.chip { background: #f0f2ee; border: 1px solid #e1e5df; padding: 5px 8px; border-radius: 999px; font-size: 0.72rem; }
.entry-meta { display: flex; gap: 6px; color: var(--muted); font-size: 0.72rem; margin-top: 13px; }
.text-button { border: 0; padding: 6px 0; background: none; color: var(--danger); font-size: 0.78rem; font-weight: 700; cursor: pointer; margin-top: 12px; }
.empty-state { border: 1px dashed #cbd3ca; background: rgba(255, 255, 255, 0.42); border-radius: 20px; padding: 28px; color: var(--muted); text-align: center; }
.empty-state.large { min-height: 260px; display: grid; place-items: center; padding: 40px; }

.matches-list { display: grid; gap: 18px; }
.match-card { display: grid; grid-template-columns: 110px minmax(0, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: 24px; overflow: hidden; box-shadow: 0 8px 24px rgba(22, 34, 29, 0.04); }
.match-score { background: var(--mint-light); display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 240px; }
.match-score strong { font-family: Georgia, "Times New Roman", serif; font-size: 2.1rem; font-weight: 500; }
.match-score small { color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.match-content { padding: 24px; }
.match-content h2 { margin: 14px 0 8px; font-family: Georgia, "Times New Roman", serif; font-size: 1.75rem; font-weight: 500; }
.match-content > p { color: var(--muted); white-space: pre-wrap; }
.match-facts { display: flex; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 0.78rem; margin: 10px 0; }
.match-facts span { border-right: 1px solid var(--line); padding-right: 8px; }
.reasons { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 18px; padding: 0; margin: 17px 0; list-style: none; font-size: 0.82rem; }
.reasons li::before { content: "✓"; color: var(--forest); font-weight: 900; margin-right: 8px; }
details { font-size: 0.82rem; color: var(--muted); }
details summary { cursor: pointer; font-weight: 750; color: var(--ink); }
.decision-state { border-radius: 12px; background: #f2f3ef; padding: 10px 12px; font-size: 0.82rem; }
.decision-state.mutual { background: var(--mint-light); color: var(--forest-dark); font-weight: 750; }
.match-actions { display: flex; gap: 10px; margin-top: 18px; }
.context-actions { display: flex; gap: 10px; }
.context-actions button { border: 0; background: transparent; color: var(--danger); cursor: pointer; font-size: 0.76rem; }

.chat-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: 560px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; overflow: hidden; }
.conversation-list { border-right: 1px solid var(--line); background: #fafbf8; }
.conversation-list button { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 17px; display: flex; flex-direction: column; align-items: flex-start; text-align: left; cursor: pointer; }
.conversation-list button.active { background: var(--mint-light); }
.conversation-list small { width: 100%; color: var(--muted); margin-top: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conversation-panel { min-width: 0; display: grid; grid-template-rows: auto 1fr auto; }
.conversation-panel > header { padding: 15px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.conversation-panel > header span { color: var(--forest); font-size: 0.75rem; font-weight: 700; }
.message-list { height: 440px; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.message { max-width: min(74%, 580px); border-radius: 16px; padding: 10px 13px; }
.message p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.message small { display: block; margin-top: 5px; font-size: 0.66rem; opacity: 0.7; }
.message.mine { align-self: flex-end; background: var(--forest); color: white; border-bottom-right-radius: 5px; }
.message.theirs { align-self: flex-start; background: #eef0eb; border-bottom-left-radius: 5px; }
.message-form { padding: 14px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 10px; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.settings-card { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 22px; }
.settings-card h2 { margin-top: 0; }
.settings-card p { color: var(--muted); }
.settings-card .button { margin-top: 16px; }
.settings-card .subheading { margin-top: 30px; }
.device-list { list-style: none; padding: 0; margin: 18px 0; border-top: 1px solid var(--line); }
.device-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.device-list span { display: flex; flex-direction: column; gap: 3px; }
.device-list small { color: var(--muted); }
.device-list button { border: 0; background: transparent; color: var(--danger); cursor: pointer; }
.settings-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; }
.inline-check { display: flex; align-items: center; gap: 7px; font-weight: 500; }
.transfer-box { margin-top: 18px; border: 1px solid var(--line); border-radius: 16px; padding: 16px; text-align: center; background: #fafbf8; }
.transfer-box img { display: block; width: min(300px, 100%); margin: auto; }
.settings-card.danger { grid-column: 1 / -1; border-color: #ecc9c5; background: #fffafa; }

.bottom-nav { position: fixed; z-index: 20; left: 50%; transform: translateX(-50%); bottom: max(14px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(4, 82px); background: rgba(22, 34, 29, 0.94); backdrop-filter: blur(14px); padding: 6px; border-radius: 20px; box-shadow: 0 16px 40px rgba(22, 34, 29, 0.24); }
.bottom-nav button { border: 0; border-radius: 14px; background: transparent; color: #c7d0cb; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; }
.bottom-nav button.active { background: rgba(255, 255, 255, 0.12); color: white; }
.bottom-nav button span { font-size: 1.15rem; }
.bottom-nav button small { font-size: 0.68rem; }

.entry-dialog { width: min(680px, calc(100% - 24px)); max-height: min(880px, calc(100vh - 24px)); padding: 0; border: 0; border-radius: 24px; box-shadow: 0 30px 90px rgba(22, 34, 29, 0.28); }
.entry-dialog::backdrop { background: rgba(14, 25, 20, 0.6); backdrop-filter: blur(5px); }
.entry-dialog form { padding: 24px; overflow-y: auto; max-height: calc(100vh - 24px); }
.dialog-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; }
.dialog-header h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: 2rem; }
.icon-button { width: 36px; height: 36px; border-radius: 50%; border: 0; background: #eef0eb; font-size: 1.4rem; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
fieldset { border: 0; padding: 0; margin: 16px 0 0; }
legend { font-weight: 700; font-size: 0.87rem; margin-bottom: 8px; }
.compensation-grid { display: grid; grid-template-columns: 1fr 1fr 90px 130px; gap: 8px; }
.visibility-field { background: #f5f7f3; border-radius: 14px; padding: 14px; }
.choice { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 8px; font-weight: 600; }
.choice + .choice { margin-top: 8px; }
.choice input { width: auto; }
.visibility-field small { display: block; margin-top: 10px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

.system-banner { position: fixed; z-index: 50; left: 50%; top: 12px; transform: translateX(-50%); background: var(--ink); color: white; border-radius: 12px; padding: 10px 13px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow); font-size: 0.82rem; }
.system-banner button { border: 0; border-radius: 8px; padding: 6px 9px; background: var(--mint); color: var(--ink); font-weight: 700; cursor: pointer; }
.system-banner.offline { top: auto; bottom: 90px; background: #5c4430; }
#toast { position: fixed; z-index: 60; left: 50%; bottom: 92px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: var(--forest-dark); color: white; border-radius: 12px; padding: 11px 15px; transition: opacity 160ms ease, transform 160ms ease; box-shadow: var(--shadow); }
#toast.visible { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); }

@media (max-width: 820px) {
  .landing-grid { grid-template-columns: 1fr; padding: 52px 0; }
  .hero-copy h1 { font-size: clamp(3.1rem, 13vw, 5rem); }
  .auth-card { max-width: 520px; width: 100%; }
  .entry-grid { grid-template-columns: 1fr 1fr; }
  .chat-layout { grid-template-columns: 230px minmax(0, 1fr); }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-card.danger { grid-column: auto; }
}

@media (max-width: 620px) {
  .landing-shell { padding: 18px; }
  .landing-header .brand small, .app-header .brand small { display: none; }
  .landing-grid { gap: 36px; padding: 42px 0; }
  .hero-copy h1 { margin-top: 18px; }
  .how-it-works { font-size: 0.76rem; }
  .landing-footer { align-items: flex-start; gap: 14px; flex-direction: column; }
  .app-header { height: 64px; padding: 0 16px; }
  .app-header .button.quiet { display: none; }
  .app-main { padding: 91px 15px 106px; }
  .page-heading.split { align-items: flex-start; flex-direction: column; }
  .page-heading.split .button { width: 100%; }
  .primary-actions, .secondary-actions, .entry-grid, .entry-grid.logbook-grid { grid-template-columns: 1fr; }
  .intent-card { min-height: 176px; }
  .match-card { grid-template-columns: 1fr; }
  .match-score { min-height: auto; padding: 12px; flex-direction: row; gap: 8px; justify-content: flex-start; }
  .match-score strong { font-size: 1.4rem; }
  .match-content { padding: 18px; }
  .reasons { grid-template-columns: 1fr; }
  .chat-layout { display: block; min-height: 0; }
  .conversation-list { border-right: 0; max-height: 170px; overflow-y: auto; }
  .conversation-panel { min-height: 460px; }
  .message-list { height: 360px; }
  .bottom-nav { width: calc(100% - 24px); grid-template-columns: repeat(4, 1fr); bottom: max(8px, env(safe-area-inset-bottom)); }
  .form-grid, .compensation-grid { grid-template-columns: 1fr 1fr; }
  .entry-dialog form { padding: 20px 16px; }
  #toast { width: calc(100% - 32px); text-align: center; bottom: 84px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

.offline-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.offline-card { max-width: 480px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 34px; text-align: center; box-shadow: var(--shadow); }
.offline-card img { width: 64px; }
.offline-card p { color: var(--muted); }
.legal-page { width: min(780px, calc(100% - 36px)); margin: 48px auto 90px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: clamp(24px, 5vw, 48px); box-shadow: var(--shadow); }
.legal-page h1 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: clamp(2.3rem, 7vw, 4rem); line-height: 1; }
.legal-page h2 { margin-top: 34px; }
.legal-page h3 { margin: 24px 0 4px; }
.legal-page p { color: #44524c; }
.legal-page hr { border: 0; border-top: 1px solid var(--line); margin: 40px 0; }
