/* Workbench layout · Lime palette */
:root {
  color-scheme: light;
  --bg: #f4f4ef;
  --surface: #ffffff;
  --soft: #e7ebd9;
  --soft-2: #eef0e6;
  --ink: #111111;
  --ink-2: #3a3d33;
  --muted: #6c6f64;
  --line: rgba(17, 17, 17, 0.09);
  --line-strong: rgba(17, 17, 17, 0.2);
  --accent: #c6f432;
  --accent-ink: #1d2a00;
  --danger: #d13b40;
  --danger-soft: rgba(229, 72, 77, 0.1);
  --avoid-bg: #fde6e5;
  --shadow: 0 1px 2px rgba(17, 17, 17, 0.04), 0 16px 40px -20px rgba(40, 50, 10, 0.18);
  --radius: 24px;
  --radius-sm: 14px;
  --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111210;
  --surface: #1a1c18;
  --soft: #23261f;
  --soft-2: #1f221c;
  --ink: #f1f3ea;
  --ink-2: #cfd3c4;
  --muted: #92978a;
  --line: rgba(241, 243, 234, 0.08);
  --line-strong: rgba(241, 243, 234, 0.2);
  --accent: #c6f432;
  --accent-ink: #1d2a00;
  --danger: #ff6b6f;
  --danger-soft: rgba(255, 107, 111, 0.1);
  --avoid-bg: rgba(255, 107, 111, 0.14);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03), 0 20px 50px -24px rgba(0, 0, 0, 0.7);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111210;
    --surface: #1a1c18;
    --soft: #23261f;
    --soft-2: #1f221c;
    --ink: #f1f3ea;
    --ink-2: #cfd3c4;
    --muted: #92978a;
    --line: rgba(241, 243, 234, 0.08);
    --line-strong: rgba(241, 243, 234, 0.2);
    --accent: #c6f432;
    --accent-ink: #1d2a00;
    --danger: #ff6b6f;
    --danger-soft: rgba(255, 107, 111, 0.1);
    --avoid-bg: rgba(255, 107, 111, 0.14);
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.03), 0 20px 50px -24px rgba(0, 0, 0, 0.7);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 8px; }

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* ---------- Top bar ---------- */
.topbar {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px 8px;
}

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand strong { font-weight: 800; font-size: 16px; letter-spacing: -0.02em; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; }
.brand-mark svg { width: 22px; height: 22px; fill: none; stroke: var(--accent-ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

.top-actions { display: flex; gap: 8px; }

.pill-btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  transition: border-color 160ms var(--ease);
}
.pill-btn { padding: 0 14px; font-weight: 700; font-size: 14px; }
.icon-btn { width: 40px; }
.pill-btn:hover, .icon-btn:hover { border-color: var(--line-strong); }

.badge {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  background: var(--accent);
  color: var(--accent-ink);
}
.badge[hidden] { display: none; }

.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}

