:root {
  --ink: #17353a;
  --muted: #64777a;
  --paper: #f5f7f3;
  --white: #ffffff;
  --line: #dbe3de;
  --teal: #0a716e;
  --teal-dark: #075a59;
  --lime: #cfe969;
  --navy: #103b42;
  --red: #b33a35;
  --shadow: 0 10px 35px rgba(23, 53, 58, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 90% 5%, rgba(207, 233, 105, .14), transparent 22rem), var(--paper); }
a { color: inherit; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.site-header {
  min-height: 72px; padding: 0 max(24px, calc((100vw - 1160px) / 2)); display: flex; align-items: center;
  justify-content: space-between; gap: 24px; background: var(--navy); color: white;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: white; text-decoration: none; font-size: 1.03rem; letter-spacing: .01em; }
.brand strong { color: var(--lime); }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--lime); color: var(--navy); font-weight: 900; }
.nav-actions { display: flex; align-items: center; gap: 24px; font-size: .92rem; }
.nav-actions a, .link-button { color: #e2eded; text-decoration: none; background: none; border: 0; padding: 4px 0; }
.nav-actions a:hover, .link-button:hover { color: var(--lime); }
.nav-actions form { display: contents; }

.page-shell { width: min(1160px, calc(100% - 32px)); min-height: calc(100vh - 150px); margin: 0 auto; padding: 54px 0 72px; }
footer { padding: 24px; text-align: center; color: var(--muted); font-size: .82rem; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 14px; font-size: clamp(2rem, 5vw, 3.6rem); line-height: 1.02; letter-spacing: -.045em; }
h2 { margin-bottom: 6px; font-size: 1.35rem; letter-spacing: -.02em; }
h3 { margin: 9px 0 6px; }
p { line-height: 1.6; }
.lede { max-width: 700px; color: var(--muted); font-size: 1.06rem; }
.eyebrow { margin-bottom: 12px; color: var(--teal); font-size: .75rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.card { background: rgba(255, 255, 255, .94); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.narrow, .auth-card { width: min(500px, 100%); margin: 4vh auto 0; padding: clamp(26px, 6vw, 48px); }
.auth-card h1 { max-width: 410px; }

.stack-form { display: grid; gap: 20px; margin-top: 30px; }
.stack-form.compact { gap: 14px; margin-top: 20px; }
label { display: grid; gap: 7px; color: var(--ink); font-size: .86rem; font-weight: 700; }
input, textarea, select { width: 100%; border: 1px solid #c7d4cf; border-radius: 9px; background: white; color: var(--ink); padding: 11px 12px; outline: none; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(10, 113, 110, .13); }
.hint { color: var(--muted); font-size: .77rem; font-weight: 400; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.button, button.primary, button.secondary, button.ghost, button.danger { display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 9px; padding: 11px 16px; font-weight: 750; text-decoration: none; }
.primary { border: 0; background: var(--teal); color: white; }
.primary:hover { background: var(--teal-dark); }
.secondary { border-color: var(--teal) !important; background: white; color: var(--teal); }
.ghost { border-color: var(--line) !important; background: white; color: var(--ink); }
.danger { border-color: #e8c4c1 !important; background: #fff7f6; color: var(--red); }
.small { padding: 7px 10px !important; border-radius: 7px !important; font-size: .77rem; }
.full { width: 100%; }

.alert { margin: -24px 0 28px; padding: 13px 16px; border-radius: 10px; font-size: .9rem; }
.alert.success { border: 1px solid #b8d7bd; background: #ebf7ec; color: #286039; }
.alert.error { border: 1px solid #e4bbb8; background: #fff0ef; color: #7f2f2b; }
.round-hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 50px; margin-bottom: 48px; }
.round-hero h1 { max-width: 760px; }
.status { display: inline-block; padding: 4px 8px; border-radius: 99px; background: #e7ece9; color: var(--muted); font-size: .66rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.status.active { background: #dcf2de; color: #28653a; }
.status.closed { background: #e9ebed; color: #5d686c; }
.budget-card { min-width: 190px; padding: 20px 24px; border-radius: 14px; background: var(--navy); color: white; box-shadow: var(--shadow); }
.budget-card span, .budget-card small { display: block; color: #c6d5d6; font-size: .78rem; }
.budget-card strong { display: block; margin: 2px 0; color: var(--lime); font-size: 2.65rem; line-height: 1; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: 0 0 18px; color: var(--muted); font-size: .9rem; }
.toolbar strong { color: var(--ink); }
.toolbar-actions { display: flex; align-items: center; gap: 10px; }
.ideas-list { display: grid; gap: 10px; }
.idea-card { display: grid; grid-template-columns: 48px 1fr 105px; align-items: center; gap: 17px; min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: 13px; background: white; transition: transform .15s, box-shadow .15s; }
.idea-card:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(23, 53, 58, .07); }
.rank { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: #edf2ee; color: var(--teal); font-weight: 850; }
.idea-main { min-width: 0; }
.idea-heading { display: flex; justify-content: space-between; gap: 12px; font-size: 1.05rem; font-weight: 800; }
.idea-heading a { overflow-wrap: anywhere; text-decoration: none; }
.idea-heading a:hover { color: var(--teal); }
.idea-main p { margin: 5px 0 9px; color: var(--muted); font-size: .89rem; line-height: 1.45; }
.points-total { flex: none; color: var(--teal); font-size: .8rem; }
.meta { color: #7a898a; font-size: .73rem; }
.score-bar { height: 3px; margin-top: 12px; border-radius: 99px; background: #edf1ee; overflow: hidden; }
.score-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), #48a686); }
.vote-box { justify-items: end; color: var(--muted); font-size: .72rem; }
.vote-box input { width: 78px; padding: 9px; text-align: center; font-size: 1rem; font-weight: 800; }
.vote-save { position: sticky; bottom: 16px; display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 8px; padding: 14px 16px 14px 20px; border: 1px solid #bfcfc9; border-radius: 12px; background: rgba(255, 255, 255, .95); box-shadow: 0 12px 35px rgba(23, 53, 58, .15); backdrop-filter: blur(10px); color: var(--muted); font-size: .82rem; }
.vote-save strong { color: var(--ink); }
.quiet { color: var(--muted); }
.centered { text-align: center; }

.display-mode .site-header { min-height: 84px; }
.display-mode .page-shell { width: min(1440px, calc(100% - 48px)); padding-top: 42px; }
.display-mode .round-hero { margin-bottom: 32px; }
.display-mode .round-hero h1 { font-size: clamp(2.8rem, 5vw, 5rem); }
.display-mode .idea-card { grid-template-columns: 64px 1fr; gap: 22px; padding: 24px 28px; }
.display-mode .idea-card:hover { transform: none; }
.display-mode .rank { width: 54px; height: 54px; font-size: 1.25rem; }
.display-mode .idea-heading { font-size: 1.25rem; }
.display-mode .idea-main p { font-size: 1rem; }
.display-mode .points-total { font-size: 1rem; }

.empty-state { padding: 60px 24px; text-align: center; }
.empty-state p { color: var(--muted); }
.empty-icon { margin-bottom: 12px; color: var(--teal); font-size: 2rem; }
.form-page, .detail-page { width: min(820px, 100%); margin: auto; }
.back-link { display: inline-block; margin-bottom: 40px; color: var(--teal); font-size: .86rem; font-weight: 750; text-decoration: none; }
.form-page .card { padding: clamp(22px, 5vw, 38px); }
.detail-header { display: grid; grid-template-columns: 1fr auto; gap: 40px; align-items: start; margin-bottom: 38px; }
.points-badge { min-width: 130px; padding: 18px; border-radius: 14px; background: var(--navy); color: white; text-align: center; }
.points-badge strong, .points-badge span { display: block; }
.points-badge strong { color: var(--lime); font-size: 2rem; }
.points-badge span { font-size: .72rem; }
.markdown-body { padding: clamp(24px, 5vw, 42px); line-height: 1.7; overflow-wrap: anywhere; }
.markdown-body h1 { font-size: 1.75rem; }
.markdown-body h2 { margin-top: 2rem; }
.markdown-body a { color: var(--teal); }
.markdown-body img { max-width: 100%; }
.markdown-body code { padding: 2px 5px; border-radius: 4px; background: #edf1ee; }
.markdown-body pre { padding: 16px; border-radius: 10px; background: var(--navy); color: white; overflow: auto; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.detail-page > .markdown-body + .markdown-body { margin-top: 16px; }
.idea-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 22px; font-size: .82rem; }
.comments-section { margin-top: 56px; padding-top: 8px; }
.comment-card { margin-top: 10px; padding: 18px 20px; }
.comment-card p { margin: 10px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-meta { display: flex; justify-content: space-between; gap: 18px; color: var(--muted); font-size: .76rem; }
.comment-meta strong { color: var(--ink); }
.comment-form { display: grid; gap: 14px; margin-top: 18px; padding: 20px; }
.comment-form button { justify-self: end; }
.comments-section .alert { margin: 18px 0; }
.my-ideas-list { display: grid; gap: 12px; margin-top: 32px; }
.my-idea { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 22px; }
.my-idea h2 a { text-decoration: none; }
.my-idea h2 a:hover { color: var(--teal); }
.my-idea p { margin-bottom: 0; color: var(--muted); }
.my-idea-actions { display: flex; flex: none; align-items: center; gap: 8px; font-size: .78rem; }

.rules-page { width: min(940px, 100%); margin: auto; }
.rules-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 38px 0 20px; }
.rule-card { padding: 26px; }
.rule-card > strong { display: block; margin-bottom: 12px; color: var(--teal); font-size: 2.25rem; line-height: 1; }
.rule-card p, .privacy-note p { margin-bottom: 0; color: var(--muted); font-size: .9rem; }
.privacy-note { display: flex; align-items: center; justify-content: space-between; gap: 30px; padding: 28px; border-color: #bcd3cc; }
.privacy-note > span { flex: none; color: var(--teal); font-size: 2rem; }

.form-page.wide { width: min(940px, 100%); }
.audit-list { display: grid; gap: 12px; margin-top: 34px; }
.audit-person { padding: 22px; }
.audit-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.audit-heading h2 { margin: 0; }
.audit-heading span { color: var(--muted); font-size: .78rem; }
.audit-heading > div:last-child { text-align: right; }
.audit-heading > div:last-child strong, .audit-heading > div:last-child span { display: block; }
.audit-heading > div:last-child strong { color: var(--teal); font-size: 1.4rem; }
.audit-person ul { display: grid; gap: 8px; margin: 16px 0 0; padding: 0; list-style: none; }
.audit-person li { display: flex; justify-content: space-between; gap: 20px; font-size: .86rem; }
.audit-person li a { color: var(--teal); text-decoration: none; }
.danger-panel { border-color: #e4bbb8; }
.danger-panel .back-link { margin-bottom: 26px; }

.admin-header { margin-bottom: 42px; }
.admin-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 28px; align-items: start; }
.section-title { display: flex; justify-content: space-between; margin-bottom: 14px; }
.section-title p { margin: 0; color: var(--muted); font-size: .82rem; }
.create-panel { margin-bottom: 14px; padding: 16px 18px; }
.create-panel > summary { color: var(--teal); cursor: pointer; font-size: .86rem; font-weight: 800; }
.round-list { display: grid; gap: 10px; }
.admin-round { display: flex; justify-content: space-between; gap: 20px; padding: 20px; }
.admin-round p { margin-bottom: 8px; color: var(--muted); font-size: .86rem; }
.round-actions { display: flex; flex: none; align-items: flex-start; gap: 7px; }
.round-actions form { display: contents; }
.empty-mini { padding: 24px; color: var(--muted); text-align: center; }
.table-card { margin-top: 30px; overflow: visible; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th, td { padding: 15px 18px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
td small { display: block; margin-top: 3px; color: var(--muted); }
.pill { padding: 3px 7px; border-radius: 99px; background: #edf1ee; font-size: .68rem; text-transform: uppercase; }
.row-actions { display: flex; align-items: center; gap: 7px; }
.row-actions form { display: contents; }
details { position: relative; }
details summary { list-style: none; cursor: pointer; }
details summary::-webkit-details-marker { display: none; }
.popover { position: absolute; z-index: 5; right: 0; top: calc(100% + 8px); width: 260px; padding: 15px; border: 1px solid var(--line); border-radius: 10px; background: white; box-shadow: var(--shadow); }
.popover button { margin-top: 10px; }

@media (max-width: 800px) {
  .page-shell { padding-top: 36px; }
  .round-hero, .detail-header { align-items: stretch; flex-direction: column; grid-template-columns: 1fr; }
  .budget-card, .points-badge { width: 100%; }
  .admin-grid { grid-template-columns: 1fr; }
  .rules-grid { grid-template-columns: 1fr; }
  .idea-card { grid-template-columns: 38px 1fr; align-items: start; }
  .rank { width: 36px; height: 36px; }
  .vote-box { grid-column: 2; display: flex; justify-content: flex-end; align-items: center; }
  .vote-save { align-items: stretch; flex-direction: column; }
  .vote-save button { width: 100%; }
  .display-mode .page-shell { width: min(100% - 28px, 1440px); }
  .display-mode .idea-card { grid-template-columns: 44px 1fr; gap: 12px; padding: 18px; }
  .display-mode .rank { width: 40px; height: 40px; font-size: 1rem; }
}

@media (max-width: 560px) {
  .site-header { padding: 12px 16px; align-items: flex-start; flex-direction: column; }
  .nav-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; gap: 10px 18px; }
  .page-shell { width: min(100% - 22px, 1160px); }
  h1 { font-size: 2.25rem; }
  .toolbar, .admin-round { align-items: stretch; flex-direction: column; }
  .my-idea { align-items: stretch; flex-direction: column; }
  .my-idea-actions { flex-wrap: wrap; }
  .toolbar-actions { align-items: stretch; flex-direction: column; }
  .toolbar-actions > * { width: 100%; }
  .idea-card { padding: 15px 12px; gap: 10px; }
  .idea-heading { align-items: flex-start; flex-direction: column; gap: 4px; }
  .two-cols { grid-template-columns: 1fr; }
  .round-actions { flex-wrap: wrap; }
  .audit-heading { align-items: flex-start; flex-direction: column; }
  .audit-heading > div:last-child { text-align: left; }
  .form-actions { align-items: stretch; flex-direction: column-reverse; }
  .form-actions > * { width: 100%; }
  .comment-meta { flex-direction: column; gap: 3px; }
  .comment-form button { width: 100%; }
}

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