:root {
  color-scheme: light;
  --ink: #1f2733;
  --muted: #667085;
  --line: #e6e1d8;
  --paper: #f6f4ef;
  --card: #fffefb;
  --accent: #28536b;
  --accent-soft: #e3eef5;
  --green: #1f7049;
  --green-bg: #e3f5ea;
  --yellow: #8a5c00;
  --yellow-bg: #fff3d2;
  --red: #a3283a;
  --red-bg: #fde6ea;
  --blue: #2c5a82;
  --blue-bg: #e4eefb;
  --purple: #5f4b8b;
  --purple-bg: #efe9fb;
  --peach: #93522c;
  --peach-bg: #fdeee2;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 13px/1.45 "Avenir Next", "Segoe UI", system-ui, sans-serif; }
h1 { margin: 0; font-size: 20px; }
h2 { margin: 0 0 4px; font-size: 14px; }
code { background: var(--purple-bg); color: var(--purple); border-radius: 4px; padding: 0 4px; }
button, input, select, textarea { font: inherit; }
button { display: inline-flex; align-items: center; gap: 5px; border: 0; border-radius: 8px; padding: 6px 10px; background: var(--accent); color: white; cursor: pointer; font-weight: 600; white-space: nowrap; }
button:hover { filter: brightness(1.05); }
button.soft { background: var(--accent-soft); color: var(--accent); }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.danger { color: var(--red); }
button.icon-only { padding: 5px; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.icon { width: 15px; height: 15px; flex: none; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: white; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-bg); border-color: var(--blue); }
textarea { min-height: 64px; resize: vertical; }
label { display: grid; gap: 3px; font-weight: 600; margin-top: 8px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 8px 0 0; padding: 6px 8px; min-width: 0; }
legend { font-weight: 600; padding: 0 4px; }
.hidden { display: none !important; }
.error { color: var(--red); min-height: 1em; margin: 6px 0 0; }
.error:empty { display: none; }
.eyebrow { margin: 0; letter-spacing: 0.08em; text-transform: uppercase; font-size: 10px; font-weight: 700; color: var(--accent); }
.muted { color: var(--muted); margin: 3px 0 0; }

.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 700; background: #f0ece4; color: var(--muted); }
.badge .icon { width: 12px; height: 12px; }
.badge.big { font-size: 12px; padding: 4px 12px; }
.badge.GREEN { background: var(--green-bg); color: var(--green); }
.badge.YELLOW, .badge.soft-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge.RED { background: var(--red-bg); color: var(--red); }
.badge.OPEN, .badge.soft-blue, .badge.notification { background: var(--blue-bg); color: var(--blue); }
.badge.soft-purple, .badge.milestone { background: var(--purple-bg); color: var(--purple); }
.badge.wait { background: var(--green-bg); color: var(--green); }
.badge.escalation { background: var(--peach-bg); color: var(--peach); }

.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #e4eefb, #efe9fb 55%, #fdeee2); }
.login form { width: min(340px, 92vw); background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; display: grid; gap: 4px; box-shadow: 0 12px 40px rgb(40 83 107 / 0.12); }
.login h1 { font-size: 24px; margin-bottom: 4px; }
.login button { justify-content: center; margin-top: 12px; padding: 8px; }

#app { display: grid; grid-template-columns: 188px minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns 0.15s; }
#app.collapsed { grid-template-columns: 54px minmax(0, 1fr); }
#nav { position: sticky; top: 0; height: 100vh; background: #1f3d4e; color: white; display: flex; flex-direction: column; gap: 2px; padding: 10px 8px; }
#nav .brand { display: flex; justify-content: space-between; align-items: center; margin: 0 2px 10px; min-height: 28px; }
#nav .brand button { background: transparent; color: white; }
#nav .nav { justify-content: flex-start; background: transparent; color: #dce7ee; padding: 8px 10px; }
#nav .nav:hover { background: rgb(255 255 255 / 0.08); }
#nav .nav.active { background: #e4eefb; color: #1f3d4e; }
#nav .nav-end { margin-top: auto; }
#app.collapsed .label { display: none; }
#app.collapsed #nav .nav { justify-content: center; padding: 8px 0; }
#app.collapsed #nav .brand { justify-content: center; }
#main { padding: 14px 18px 32px; min-width: 0; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.card, .panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.card { display: grid; gap: 8px; align-content: start; }
.card-head { display: flex; align-items: center; gap: 6px; }
.card-head h2 { margin: 0; flex: 1; }
.card-head .icon { color: var(--accent); width: 17px; height: 17px; }
.inline-form { display: grid; grid-template-columns: 1.2fr 1fr 1.5fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.title-input { font-size: 16px; font-weight: 700; border-color: transparent; background: transparent; width: 280px; }
.title-input:hover { border-color: var(--line); }
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
th { background: #f3f0ea; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 7px 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { display: inline-flex; gap: 5px; align-items: center; margin: 0; padding: 3px 8px; border: 1px solid var(--line); border-radius: 999px; background: white; font-weight: 500; cursor: pointer; }
.chip:has(input:checked) { background: var(--blue-bg); border-color: #c4d7ef; color: var(--blue); }
.chip input { width: auto; margin: 0; }

.builder { display: grid; grid-template-columns: 180px minmax(0, 1fr) minmax(240px, 290px); gap: 10px; align-items: start; }
.builder > .panel { min-width: 0; }
.builder > .panel:last-child { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
.palette-card { display: flex; gap: 8px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; background: white; padding: 8px; margin-top: 6px; cursor: grab; }
.palette-card:hover { box-shadow: 0 2px 10px rgb(0 0 0 / 0.06); }
.palette-card .icon { margin-top: 2px; }
.palette-card.notification .icon, .box.notification .box-icon { color: var(--blue); }
.palette-card.wait .icon, .box.wait .box-icon { color: var(--green); }
.palette-card.milestone .icon, .box.milestone .box-icon { color: var(--purple); }
.palette-card.escalation .icon, .box.escalation .box-icon { color: var(--peach); }
.canvas { list-style: none; margin: 0; padding: 6px; min-height: 260px; border: 1px dashed #d7d0c3; border-radius: 10px; background: #fbfaf7; }
.canvas.over { background: var(--blue-bg); border-color: var(--blue); }
.canvas .empty { color: var(--muted); text-align: center; padding: 60px 0; }
.box { display: grid; grid-template-columns: 20px 22px 1fr auto; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: white; padding: 8px; margin-bottom: 6px; cursor: pointer; }
.box:hover { border-color: #cfc6b6; }
.box.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.box strong { margin-right: 6px; }
.step-no { color: var(--muted); font-size: 11px; font-weight: 700; text-align: center; }
.box-icon .icon { width: 18px; height: 18px; }
.preview { margin-top: 10px; padding: 8px; border-radius: 8px; background: var(--blue-bg); }
.preview p { margin: 2px 0 0; }

.player-top { margin-bottom: 10px; display: grid; gap: 6px; }
.clock-wrap { display: flex; align-items: center; gap: 8px; color: var(--accent); }
.clock-wrap .icon { width: 26px; height: 26px; }
.clock { font-size: 36px; font-weight: 700; margin: 0; font-variant-numeric: tabular-nums; color: var(--ink); }
.sequence { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.step { display: grid; grid-template-columns: 150px 1fr auto; gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--line); border-left: 4px solid #d8d1c4; border-radius: 10px; padding: 9px 12px; }
.step.GREEN { border-left-color: #7cc9a0; }
.step.YELLOW { border-left-color: #f1c35a; }
.step.RED { border-left-color: #ec8a99; background: #fff9fa; }
.step.OPEN { border-left-color: #8fb4df; background: #fbfdff; }
.when { display: grid; gap: 4px; justify-items: start; font-variant-numeric: tabular-nums; }
.step h2 { margin: 0; }
.step-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.line { margin: 4px 0 0; padding: 4px 8px; border-radius: 6px; background: #f5f2ec; color: var(--muted); }
.line.RED { background: var(--red-bg); color: var(--red); }

.act-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(135deg, #e4eefb, #efe9fb 55%, #fdeee2); font-size: 15px; }
.act-card { width: min(420px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px; display: grid; gap: 8px; box-shadow: 0 12px 40px rgb(40 83 107 / 0.12); }
.act-card h1 { font-size: 22px; }
.act-card .big { justify-content: center; padding: 14px; font-size: 17px; border-radius: 12px; margin-top: 8px; }

.person-form { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr 1.2fr auto; gap: 8px; align-items: end; margin-bottom: 6px; }
.person-form label { margin: 0; }
@media (max-width: 1000px) { .person-form { grid-template-columns: 1fr 1fr; } }
.badge.decision { background: #e0f3f1; color: #1d6b6b; }
.palette-card.decision .icon, .box.decision .box-icon { color: #1d6b6b; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.choices button { justify-content: center; }
button.alt { background: var(--peach-bg); color: var(--peach); }
.step-choices { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.responders { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; align-items: center; }
.responders .badge { font-weight: 600; }
.responder-count { font-size: 11px; color: var(--muted); margin-right: 2px; }
.choice-made { font-weight: 700; color: #1d6b6b; }
.option-list { display: grid; gap: 4px; }
.option-row { display: flex; gap: 4px; }

.member-page { background: linear-gradient(160deg, #e4eefb, #efe9fb 55%, #fdeee2); min-height: 100vh; font-size: 15px; }
.member-login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.member-card { width: min(380px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 24px; display: grid; gap: 8px; box-shadow: 0 12px 40px rgb(40 83 107 / 0.14); }
.member-card h1 { margin: 6px 0 0; font-size: 24px; }
.brand-mark { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--accent); color: white; font-weight: 800; letter-spacing: 0.04em; }
.member-card .big, .action-card .big { justify-content: center; padding: 13px; font-size: 16px; border-radius: 12px; }
.member-top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); background: rgb(255 254 251 / 0.9); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.member-top strong { font-size: 17px; }
.bell { position: relative; background: var(--accent-soft); color: var(--accent); border-radius: 50%; width: 44px; height: 44px; justify-content: center; padding: 0; }
.bell .icon { width: 22px; height: 22px; }
.bell.ringing .icon { animation: ring 1.6s ease-in-out infinite; transform-origin: 50% 10%; }
.bell-count { position: absolute; top: -3px; right: -3px; min-width: 20px; height: 20px; border-radius: 999px; background: var(--red); color: white; font-size: 11px; display: grid; place-items: center; padding: 0 5px; border: 2px solid white; }
@keyframes ring { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(14deg); } 20%, 40% { transform: rotate(-14deg); } }
.member-main { width: min(560px, 100%); margin: 0 auto; padding: 12px 14px 40px; display: grid; gap: 14px; }
.member-main h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 6px 2px 8px; }
.member-panel { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px; box-shadow: 0 10px 30px rgb(40 83 107 / 0.12); }
.member-panel-head { display: flex; justify-content: space-between; align-items: center; }
.member-panel-head h2 { margin: 0; }
.note-item { display: flex; gap: 10px; padding: 10px 4px; border-top: 1px solid var(--line); }
.note-item p { margin: 3px 0; }
.note-item.unread { background: var(--blue-bg); border-radius: 10px; padding: 10px 8px; }
.note-item.escalation .note-icon { color: var(--peach); }
.note-item.request .note-icon { color: #1d6b6b; }
.note-icon { color: var(--blue); padding-top: 2px; }
.note-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.action-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 10px; display: grid; gap: 8px; box-shadow: 0 6px 20px rgb(40 83 107 / 0.08); }
.action-card p { margin: 0; }
.action-message:empty { display: none; }
.empty { padding: 10px 2px; }
.small { font-size: 11px; }
.member-tools { display: flex; gap: 8px; align-items: center; }
.push-banner { width: min(560px, calc(100% - 28px)); margin: 12px auto 0; background: #fff3d2; color: #6a4700; border-radius: 14px; padding: 12px 14px; }
.push-banner p { margin: 4px 0 0; font-size: 13px; }
.push-banner button { margin-top: 8px; }
.member-names { font-size: 12px; color: var(--muted); margin: 6px 0 10px; line-height: 1.4; }
.modal-back { position: fixed; inset: 0; background: rgb(31 39 51 / 0.4); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal { width: min(480px, 100%); max-height: min(80vh, 640px); overflow: auto; background: var(--card); border-radius: 16px; padding: 16px; display: grid; gap: 10px; }
.member-picks { display: grid; gap: 4px; max-height: 360px; overflow: auto; }
.member-pick { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 500; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.member-pick .muted { margin-left: auto; font-size: 11px; }
.mode-pick { margin: 0; min-width: 180px; }
.stop-chip { margin: 0; font-size: 12px; white-space: nowrap; align-items: center; }
.step.SKIPPED { opacity: 0.55; }
.step.WAITING { opacity: 0.8; }
.badge.SKIPPED, .badge.WAITING { background: #f0ece4; color: var(--muted); }

@media (max-width: 1000px) {
  .builder { grid-template-columns: 1fr; }
  .builder > .panel:last-child { position: static; max-height: none; }
  .inline-form { grid-template-columns: 1fr; }
  .step { grid-template-columns: 1fr; }
}
