:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #647086;
  --line: #d9dfeb;
  --paper: #fbfaf7;
  --panel: #ffffff;
  --navy: #0b2a57;
  --gold: #b88932;
  --red: #b64444;
  --blue: #2d65b8;
  --green: #36764a;
  --yellow: #b88b25;
  --shadow: 0 12px 30px rgba(28, 40, 68, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Yu Gothic", "Hiragino Sans", "Meiryo", system-ui, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(16px, 4vw, 48px) 22px;
  background: linear-gradient(180deg, #ffffff 0%, #f6f1e8 100%);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.05;
}

.lead {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
}

.summary-panel {
  align-self: end;
  display: grid;
  grid-template-columns: repeat(3, minmax(86px, 1fr));
  gap: 8px;
  min-width: min(430px, 100%);
}

.summary-panel span {
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--muted);
}

.summary-panel strong {
  display: block;
  color: var(--navy);
  font-size: 24px;
}

main {
  padding: 18px clamp(12px, 3vw, 32px) 36px;
}

.ad-strip {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 auto 16px;
  padding: 10px 14px;
  max-width: 1500px;
  min-height: 58px;
  border: 1px dashed #c4af82;
  border-radius: 8px;
  background: #fffdf7;
  color: var(--muted);
}

.ad-strip span {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 4px;
  background: #f0e4cc;
  color: #70511b;
  font-weight: 700;
}

.ad-strip p {
  margin: 0;
}

.mode-tabs {
  display: flex;
  gap: 8px;
  max-width: 1500px;
  margin: 0 auto 12px;
  overflow-x: auto;
}

.tab,
.segmented button,
.icon-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  cursor: pointer;
}

.tab {
  min-width: 124px;
  padding: 10px 16px;
  font-weight: 700;
}

.tab.active,
.segmented button.active {
  border-color: var(--navy);
  background: var(--navy);
  color: #fff;
}

.notice {
  max-width: 1500px;
  margin: 0 auto 14px;
  padding: 10px 12px;
  border-left: 4px solid var(--red);
  border-radius: 6px;
  background: #fff5f2;
  color: #683024;
}

.workspace {
  display: grid;
  grid-template-columns: 250px minmax(820px, 1fr) 300px;
  gap: 14px;
  max-width: 1500px;
  margin: 0 auto;
  align-items: start;
}

.filters,
.compare-area,
.detail-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.filters {
  position: sticky;
  top: 12px;
  padding: 14px;
}

.filter-block + .filter-block {
  margin-top: 18px;
}

.filter-block label,
.filter-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

input[type="search"],
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.segmented button {
  min-height: 36px;
}

.check-list {
  display: grid;
  gap: 8px;
}

.check-list label {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0;
  color: var(--muted);
  font-weight: 500;
}

.compare-area {
  min-width: 0;
  overflow: hidden;
}

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

.table-toolbar h2 {
  margin-bottom: 2px;
}

.table-toolbar p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.icon-button {
  width: 40px;
  height: 40px;
  font-size: 20px;
}

.small-button {
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.table-wrap {
  overflow: auto;
  max-height: 520px;
  scrollbar-gutter: stable;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1180px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th:nth-child(1),
td:nth-child(1) {
  width: 64px;
}

th:nth-child(2),
td:nth-child(2) {
  width: 200px;
}

th:nth-child(3),
td:nth-child(3) {
  width: 290px;
}

th:nth-child(4),
td:nth-child(4) {
  width: 250px;
}

th:nth-child(5),
td:nth-child(5) {
  width: 64px;
}

th:nth-child(6),
td:nth-child(6),
th:nth-child(7),
td:nth-child(7),
th:nth-child(8),
td:nth-child(8) {
  width: 112px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f2f5fa;
  color: #273653;
  font-size: 12px;
  white-space: nowrap;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: #fff7e8;
}

.character-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 160px;
}

.mini-avatar,
.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  border: 2px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 0 1px rgba(18, 34, 62, 0.18);
}

.mini-avatar {
  width: 30px;
  height: 30px;
  font-size: 13px;
}

