/* =========================================================
   Storymap — workshop wall, cream paper, three post-its
   ========================================================= */

:root {
  --paper: #F2EBD9;
  --paper-deep: #ECE0C6;
  --paper-deep-2: #E4D6B6;

  --ink: #1B1B1B;
  --ink-soft: #3F3A33;
  --ink-mute: #8C8578;
  --ink-line: #2A2622;
  --rule: rgba(20, 16, 8, 0.16);
  --rule-soft: rgba(20, 16, 8, 0.08);

  --coral: #F4615F;
  --coral-deep: #4B0F1A;
  --coral-edge: #C9413F;

  --danger: #B5322F;
  --danger-deep: #7A1C1A;

  --amber: #F2BD3A;
  --amber-deep: #443206;
  --amber-edge: #C9952A;

  --mint: #A6D9B4;
  --mint-deep: #1A3D27;
  --mint-edge: #79B58E;

  --shadow-card:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 1px 2px rgba(40, 28, 8, 0.10),
    0 6px 12px -2px rgba(40, 28, 8, 0.16),
    0 18px 32px -16px rgba(40, 28, 8, 0.22);
  --shadow-card-lift:
    0 2px 0 rgba(255, 255, 255, 0.5) inset,
    0 6px 14px rgba(40, 28, 8, 0.20),
    0 26px 48px -12px rgba(40, 28, 8, 0.34);

  --topbar-h: 60px;
  --legend-h: 38px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Fraunces', 'Iowan Old Style', 'Charter', Georgia, serif;
  font-size: 14px;
  font-feature-settings: 'ss01', 'kern';
  font-variation-settings: 'opsz' 16, 'SOFT' 50;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 800px at 20% 18%, rgba(255, 252, 240, 0.85), transparent 60%),
    radial-gradient(1100px 700px at 82% 88%, rgba(220, 198, 152, 0.32), transparent 70%),
    var(--paper);
}

/* Paper grain overlay over everything */
body::after {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.5;
  mix-blend-mode: multiply;
  background-image:
    url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.88' numOctaves='2' seed='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.10  0 0 0 0 0.07  0 0 0 0 0.02  0 0 0 0.14 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* =========================================================
   TOP BAR
   ========================================================= */

.topbar {
  flex: 0 0 var(--topbar-h);
  height: var(--topbar-h);
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background:
    linear-gradient(180deg, rgba(255, 250, 235, 0.95), rgba(244, 235, 213, 0.85));
  border-bottom: 1px solid var(--rule);
  position: relative;
  z-index: 300;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  position: relative;
  display: inline-flex;
  width: 28px; height: 28px;
  transform: translateY(2px) rotate(-3deg);
  flex: 0 0 28px;
}
.brand-mark .bm {
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.16), inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.brand-mark .bm-coral { left: 0;   top: 0;   background: var(--coral); transform: rotate(-6deg); }
.brand-mark .bm-amber { left: 9px; top: 4px; background: var(--amber); transform: rotate(4deg); z-index: 1; }
.brand-mark .bm-mint  { left: 4px; top: 12px; background: var(--mint); transform: rotate(-2deg); z-index: 2; }

.title {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.012em;
  font-variation-settings: 'opsz' 28, 'SOFT' 0;
  margin: 0;
  outline: none;
  padding: 2px 6px;
  border-radius: 3px;
  min-width: 120px;
  max-width: 520px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: text;
}
.title:hover { background: rgba(0, 0, 0, 0.035); }
.title:focus { background: rgba(0, 0, 0, 0.06); white-space: normal; overflow: visible; }
.title:empty::before {
  content: attr(data-placeholder);
  color: var(--ink-mute);
  font-style: italic;
}

.brand-sub {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-variation-settings: 'opsz' 11;
  color: var(--ink-mute);
  font-size: 11.5px;
  letter-spacing: 0.01em;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.btn {
  font-family: 'Fraunces', serif;
  font-variation-settings: 'opsz' 12;
  font-weight: 500;
  font-size: 13px;
  padding: 8px 14px;
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  border-radius: 2px;
  letter-spacing: 0.01em;
  transition: transform 80ms ease, background 120ms ease, color 120ms ease;
  white-space: nowrap;
  position: relative;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn:active { transform: translateY(1px); }

.btn-ghost {
  border-color: var(--rule);
  background: transparent;
  color: var(--ink-soft);
  font-weight: 400;
}
.btn-ghost:hover {
  border-color: var(--ink);
  background: rgba(0, 0, 0, 0.04);
  color: var(--ink);
}

.btn-dark {
  background: var(--ink);
  color: var(--paper);
}
.btn-dark:hover {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--ink);
}

.btn-icon {
  padding: 0;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-family: 'Fraunces', serif;
  font-variation-settings: 'opsz' 14;
  line-height: 1;
}
.btn-icon:active { transform: translateY(1px) scale(0.96); }

.btn:disabled,
.btn-ghost:disabled,
.btn-icon:disabled {
  opacity: 0.28;
  cursor: not-allowed;
  pointer-events: none;
}

/* Undo / redo — a single segmented pill of inked hook-arrows */
.history-group {
  display: inline-flex;
  align-items: stretch;
  flex: 0 0 auto;
  border: 1px solid var(--rule);
  border-radius: 5px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 252, 240, 0.7), rgba(244, 235, 213, 0.35));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    0 1px 1.5px rgba(40, 28, 8, 0.07);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.history-group:hover {
  border-color: rgba(20, 16, 8, 0.32);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    0 2px 5px -1px rgba(40, 28, 8, 0.14);
}

.hist-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 34px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, transform 80ms ease;
}
.hist-btn + .hist-btn { border-left: 1px solid var(--rule); }
.hist-btn:hover { background: var(--ink); color: var(--paper); }
.hist-btn:active { transform: translateY(1px); }

