:root {
  --orange: #ff6b00;
  --orange-dark: #e66000;
  --orange-soft: #fff4e6;
  --ink: #1a1a1a;
  --ink-2: #4a4a4a;
  --ink-3: #6b7c93;
  --bg: #faf9f7;
  --card: #ffffff;
  --line: #e6e6e6;
  --line-strong: #cfcfcf;
  --green: #1e8e3e;
  --green-soft: #e6f4ea;
  --red: #c5221f;
  --red-soft: #fce8e6;
  --blue-soft: #f4f8fb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(26,26,26,.06), 0 4px 16px rgba(26,26,26,.05);
  --font: "Karla", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg);
  font-size: 17px; line-height: 1.5; overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: var(--orange-dark); }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .4em; font-weight: 700; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.45rem; } h3 { font-size: 1.1rem; }
p { margin: 0 0 .8em; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--ink-3); }
.small { font-size: .9rem; }
.hidden { display: none !important; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: .45em; padding: .6em 1.1em; min-height: 44px;
  border-radius: 999px; border: 1.5px solid var(--ink); background: var(--ink); color: #fff;
  font-weight: 700; cursor: pointer; text-decoration: none; transition: transform .08s, background .15s;
}
.btn:hover { background: #000; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--orange); border-color: var(--orange); }
.btn.primary:hover { background: var(--orange-dark); border-color: var(--orange-dark); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover { background: #fff; border-color: var(--ink); }
.btn.small { min-height: 36px; padding: .35em .9em; font-size: .92rem; }
.btn.link { background: none; border: none; color: var(--orange-dark); padding: .3em .2em; min-height: 36px; text-decoration: underline; }
.btn[disabled] { opacity: .5; cursor: default; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: none; background: transparent; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink-3); font-size: 1.1rem;
}
.icon-btn:hover { background: var(--orange-soft); color: var(--ink); }

/* Inputs */
.input, textarea.input {
  width: 100%; padding: .65em .85em; border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fff; min-height: 44px; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255,107,0,.15); outline: none; }
textarea.input { resize: vertical; line-height: 1.45; }
label.lbl, .lbl { display: block; font-weight: 700; margin-bottom: .3em; }
.hint { color: var(--ink-3); font-size: .93rem; margin: -.1em 0 .55em; }

/* Layout */
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(250,249,247,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; padding: 10px 16px; min-height: 60px;
}
.topbar .logo { height: 34px; width: auto; }
.topbar .title { font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title span { color: var(--ink-3); font-weight: 400; }
.save-state { font-size: .9rem; color: var(--ink-3); display: inline-flex; align-items: center; gap: .4em; white-space: nowrap; }
.save-state.saved { color: var(--green); }
.save-state.saving { color: var(--ink-3); }
.save-state.error { color: var(--red); }
.save-state .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: calc(100vh - 60px); }
.sidenav { border-right: 1px solid var(--line); padding: 20px 14px 40px; background: #fff; position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto; align-self: start; }
.sidenav .sess { margin-bottom: 14px; }
.sidenav .sess-title { display: flex; align-items: baseline; gap: .5em; font-weight: 700; padding: 6px 10px; color: var(--ink); }
.sidenav .sess-title .lock { margin-left: auto; font-size: .85rem; }
.sidenav .sess.locked .sess-title, .sidenav .sess.locked .step-link { color: var(--ink-3); }
.locked-panel { max-width: 520px; padding-top: 20px; }
.locked-panel .big { font-size: 2.6rem; margin-bottom: 8px; }
.locked-panel .form-row { max-width: 420px; }
.sidenav .sess-title small { color: var(--ink-3); font-weight: 400; font-size: .8rem; }
.sidenav .step-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; border: none; background: none;
  width: 100%; text-align: left; cursor: pointer; color: var(--ink-2); font-size: .95rem; line-height: 1.3;
}
.sidenav .step-link:hover { background: var(--bg); color: var(--ink); }
.sidenav .step-link.active { background: var(--orange-soft); color: var(--ink); font-weight: 700; }
.sidenav .step-link .pip { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line-strong); flex: none; }
.sidenav .step-link.done .pip { background: var(--green); border-color: var(--green); }
.sidenav .step-link.active .pip { border-color: var(--orange); }

