  :root {
    --bg: #E6F2E9;
    --check: rgba(46, 125, 87, 0.13);
    --card: #FFFFFF;
    --ink: #1E2B24;
    --muted: #5C6E64;
    --line: #CFDFD4;
    --field: #F5FAF6;
    --focus: #2E7D57;
    --yolk: #F4B400;
    --yolk-ink: #2B2200;
    --green: #2E7D57;
    --chip: #EAF4ED;
    --chip-ink: #24563D;
    --warn: #A4361C;
    --shadow: 0 18px 50px -24px rgba(30, 60, 42, 0.45);
    box-sizing: border-box;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --bg: #121C16;
      --check: rgba(127, 209, 164, 0.06);
      --card: #1B241F;
      --ink: #E8F1EB;
      --muted: #9CB0A4;
      --line: #304038;
      --field: #222D27;
      --focus: #7FD1A4;
      --green: #7FD1A4;
      --chip: #263630;
      --chip-ink: #BFE8D0;
      --warn: #F0A08A;
      --shadow: 0 18px 50px -24px rgba(0, 0, 0, 0.8);
    }
  }
  :root[data-theme="dark"] {
    --bg: #121C16;
    --check: rgba(127, 209, 164, 0.06);
    --card: #1B241F;
    --ink: #E8F1EB;
    --muted: #9CB0A4;
    --line: #304038;
    --field: #222D27;
    --focus: #7FD1A4;
    --green: #7FD1A4;
    --chip: #263630;
    --chip-ink: #BFE8D0;
    --warn: #F0A08A;
    --shadow: 0 18px 50px -24px rgba(0, 0, 0, 0.8);
  }
  *, *::before, *::after { box-sizing: inherit; }
  html { height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
  body {
    margin: 0;
    min-height: 100%;
    color: var(--ink);
    font-family: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    background-color: var(--bg);
    background-image:
      linear-gradient(90deg, var(--check) 50%, transparent 50%),
      linear-gradient(var(--check) 50%, transparent 50%);
    background-size: 44px 44px;
  }
  .page {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px 40px;
    gap: 20px;
  }
  .card {
    width: 100%;
    max-width: 560px;
    background: var(--card);
    border-radius: 22px;
    padding: 36px 28px 28px;
    box-shadow: var(--shadow);
  }
  @media (max-width: 420px) { .card { padding: 28px 18px 22px; } }

  .hero { text-align: center; margin-bottom: 28px; }
  .mascot { width: 72px; height: 72px; display: block; margin: 0 auto 14px; }
  .hero h1 {
    font-family: "Jua", "IBM Plex Sans KR", system-ui, sans-serif;
    font-weight: 400;
    font-size: 1.55rem;
    line-height: 1.35;
    margin: 0;
    letter-spacing: -0.01em;
  }
  .hero p { margin: 8px 0 0; color: var(--muted); font-size: 0.95rem; }

  .rows { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
  .row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--field);
    border: 1.5px solid var(--line);
    border-radius: 12px;
    padding: 0 6px 0 14px;
    transition: border-color .15s;
  }
  .row:focus-within { border-color: var(--focus); }
  .row .num { color: var(--green); font-weight: 600; min-width: 1.6em; }
  .row input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    font: inherit;
    color: var(--ink);
    padding: 14px 0;
    outline: none;
  }
  .row input::placeholder { color: var(--muted); opacity: .8; }
  .icon-btn {
    border: 0;
    background: transparent;
    color: var(--muted);
    width: 36px;
    height: 36px;
    border-radius: 9px;
    font-size: 1.2rem;
    cursor: pointer;
    flex-shrink: 0;
  }
  .icon-btn:hover { background: var(--chip); color: var(--ink); }

  .quick { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
  .quick span { color: var(--muted); font-size: .85rem; margin-right: 2px; }
  .chip {
    border: 0;
    background: var(--chip);
    color: var(--chip-ink);
    font: inherit;
    font-size: .85rem;
    padding: 5px 11px;
    border-radius: 999px;
    cursor: pointer;
  }
  .chip:hover { filter: brightness(0.96); }
  .chip[aria-pressed="true"] { background: var(--green); color: var(--card); }

  .add {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin: 18px 0 6px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
  }
  .add:hover:not(:disabled) { color: var(--ink); background: var(--chip); }
  .add:disabled { cursor: default; opacity: .7; }
  .add svg { color: var(--green); }

  details.opts { margin: 4px 0 18px; border-top: 1px dashed var(--line); padding-top: 12px; }
  details.opts summary { cursor: pointer; color: var(--muted); font-size: .92rem; list-style: none; text-align: center; }
  details.opts summary::-webkit-details-marker { display: none; }
  details.opts summary::after { content: " ▾"; }
  details.opts[open] summary::after { content: " ▴"; }
  .opt-grid { display: grid; gap: 12px; margin-top: 14px; }
  .opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
  .opt > span { font-size: .95rem; }
  .seg { display: inline-flex; background: var(--field); border: 1.5px solid var(--line); border-radius: 10px; padding: 3px; }
  .seg button {
    border: 0; background: transparent; font: inherit; font-size: .9rem; color: var(--muted);
    padding: 6px 14px; border-radius: 7px; cursor: pointer;
  }
  .seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }

  .primary {
    width: 100%;
    border: 0;
    background: var(--yolk);
    color: var(--yolk-ink);
    font-family: "Jua", "IBM Plex Sans KR", system-ui, sans-serif;
    font-size: 1.2rem;
    padding: 16px;
    border-radius: 14px;
    cursor: pointer;
    transition: transform .08s, filter .15s;
  }
  .primary:hover:not(:disabled) { filter: brightness(1.04); }
  .primary:active:not(:disabled) { transform: translateY(1px); }
  .primary:disabled { opacity: .65; cursor: progress; }
  .secondary {
    flex: 1;
    border: 1.5px solid var(--line);
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-weight: 500;
    padding: 13px;
    border-radius: 12px;
    cursor: pointer;
  }
  .secondary:hover { background: var(--chip); }

  .random-link {
    border: 0;
    background: var(--card);
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    font-size: .95rem;
    padding: 10px 20px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: var(--shadow);
  }
  .random-link:hover { filter: brightness(0.98); }
  .note { color: var(--muted); font-size: .8rem; text-align: center; margin: 16px 0 0; }

  :focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
  .row input:focus-visible { outline: none; }

  /* results */
  .result-head { text-align: center; margin-bottom: 22px; }
  .result-head h2 { font-family: "Jua", "IBM Plex Sans KR", system-ui, sans-serif; font-weight: 400; font-size: 1.5rem; margin: 0; }
  .result-head p { margin: 6px 0 0; color: var(--muted); font-size: .92rem; }
  .menus { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
  .menu { border: 1.5px solid var(--line); border-radius: 16px; padding: 16px 18px; }
  .menu:first-child { border-color: var(--yolk); border-width: 2px; }
  .menu .top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
  .menu h3 { font-family: "Jua", "IBM Plex Sans KR", system-ui, sans-serif; font-weight: 400; font-size: 1.3rem; margin: 0; }
  .cat { font-size: .78rem; color: var(--chip-ink); background: var(--chip); border-radius: 6px; padding: 2px 8px; }
  .menu p { margin: 6px 0 0; font-size: .95rem; }
  .avoid { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
  .avoid span { font-size: .8rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; }
  .actions { display: flex; gap: 8px; margin-top: 18px; }
  .empty { text-align: center; padding: 18px 8px; }
  .empty p { margin: 0 0 4px; }
  .empty small { color: var(--muted); }
  details.payload { margin-top: 18px; }
  details.payload summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
  details.payload pre {
    margin: 10px 0 0; padding: 12px; background: var(--field); border-radius: 10px;
    font-size: .78rem; line-height: 1.5; overflow-x: auto; white-space: pre;
  }

  /* random */
  .slot { text-align: center; padding: 18px 0 8px; }
  .slot .label { color: var(--muted); font-size: .92rem; margin: 0; min-height: 1.5em; }
  .slot .name {
    font-family: "Jua", "IBM Plex Sans KR", system-ui, sans-serif;
    font-size: clamp(2rem, 8vw, 2.8rem);
    line-height: 1.25;
    margin: 10px 0 6px;
    min-height: 1.3em;
  }
  .slot .desc { margin: 0 auto; max-width: 30em; font-size: .95rem; min-height: 1.5em; }
  .slot.landed .name { color: var(--green); }

  .reveal { animation: rise .35s ease-out both; }
  @keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
  @media (prefers-reduced-motion: reduce) {
    .reveal { animation: none; }
    .primary, .row { transition: none; }
  }
  .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 에러 메시지 */
.error {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--chip);
  color: var(--warn);
  font-size: .9rem;
  text-align: center;
}
.random-link:disabled { opacity: .6; cursor: progress; }
.secondary:disabled { opacity: .6; cursor: progress; }

/* ---------- 링크 공유 방 ---------- */
[hidden] { display: none !important; }

.pills { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
a.random-link { display: inline-block; text-decoration: none; }
.random-link:disabled { opacity: .6; cursor: progress; }

.hero.compact { margin-bottom: 22px; }
.hero.compact .mascot { width: 56px; height: 56px; margin-bottom: 10px; }
.hero.compact h1 { font-size: 1.4rem; }

.share { display: flex; gap: 8px; }
.share input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: .9rem;
  color: var(--ink);
  background: var(--field);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
}
.share input:focus-visible { outline: none; border-color: var(--focus); }
.secondary.small { flex: none; padding: 11px 14px; font-size: .9rem; }
.secondary:disabled { opacity: .6; cursor: progress; }

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 28px 0 10px;
  font-size: .95rem;
  font-weight: 600;
}
.section-title small { color: var(--muted); font-weight: 400; font-size: .82rem; }

.row .lab { color: var(--muted); font-size: .85rem; min-width: 4.8em; }
.leave { text-align: right; margin-top: 6px; }
.text-btn {
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: .85rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 6px 2px;
}
.text-btn:hover { color: var(--ink); }
#room .quick + .primary { margin-top: 16px; }
.notice {
  margin: 0 0 10px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--chip);
  color: var(--chip-ink);
  font-size: .9rem;
}

.people { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.person {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
}
.person .who { flex: 1; min-width: 0; }
.pname { font-weight: 600; }
.me-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--green);
  color: var(--card);
  font-size: .72rem;
  vertical-align: 2px;
}
.pfood { margin: 2px 0 0; color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.empty-people {
  margin: 0;
  padding: 16px;
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: .9rem;
  text-align: center;
}

.opts .hint { margin: 2px 0 0; color: var(--muted); font-size: .82rem; text-align: center; }
.seg button:disabled { cursor: default; }
.pending { margin: 0 0 12px; text-align: center; color: var(--green); font-size: .92rem; }
.result-head .stale { margin: 10px 0 0; color: var(--warn); font-size: .88rem; }
#room .slot + .result-head { margin: 6px 0 0; }