.hist-ico {
  display: block;
  transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
}
/* arrows lean toward their direction of travel on hover */
.hist-btn[data-action="undo"]:hover .hist-ico { transform: translateX(-1.5px) rotate(-12deg); }
.hist-btn[data-action="redo"]:hover .hist-ico { transform: translateX(1.5px) rotate(12deg); }

.hist-btn:disabled {
  opacity: 0.26;
  color: var(--ink-mute);
  cursor: not-allowed;
  pointer-events: none;
}

.actions-sep {
  width: 1px;
  height: 22px;
  background: var(--rule);
  margin: 0 2px;
  flex: 0 0 1px;
}

.btn-danger {
  background: var(--danger);
  color: var(--paper);
  border-color: var(--danger);
}
.btn-danger:hover {
  background: var(--paper);
  color: var(--danger);
  border-color: var(--danger);
}

/* =========================================================
   KEBAB MENU
   ========================================================= */

.kebab {
  position: relative;
  flex: 0 0 auto;
}

.kebab-toggle {
  font-size: 20px;
  letter-spacing: -0.02em;
}
.kebab.open .kebab-toggle {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.kebab-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 400;
  min-width: 208px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background:
    linear-gradient(180deg, rgba(255, 252, 240, 0.7), rgba(255, 250, 232, 0.0) 130px),
    var(--paper);
  border: 1px solid var(--ink);
  border-radius: 3px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 14px 28px -10px rgba(40, 28, 8, 0.34),
    0 40px 64px -28px rgba(20, 12, 0, 0.42);
  animation: kebab-pop 140ms cubic-bezier(0.22, 1, 0.36, 1);
  transform-origin: top right;
}
.kebab-menu[hidden] { display: none; }

@keyframes kebab-pop {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

.kebab-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: 'Fraunces', serif;
  font-variation-settings: 'opsz' 13;
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.004em;
  text-align: left;
  border-radius: 2px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 100ms ease, color 100ms ease;
}
.kebab-item:hover { background: rgba(20, 16, 8, 0.07); }

.kebab-item-danger { color: var(--danger); }
.kebab-item-danger:hover {
  background: var(--danger);
  color: var(--paper);
}

.kebab-sep {
  height: 1px;
  margin: 5px 8px;
  background: var(--rule);
}

/* =========================================================
   LEGEND STRIP
   ========================================================= */

.legend {
  flex: 0 0 var(--legend-h);
  height: var(--legend-h);
  padding: 0 22px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px dashed var(--rule);
  background: rgba(255, 250, 235, 0.55);
  font-size: 12px;
  position: relative;
  z-index: 250;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 4px;
  border-radius: 2px;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-variation-settings: 'opsz' 9;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 10px;
  border: 1px solid rgba(0, 0, 0, 0.25);
  box-shadow: 0 1px 1px rgba(40, 28, 8, 0.08);
}
.chip-flow  { background: var(--coral); color: var(--coral-deep); }
.chip-epic  { background: var(--amber); color: var(--amber-deep); }
.chip-story { background: var(--mint);  color: var(--mint-deep); }