/* ---------- Workbench grid ---------- */
.bench {
  max-width: 1320px;
  margin: 0 auto;
  padding: 16px 24px 48px;
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

/* ---------- Left rail ---------- */
.rail { position: sticky; top: 16px; display: grid; gap: 26px; }
.rail-title { margin: 0 0 8px; padding: 0 12px; font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.rail-head { display: flex; justify-content: space-between; align-items: center; padding-right: 4px; }
.rail-head .rail-title { margin-bottom: 4px; }
.rail-list { display: grid; gap: 2px; }

.rail-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  transition: background 140ms var(--ease), color 140ms var(--ease);
}
.rail-item:hover { background: var(--soft); color: var(--ink); }
.rail-item[aria-checked="true"] { color: var(--ink); font-weight: 700; }
.rail-label { flex: 1; min-width: 0; }

.check {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1.6px solid var(--line-strong);
  display: grid;
  place-items: center;
  background: var(--surface);
  transition: background 140ms var(--ease), border-color 140ms var(--ease);
}
.check svg { width: 11px; height: 11px; fill: none; stroke: var(--accent-ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transform: scale(0.6); transition: 160ms var(--ease); }
.rail-item[aria-checked="true"] .check { background: var(--accent); border-color: var(--accent); }
.rail-item[aria-checked="true"] .check svg { opacity: 1; transform: none; }

.rail-group:not(.expanded) .is-extra { display: none; }
.more-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0 0;
  padding: 7px 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}
.more-btn:hover { color: var(--ink); background: var(--soft); }
.more-btn .icon { width: 14px; height: 14px; transition: transform 200ms var(--ease); }
.rail-group.expanded .more-btn .icon { transform: rotate(180deg); }
.more-btn[hidden] { display: none; }

.text-btn { border: 0; background: none; color: var(--muted); font-size: 12.5px; font-weight: 700; padding: 4px; }
.text-btn:hover { color: var(--ink); }

.recent { list-style: none; margin: 0; padding: 0 4px; }
.recent button {
  width: 100%;
  display: grid;
  gap: 1px;
  text-align: left;
  border: 0;
  border-top: 1px solid var(--line);
  background: none;
  padding: 9px 8px;
}
.recent li:first-child button { border-top: 0; }
.recent .r-task { font-size: 13px; font-weight: 600; line-height: 1.35; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.recent .r-meta { font-size: 11.5px; color: var(--muted); }
.recent button:hover .r-task { color: var(--ink); }
.recent button[aria-current="true"] .r-task { color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 3px; text-underline-offset: 3px; }
.empty { color: var(--muted); font-size: 13px; margin: 4px 8px 0; }

/* ---------- Center card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(24px, 3.4vw, 44px);
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: min(640px, calc(100vh - 110px));
}

.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }

.tag {
  display: inline-block;
  height: 28px;
  line-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.level { flex: none; display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.bars { display: inline-flex; gap: 3px; align-items: flex-end; }
.bars i { display: block; width: 4px; border-radius: 2px; background: var(--line-strong); }
.bars i:nth-child(1) { height: 7px; }
.bars i:nth-child(2) { height: 11px; }
.bars i:nth-child(3) { height: 15px; }
.bars i.on { background: var(--ink); }

.card-body { margin-top: auto; }

.task {
  margin: 0;
  font-weight: 800;
  font-size: clamp(30px, 3.9vw, 54px);
  line-height: 1.04;
  letter-spacing: -0.045em;
  text-wrap: balance;
  max-width: 20ch;
}

.domain { margin: 14px 0 0; font-size: clamp(17px, 1.6vw, 20px); font-weight: 600; color: var(--muted); letter-spacing: -0.01em; }
.domain strong { color: var(--ink); font-weight: 800; box-shadow: inset 0 -0.42em 0 var(--accent); padding: 0 2px; }
:root[data-theme="dark"] .domain strong { color: var(--accent); box-shadow: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .domain strong { color: var(--accent); box-shadow: none; } }

.constraint {
  margin: 0;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--soft);
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.5;
  max-width: 64ch;
}

.card-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: 50px;
  padding: 0 20px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.01em;
  transition: transform 160ms var(--ease), background 160ms var(--ease), border-color 160ms var(--ease), color 160ms var(--ease);
}
.btn:hover { border-color: var(--line-strong); }
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-primary:hover { border-color: var(--ink); }
.btn-primary .icon { transition: transform 200ms var(--ease); }
.btn-primary:hover .icon { transform: translateX(3px); }

.btn-accent { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-accent:hover { border-color: transparent; filter: brightness(0.97); }

.btn-like .heart { transition: transform 300ms var(--ease), fill 200ms; }
.btn-like[aria-pressed="true"] { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn-like[aria-pressed="true"] .heart { fill: currentColor; }
.btn-like.pop .heart { animation: pop 500ms var(--ease); }
@keyframes pop { 35% { transform: scale(1.4); } }

.btn-ghost { background: transparent; }

.card.is-swapping .card-body,
.card.is-swapping .constraint,
.card.is-swapping .card-meta { animation: swap 460ms var(--ease) both; }
.card.is-swapping .constraint { animation-delay: 50ms; }
@keyframes swap { from { opacity: 0; transform: translateY(12px); } }

/* ---------- Right: brief ---------- */
.brief {
  position: sticky;
  top: 16px;
  background: var(--soft);
  border-radius: var(--radius);
  padding: 24px;
  overflow: hidden;
  min-height: 420px;
}

.brief-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; }
.brief-head h2 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.03em; }
.done-count { font-size: 13px; font-weight: 800; color: var(--ink); background: var(--accent); color: var(--accent-ink); padding: 3px 9px; border-radius: 999px; }
.done-count:empty { display: none; }