.main { padding: 28px 24px 80px; max-width: 860px; width: 100%; margin: 0 auto; }
.crumb { color: var(--ink-3); font-size: .9rem; margin-bottom: .3em; }
.step-head { margin-bottom: 22px; }
.step-head .intro { font-size: 1.05rem; color: var(--ink-2); max-width: 65ch; }
.session-intro { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--orange); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 26px; color: var(--ink-2); }

.block { margin-bottom: 30px; }
.note { background: var(--blue-soft); border-radius: var(--radius); padding: 16px 18px; color: var(--ink-2); }
.note p:last-child { margin-bottom: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: .93rem; color: var(--ink-2); max-width: 100%; }

/* List block */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-row { display: flex; align-items: center; gap: 6px; }
.list-row .idx { width: 1.6em; text-align: right; color: var(--ink-3); font-size: .85rem; flex: none; }
.list-row .input { flex: 1; min-width: 0; }
.list-row .star { color: var(--line-strong); font-size: 1.35rem; }
.list-row .star.on { color: var(--orange); }
.list-row .del { opacity: 0; }
.list-row:hover .del, .list-row:focus-within .del { opacity: 1; }
.list-row.phantom .input { border-style: dashed; background: transparent; }
.list-row.phantom .del { display: none; }
.list-foot { margin-top: 8px; display: flex; align-items: center; gap: 12px; }
.star-hint { color: var(--ink-3); font-size: .9rem; }

/* Cards block */
.cards { display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-head h3 { margin: 0; color: var(--ink-3); font-size: .9rem; text-transform: uppercase; letter-spacing: .04em; }
.card .field { margin-bottom: 14px; } .card .field:last-child { margin-bottom: 0; }
.card.persona .persona-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 22px; }
.card.persona .persona-grid .span2 { grid-column: 1 / -1; }
.card.persona .quote-wrap { position: relative; padding-left: 1.6em; }
.card.persona .quote-wrap::before { content: "\201C"; position: absolute; left: 0; top: -.1em; font-size: 2.4em; color: var(--orange); line-height: 1; }

/* Choose block */
.choose-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.pill { border: 1.5px solid var(--line-strong); background: #fff; border-radius: 999px; padding: 7px 14px; cursor: pointer; font-size: .95rem; max-width: 100%; text-align: left; }
.pill:hover { border-color: var(--orange); }
.pill.on { background: var(--orange-soft); border-color: var(--orange); font-weight: 700; }
.pill .s { color: var(--orange); margin-right: .3em; }

/* Photos */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photo { position: relative; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); background: #fff; aspect-ratio: 1; }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo .del { position: absolute; top: 4px; right: 4px; background: rgba(255,255,255,.9); }
.photo-add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 2px dashed var(--line-strong); border-radius: var(--radius-sm); cursor: pointer; color: var(--ink-3); aspect-ratio: 1; }
.photo-add:hover { border-color: var(--orange); color: var(--ink); background: var(--orange-soft); }
.photo-add input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.photo.uploading::after { content: "Uploading…"; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255,255,255,.7); font-size: .9rem; }