.avatar {
  width: 58px;
  height: 58px;
  margin-bottom: 12px;
  font-size: 20px;
}

.attr-藍 { background: var(--blue); }
.attr-紅 { background: var(--red); }
.attr-翠 { background: var(--green); }
.attr-黄 { background: var(--yellow); }
.attr-天 { background: #7f71c8; }
.attr-冥 { background: #6f6077; }

.number {
  font-weight: 700;
  color: var(--navy);
  white-space: nowrap;
}

.target-cell {
  min-width: 230px;
  line-height: 1.55;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.condition-cell {
  min-width: 260px;
  line-height: 1.55;
}

.row-check {
  display: flex;
  gap: 8px;
  align-items: center;
}

.row-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--navy);
}

.empty-state {
  padding: 34px 18px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 18px;
}

.pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: #edf1f8;
  color: #3b4b65;
  font-size: 12px;
  white-space: nowrap;
}

.reality-high { background: #eaf7ee; color: #27613a; }
.reality-mid { background: #fff1d8; color: #805519; }
.reality-low { background: #ffe8e3; color: #8b382a; }

.detail-panel {
  position: sticky;
  top: 12px;
  display: grid;
  gap: 12px;
}

.detail-card,
.compare-bin {
  padding: 16px;
}

.compare-bin {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.compare-bin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.compare-bin h2 {
  margin-bottom: 0;
  font-size: 18px;
}

#compareBinEmpty {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.compare-bin-list {
  display: grid;
  gap: 8px;
}

.compare-chip {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.compare-chip strong {
  display: block;
  font-size: 13px;
}

.compare-chip span {
  color: var(--muted);
  font-size: 12px;
}

.remove-chip {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.compare-board {
  border-top: 1px solid var(--line);
  background: #fffdf8;
}

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

.compare-board-head h2 {
  margin-bottom: 2px;
  font-size: 20px;
}

.compare-board-head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.board-count {
  padding: 5px 10px;
  border-radius: 999px;
  background: #edf1f8;
  color: #3b4b65;
  font-weight: 700;
  white-space: nowrap;
}

.board-empty {
  padding: 22px 14px;
  color: var(--muted);
  text-align: center;
}

.board-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(240px, 1fr);
  gap: 10px;
  overflow-x: auto;
  padding: 14px;
}

.board-card {
  min-width: 240px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.board-card-head {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #f7f3ea;
}

.board-card-head strong {
  display: block;
  line-height: 1.3;
}

.board-card-head span {
  color: var(--muted);
  font-size: 12px;
}

.board-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
}

.board-metrics div {
  padding: 10px 8px;
  border-right: 1px solid var(--line);
}

.board-metrics div:last-child {
  border-right: 0;
}

.board-metrics dt,
.board-note dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.board-metrics dd {
  margin: 3px 0 0;
  color: var(--navy);
  font-size: 18px;
  font-weight: 800;
}

.board-note {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.board-note dd {
  margin: 2px 0 0;
  line-height: 1.5;
}

.detail-kicker {
  margin-bottom: 4px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
}

.detail-card h2 {
  margin-bottom: 6px;
  font-size: 22px;
}

#detailMeta {
  color: var(--muted);
  line-height: 1.6;
}

dl {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

dd {
  margin: 2px 0 0;
  line-height: 1.55;
}

.note-link {
  display: inline-flex;
  justify-content: center;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}

@media (max-width: 1180px) {
  .app-header,
  .workspace {
    grid-template-columns: 1fr;
  }

  .app-header {
    display: block;
  }

  .summary-panel {
    margin-top: 18px;
  }

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

  .filters,
  .detail-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  main {
    padding-inline: 10px;
  }

  .app-header {
    padding-inline: 16px;
  }

  .summary-panel {
    grid-template-columns: 1fr;
  }

  .ad-strip {
    align-items: flex-start;
    flex-direction: column;
  }

  .segmented {
    grid-template-columns: repeat(3, 1fr);
  }

  .table-toolbar {
    align-items: flex-start;
  }

  table {
    min-width: 980px;
  }
}
