:root {
    color-scheme: light;
    --paper: #f7f2e8;
    --paper-deep: #eee5d6;
    --ink: #17211c;
    --ink-soft: #5b645f;
    --forest: #174f3b;
    --forest-dark: #103a2c;
    --lime: #d8ef73;
    --coral: #f18769;
    --sun: #f3c65e;
    --white: #fffdf8;
    --line: #d9d0c1;
    --action-text: #ffffff;
    --share-bg: #174f3b;
    --share-text: #fffdf8;
    --shadow: 0 18px 50px rgba(44, 52, 45, 0.11);
    --radius-large: 26px;
    --radius-medium: 18px;
    --radius-small: 12px;
    --font-display: "Avenir Next", "Segoe UI Variable Display", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --paper: #111713;
    --paper-deep: #1c261f;
    --ink: #f2f6f3;
    --ink-soft: #aebbb3;
    --forest: #72cf9e;
    --forest-dark: #8bdbaf;
    --lime: #c5e967;
    --coral: #ff9a7d;
    --sun: #efc35d;
    --white: #18211b;
    --line: #39483e;
    --action-text: #102018;
    --share-bg: #1f5d43;
    --share-text: #f4faf6;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--paper); }

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 8% 8%, rgba(216, 239, 115, 0.35), transparent 28rem),
        radial-gradient(circle at 92% 92%, rgba(241, 135, 105, 0.2), transparent 30rem),
        var(--paper);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

html[data-theme="dark"] body {
    background:
        radial-gradient(circle at 8% 8%, rgba(114, 207, 158, 0.13), transparent 28rem),
        radial-gradient(circle at 92% 92%, rgba(255, 154, 125, 0.1), transparent 30rem),
        var(--paper);
}

button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

.header-actions { display: flex; align-items: center; gap: 8px; }
.theme-toggle { display: grid; place-items: center; width: 56px; height: 36px; border: 0; border-radius: 999px; padding: 4px; background: transparent; cursor: pointer; }
.theme-toggle-track { position: relative; display: block; width: 48px; height: 28px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper-deep); }
.theme-toggle-track::before, .theme-toggle-track::after { position: absolute; top: 4px; font-size: 12px; line-height: 18px; }
.theme-toggle-track::before { content: '☀'; left: 5px; }
.theme-toggle-track::after { content: '☾'; right: 6px; }
.theme-toggle-track > span { position: absolute; top: 3px; left: 3px; z-index: 1; width: 20px; height: 20px; border-radius: 50%; background: var(--white); box-shadow: 0 2px 7px rgba(23, 33, 28, 0.24); transition: transform 160ms ease; }
html[data-theme="dark"] .theme-toggle-track > span { transform: translateX(20px); }
.theme-toggle:focus-visible { outline: 3px solid var(--forest); outline-offset: 2px; }

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: min(100% - 32px, 980px);
    margin: 0 auto;
    padding: 22px 0;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 11px;
    color: var(--action-text);
    background: var(--forest);
    letter-spacing: 0;
}

.app-shell {
    width: min(100% - 32px, 760px);
    margin: 0 auto;
    padding: 48px 0 80px;
}

.join-view { max-width: 620px; margin: 7vh auto 0; }