/* Matrix */
.matrix-wrap { display: grid; grid-template-columns: 28px 1fr; grid-template-rows: 1fr 28px; gap: 6px; user-select: none; }
.matrix-ylabel { writing-mode: vertical-rl; transform: rotate(180deg); text-align: center; font-weight: 700; font-size: .9rem; }
.matrix-xlabel { grid-column: 2; text-align: center; font-weight: 700; font-size: .9rem; }
.matrix-board { position: relative; aspect-ratio: 1; background: #fff; border: 1.5px solid var(--line-strong); border-radius: var(--radius); overflow: visible; touch-action: none; }
.matrix-board::before, .matrix-board::after { content: ""; position: absolute; background: var(--line); }
.matrix-board::before { left: 50%; top: 0; bottom: 0; width: 1px; }
.matrix-board::after { top: 50%; left: 0; right: 0; height: 1px; }
.matrix-board .corner { position: absolute; font-size: .78rem; color: var(--ink-3); padding: 8px; max-width: 45%; }
.matrix-board .corner.tl { top: 0; left: 0; } .matrix-board .corner.tr { top: 0; right: 0; text-align: right; }
.matrix-board .corner.bl { bottom: 0; left: 0; } .matrix-board .corner.br { bottom: 0; right: 0; text-align: right; }
.matrix-board .corner.tr { color: var(--green); font-weight: 700; }
.matrix-axis { display: flex; justify-content: space-between; font-size: .8rem; color: var(--ink-3); grid-column: 2; }
.matrix-tray { margin-top: 14px; padding: 12px; border: 2px dashed var(--line-strong); border-radius: var(--radius); display: flex; flex-wrap: wrap; gap: 8px; min-height: 60px; }
.matrix-tray.empty::before { content: "All ideas placed. Nice."; color: var(--ink-3); font-size: .9rem; }
.idea {
  background: #fff7a8; border-radius: 6px; padding: 6px 10px; font-size: .85rem; line-height: 1.25; box-shadow: 0 1px 3px rgba(0,0,0,.15);
  cursor: grab; max-width: 180px; touch-action: none;
}
.idea:active, .idea.dragging { cursor: grabbing; box-shadow: 0 6px 16px rgba(0,0,0,.2); z-index: 5; }
.matrix-board .idea { position: absolute; transform: translate(-50%, -50%); max-width: 140px; }
.idea.dragging { position: fixed; transform: translate(-50%, -50%); pointer-events: none; }
.matrix-empty { color: var(--ink-3); }

/* Step footer / nav */
.step-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); }
.finish { text-align: center; padding: 40px 20px; }
.finish .big { font-size: 3rem; }

/* Timer */
.timer { display: inline-flex; align-items: center; gap: 10px; margin-top: 8px; }
.timer .clock { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.3rem; min-width: 3.2em; }
.timer .clock.done { color: var(--red); animation: pulse 1s ease-in-out 3; }
@keyframes pulse { 50% { opacity: .3; } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 12px 16px; border-radius: 10px; display: flex; gap: 14px; align-items: center; z-index: 50; box-shadow: var(--shadow);
  max-width: calc(100vw - 32px);
}
.toast button { background: none; border: none; color: var(--orange); font-weight: 700; cursor: pointer; padding: 4px 6px; }

/* Readonly rendering (facilitator view) */
.ro .list-row .input { border: none; background: transparent; padding: .2em .4em; min-height: 0; }
.ro .list-row.phantom { display: none; }
.ro-empty { color: var(--ink-3); font-style: italic; }
.ro-text { white-space: pre-wrap; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .6em .85em; min-height: 2.4em; }
.ro-list { margin: 0; padding-left: 1.3em; }
.ro-list li.star::marker { content: "★ "; color: var(--orange); }

/* Landing / login */
.center { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 32px; max-width: 460px; width: 100%; }
.panel .logo { height: 42px; margin-bottom: 20px; }
.form-row { display: flex; gap: 8px; }
.form-row .input { flex: 1; }
.error { color: var(--red); background: var(--red-soft); padding: 10px 12px; border-radius: 8px; margin-top: 10px; }

/* Mobile */
.navtoggle { display: none; }
@media (max-width: 860px) {
  body { font-size: 16px; }
  .shell { grid-template-columns: 1fr; }
  .sidenav { display: none; border-right: none; border-bottom: 1px solid var(--line); position: static; height: auto; }
  .sidenav.open { display: block; }
  .navtoggle { display: inline-flex; }
  .main { padding: 20px 16px 80px; }
  .card.persona .persona-grid { grid-template-columns: 1fr; }
  .topbar .save-state span.txt { display: none; }
  .list-row .del { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