.brief-body { display: grid; gap: 20px; transition: filter 420ms var(--ease), opacity 420ms var(--ease); }
.brief.locked .brief-body { filter: blur(8px); opacity: 0.5; pointer-events: none; user-select: none; }
.brief.unlocking .brief-body { animation: unblur 520ms var(--ease); }
@keyframes unblur { from { filter: blur(8px); opacity: 0.5; } }

.brief-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.meta-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 999px; background: var(--surface); font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.meta-chip .icon { width: 14px; height: 14px; color: var(--muted); }

.block h3 { margin: 0 0 10px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

.bullets { margin: 0; padding: 0; list-style: none; display: grid; gap: 9px; }
.bullets li { position: relative; padding-left: 18px; font-size: 14.5px; line-height: 1.45; color: var(--ink); }
.bullets li::before { content: ""; position: absolute; left: 0; top: 0.5em; width: 8px; height: 8px; border-radius: 3px; background: var(--accent); box-shadow: inset 0 0 0 1px rgba(29, 42, 0, 0.25); }

.real { margin: 12px 0 0; font-size: 13px; line-height: 1.45; color: var(--muted); }
.real strong { color: var(--ink-2); font-weight: 700; }

.avoid { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--avoid-bg); color: var(--ink); font-size: 14.5px; line-height: 1.45; }

.checklist { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.checklist label { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; cursor: pointer; font-size: 14.5px; line-height: 1.4; color: var(--ink); padding: 8px 10px; border-radius: 12px; background: var(--surface); }
.checklist input { position: absolute; opacity: 0; pointer-events: none; }
.checklist .box { width: 20px; height: 20px; border-radius: 6px; border: 1.6px solid var(--line-strong); display: grid; place-items: center; transition: background 160ms, border-color 160ms; }
.checklist .box svg { width: 12px; height: 12px; stroke: var(--accent-ink); stroke-width: 3; fill: none; opacity: 0; transform: scale(0.6); transition: 180ms var(--ease); }
.checklist input:checked + .box { background: var(--accent); border-color: var(--accent); }
.checklist input:checked + .box svg { opacity: 1; transform: none; }
.checklist input:checked ~ span:last-child { color: var(--muted); text-decoration: line-through; }
.checklist input:focus-visible + .box { outline: 2px solid var(--ink); outline-offset: 2px; }

.lock { position: absolute; inset: 0; display: none; place-items: center; padding: 24px; }
.brief.locked .lock { display: grid; }
.lock-card {
  display: grid;
  justify-items: center;
  gap: 6px;
  text-align: center;
  max-width: 270px;
  padding: 22px 20px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 24px 50px -24px rgba(0, 0, 0, 0.35);
}
.lock-card > .icon { width: 22px; height: 22px; margin-bottom: 4px; }
.lock-card strong { font-size: 16px; font-weight: 800; letter-spacing: -0.02em; }
.lock-card span { font-size: 13.5px; color: var(--muted); line-height: 1.45; }
.lock-card .btn { margin-top: 10px; height: 44px; font-size: 14px; }

/* ---------- Liked panel (drawer on desktop, bottom sheet on mobile) ---------- */
.scrim { position: fixed; inset: 0; background: rgba(10, 12, 6, 0.4); z-index: 20; animation: fade 200ms var(--ease); }
@keyframes fade { from { opacity: 0; } }

.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100%);
  background: var(--surface);
  border-left: 1px solid var(--line);
  z-index: 21;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 320ms var(--ease);
  visibility: hidden;
}
.panel.is-open { transform: none; visibility: visible; }
.panel.is-dragging { transition: none; }
.grabber { display: none; }

