/* ===== StoryBoard design system ===== */
:root {
  --bg: #f6f5f2;
  --bg-rail: #1c1d22;
  --bg-rail-hover: #2a2c33;
  --surface: #ffffff;
  --surface-2: #f0efeb;
  --surface-3: #e7e6e0;
  --line: #e3e1da;
  --line-strong: #d2cfc6;
  --ink: #1d1e22;
  --ink-2: #54565e;
  --ink-3: #8b8d96;
  --accent: #c4452f;       /* warm cinematic red */
  --accent-soft: #f3ddd7;
  --accent-ink: #fff;
  --ok: #2e9e6b;
  --warn: #d98a1f;
  --shadow-sm: 0 1px 2px rgba(20,18,15,.06), 0 1px 3px rgba(20,18,15,.05);
  --shadow-md: 0 4px 14px rgba(20,18,15,.10), 0 2px 6px rgba(20,18,15,.06);
  --shadow-lg: 0 18px 50px rgba(20,18,15,.20), 0 6px 16px rgba(20,18,15,.12);
  --radius: 14px;
  --radius-sm: 10px;
  --rail-w: 248px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --display: 'Fraunces', Georgia, serif;

  /* card palette */
  --c-default:#ffffff; --c-butter:#fff4c7; --c-sage:#d8ecd0; --c-blush:#ffd9d4; --c-sky:#cfe6f7;
  --c-amber:#ffe08a; --c-mint:#a9e3bd; --c-coral:#ff9f8e; --c-orange:#ffc785; --c-blue:#a9c7ff;
  --c-grape:#d8c4ef; --c-pink:#ffc4dd; --c-stone:#dcdbd5;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--ink);
  background: var(--bg); -webkit-font-smoothing: antialiased; overflow: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
svg { width: 18px; height: 18px; flex: none; display: block; }   /* baseline; class rules override */
input, textarea { font-family: inherit; }
::-webkit-scrollbar { height: 10px; width: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 20px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); background-clip: content-box; }

/* ===== App shell ===== */
.app { display: grid; grid-template-columns: var(--rail-w) 1fr; height: 100vh; }
.app--norail { grid-template-columns: 1fr; }