.eyebrow {
    color: var(--forest);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

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

h1 {
    max-width: 15ch;
    margin-bottom: 18px;
    font-family: var(--font-display);
    font-size: clamp(40px, 8vw, 64px);
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.045em;
}

h2 {
    margin-bottom: 0;
    font-family: var(--font-display);
    font-size: clamp(28px, 5vw, 40px);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.035em;
}

.lead {
    max-width: 48ch;
    margin-bottom: 30px;
    color: var(--ink-soft);
    font-size: 18px;
}

.join-card, .add-choice-card, .progress-card {
    border: 1px solid rgba(23, 33, 28, 0.1);
    border-radius: var(--radius-large);
    background: var(--white);
    box-shadow: var(--shadow);
}

.join-card {
    display: grid;
    gap: 12px;
    padding: clamp(22px, 5vw, 34px);
}

label { font-size: 14px; font-weight: 800; }

input {
    width: 100%;
    min-height: 56px;
    border: 2px solid var(--line);
    border-radius: var(--radius-small);
    padding: 12px 16px;
    color: var(--ink);
    background: var(--white);
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus {
    border-color: var(--forest);
    box-shadow: 0 0 0 4px rgba(23, 79, 59, 0.12);
}

textarea {
    width: 100%;
    border: 2px solid var(--line);
    border-radius: var(--radius-small);
    padding: 14px 16px;
    color: var(--ink);
    background: var(--white);
    outline: none;
    line-height: 1.5;
    resize: vertical;
}

textarea:focus { border-color: var(--forest); box-shadow: 0 0 0 4px rgba(23, 79, 59, 0.12); }

#roomCode {
    text-transform: uppercase;
    font-size: 30px;
    font-weight: 900;
    letter-spacing: 0.16em;
}

#pinField { display: grid; gap: 8px; margin-top: 8px; }

.primary-button, .secondary-button, .text-button { border: 0; cursor: pointer; }

.primary-button {
    min-height: 58px;
    border-radius: 16px;
    padding: 14px 22px;
    color: var(--action-text);
    background: var(--forest);
    font-size: 17px;
    font-weight: 900;
    transition: transform 120ms ease, background 120ms ease, opacity 120ms ease;
}

.primary-button:hover:not(:disabled) { background: var(--forest-dark); transform: translateY(-1px); }
.primary-button:disabled { cursor: not-allowed; opacity: 0.42; }

.secondary-button {
    min-width: 90px;
    border: 2px solid var(--forest);
    border-radius: 14px;
    padding: 12px 18px;
    color: var(--forest);
    background: transparent;
    font-weight: 900;
}

.text-button { padding: 8px; color: var(--ink-soft); background: transparent; font-size: 14px; font-weight: 800; }
.form-message { margin: 4px 0 0; font-size: 14px; font-weight: 700; }
.error-message { color: #a02f25; }
.start-decision-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 24px;
    margin-bottom: 20px;
    border: 1px solid rgba(23, 33, 28, 0.1);
    border-radius: var(--radius-large);
    padding: clamp(22px, 5vw, 30px);
    background: var(--white);
    box-shadow: var(--shadow);
}

.start-decision-card h2 { margin: 4px 0 8px; font-size: clamp(26px, 5vw, 34px); }
.start-decision-card p { margin-bottom: 0; color: var(--ink-soft); }

.start-decision-button {
    display: grid;
    place-items: center;
    min-width: 190px;
    text-align: center;
    text-decoration: none;
}
.decision-view { display: grid; gap: 22px; }

.decision-heading { display: block; }

.decision-heading h1 { margin: 5px 0 0; font-size: clamp(38px, 7vw, 62px); }
.room-code { color: var(--ink-soft); font-size: 13px; font-weight: 900; letter-spacing: 0.14em; text-transform: uppercase; }

.status-pill {
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 8px 12px;
    color: var(--forest-dark);
    background: var(--lime);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.decision-meta { display: grid; gap: 12px; }
.progress-card { padding: 18px 20px; box-shadow: none; }
.progress-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; }
.progress-heading > div:first-child { display: grid; gap: 2px; }
.progress-track { height: 9px; margin-top: 12px; overflow: hidden; border-radius: 999px; background: var(--paper-deep); }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: var(--forest); transition: width 260ms ease; }

.notice {
    border-left: 5px solid var(--coral);
    border-radius: 0 var(--radius-small) var(--radius-small) 0;
    padding: 14px 16px;
    background: rgba(241, 135, 105, 0.14);
    font-weight: 700;
}

.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.choice-counter { flex: 0 0 auto; color: var(--ink-soft); font-size: 13px; font-weight: 800; }
.choices-list, .results-list { display: grid; gap: 14px; }
.choice-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-medium); background: var(--white); }
.choice-label { min-height: 78px; display: flex; align-items: center; padding: 18px 20px; font-size: 20px; font-weight: 850; }
.vote-options { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }

.vote-button {
    min-height: 72px;
    border: 0;
    border-right: 1px solid var(--line);
    padding: 10px 6px;
    color: var(--ink-soft);
    background: transparent;
    cursor: pointer;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.05em;
}