.legend-sep { color: var(--ink-mute); padding: 0 4px; }

.hint {
  color: var(--ink-mute);
  font-style: italic;
  font-family: 'Fraunces', serif;
  font-variation-settings: 'opsz' 11;
  font-size: 12px;
  margin-left: auto;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

kbd {
  font-family: ui-monospace, 'JetBrains Mono', Menlo, monospace;
  font-size: 10.5px;
  padding: 1px 5px 2px;
  margin: 0 1px;
  background: rgba(255, 250, 235, 0.9);
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 3px;
  color: var(--ink-soft);
  font-style: normal;
}

/* =========================================================
   SCROLLER + CANVAS
   ========================================================= */

.scroller {
  flex: 1 1 auto;
  overflow: auto;
  position: relative;
  background:
    /* faint 24px dot grid */
    radial-gradient(circle at 1px 1px, rgba(20, 16, 8, 0.13) 1px, transparent 1px),
    var(--paper);
  background-size: 24px 24px;
  scroll-behavior: auto;
  cursor: default;
}
.scroller.panning {
  cursor: grabbing;
}
.scroller.panning .card,
.scroller.panning .zone-divider,
.scroller.panning .release-line {
  pointer-events: none;
}

/* Scrollbar styling — subtle, paper-aware */
.scroller::-webkit-scrollbar { width: 12px; height: 12px; }
.scroller::-webkit-scrollbar-track { background: transparent; }
.scroller::-webkit-scrollbar-thumb {
  background: rgba(20, 16, 8, 0.18);
  border: 3px solid var(--paper);
  border-radius: 6px;
}
.scroller::-webkit-scrollbar-thumb:hover { background: rgba(20, 16, 8, 0.32); }

/* =========================================================
   COLUMN HEADERS (sticky)
   ========================================================= */

.headers {
  position: sticky;
  top: 0;
  height: 64px;
  z-index: 200;
  display: flex;
  align-items: stretch;
  background:
    linear-gradient(180deg, rgba(248, 242, 224, 0.96), rgba(244, 235, 211, 0.85));
  border-bottom: 1px solid var(--rule);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.header-rail {
  flex: 0 0 120px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 18px;
  border-right: 1px dashed var(--rule);
  color: var(--ink-mute);
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-variation-settings: 'opsz' 11;
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.col-insert {
  flex: 0 0 24px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.col-insert::before {
  content: '';
  position: absolute;
  top: 12px; bottom: 12px;
  left: 50%;
  width: 1px;
  background: var(--rule);
  transform: translateX(-0.5px);
  transition: background 100ms;
}
.col-insert:hover::before { background: var(--ink); }
.col-insert button {
  position: relative;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--paper);
  border: 1px solid var(--ink);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms, transform 100ms, background 120ms;
  font-family: 'Fraunces', serif;
  font-weight: 400;
  font-size: 14px;
  line-height: 1;
  padding: 0 0 1px;
}
.col-insert:hover button { opacity: 1; }
.col-insert button:hover { background: var(--ink); color: var(--paper); transform: scale(1.08); }

.col-insert-end button { opacity: 0.55; }
.col-insert-end:hover button { opacity: 1; }

.column-header {
  flex: 0 0 240px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 8px;
  position: relative;
  transition: flex-basis 200ms cubic-bezier(0.22, 1, 0.36, 1);
}

.column-no {
  font-family: ui-monospace, 'JetBrains Mono', Menlo, monospace;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
  padding: 2px 5px;
  background: rgba(20, 16, 8, 0.05);
  border-radius: 2px;
  flex: 0 0 auto;
}

.column-header .label {
  flex: 1 1 auto;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-variation-settings: 'opsz' 20, 'SOFT' 0;
  font-size: 17px;
  letter-spacing: -0.008em;
  color: var(--ink);
  padding: 4px 6px;
  margin: 0 -6px;
  border-radius: 3px;
  outline: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: text;
  min-width: 0;
}
.column-header .label:hover { background: rgba(20, 16, 8, 0.05); }
.column-header .label:focus { background: rgba(20, 16, 8, 0.08); white-space: normal; overflow: visible; }
.column-header .label:empty::before {
  content: attr(data-placeholder);
  color: var(--ink-mute);
  font-style: italic;
  font-weight: 400;
}

.column-header .col-delete {
  opacity: 0;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ink-mute);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  flex: 0 0 22px;
  padding: 0 0 2px;
  font-family: 'Fraunces', serif;
}
.column-header:hover .col-delete { opacity: 1; }
.column-header .col-delete:hover { background: var(--ink); color: var(--paper); }

/* =========================================================
   CANVAS BASE
   ========================================================= */

.canvas {
  position: relative;
  width: max-content;
  min-width: 100%;
  min-height: 1400px;
}

/* Column background tracks */
.col-bg {
  position: absolute;
  top: 0; bottom: 0;
  background:
    linear-gradient(180deg, rgba(255, 252, 240, 0.6), rgba(255, 250, 232, 0.0) 220px),
    rgba(255, 250, 232, 0.18);
  border-left: 1px dashed var(--rule-soft);
  border-right: 1px dashed var(--rule-soft);
  pointer-events: none;
  transition:
    left 200ms cubic-bezier(0.22, 1, 0.36, 1),
    width 200ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Horizontal zone tints */
.zone-band {
  position: absolute;
  pointer-events: none;
}
.zone-band-flow {
  background:
    linear-gradient(180deg, rgba(244, 97, 95, 0.045), rgba(244, 97, 95, 0.015));
}
.zone-band-epic {
  background:
    linear-gradient(180deg, rgba(242, 189, 58, 0.045), rgba(242, 189, 58, 0.015));
}

/* =========================================================
   LEFT-RAIL ZONE LABELS
   ========================================================= */

.zone-label {
  position: absolute;
  left: 0;
  width: 120px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 12px 16px 12px 22px;
  pointer-events: none;
  border-right: 1px dashed var(--rule);
  background:
    linear-gradient(90deg, rgba(255, 250, 235, 0.5), rgba(255, 250, 235, 0.0));
  overflow: hidden;
}
.zone-label-text {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-variation-settings: 'opsz' 14, 'SOFT' 80;
  font-weight: 500;
  font-size: 13px;
  color: var(--ink);
  letter-spacing: -0.005em;
  display: block;
  margin-bottom: 2px;
  writing-mode: initial;
}
.zone-label-meta {
  font-family: ui-monospace, 'JetBrains Mono', Menlo, monospace;
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.zone-label-release .zone-label-text {
  font-family: 'Fraunces', serif;
  font-style: normal;
  font-weight: 700;
  font-variation-settings: 'opsz' 22;
  font-size: 22px;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.zone-label-backlog {
  background:
    linear-gradient(90deg, rgba(20, 16, 8, 0.04), rgba(20, 16, 8, 0.0));
}
.zone-label-backlog .zone-label-text {
  color: var(--ink-mute);
}

/* =========================================================
   ZONE DIVIDERS  (FLOWS / EPICS, EPICS / STORIES)
   ========================================================= */

.zone-divider {
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  z-index: 6;
  cursor: ns-resize;
  background-image: linear-gradient(90deg, var(--ink) 0 8px, transparent 8px 16px);
  background-size: 16px 1px;
}
.zone-divider::before {
  /* enlarged hit area */
  content: '';
  position: absolute;
  inset: -8px 0;
}
.zone-divider.dragging {
  background-image: linear-gradient(90deg, var(--coral) 0 8px, transparent 8px 16px);
}

/* Divider section labels ride the right edge of the viewport. They are pinned
   horizontally via the --vx (scrollLeft) / --vw (viewport width) vars that
   view.js keeps on the scroller, and track the divider's Y vertically (the
   inline `top` follows the line, including mid-drag). Sits above cards. */
.zone-divider-label {
  position: absolute;
  left: calc(var(--vx, 0px) + var(--vw, 100vw) - 22px);
  transform: translate(-100%, -50%);
  z-index: 60;
  font-family: ui-monospace, 'JetBrains Mono', Menlo, monospace;
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mute);
  background: var(--paper);
  padding: 2px 8px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(40, 28, 8, 0.16);
}
.zone-divider-label.dragging {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

/* =========================================================
   RELEASE LINES  (heavy ink)
   ========================================================= */

.release-line {
  position: absolute;
  left: 0; right: 0;
  height: 3px;
  background: var(--ink-line);
  z-index: 7;
  cursor: ns-resize;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}
.release-line::before {
  content: '';
  position: absolute;
  inset: -8px 0;
}
.release-line::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: -1px;
  height: 1px;
  background: rgba(255, 250, 235, 0.5);
}
.release-line.dragging {
  background: var(--coral);
  height: 3px;
  z-index: 80;
}

.release-tab {
  position: absolute;
  left: 22px;
  transform: translateY(-100%);
  display: inline-flex;
  align-items: stretch;
  background: var(--ink);
  color: var(--paper);
  font-family: 'Fraunces', serif;
  font-variation-settings: 'opsz' 12;
  font-weight: 600;
  font-size: 12px;
  padding: 0;
  letter-spacing: 0.04em;
  border-radius: 2px 2px 0 0;
  z-index: 8;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.10);
}
.release-tab .release-arrow {
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  font-size: 9px;
  color: var(--coral);
  border-right: 1px solid rgba(255, 250, 235, 0.15);
}
.release-tab .label {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px 6px;
  outline: none;
  cursor: text;
  min-width: 60px;
  white-space: nowrap;
}
.release-tab .label:focus {
  background: rgba(255, 250, 235, 0.12);
}
.release-tab .delete {
  background: transparent;
  border: none;
  color: rgba(255, 250, 235, 0.55);
  cursor: pointer;
  font-family: 'Fraunces', serif;
  font-size: 14px;
  padding: 0 9px 1px;
  line-height: 1;
  border-left: 1px solid rgba(255, 250, 235, 0.15);
}
.release-tab .delete:hover { color: var(--coral); }

/* Right-edge mirror of the release tab — pinned to the viewport right (via the
   --vx / --vw vars view.js keeps on the scroller) so the current release stays
   identified when the left tab scrolls out of view. Sits above its line like
   the tab and tracks Y, including mid-drag. */
.release-note {
  position: absolute;
  left: calc(var(--vx, 0px) + var(--vw, 100vw) - 22px);
  transform: translate(-100%, -100%);
  z-index: 60;
  background: var(--ink);
  color: var(--paper);
  font-family: 'Fraunces', serif;
  font-variation-settings: 'opsz' 12;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
  padding: 4px 11px 5px;
  border-radius: 2px 2px 0 0;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.12);
}

/* =========================================================
   STICKY CARDS
   ========================================================= */

.card {
  --rot: 0deg;
  position: absolute;
  border-radius: 2px;
  box-shadow: var(--shadow-card);
  font-family: 'Caveat', 'Marker Felt', cursive;
  font-weight: 500;
  font-size: 19px;
  line-height: 1.18;
  color: var(--ink-line);
  padding: 14px 16px 18px;
  cursor: grab;
  z-index: 10;
  user-select: none;
  display: flex;
  align-items: stretch;
  transform: rotate(var(--rot));
  transition:
    box-shadow 140ms ease,
    transform 140ms ease,
    left 200ms cubic-bezier(0.22, 1, 0.36, 1),
    top 200ms cubic-bezier(0.22, 1, 0.36, 1),
    width 200ms cubic-bezier(0.22, 1, 0.36, 1),
    height 200ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}
.card:hover {
  z-index: 11;
  box-shadow: var(--shadow-card-lift);
  transform: rotate(0deg) translateY(-1px);
}
.card.dragging {
  cursor: grabbing;
  box-shadow: var(--shadow-card-lift);
  z-index: 1000;
  transform: rotate(0deg);
  transition: none;
}
.card.editing {
  cursor: text;
  z-index: 1100;
  transform: rotate(0deg) scale(1.02);
  box-shadow: var(--shadow-card-lift), 0 0 0 2px var(--ink);
  transition: transform 120ms, box-shadow 120ms;
}

/* The paper "fiber" highlight */
.card-paper {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(135deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 35%),
    linear-gradient(180deg, rgba(0, 0, 0, 0) 70%, rgba(0, 0, 0, 0.06) 100%);
  pointer-events: none;
  mix-blend-mode: soft-light;
}

/* Folded corner */
.card-corner {
  position: absolute;
  right: 0; bottom: 0;
  width: 12px; height: 12px;
  background:
    linear-gradient(135deg, transparent 50%, rgba(0, 0, 0, 0.10) 50%);
  pointer-events: none;
}

.card-flow {
  background-color: var(--coral);
  color: var(--coral-deep);
  font-weight: 700;
  font-size: 21px;
}
.card-epic {
  background-color: var(--amber);
  color: var(--amber-deep);
}
.card-story {
  background-color: var(--mint);
  color: var(--mint-deep);
  font-size: 18px;
}

.card .text {
  flex: 1 1 auto;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: hidden;
  position: relative;
  z-index: 1;
  cursor: inherit;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  line-clamp: 5;
}
/* While editing, show every line and let the sticky grow to fit (height is set
   to auto in JS on edit-enter), so hidden text past 5 lines stays reachable. */
.card.editing .text {
  cursor: text;
  display: block;
  -webkit-line-clamp: unset;
  line-clamp: unset;
  overflow: visible;
}
.card .text:empty::before {
  content: attr(data-placeholder);
  opacity: 0.45;
  font-style: italic;
  font-family: 'Fraunces', serif;
  font-size: 14px;
  font-variation-settings: 'opsz' 11;
}

.card-meta {
  position: absolute;
  bottom: 4px; right: 14px;
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-variation-settings: 'opsz' 9;
  font-weight: 400;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.45;
  pointer-events: none;
}

.card .delete {
  position: absolute;
  top: 3px; right: 4px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: inherit;
  opacity: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fraunces', serif;
  font-size: 14px;
  line-height: 1;
  padding: 0 0 2px;
  transition: opacity 100ms, background 100ms;
  z-index: 2;
}
.card:hover .delete { opacity: 0.5; }
.card .delete:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.10);
}