/* ----- Sidebar rail ----- */
.rail { background: var(--bg-rail); color: #e9e9ec; display: flex; flex-direction: column; padding: 14px 12px; gap: 2px; min-width: 0; }
.rail__brand { display: flex; align-items: center; gap: 10px; padding: 8px 8px 14px; }
.rail__logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #e0775f); display: grid; place-items: center; box-shadow: var(--shadow-sm); flex: none; }
.rail__logo svg { width: 18px; height: 18px; }
.rail__brandtext { font-family: var(--display); font-weight: 600; font-size: 18px; letter-spacing: .2px; }
.rail__proj { padding: 10px 10px 12px; margin-bottom: 6px; border-radius: var(--radius-sm); background: rgba(255,255,255,.04); }
.rail__proj-title { font-weight: 600; font-size: 14px; line-height: 1.3; }
.rail__proj-sub { font-size: 11.5px; color: #9a9ba4; margin-top: 3px; }
.rail__section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: #75767f; padding: 14px 10px 5px; }
.navitem { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px; color: #c8c9d0; font-size: 13.5px; font-weight: 500; width: 100%; text-align: left; transition: background .12s, color .12s; }
.navitem:hover { background: var(--bg-rail-hover); color: #fff; }
.navitem.active { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.navitem.active .navitem__ico { opacity: 1; }
.navitem__ico { width: 17px; height: 17px; opacity: .8; flex: none; }
.navitem__badge { margin-left: auto; font-size: 11px; color: #8d8e97; background: rgba(255,255,255,.07); padding: 1px 7px; border-radius: 20px; }
.navitem.active .navitem__badge { background: rgba(255,255,255,.22); color: #fff; }
.rail__sub { display: flex; flex-direction: column; gap: 1px; padding: 3px 0 3px 14px; margin-left: 8px; border-left: 1px solid rgba(255,255,255,.08); }
.rail__chip { display:flex; align-items:center; gap:8px; padding: 6px 9px; border-radius: 8px; color: #b5b6be; font-size: 12.5px; cursor: pointer; }
.rail__chip:hover { background: var(--bg-rail-hover); color:#fff; }
.rail__chip.active { color:#fff; background: rgba(196,69,47,.22); }
.rail__chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity:.6; flex:none;}
.rail__chip-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail__chip-act { flex: none; width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; color: #8d8e97; opacity: 0; transition: opacity .12s, background .12s, color .12s; }
.rail__chip:hover .rail__chip-act { opacity: 1; }
.rail__chip-act:hover { background: rgba(255,255,255,.12); color: #fff; }
.rail__chip-act.danger:hover { color: #ff8a72; }
.rail__chip-act svg { width: 14px; height: 14px; }
.rail__spacer { flex: 1; }
.rail__foot { padding: 8px 6px 2px; border-top: 1px solid rgba(255,255,255,.07); }

/* ----- Main column ----- */
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.topbar { height: 60px; flex: none; display: flex; align-items: center; gap: 14px; padding: 0 22px; border-bottom: 1px solid var(--line); background: rgba(246,245,242,.85); backdrop-filter: blur(8px); }
.topbar__crumb { display:flex; align-items:center; gap: 8px; min-width: 0; }
.topbar__title { font-family: var(--display); font-size: 20px; font-weight: 600; white-space: nowrap; overflow:hidden; text-overflow: ellipsis; }
.topbar__sep { color: var(--ink-3); }
.topbar__sub { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.topbar__titleedit { font-size: 14px; color: var(--ink); font-weight: 500; background: transparent; border: 1px solid transparent; border-radius: 7px; padding: 4px 8px; outline: none; min-width: 120px; max-width: 360px; transition: background .12s, border-color .12s; }
.topbar__titleedit::placeholder { color: var(--ink-3); font-weight: 400; font-style: italic; }
.topbar__titleedit:hover { background: var(--surface-2); }
.topbar__titleedit:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.topbar__spacer { flex: 1; }
.seg--sm { padding: 2px; }
.seg--sm button { padding: 5px 11px; font-size: 12.5px; font-weight: 700; min-width: 30px; }
.sizegroup { display: inline-flex; align-items: center; gap: 5px; padding: 0 2px 0 6px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.sizegroup .seg { background: transparent; border: none; padding: 2px; }
.sizegroup__ico { display: grid; place-items: center; color: var(--ink-3); flex: none; }
.sizegroup__ico svg { width: 14px; height: 14px; }
.btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 10px; font-size: 13.5px; font-weight: 600; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow-sm); transition: transform .08s, box-shadow .12s, background .12s; }
.btn:hover { box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn--primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn--primary:hover { background: #b03c29; }
.btn--ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn--ai { background: linear-gradient(135deg,#7b3ff2,#c4452f); color:#fff; border-color: transparent; }
.btn--ai:hover { filter: brightness(1.06); }
.iconbtn { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--ink-2); transition: background .12s, color .12s; }
.iconbtn:hover { background: var(--surface-2); color: var(--ink); }
.iconbtn svg { width: 18px; height: 18px; }
.kbd { font-size: 11px; font-weight: 600; color: var(--ink-3); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; background: var(--surface); }

/* ----- Board surface ----- */
.board { flex: 1; overflow: auto; padding: 22px; }
.board-head { display:flex; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.board-head h2 { font-family: var(--display); font-size: 22px; margin: 0; font-weight: 600; }
.board-head .muted { color: var(--ink-2); font-size: 13.5px; }

/* ===== Act lanes ===== */
.lane { margin: 16px 0; border-radius: var(--radius); }
.lane__head { display:flex; align-items:center; gap: 10px; margin-bottom: 9px; }
.lane__label { font-weight: 700; font-size: 13px; letter-spacing: .02em; color: var(--ink); display:flex; align-items:center; gap: 9px; }
.lane__tag { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; padding: 3px 9px; border-radius: 30px; color: var(--accent); background: var(--accent-soft); }
.lane__count { font-size: 12px; color: var(--ink-3); }
.lane__rule { flex: 1; height: 1px; background: var(--line); }
.lane__track { display: flex; gap: 14px; align-items: stretch; overflow-x: auto; padding: 4px 2px 14px; scroll-snap-type: x proximity; }
.lane__track.is-drop { background: linear-gradient(0deg, rgba(196,69,47,.05), rgba(196,69,47,.05)); border-radius: var(--radius); }

/* ===== Compact Episode grid (act labels on the left, fills the viewport) ===== */
.board--episode { padding: 14px 16px; }
.ep-grid { display: flex; flex-direction: column; gap: 8px; min-height: 100%; }
.eprow { display: flex; gap: 10px; align-items: stretch; flex: 1 1 auto; min-height: var(--card-h-min, 92px); max-height: var(--card-h-max, 124px); }
.eprow__cell { width: 112px; flex: none; background: var(--surface-3); border: 1px solid var(--line); border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; position: relative; padding: 8px 6px 4px; overflow: hidden; }
.eprow__cell.teaser, .eprow__cell.tag { background: var(--surface-2); }
.eprow__name { font-family: var(--display); font-weight: 600; font-size: 18px; color: var(--ink); text-align: center; line-height: 1.05;
  width: 100%; background: transparent; border: 1px solid transparent; border-radius: 7px; padding: 2px 4px; outline: none; transition: background .12s, border-color .12s; }
.eprow__name:hover { background: rgba(0,0,0,.04); }
.eprow__name:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.eprow__tag { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--accent); }
.eprow__count { font-size: 10.5px; color: var(--ink-3); font-weight: 600; transition: opacity .12s; }
.eprow:hover .eprow__count { opacity: 0; }
.eprow__grip { position: absolute; top: 3px; left: 50%; transform: translateX(-50%); width: 26px; height: 15px; display: grid; place-items: center; color: var(--ink-3); cursor: grab; opacity: 0; transition: opacity .12s; }
.eprow__grip svg { width: 18px; height: 13px; }
.eprow:hover .eprow__grip { opacity: .65; }
.eprow__grip:active { cursor: grabbing; }
.eprow__tools { position: absolute; left: 0; right: 0; bottom: 4px; display: flex; justify-content: center; gap: 1px; opacity: 0; transition: opacity .12s; }
.eprow:hover .eprow__tools { opacity: 1; }
.eprow__tool { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; color: var(--ink-3); transition: background .12s, color .12s; }
.eprow__tool:hover { background: rgba(0,0,0,.08); color: var(--ink); }
.eprow__tool.danger:hover { color: var(--accent); }
.eprow__tool svg { width: 15px; height: 15px; }
.row-dragging { opacity: .4; }
.row-drop { height: 3px; background: var(--accent); border-radius: 3px; box-shadow: 0 0 0 3px var(--accent-soft); margin: -1px 0; }
.row-floating { position: fixed; z-index: 300; pointer-events: none; margin: 0; box-shadow: var(--shadow-lg); transform: rotate(-1.5deg) scale(1.03); opacity: .97; }
.eprow--add { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; margin-top: 2px; padding: 7px 12px; border-radius: 9px;
  border: 1px dashed var(--line-strong); color: var(--ink-3); font-size: 12.5px; font-weight: 600; background: transparent; flex: none; transition: border-color .12s, color .12s; }
.eprow--add:hover { border-color: var(--accent); color: var(--accent); }
.eprow--add svg { width: 15px; height: 15px; }
.iconbtn--on { background: var(--accent); color: #fff; }
.iconbtn--on:hover { background: #b03c29; color: #fff; }

/* scale-to-fit: rows evenly split the full board height, however many acts there are */
.ep-grid.fit .eprow { flex: 1 1 0; min-height: 0; max-height: none; }

/* collapsed (titles only) */
.ep-grid.collapsed .eprow { flex: 0 0 auto; min-height: 0; max-height: none; height: 58px; }
.ep-grid.collapsed .eprow__cell { padding: 4px; }
.ep-grid.collapsed .eprow__name { font-size: 14px; }
.ep-grid.collapsed .eprow__tag { display: none; }
.ep-grid.collapsed .eprow__grip { top: 2px; }
.ep-grid.collapsed .card { padding: 8px 11px; }
.ep-grid.collapsed .card:has(.card__title) .card__body { display: none; }
.ep-grid.collapsed .card__foot { display: none; }
.ep-grid.collapsed .card__title { -webkit-line-clamp: 2; margin: 0; }
.ep-grid.collapsed .card__body { -webkit-line-clamp: 2; }
.eprow__track { flex: 1; min-width: 0; display: flex; gap: 10px; overflow-x: auto; align-items: stretch; padding-bottom: 2px; }
.ep-grid .card { width: var(--card-w, 196px); height: 100%; min-height: 0; padding: 10px 12px 8px; }
.ep-grid .card__title { font-size: calc(13px * var(--ts, 1)); margin-bottom: 3px; }
.ep-grid .card__body { font-size: calc(12px * var(--bs, 1)); -webkit-line-clamp: 3; }
.ep-grid .card__foot { margin-top: 6px; }
.ep-grid .addcard { width: var(--card-w, 196px); height: 100%; min-height: 0; }
.ep-grid .drop-line { height: 100%; min-height: 0; }

/* ===== Card ===== */
.card { position: relative; width: 232px; min-height: 132px; flex: none; background: var(--card-bg, #fff); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); padding: 13px 14px 12px; display: flex; flex-direction: column;
  scroll-snap-align: start; cursor: grab; transition: box-shadow .14s, transform .14s, border-color .12s; overflow: hidden; }
.card::before { content:''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--card-strip, transparent); }
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--line-strong); }
.card.dragging { opacity: .35; }
.card.drag-ghost { box-shadow: var(--shadow-lg); transform: rotate(1.5deg) scale(1.02); cursor: grabbing; z-index: 60; }
.card.selected { outline: 2px solid var(--accent); outline-offset: 2px; box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-md); }
.minicard.selected { outline: 2px solid var(--accent); outline-offset: 2px; box-shadow: 0 0 0 4px var(--accent-soft); }
.drag-badge { position: fixed; z-index: 301; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; pointer-events: none; box-shadow: var(--shadow-md); }
.card-floating { position: fixed; z-index: 300; pointer-events: none; margin: 0; box-shadow: var(--shadow-lg); transform: rotate(2deg) scale(1.03); opacity: .97; }
.card:active { cursor: grabbing; }
.card__title { font-weight: 700; font-size: calc(13.5px * var(--ts, 1)); line-height: 1.3; margin: 0 0 5px; word-break: break-word; }
.card__body { font-size: calc(12.5px * var(--bs, 1)); line-height: 1.45; color: var(--ink-2); flex: 1; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; word-break: break-word; }
.card__body:empty::after { content: 'No description'; color: var(--ink-3); font-style: italic; }
.card__foot { display: flex; align-items: center; gap: 6px; margin-top: 9px; min-height: 18px; }
.card__status { font-size: 10.5px; font-weight: 700; letter-spacing: .02em; padding: 2px 8px; border-radius: 20px; display:inline-flex; align-items:center; gap: 5px; }
.card__menu { margin-left: auto; opacity: 0; transition: opacity .12s; color: var(--ink-3); width: 24px; height: 22px; border-radius: 6px; display: grid; place-items:center; }
.card:hover .card__menu { opacity: 1; }
.card__menu:hover { background: rgba(0,0,0,.06); color: var(--ink); }
.card__num { position:absolute; top: 10px; right: 11px; font-size: 10.5px; font-weight:700; color: var(--ink-3); opacity:.6;}

/* status colors */
.st-idea   { background:#eee9fb; color:#6b3fd0; }
.st-draft  { background:#fdf0d8; color:#9a6a12; }
.st-approved{ background:#dcf2e6; color:#1f7a4d; }
.st-cut    { background:#f0e9e6; color:#8a6a5e; text-decoration: line-through; }
.st-question{ background:#e4eefb; color:#2c6bbf; }

/* add card slot */
.addcard { width: 152px; min-height: 132px; flex: none; border: 1.5px dashed var(--line-strong); border-radius: var(--radius-sm); color: var(--ink-3);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; font-size: 12.5px; font-weight: 600; background: transparent; transition: border-color .12s, color .12s, background .12s; }
.addcard:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.addcard svg { width: 20px; height: 20px; }
.lane__empty { color: var(--ink-3); font-size: 13px; padding: 6px 2px; }

/* drop indicator */
.drop-line { width: 3px; align-self: stretch; min-height: 132px; border-radius: 3px; background: var(--accent); flex: none; box-shadow: 0 0 0 3px var(--accent-soft); }

/* ===== Season board ===== */
.season-grid { display: flex; gap: 16px; padding-bottom: 18px; align-items: flex-start; overflow-x: auto; }
.epcol { width: 268px; flex: none; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.epcol__head { display:flex; align-items:center; gap: 9px; margin-bottom: 10px; cursor: pointer; }
.epcol__no { font-family: var(--display); font-weight:600; font-size: 15px; background: var(--surface); border:1px solid var(--line-strong); border-radius: 8px; padding: 2px 9px; }
.epcol__title { font-weight: 600; font-size: 13.5px; flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.epcol__open { color: var(--ink-3); }
.epcol__head:hover .epcol__open { color: var(--accent); }
.epcol__cards { display:flex; flex-direction: column; gap: 10px; }
.minicard { background: var(--card-bg,#fff); border:1px solid var(--line-strong); border-radius: 9px; padding: 10px 11px; box-shadow: var(--shadow-sm); position: relative; overflow:hidden; }
.minicard::before { content:''; position:absolute; left:0; top:0; bottom:0; width:4px; background: var(--card-strip, transparent);}
.minicard__t { font-weight:700; font-size: calc(12.5px * var(--ts, 1)); margin-bottom: 3px;}
.minicard__b { font-size: calc(11.5px * var(--bs, 1)); color: var(--ink-2); line-height:1.4; display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;}
.epcol__beats { margin-top: 10px; font-size: 11.5px; color: var(--ink-3); display:flex; gap: 6px; flex-wrap:wrap;}
.epcol__beats b { color: var(--ink-2); }

/* ===== Scrap / free canvas ===== */
.scrap { position: relative; min-height: 1400px; min-width: 1800px; background-image: radial-gradient(var(--line-strong) 1px, transparent 1px); background-size: 24px 24px; border-radius: var(--radius); }
.scrap .card { position: absolute; }

/* ===== Overlays (modal / menu / palette / editor) ===== */
.scrim { position: fixed; inset: 0; background: rgba(28,24,20,.34); backdrop-filter: blur(2px); z-index: 100; animation: fade .14s ease; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity:0; transform: translateY(8px) scale(.98); } }
@keyframes slidein { from { opacity:0; transform: translateY(10px); } }

.modal { position: fixed; z-index: 101; left: 50%; top: 50%; transform: translate(-50%,-50%); width: min(680px, 94vw); background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); animation: popModal .18s cubic-bezier(.2,.8,.2,1); overflow:hidden; }
@keyframes popModal { from { opacity:0; transform: translate(-50%,-50%) translateY(10px) scale(.98); } to { opacity:1; transform: translate(-50%,-50%); } }
.modal__head { padding: 22px 26px 6px; }
.modal__head h3 { margin: 0; font-family: var(--display); font-size: 21px; font-weight: 600; }
.modal__head p { margin: 5px 0 0; color: var(--ink-2); font-size: 13.5px; }
.modal__body { padding: 18px 26px; max-height: 64vh; overflow:auto; }
.modal__foot { padding: 16px 26px; display:flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line); background: var(--surface-2); }
.steps { display:flex; gap: 8px; padding: 14px 26px 4px; }
.step { display:flex; align-items:center; gap: 8px; font-size: 12.5px; color: var(--ink-3); font-weight:600; }
.step.active { color: var(--ink); }
.step.done .step__n { background: var(--ok); color:#fff; }
.step__n { width: 22px; height: 22px; border-radius: 50%; display:grid; place-items:center; background: var(--surface-3); color: var(--ink-2); font-size: 12px; font-weight:700;}
.step.active .step__n { background: var(--accent); color:#fff;}
.step__line { width: 28px; height: 2px; background: var(--line); }

.field { margin-bottom: 16px; }
.field > label { display:block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.input, .textarea, .select { width: 100%; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 10px; padding: 10px 12px; font-size: 14px; color: var(--ink); outline: none; transition: border-color .12s, box-shadow .12s; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { resize: vertical; min-height: 70px; line-height: 1.5; }
.row { display:flex; gap: 14px; }
.row > * { flex: 1; }
.choice { display:flex; gap: 12px; }
.choice__opt { flex:1; border: 1.5px solid var(--line-strong); border-radius: 12px; padding: 14px; cursor: pointer; transition: border-color .12s, background .12s; }
.choice__opt:hover { border-color: var(--ink-3); }
.choice__opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.choice__opt b { display:block; font-size: 14px; margin-bottom: 3px;}
.choice__opt span { font-size: 12px; color: var(--ink-2); line-height:1.4; }
.seg { display:inline-flex; background: var(--surface-2); border:1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { padding: 6px 13px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--ink-2);}
.seg button.sel { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.toggle { display:flex; align-items:center; gap: 9px; font-size: 13.5px; font-weight: 500; cursor:pointer; }
.toggle input { display:none; }
.toggle .sw { width: 38px; height: 22px; border-radius: 20px; background: var(--surface-3); position: relative; transition: background .15s; flex:none; }
.toggle .sw::after { content:''; position:absolute; top: 2px; left:2px; width:18px; height:18px; border-radius:50%; background:#fff; box-shadow: var(--shadow-sm); transition: left .15s; }
.toggle input:checked + .sw { background: var(--accent); }
.toggle input:checked + .sw::after { left: 18px; }

/* context menu */
.menu { position: fixed; z-index: 102; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 7px; min-width: 196px; animation: pop .12s ease; }
.menu__group { padding: 4px; }
.menu__label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); padding: 4px 8px 6px; font-weight: 700;}
.menu__item { display:flex; align-items:center; gap: 10px; width:100%; text-align:left; padding: 8px 9px; border-radius: 8px; font-size: 13px; color: var(--ink); font-weight: 500; }
.menu__item:hover { background: var(--surface-2); }
.menu__item.danger { color: var(--accent); }
.menu__item svg { width: 16px; height: 16px; opacity:.75; }
.menu__sep { height:1px; background: var(--line); margin: 5px 2px; }
.swatches { display:grid; grid-template-columns: repeat(7, 1fr); gap: 6px; padding: 4px 6px 6px; }
.swatch { width: 24px; height: 24px; border-radius: 7px; border: 1px solid rgba(0,0,0,.12); cursor:pointer; transition: transform .1s; }
.swatch:hover { transform: scale(1.12); }
.swatch.sel { box-shadow: 0 0 0 2px var(--accent), 0 0 0 4px #fff; }
.statusrow { display:flex; flex-wrap: wrap; gap: 6px; padding: 2px 6px 4px; }
.statuspill { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 20px; cursor:pointer; border: 1px solid transparent; }
.statuspill.sel { outline: 2px solid var(--accent); outline-offset: 1px; }

/* command palette */
.palette { position: fixed; z-index: 103; left: 50%; top: 14vh; transform: translateX(-50%); width: min(620px, 92vw); background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); overflow:hidden; animation: popPal .16s ease; }
@keyframes popPal { from { opacity:0; transform: translateX(-50%) translateY(10px) scale(.98); } to { opacity:1; transform: translateX(-50%); } }
.palette__in { display:flex; align-items:center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.palette__in input { flex:1; border:none; outline:none; font-size: 16px; background: transparent; color: var(--ink); }
.palette__list { max-height: 56vh; overflow:auto; padding: 8px; }
.palette__item { display:flex; align-items:center; gap: 12px; padding: 11px 12px; border-radius: 10px; cursor:pointer; font-size: 14px; }
.palette__item .pk { margin-left:auto; font-size: 11px; color: var(--ink-3);}
.palette__item.active { background: var(--accent-soft); }
.palette__item .ico { width: 30px; height: 30px; border-radius: 8px; background: var(--surface-2); display:grid; place-items:center; color: var(--ink-2); flex:none;}
.palette__item small { display:block; color: var(--ink-3); font-size: 11.5px; }

/* inline card editor */
.editor { position: fixed; z-index: 104; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); width: 420px; animation: pop .16s cubic-bezier(.2,.8,.2,1); overflow: hidden; }
.editor__strip { height: 6px; background: var(--card-strip, var(--accent)); }
.editor__b { padding: 16px 18px; }
.editor__title { width:100%; border:none; outline:none; font-size: calc(16px * var(--ts, 1)); font-weight: 700; color: var(--ink); background: transparent; margin-bottom: 6px; }
.editor__title::placeholder { color: var(--ink-3); }
.editor__text { width:100%; border:none; outline:none; resize: none; font-size: calc(14px * var(--bs, 1)); line-height: 1.55; color: var(--ink-2); background: transparent; min-height: 120px; }
.editor__sizes { display: flex; align-items: center; gap: 12px; padding: 9px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.szgroup { display: flex; align-items: center; gap: 4px; }
.szlabel { font-size: 11.5px; font-weight: 600; color: var(--ink-3); margin-right: 2px; }
.szbtn { width: 26px; height: 24px; border-radius: 7px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 12px; font-weight: 700; color: var(--ink-2); }
.szbtn:hover { background: var(--surface-2); color: var(--ink); }
.szval { font-size: 11px; font-weight: 700; color: var(--ink-2); min-width: 36px; text-align: center; }
.szicon { width: 26px; height: 24px; border-radius: 7px; border: 1px solid var(--line-strong); background: var(--surface); display: grid; place-items: center; color: var(--ink-2); }
.szicon:hover { background: var(--surface-2); color: var(--ink); }
.szicon svg { width: 14px; height: 14px; }
.szapply { margin-left: auto; height: 26px; padding: 0 11px; border-radius: 7px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 11.5px; font-weight: 600; color: var(--ink-2); }
.szapply:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.editor__bar { display:flex; align-items:center; gap: 8px; padding: 11px 14px; border-top: 1px solid var(--line); background: var(--surface-2); }
.editor__bar .iconbtn { width: 32px; height: 32px; }
.editor__bar .iconbtn svg { width:16px; height:16px; }
.editor__bar .grow { flex:1; }

/* AI panel */
.ai-result { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-top: 12px; background: var(--surface-2); }
.ai-beat { display:flex; gap: 10px; align-items:flex-start; padding: 9px; border-radius: 9px; background: var(--surface); border:1px solid var(--line); margin-bottom: 8px; }
.ai-beat__act { font-size: 10.5px; font-weight:700; color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 20px; white-space:nowrap; }
.ai-beat__txt b { display:block; font-size: 13px; margin-bottom:2px;}
.ai-beat__txt span { font-size: 12.5px; color: var(--ink-2); }
.spinner { width: 16px; height:16px; border: 2px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* empty / first run */
.empty { display:grid; place-items:center; height: 100%; text-align:center; }
.empty__in { max-width: 460px; }
.empty__art { width: 120px; height: 120px; margin: 0 auto 22px; border-radius: 28px; background: linear-gradient(135deg, var(--accent-soft), #fff); display:grid; place-items:center; box-shadow: var(--shadow-md);}
.empty__art svg { width: 56px; height:56px; color: var(--accent); }
.empty h1 { font-family: var(--display); font-size: 30px; margin: 0 0 10px; }
.empty p { color: var(--ink-2); font-size: 15px; line-height: 1.6; margin: 0 0 22px; }

/* ===== Auth screen ===== */
.auth-card { max-width: 380px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; text-align: left; margin-top: 6px; }
.auth-form .field { display: flex; flex-direction: column; gap: 6px; }
.auth-form label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.auth-error { background: #fdecea; color: #b03c29; font-size: 13px; padding: 9px 12px; border-radius: 8px; border: 1px solid #f4c6bd; }
.auth-switch { font-size: 13.5px; color: var(--ink-2); margin-top: 16px; margin-bottom: 0; }
.linklike { background: none; border: none; padding: 0; color: var(--accent); font-weight: 600; font-size: inherit; cursor: pointer; }
.linklike:hover { text-decoration: underline; }

/* ===== Save status pill ===== */
.savepill { position: fixed; right: 18px; bottom: 16px; z-index: 50; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line-strong); padding: 6px 12px; border-radius: 30px; box-shadow: var(--shadow-sm); }
.savepill svg { width: 13px; height: 13px; }
.savepill--ok { color: #2f8f5b; }
.savepill--ok svg { color: #2f8f5b; }
.savepill--err { color: #b03c29; }

/* ===== Home / projects list ===== */
.home { max-width: 1080px; margin: 0 auto; padding: 52px 32px; height: 100vh; overflow: auto; }
.home__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 30px; }
.home__brand { display: flex; align-items: center; gap: 14px; }
.home__brand .rail__logo { width: 46px; height: 46px; border-radius: 13px; }
.home__brand .rail__logo svg { width: 27px; height: 27px; }
.home__brand h1 { font-family: var(--display); font-size: 28px; margin: 0; }
.home__brand p { margin: 2px 0 0; color: var(--ink-2); font-size: 14px; }
.home__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(284px, 1fr)); gap: 18px; }
.projcard { position: relative; display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; cursor: pointer; box-shadow: var(--shadow-sm); transition: box-shadow .14s, transform .12s, border-color .12s; text-align: left; }
.projcard:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--line-strong); }
.projcard__thumb { width: 52px; height: 52px; border-radius: 12px; flex: none; background: linear-gradient(135deg, var(--accent-soft), #fff); display: grid; place-items: center; color: var(--accent); }
.projcard__thumb svg { width: 28px; height: 28px; }
.projcard__body { min-width: 0; flex: 1; }
.projcard__title { font-weight: 700; font-size: 15px; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.projcard__meta { font-size: 12.5px; color: var(--ink-2); }
.projcard__date { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.projcard__tools { position: absolute; top: 8px; right: 8px; display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.projcard:hover .projcard__tools { opacity: 1; }
.projcard__tool { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: var(--ink-3); background: var(--surface); transition: background .12s, color .12s; }
.projcard__tool:hover { background: var(--surface-2); color: var(--ink); }
.projcard__tool.danger:hover { background: var(--accent-soft); color: var(--accent); }
.projcard__tool svg { width: 15px; height: 15px; }
.projnew { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; min-height: 92px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius); color: var(--ink-3); font-size: 13.5px; font-weight: 600; background: transparent; transition: border-color .12s, color .12s; }
.projnew:hover { border-color: var(--accent); color: var(--accent); }
.projnew__plus { width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; }

/* rail brand + project block become clickable (go home) */
.rail__brand { width: 100%; text-align: left; }
.rail__brand:hover { background: rgba(255,255,255,.05); border-radius: 10px; }
.rail__proj { width: 100%; text-align: left; cursor: pointer; transition: background .12s; }
.rail__proj:hover { background: rgba(255,255,255,.09); }
.rail__proj-sub { display: flex; align-items: center; gap: 3px; }
.rail__proj-sub svg { width: 13px; height: 13px; opacity: .7; margin-left: -2px; }

/* toast */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200; background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-lg); animation: slidein .2s ease; display:flex; align-items:center; gap: 10px; }
.toast .ok { color: #7ee6ad; }

/* ===== Selection toolbar (appears when cards are multi-selected) ===== */
.selbar { position: fixed; left: 50%; bottom: 78px; transform: translateX(-50%); z-index: 150; display: flex; align-items: center; gap: 6px;
  background: var(--ink); color: #fff; padding: 8px 10px 8px 14px; border-radius: 14px; box-shadow: var(--shadow-lg); animation: slidein .16s ease; }
.selbar__count { font-size: 13px; font-weight: 600; white-space: nowrap; margin-right: 4px; }
.selbar__sep { width: 1px; height: 18px; background: rgba(255,255,255,.18); }
.selbar__btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 9px; font-size: 12.5px; font-weight: 600; color: #fff; background: rgba(255,255,255,.08); transition: background .12s; }
.selbar__btn:hover { background: rgba(255,255,255,.18); }
.selbar__btn.danger:hover { background: rgba(255,90,70,.35); }
.selbar__btn svg { width: 14px; height: 14px; }

.hint { font-size: 12px; color: var(--ink-3); margin-top: 6px; line-height:1.5; }
.tag-soft { font-size: 11px; font-weight: 700; color: var(--ink-2); background: var(--surface-3); padding: 2px 8px; border-radius: 20px;}
.changelog { max-width: 720px; }
.cl-item { display:flex; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.cl-item .t { color: var(--ink-3); font-size: 12px; white-space: nowrap; width: 86px; flex:none;}
.cl-item .d { color: var(--ink); }