.vote-button:last-child { border-right: 0; }
.vote-button span { display: block; margin-bottom: 2px; font-size: 23px; }
.vote-button[data-vote="yes"].selected { color: var(--action-text); background: var(--forest); }
.vote-button[data-vote="ok"].selected { color: var(--ink); background: var(--sun); }
.vote-button[data-vote="no"].selected { color: #fff; background: #b94e3c; }

.add-choice-card { display: grid; gap: 8px; padding: 18px; box-shadow: none; }
.inline-form { display: flex; gap: 10px; }

.ballot-actions {
    position: sticky;
    bottom: 14px;
    z-index: 5;
    border: 1px solid rgba(23, 33, 28, 0.1);
    border-radius: var(--radius-medium);
    padding: 14px;
    background: rgba(247, 242, 232, 0.94);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

html[data-theme="dark"] .ballot-actions { background: rgba(17, 23, 19, 0.94); }
html[data-theme="dark"] .status-pill { color: #173023; }
html[data-theme="dark"] .notice { color: var(--ink); background: rgba(255, 154, 125, 0.12); }

.ballot-actions .primary-button { width: 100%; }
.ballot-actions p { margin: 8px 4px 0; color: var(--ink-soft); font-size: 13px; text-align: center; }
.results-section { display: grid; gap: 18px; padding-top: 10px; }

.result-card {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 16px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: var(--radius-medium);
    padding: 18px;
    background: var(--white);
}

.result-card.winner { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(23, 79, 59, 0.1); }
.result-card.final-choice { color: #17211c; background: linear-gradient(135deg, var(--lime), #ecf8b0); }
.result-rank { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: var(--action-text); background: var(--forest); font-weight: 900; }
.result-name { font-size: 18px; font-weight: 900; }
.result-counts { margin-top: 4px; color: var(--ink-soft); font-size: 13px; }

.promotion-share {
    display: grid;
    gap: 12px;
    margin-top: 8px;
    border-radius: var(--radius-large);
    padding: clamp(22px, 5vw, 32px);
    color: var(--share-text);
    background: var(--share-bg);
    box-shadow: var(--shadow);
}

.promotion-share .eyebrow { color: var(--lime); }
.promotion-share h2 { max-width: 18ch; }
.promotion-share p { margin-bottom: 4px; color: rgba(255, 255, 255, 0.78); }
.promotion-share-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.promotion-share-actions .primary-button { color: #17211c; background: var(--lime); }
.promotion-share-actions .secondary-button { border-color: var(--lime); color: var(--lime); }

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 20;
    max-width: min(380px, calc(100% - 36px));
    border-radius: var(--radius-small);
    padding: 13px 16px;
    color: #fff;
    background: var(--ink);
    box-shadow: var(--shadow);
    font-weight: 800;
}

.site-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px 22px;
    width: min(100% - 32px, 980px);
    margin: 0 auto;
    padding: 18px 0 28px;
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 750;
}

.site-footer a { color: inherit; text-decoration-color: var(--line); text-underline-offset: 3px; }
.site-footer a:hover { color: var(--forest); }
.site-version { flex-basis: 100%; color: var(--ink-soft); font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-align: center; }

.content-shell { width: min(100% - 32px, 860px); margin: 0 auto; padding: 54px 0 60px; }
.content-shell > h1 { max-width: 17ch; }
.content-lead { max-width: 62ch; margin-bottom: 34px; color: var(--ink-soft); font-size: 19px; }
.content-card { display: grid; gap: 16px; margin-top: 18px; border: 1px solid var(--line); border-radius: var(--radius-large); padding: clamp(22px, 5vw, 34px); background: var(--white); box-shadow: var(--shadow); }
.content-card h2 { margin-bottom: 0; }
.content-card p:last-child, .content-card ul:last-child { margin-bottom: 0; }
.content-card li + li { margin-top: 8px; }
.steps-list { display: grid; gap: 18px; margin: 4px 0 0; padding: 0; list-style: none; counter-reset: steps; }
.steps-list li { display: grid; grid-template-columns: 42px 1fr; column-gap: 14px; counter-increment: steps; }
.steps-list li::before { content: counter(steps); grid-row: span 2; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; color: var(--action-text); background: var(--forest); font-weight: 900; }
.steps-list span { color: var(--ink-soft); }
.example-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 18px; }
.example-card { border: 1px solid var(--line); border-radius: var(--radius-medium); padding: 22px; background: var(--white); }
.example-card > span { font-size: 28px; }
.example-card h2 { margin: 12px 0 8px; font-size: 23px; }
.example-card p { margin-bottom: 0; color: var(--ink-soft); }
.content-callout { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.content-action { display: grid; place-items: center; text-align: center; text-decoration: none; }
.policy-page { max-width: 760px; }
.policy-page .content-card { box-shadow: none; }
.policy-page ul { margin-top: 0; padding-left: 22px; }
.policy-updated { margin-top: 24px; color: var(--ink-soft); font-size: 13px; }
.feedback-shell { max-width: 680px; }
.feedback-form { position: relative; }
.feedback-form-meta { display: flex; justify-content: space-between; gap: 16px; color: var(--ink-soft); font-size: 12px; }
.feedback-trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.feedback-success { justify-items: start; }
.feedback-success > div { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; color: var(--action-text); background: var(--forest); font-size: 26px; font-weight: 900; }

select {
    width: 100%;
    min-height: 56px;
    border: 2px solid var(--line);
    border-radius: var(--radius-small);
    padding: 12px 42px 12px 16px;
    color: var(--ink);
    background: var(--white);
    font: inherit;
    outline: none;
}

select:focus { border-color: var(--forest); box-shadow: 0 0 0 4px rgba(23, 79, 59, 0.12); }
.moderator-shell { width: min(100% - 32px, 920px); }
.create-view { max-width: 760px; margin: 3vh auto 0; }

.setup-card {
    display: grid;
    gap: 22px;
    border: 1px solid rgba(23, 33, 28, 0.1);
    border-radius: var(--radius-large);
    padding: clamp(22px, 5vw, 34px);
    background: var(--white);
    box-shadow: var(--shadow);
}

.field-group { display: grid; gap: 8px; }
.field-grid { display: grid; grid-template-columns: 1fr; gap: 18px; }
.full-field input { font-size: 18px; }

.number-stepper { display: grid; grid-template-columns: 56px minmax(0, 1fr) 56px; overflow: hidden; border: 2px solid var(--line); border-radius: var(--radius-small); background: var(--white); }
.number-stepper:focus-within { border-color: var(--forest); box-shadow: 0 0 0 4px rgba(23, 79, 59, 0.12); }
.number-stepper input { min-width: 0; border: 0; border-radius: 0; padding-inline: 8px; font-size: 20px; font-weight: 900; text-align: center; box-shadow: none; }
.number-stepper input:focus { box-shadow: none; }
.number-stepper input::-webkit-inner-spin-button, .number-stepper input::-webkit-outer-spin-button { margin: 0; appearance: none; }
.number-stepper button { border: 0; color: var(--forest); background: var(--paper-deep); cursor: pointer; font-size: 26px; font-weight: 800; }
.number-stepper button:hover { background: var(--line); }

.check-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border-radius: var(--radius-small);
    padding: 14px;
    background: var(--paper);
    cursor: pointer;
}

.check-row input { width: 22px; min-height: 22px; margin-top: 1px; accent-color: var(--forest); }
.check-row span { display: grid; gap: 2px; }
.check-row small { color: var(--ink-soft); font-weight: 500; }
.moderator-view { display: grid; gap: 26px; }
.moderator-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.moderator-heading h1 { margin: 5px 0 0; font-size: clamp(38px, 7vw, 62px); }

.share-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border-radius: var(--radius-large);
    padding: clamp(20px, 4vw, 30px);
    color: var(--share-text);
    background: var(--share-bg);
    box-shadow: var(--shadow);
}

.share-card .eyebrow { color: var(--lime); }
.share-card .secondary-button { border-color: var(--lime); color: var(--lime); }
.share-code { margin-top: 4px; font-size: clamp(38px, 8vw, 62px); font-weight: 950; letter-spacing: 0.1em; line-height: 1; }
.pin-reminder { margin: 10px 0 0; color: rgba(255, 255, 255, 0.75); font-size: 13px; }
.moderator-progress { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.metric-card {
    display: grid;
    gap: 2px;
    border: 1px solid var(--line);
    border-radius: var(--radius-medium);
    padding: 18px;
    background: var(--white);
}

.metric-card span { color: var(--ink-soft); font-size: 13px; font-weight: 800; }
.metric-card strong { font-family: var(--font-display); font-size: 36px; font-weight: 800; line-height: 1; }
.moderator-section { display: grid; gap: 16px; }
.moderator-choice-list { display: grid; gap: 10px; }

.moderator-choice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-medium);
    padding: 16px 18px;
    background: var(--white);
    font-size: 17px;
    font-weight: 850;
}