.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }

.liked-list { list-style: none; margin: 0; padding: 8px 10px 24px; overflow-y: auto; overscroll-behavior: contain; display: grid; gap: 4px; align-content: start; flex: 1; }
.liked-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 12px; border-radius: 14px; transition: background 160ms; }
.liked-item:hover { background: var(--soft-2); }
.liked-open { border: 0; background: none; text-align: left; padding: 0; display: grid; gap: 4px; }
.liked-open .t { font-size: 15px; font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; }
.liked-open .d { font-size: 13px; color: var(--muted); }
.liked-open .p { justify-self: start; font-size: 11.5px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); }
.unlike { align-self: start; width: 34px; height: 34px; border-radius: 10px; border: 0; background: none; color: var(--ink); display: grid; place-items: center; }
.unlike:hover { background: var(--soft); }
.unlike .icon { fill: currentColor; }

.panel-empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.panel-empty strong { display: block; font-size: 17px; color: var(--ink); margin-bottom: 4px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 30;
  transform: translate(-50%, 16px);
  opacity: 0;
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  font-weight: 700;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .bench { grid-template-columns: 190px minmax(0, 1fr); }
  .brief { grid-column: 2; position: relative; top: auto; min-height: 0; }
}

@media (max-width: 820px) {
  .topbar { padding: 14px 16px 4px; }
  .bench { grid-template-columns: minmax(0, 1fr); padding: 12px 16px 40px; gap: 14px; }
  .brief { grid-column: auto; }
  .rail { position: static; gap: 10px; min-width: 0; grid-template-columns: minmax(0, 1fr); }
  .rail-group { min-width: 0; }
  .rail-group:not(.expanded) .rail-list .is-extra { display: flex; }
  .more-btn { display: none; }
  .rail-title, .rail-recent { display: none; }
  .rail-list {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    margin: 0 -16px;
    padding: 0 16px;
  }
  .rail-list::-webkit-scrollbar { display: none; }
  .rail-item { width: auto; flex: none; white-space: nowrap; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 14px; font-size: 13.5px; }
  .rail-item[aria-checked="true"] { border-color: var(--ink); background: var(--soft); }
  .rail-item { gap: 8px; }
  .check { width: 16px; height: 16px; border-radius: 5px; }
  .rail-item .bars { display: none; }
  .card { min-height: 0; padding: 22px 20px; gap: 20px; }
  .card-body { margin-top: 12px; }
  .card-actions { display: grid; grid-template-columns: 1fr 1fr auto; }
  .btn-primary { grid-column: 1 / -1; }
  .copy-label { display: none; }
  .btn-ghost { width: 50px; padding: 0; }
  .pill-label { display: none; }
  .pill-btn { padding: 0 12px; }
  .brief { padding: 20px; scroll-margin-top: 12px; }
  .brief.locked { min-height: 340px; }

  /* Liked → bottom sheet */
  .panel {
    top: auto;
    left: 0;
    width: 100%;
    max-height: 85dvh;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -20px 50px -20px rgba(0, 0, 0, 0.35);
    transform: translateY(100%);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .panel.is-open { transform: translateY(var(--drag, 0px)); }
  .grabber { display: grid; place-items: center; height: 22px; touch-action: none; cursor: grab; }
  .grabber span { width: 40px; height: 5px; border-radius: 999px; background: var(--line-strong); }
  .panel-head { padding: 4px 20px 12px; touch-action: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
}
