:root {
  color-scheme: light;
  --bg: #f3f6f5;
  --surface: #ffffff;
  --surface-soft: #edf2ef;
  --ink: #17211e;
  --muted: #65716d;
  --line: #d8dfdb;
  --accent: #0a7a70;
  --accent-strong: #075d56;
  --blue: #255fcf;
  --amber: #d49a17;
  --danger: #b43737;
  --shadow: 0 16px 44px rgba(23, 33, 30, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans KR", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(37, 95, 207, 0.28);
  outline-offset: 2px;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
}

.title-block {
  min-width: 190px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.12rem;
  line-height: 1.2;
}

.title-block p,
#selectionLabel {
  color: var(--muted);
  font-size: 0.84rem;
  margin-top: 3px;
}

.header-controls {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

select,
input {
  min-height: 38px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 7px 10px;
}

.point-control input {
  width: 94px;
}

.primary-button,
.quiet-button {
  min-height: 38px;
  border-radius: 7px;
  font-weight: 900;
  transition:
    transform 120ms ease,
    background 120ms ease;
}

.primary-button {
  padding: 0 15px;
  background: var(--ink);
  color: #fff;
}

.quiet-button {
  padding: 0 11px;
  background: var(--surface-soft);
  color: var(--ink);
}

.primary-button:hover,
.quiet-button:hover {
  transform: translateY(-1px);
}

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(520px, 1fr) minmax(290px, 360px);
  gap: 14px;
  padding: 14px;
}

.board-panel,
.side-panel {
  min-width: 0;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.board-panel {
  display: flex;
  flex-direction: column;
}

.side-panel {
  display: flex;
  flex-direction: column;
}

.result-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
}

.result-strip div {
  padding: 12px 14px;
  border-right: 1px solid var(--line);
}

.result-strip div:last-child {
  border-right: 0;
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  margin-bottom: 3px;
}

.result-strip strong {
  font-size: 1.25rem;
}

.board-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.legend {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 9px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend i {
  width: 12px;
  height: 12px;
  display: inline-block;
  border-radius: 3px;
  border: 1px solid rgba(23, 33, 30, 0.16);
}

.legend-selected {
  background: #ffffff;
  box-shadow: inset 0 0 0 2px #d82222;
}

.legend-unselected {
  background: #b9c0bd;
}

.legend-center {
  background: #efc84a;
}

.legend-cost {
  border-radius: 50%;
}

.cost-1 {
  background: #111111;
}

.cost-2 {
  background: #11934a;
}

.cost-3 {
  background: #1f61d8;
}

.cost-4 {
  background: #d82222;
}

.board-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px;
  background:
    linear-gradient(#e2e8e4 1px, transparent 1px),
    linear-gradient(90deg, #e2e8e4 1px, transparent 1px),
    #f8faf8;
  background-size: 22px 22px;
}

.boards-container {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
  gap: 14px;
  align-items: start;
}

.board-card {
  min-width: 0;
  display: grid;
  gap: 10px;
  justify-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
}

.board-card-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.board-card-header h3 {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.15;
}

.board-card-header span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.board-card-header strong {
  flex: 0 0 auto;
  font-size: 0.84rem;
  white-space: nowrap;
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell-size));
  grid-auto-rows: var(--cell-size);
  gap: 3px;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
  user-select: none;
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 5px;
  border: 1px solid #cbd1ce;
  background: #f8faf9;
  color: var(--muted);
  padding: 0;
  line-height: 1;
  font-size: 0.66rem;
  font-weight: 900;
}

.cell:hover {
  box-shadow: 0 0 0 2px rgba(37, 95, 207, 0.26);
  z-index: 20;
}

.cell.slot {
  background: #b9c0bd;
  color: #2a312e;
  text-shadow: none;
}

.cell.selected {
  background: #f8faf9;
  border-color: #d82222;
  box-shadow:
    inset 0 0 0 2px #d82222,
    0 4px 12px rgba(216, 34, 34, 0.18);
}

.cell.connector {
  box-shadow:
    inset 0 0 0 2px #d82222,
    0 4px 12px rgba(216, 34, 34, 0.18);
}

.cell.center {
  background: #efc84a;
  color: #211900;
  border-color: #c99819;
  text-shadow: none;
}

.cell.empty {
  color: #c0c9c4;
}

.cell::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  width: max-content;
  max-width: 260px;
  padding: 7px 9px;
  border-radius: 7px;
  background: rgba(23, 33, 30, 0.94);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.35;
  white-space: normal;
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
  z-index: 50;
}

.cell:hover::after,
.cell:focus-visible::after {
  opacity: 1;
}

.code-label {
  position: absolute;
  left: 4px;
  bottom: 4px;
  font-size: 0.56rem;
  color: rgba(23, 33, 30, 0.78);
}

.cell.slot:not(.selected) .code-label,
.cell.slot:not(.selected) .cost {
  color: #68716d;
}

.cost-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #8f9793;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.72);
}

.cell.slot:not(.selected) .cost-dot {
  background: #8f9793;
}

.cell.selected .cost-dot.cost-1 {
  background: #111111;
}

.cell.selected .cost-dot.cost-2 {
  background: #11934a;
}

.cell.selected .cost-dot.cost-3 {
  background: #1f61d8;
}

.cell.selected .cost-dot.cost-4 {
  background: #d82222;
}

.cell .cost {
  position: absolute;
  right: 3px;
  bottom: 3px;
  min-width: 14px;
  height: 14px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-size: 0.56rem;
  text-shadow: none;
}

.cell .order {
  position: absolute;
  left: 3px;
  top: 3px;
  min-width: 14px;
  height: 14px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: rgba(23, 33, 30, 0.74);
  color: #fff;
  font-size: 0.54rem;
}

.panel-section {
  min-height: 0;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.panel-section:last-child {
  border-bottom: 0;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

h2 {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0;
}

.priority-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: min(52vh, 620px);
  overflow: auto;
  display: grid;
  gap: 7px;
}

.priority-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 48px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.priority-item.dragging {
  opacity: 0.55;
}

.priority-item.drop-before {
  border-top-color: var(--blue);
  box-shadow: 0 -2px 0 var(--blue);
}

.drag-handle {
  width: 28px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 900;
}

.priority-main {
  min-width: 0;
}

.priority-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
  font-weight: 900;
}

.priority-meta {
  display: flex;
  gap: 7px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  margin-top: 3px;
}

.priority-code {
  min-width: 42px;
  border: 0;
  border-radius: 6px;
  padding: 5px 7px;
  background: var(--surface-soft);
  color: var(--ink);
  text-align: center;
  font-size: 0.76rem;
  font-weight: 900;
  cursor: pointer;
}

.priority-code:hover {
  background: #dde6e1;
}

.result-section {
  flex: 1;
  overflow: auto;
}

.summary-list {
  display: grid;
  gap: 7px;
}

.summary-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 9px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.summary-item strong {
  min-width: 48px;
  text-align: right;
}

.summary-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
  font-weight: 800;
}

.summary-note,
.load-error {
  padding: 10px;
  border-radius: 8px;
  background: #fff5df;
  color: #7b4b08;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.45;
}

@media (max-width: 980px) {
  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .header-controls {
    justify-content: start;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .side-panel {
    min-height: 540px;
  }

  .boards-container {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .workspace {
    padding: 10px;
  }

  .result-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .board-toolbar {
    align-items: start;
    flex-direction: column;
  }

  .boards-container {
    grid-template-columns: minmax(0, 1fr);
  }

  .board-card {
    align-items: start;
    justify-items: start;
    overflow: auto;
  }
}
