:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --col-bg: #ebecf0;
  --border: #dfe1e6;
  --text: #172b4d;
  --text-soft: #5e6c84;
  --shadow: 0 1px 2px rgba(9, 30, 66, 0.18), 0 0 1px rgba(9, 30, 66, 0.25);
  --shadow-drag: 0 8px 20px rgba(9, 30, 66, 0.28);
  --accent: #0052cc;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

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

.status { color: var(--text-soft); font-size: 13px; margin-right: 6px; }

.search-wrap { position: relative; }
.search-input {
  font: inherit;
  font-size: 14px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 220px;
  background: var(--surface);
  color: var(--text);
}
.search-input:focus { outline: none; border-color: var(--accent); }

.search-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 380px;
  max-height: 72vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(9, 30, 66, 0.25);
  padding: 6px;
  z-index: 30;
}
.search-count { font-size: 12px; color: var(--text-soft); padding: 6px 10px; }
.search-empty { padding: 14px; color: var(--text-soft); font-size: 13px; }
.search-result {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 9px 11px;
  border-radius: 7px;
  border-left: 4px solid var(--lane, #ccc);
  cursor: pointer;
}
.search-result:hover { background: var(--col-bg); }
.search-result .r-title { font-size: 14px; line-height: 1.35; word-break: break-word; }
.search-result .r-meta { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-soft); }
.search-result .r-status {
  background: rgba(9, 30, 66, 0.08);
  border-radius: 10px;
  padding: 1px 8px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
}