/* Pop-in animation runs only on truly new cards (added with .card-new) so the
   full re-render after a drag doesn't make every sticky flash. */
@keyframes card-in {
  0% { opacity: 0; transform: rotate(0deg) scale(0.85); }
  60% { opacity: 1; transform: rotate(calc(var(--rot) * 1.4)) scale(1.06); }
  100% { opacity: 1; transform: rotate(var(--rot)) scale(1); }
}
.card.card-new { animation: card-in 200ms ease-out; }
.card.dragging, .card.editing { animation: none; }

/* =========================================================
   FOCUS RINGS (keyboard a11y)
   ========================================================= */

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
.card .text:focus-visible,
.title:focus-visible,
.column-header .label:focus-visible,
.release-tab .label:focus-visible {
  outline: none;
}

/* =========================================================
   ACTION LOG MODAL
   ========================================================= */

body.modal-open { overflow: hidden; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background:
    radial-gradient(900px 600px at 50% 40%, rgba(20, 16, 8, 0.30), transparent 70%),
    rgba(20, 16, 8, 0.46);
  animation: modal-fade 140ms ease-out;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

@keyframes modal-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-sheet {
  position: relative;
  width: min(660px, 100%);
  max-height: min(720px, 84vh);
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(255, 252, 240, 0.6), rgba(255, 250, 232, 0.0) 240px),
    var(--paper);
  border: 1px solid var(--ink);
  border-radius: 2px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 18px 32px -8px rgba(40, 28, 8, 0.38),
    0 56px 96px -24px rgba(20, 12, 0, 0.50);
  overflow: hidden;
  animation: modal-rise 240ms cubic-bezier(0.22, 1, 0.36, 1);
  transform-origin: center top;
}