.participant-tag { border-radius: 999px; padding: 5px 8px; color: var(--forest); background: rgba(216, 239, 115, 0.45); font-size: 10px; font-weight: 900; text-transform: uppercase; }

.control-card {
    display: grid;
    gap: 20px;
    border-radius: var(--radius-large);
    padding: clamp(20px, 4vw, 28px);
    background: var(--paper-deep);
}

.control-buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.control-buttons button { flex: 1 1 180px; }
.danger-button { min-height: 54px; border: 0; border-radius: 14px; padding: 12px 18px; color: #fff; background: #9f3f32; cursor: pointer; font-weight: 900; }
.quiet-button { min-height: 54px; border: 2px solid var(--line); border-radius: 14px; padding: 12px 18px; color: var(--ink); background: var(--white); cursor: pointer; font-weight: 900; }
.tie-choice-button { width: 100%; border: 2px solid transparent; border-radius: var(--radius-medium); padding: 16px; color: var(--ink); background: var(--white); cursor: pointer; text-align: left; }
.tie-choice-button.selected { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(23, 79, 59, 0.1); }

@media (max-width: 620px) {
    .site-header { padding: 12px 0; }
    .brand-mark { width: 30px; height: 30px; border-radius: 9px; }
    .app-shell { padding: 12px 0 18px; }
    .join-view { margin-top: 0; }
    .join-view > .eyebrow { font-size: 10px; }
    .join-view h1 { margin: 7px 0 10px; font-size: clamp(36px, 10.5vw, 43px); line-height: 1.01; }
    .join-view .lead { margin-bottom: 16px; font-size: 15px; line-height: 1.35; }
    .join-card { gap: 8px; padding: 16px; }
    .join-card input { min-height: 50px; }
    .join-card .primary-button { min-height: 52px; }
    #roomCode { font-size: 24px; }
    .start-decision-card { grid-template-columns: 1fr; gap: 10px; margin-bottom: 12px; padding: 16px; }
    .start-decision-card h2 { margin: 2px 0 0; font-size: 24px; }
    .start-decision-card p { display: none; }
    .start-decision-button { width: 100%; }
    .promotion-share-actions { display: grid; }
    .promotion-share-actions .primary-button, .promotion-share-actions .secondary-button { width: 100%; }
    .decision-heading h1 { font-size: clamp(34px, 10vw, 46px); }
    .decision-view { gap: 18px; }
    .section-heading { align-items: flex-start; margin-bottom: 12px; }
    .choice-label { font-size: 18px; }
    .inline-form { display: grid; }
    .field-grid { grid-template-columns: 1fr; }
    .moderator-heading, .share-card { display: grid; }
    .share-card .secondary-button { width: 100%; }
    .moderator-progress { grid-template-columns: repeat(3, 1fr); }
    .metric-card { padding: 14px 10px; text-align: center; }
    .metric-card strong { font-size: 30px; }
    .home-footer { gap: 6px 16px; margin-top: 0; padding: 0 0 12px; font-size: 11px; line-height: 1.2; }
    .content-shell { padding: 24px 0 36px; }
    .content-shell > h1 { font-size: 40px; }
    .content-lead { margin-bottom: 22px; font-size: 16px; }
    .example-grid { grid-template-columns: 1fr; }
    .content-callout { grid-template-columns: 1fr; }
    .content-action { width: 100%; }
    .feedback-form-meta { display: grid; gap: 3px; }
}

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