.btn {
  font: inherit;
  font-size: 14px;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s, box-shadow 0.12s;
}
.btn:hover { background: #f0f1f4; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #0046ad; }

/* ---- filter bar / legend ---- */
.filterbar {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.filter-chip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--lane, #ccc); }
.filter-chip.active { color: #fff; border-color: transparent; }
.filter-chip.all { font-weight: 700; }
.filter-chip.all.active { background: var(--text); color: #fff; }

/* ---- board ---- */
.board {
  display: flex;
  gap: 14px;
  align-items: stretch; /* columns fill full height -> whole column is a drop target */
  padding: 18px;
  height: calc(100vh - 58px - 47px);
  overflow-x: auto;
}

.column {
  flex: 1 1 0;
  min-width: 240px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--col-bg);
  border-radius: 10px;
  padding: 10px;
}

.column-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 10px;
}
.column-title { flex: 1; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-soft); }
.column-count { font-size: 12px; color: var(--text-soft); background: rgba(9,30,66,0.08); border-radius: 10px; padding: 1px 8px; }
.col-toggle {
  border: none; background: transparent; cursor: pointer;
  color: var(--text-soft); font-size: 16px; line-height: 1; padding: 0 4px; border-radius: 4px;
}
.col-toggle:hover { background: rgba(9,30,66,0.08); }

/* Collapsed column: a narrow vertical strip. Header expands it; the list below
   stays a live drop target so you can still drag cards into a collapsed column. */
.column.collapsed {
  min-width: 48px;
  max-width: 48px;
  flex: 0 0 48px;
}
.column.collapsed .column-head {
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 4px 2px 8px;
  cursor: pointer;
}
.column.collapsed .column-title {
  flex: 0 0 auto;
  writing-mode: vertical-rl;
  white-space: nowrap;
}
.column.collapsed .card { display: none; }      /* hide contents, keep the list */
.column.collapsed .cards {
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  min-height: 80px;
}

.cards {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 40px;
}

.card {
  background: var(--surface);
  border-radius: 8px;
  padding: 10px 12px 10px 14px;
  box-shadow: var(--shadow);
  position: relative;
  cursor: grab;
  border-left: 5px solid var(--lane, #ccc);
}
.card:active { cursor: grabbing; }
.card.sortable-ghost { opacity: 0.35; }
.card.sortable-chosen { box-shadow: var(--shadow-drag); }

.card-title { font-size: 15px; line-height: 1.35; word-break: break-word; }

.card-meta { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--text-soft); }
.lane-chip { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.lane-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--lane, #ccc); display: inline-block; }
.issue-link { margin-left: auto; color: var(--accent); text-decoration: none; font-weight: 600; }
.issue-link:hover { text-decoration: underline; }

.card-del {
  position: absolute; top: 6px; right: 6px;
  border: none; background: transparent; color: var(--text-soft);
  font-size: 15px; line-height: 1; cursor: pointer; opacity: 0; padding: 2px 5px; border-radius: 4px;
}
.card:hover .card-del { opacity: 1; }
.card-del:hover { background: rgba(9,30,66,0.08); color: #de350b; }

.card-pin {
  position: absolute; top: 6px; right: 28px;
  border: none; background: transparent; color: #d9b400;
  font-size: 14px; line-height: 1; cursor: pointer; opacity: 0; padding: 2px 4px; border-radius: 4px;
}
.card:hover .card-pin { opacity: 0.6; }
.card-pin:hover { opacity: 1; }
.card.pinned { border-top: 2px solid #f5c518; }
.card.pinned .card-pin { opacity: 1; color: #f5c518; }

.prio {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--prio, #6b778c); border: 1px solid var(--prio, #6b778c);
  border-radius: 4px; padding: 0 5px; line-height: 1.5;
}

/* ---- dialogs ---- */
.dialog {
  border: none; border-radius: 12px; padding: 22px; width: 420px; max-width: 92vw;
  box-shadow: 0 12px 40px rgba(9,30,66,0.35);
}
.dialog.wide { width: 560px; }
.dialog::backdrop { background: rgba(9,30,66,0.45); }
.dialog h2 { margin: 0 0 16px; font-size: 18px; }
.dialog label { display: block; margin-bottom: 14px; font-size: 13px; font-weight: 600; color: var(--text-soft); }
.dialog input[type=text], .dialog select {
  display: block; width: 100%; margin-top: 5px; padding: 9px 10px;
  font: inherit; border: 1px solid var(--border); border-radius: 6px; color: var(--text); background: #fff;
}
.hint { font-size: 12px; color: var(--text-soft); min-height: 16px; margin: -4px 0 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.lane-list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow-y: auto; }
.lane-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px; }
.lane-row input[type=color] { flex: 0 0 auto; }
.lane-row input[type=text] { flex: 1 1 auto; min-width: 130px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.lane-row .tag {
  flex: 0 1 auto; min-width: 0; max-width: 200px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 11px; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.04em;
}
.lane-row .btn { flex: 0 0 auto; }
.lane-row.archived { opacity: 0.5; }
.lane-row.archived .tag::after { content: ' · hidden'; }
.lane-add { display: flex; gap: 8px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.lane-add input[type=text] { flex: 1; min-width: 120px; padding: 8px; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ---- card detail ---- */
.detail { border-left: 5px solid var(--lane, #ccc); padding-left: 16px; }
.detail h2 { margin: 0 0 6px; font-size: 19px; line-height: 1.3; }
.detail .detail-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 13px; color: var(--text-soft); margin-bottom: 14px; }
.detail .lane-chip { font-weight: 700; }
.detail .pill { background: rgba(9,30,66,0.07); border-radius: 10px; padding: 1px 9px; }
.detail .pill.open { background: #dcfce7; color: #166534; }
.detail .pill.closed { background: #f3e8ff; color: #6b21a8; }
.detail .labels { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.detail .gh-label { font-size: 12px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--border); }
.detail .body {
  background: var(--col-bg); border-radius: 8px; padding: 14px;
  white-space: pre-wrap; word-break: break-word; font-size: 14px; line-height: 1.5;
  max-height: 45vh; overflow-y: auto; color: var(--text);
}
.detail .body.empty { color: var(--text-soft); font-style: italic; }

.detail-status { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.detail-status .ds-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.detail-status .ds-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-soft); margin-right: 4px; min-width: 56px; }
.ds-prio { font: inherit; font-size: 13px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.ds-prio-ro { font-size: 13px; color: var(--text-soft); }
.ds-btn {
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.ds-btn:hover:not(.current) { background: var(--col-bg); }
.ds-btn.current { background: var(--accent); border-color: var(--accent); color: #fff; cursor: default; }
.ds-btn:disabled { opacity: 0.5; cursor: default; }