@keyframes modal-rise {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0)   scale(1);     }
}

/* Confirm dialog — smaller sheet, no scroll list */
.modal-sheet-confirm {
  width: min(440px, 100%);
  max-height: none;
  align-self: center;
}

.confirm-body {
  padding: 26px 26px 6px;
}
.confirm-title {
  margin: 0 0 10px;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-variation-settings: 'opsz' 24, 'SOFT' 0;
  font-size: 22px;
  letter-spacing: -0.014em;
  color: var(--ink);
}
.confirm-text {
  margin: 0;
  font-family: 'Fraunces', serif;
  font-variation-settings: 'opsz' 14;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink-soft);
}
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 20px 26px 24px;
}
.confirm-actions .btn { padding: 9px 18px; }

/* Keyboard-shortcuts dialog */
.modal-sheet-shortcuts {
  width: min(480px, 100%);
  max-height: min(660px, 84vh);
}

.shortcuts-body {
  flex: 1 1 auto;
  overflow: auto;
  padding: 4px 24px 18px;
}
.shortcuts-body::-webkit-scrollbar { width: 10px; }
.shortcuts-body::-webkit-scrollbar-track { background: transparent; }
.shortcuts-body::-webkit-scrollbar-thumb {
  background: rgba(20, 16, 8, 0.18);
  border: 3px solid var(--paper);
  border-radius: 6px;
}

.sc-group { padding: 14px 0 6px; }
.sc-group + .sc-group { border-top: 1px dashed var(--rule-soft); }

.sc-group-title {
  font-family: ui-monospace, 'JetBrains Mono', Menlo, monospace;
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 6px;
}

.sc-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 7px 0;
}

.sc-action {
  font-family: 'Fraunces', serif;
  font-variation-settings: 'opsz' 14;
  font-size: 14.5px;
  color: var(--ink);
}

.sc-keys {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.sc-combo {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.sc-plus {
  color: var(--ink-mute);
  font-size: 11px;
  font-family: 'Fraunces', serif;
}
.sc-or {
  color: var(--ink-mute);
  font-style: italic;
  font-family: 'Fraunces', serif;
  font-variation-settings: 'opsz' 11;
  font-size: 12px;
}

/* =========================================================
   EXPORT / IMPORT DIALOG
   ========================================================= */

.modal-sheet-io { width: min(680px, 100%); }

.io-tabs {
  display: inline-flex;
  gap: 4px;
  flex: 1 1 auto;
  justify-content: flex-end;
  padding-right: 4px;
}
.io-tab {
  font-family: 'Fraunces', serif;
  font-variation-settings: 'opsz' 12;
  font-weight: 500;
  font-size: 12.5px;
  padding: 5px 13px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  border-radius: 2px;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.io-tab:hover { border-color: var(--ink); color: var(--ink); }
.io-tab-active,
.io-tab-active:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.io-text {
  flex: 1 1 auto;
  min-height: 260px;
  margin: 0;
  padding: 14px 16px;
  border: none;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: rgba(255, 250, 232, 0.5);
  color: var(--ink);
  font-family: ui-monospace, 'JetBrains Mono', Menlo, monospace;
  font-size: 12px;
  line-height: 1.55;
  resize: none;
  outline: none;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  tab-size: 2;
}
.io-text:focus { background: rgba(255, 252, 240, 0.72); }
.io-text::placeholder { color: var(--ink-mute); font-style: italic; }

.io-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  flex: 0 0 auto;
}
.io-spacer { flex: 1 1 auto; }
.io-hint {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-variation-settings: 'opsz' 11;
  font-size: 12px;
  color: var(--ink-mute);
}
.io-error {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-variation-settings: 'opsz' 12;
  font-size: 12.5px;
  color: var(--danger);
}

.io-import-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px 8px;
  flex: 0 0 auto;
}
.io-filebtn { cursor: pointer; }
.io-file {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.io-or-text {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-variation-settings: 'opsz' 11;
  font-size: 12px;
  color: var(--ink-mute);
}

/* =========================================================
   SESSIONS DIALOG
   ========================================================= */

.modal-sheet-sessions { width: min(540px, 100%); max-height: min(680px, 84vh); }

.session-top { padding: 14px 18px 6px; flex: 0 0 auto; }

.session-new {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: 1px dashed var(--ink);
  background: transparent;
  color: var(--ink);
  border-radius: 3px;
  cursor: pointer;
  font-family: 'Fraunces', serif;
  font-variation-settings: 'opsz' 14;
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: 0.004em;
  transition: background 120ms ease, color 120ms ease;
}
.session-new:hover { background: var(--ink); color: var(--paper); }
.session-new-plus { font-size: 18px; line-height: 1; }

.session-list {
  flex: 1 1 auto;
  overflow: auto;
  padding: 8px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.session-list::-webkit-scrollbar { width: 10px; }
.session-list::-webkit-scrollbar-track { background: transparent; }
.session-list::-webkit-scrollbar-thumb {
  background: rgba(20, 16, 8, 0.18);
  border: 3px solid var(--paper);
  border-radius: 6px;
}

.session-row {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: rgba(255, 250, 235, 0.4);
  overflow: hidden;
  transition: border-color 120ms ease, background 120ms ease;
}
.session-row:hover { border-color: rgba(20, 16, 8, 0.30); background: rgba(255, 250, 235, 0.72); }
.session-row-active { border-color: var(--ink); background: rgba(255, 250, 235, 0.85); }

.session-open {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 11px 14px;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  min-width: 0;
}
.session-title {
  max-width: 100%;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-variation-settings: 'opsz' 18, 'SOFT' 0;
  font-size: 16px;
  letter-spacing: -0.006em;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-meta {
  font-family: ui-monospace, 'JetBrains Mono', Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.session-row-active .session-meta { color: var(--ink-soft); }

.session-delete {
  flex: 0 0 44px;
  border: none;
  border-left: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-mute);
  cursor: pointer;
  font-family: 'Fraunces', serif;
  font-size: 18px;
  line-height: 1;
  transition: background 100ms ease, color 100ms ease;
}
.session-delete:hover { background: var(--danger); color: var(--paper); }

.modal-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--rule);
  background:
    linear-gradient(180deg, rgba(255, 250, 235, 0.55), rgba(244, 235, 213, 0.18));
  flex: 0 0 auto;
}

.modal-title {
  margin: 0;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-variation-settings: 'opsz' 22, 'SOFT' 0;
  font-size: 20px;
  letter-spacing: -0.012em;
  color: var(--ink);
  flex: 1 1 auto;
  min-width: 0;
}

.modal-stats {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-variation-settings: 'opsz' 11;
  font-size: 11.5px;
  color: var(--ink-mute);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.modal-close {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-family: 'Fraunces', serif;
  font-size: 18px;
  line-height: 1;
  padding: 0 0 2px;
  transition: background 100ms, color 100ms, transform 100ms;
  align-self: center;
}
.modal-close:hover {
  background: var(--ink);
  color: var(--paper);
  transform: rotate(90deg);
}

.modal-list {
  flex: 1 1 auto;
  overflow: auto;
  padding: 6px 0;
}
.modal-list::-webkit-scrollbar { width: 10px; }
.modal-list::-webkit-scrollbar-track { background: transparent; }
.modal-list::-webkit-scrollbar-thumb {
  background: rgba(20, 16, 8, 0.18);
  border: 3px solid var(--paper);
  border-radius: 6px;
}

.modal-empty {
  padding: 36px 24px;
  text-align: center;
  color: var(--ink-mute);
  font-style: italic;
  font-family: 'Fraunces', serif;
  font-variation-settings: 'opsz' 12;
  font-size: 13px;
}

.modal-now {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
}
.modal-now-rule {
  flex: 1 1 auto;
  height: 0;
  border-top: 1px solid var(--ink);
}
.modal-now-label {
  font-family: ui-monospace, 'JetBrains Mono', Menlo, monospace;
  font-size: 9.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--paper);
  padding: 3px 10px 4px;
  border-radius: 2px;
}

.log-row {
  width: 100%;
  display: grid;
  grid-template-columns: 130px 1fr 64px;
  gap: 14px;
  align-items: baseline;
  padding: 9px 20px;
  background: transparent;
  border: none;
  border-bottom: 1px dashed var(--rule-soft);
  text-align: left;
  cursor: pointer;
  color: var(--ink);
  transition: background 90ms, opacity 120ms;
  font-family: 'Fraunces', serif;
  font-size: 13px;
  position: relative;
}
.log-row::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: var(--coral);
  transition: width 100ms;
}
.log-row:hover { background: rgba(20, 16, 8, 0.05); }
.log-row:hover::before { width: 3px; }
.log-row:last-child { border-bottom: none; }

.log-row-ahead { opacity: 0.5; }
.log-row-ahead:hover { opacity: 1; }
.log-row-ahead::before { background: var(--amber); }

.log-type {
  font-family: ui-monospace, 'JetBrains Mono', Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ink-soft);
  white-space: nowrap;
}

.log-summary {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-variation-settings: 'opsz' 13;
  color: var(--ink);
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.log-time {
  font-family: ui-monospace, 'JetBrains Mono', Menlo, monospace;
  font-size: 10.5px;
  color: var(--ink-mute);
  text-align: right;
  white-space: nowrap;
}
