:root {
  color-scheme: dark;
  --bg: #111315;
  --panel: #1a1d20;
  --panel-2: #22262a;
  --line: #3a4047;
  --text: #f6f7f8;
  --muted: #aeb6bf;
  --pink: #ea7991;
  --pink-strong: #ff8ca4;
  --blue: #72bfff;
  --danger: #e65757;
  --shadow: 0 18px 44px rgba(0, 0, 0, .28);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(234, 121, 145, .12), transparent 34rem),
    linear-gradient(180deg, #111315 0%, #0d0f11 100%);
  font-family: Inter, Pretendard, "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

code {
  padding: 2px 6px;
  border-radius: 5px;
  background: #111417;
  color: #ffd0da;
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 64px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
  padding: 30px 32px;
  border: 1px solid rgba(234, 121, 145, .42);
  border-radius: 20px;
  background:
    linear-gradient(125deg, rgba(234, 121, 145, .15), transparent 42%),
    #181b1e;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--pink-strong);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .16em;
}

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

h1 {
  margin-bottom: 10px;
  font-size: clamp(30px, 5vw, 56px);
  line-height: 1.05;
}

h1 span {
  color: var(--pink-strong);
  font-size: .65em;
}

.subtitle {
  max-width: 760px;
  margin-bottom: 0;
  color: #ced4da;
  line-height: 1.7;
}

.completion-box {
  min-width: 132px;
  padding: 18px 22px;
  border: 1px solid #4a5057;
  border-radius: 16px;
  background: #101214;
  text-align: center;
}

.completion-box strong {
  display: block;
  color: var(--pink-strong);
  font-size: 27px;
}

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

.panel {
  margin-top: 22px;
  padding: 24px;
  border: 1px solid #343a40;
  border-radius: 18px;
  background: rgba(26, 29, 32, .96);
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.section-heading h2 {
  margin-bottom: 6px;
  font-size: 23px;
}

.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.button-row,
.pool-tools,
.custom-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.button {
  min-height: 42px;
  padding: 10px 15px;
  border: 1px solid #4b525a;
  border-radius: 10px;
  background: #2b3035;
  cursor: pointer;
  font-weight: 800;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}

.button:hover {
  transform: translateY(-1px);
  border-color: #7d8791;
  background: #343a40;
}

.button.primary {
  border-color: #f08aa0;
  background: var(--pink);
  color: #fff;
}

.button.danger {
  border-color: #ff7777;
  background: #b83d3d;
}

.button.danger-soft {
  border-color: rgba(230, 87, 87, .65);
  background: rgba(230, 87, 87, .14);
  color: #ffaaaa;
}

.matrix-scroll {
  overflow-x: auto;
  padding-bottom: 8px;
}

.favorite-matrix {
  display: grid;
  grid-template-columns: 126px repeat(4, minmax(190px, 1fr));
  min-width: 930px;
  overflow: hidden;
  border: 1px solid #515860;
  border-radius: 13px;
  background: #121416;
}

.matrix-corner,
.matrix-column-header,
.matrix-row-header,
.matrix-slot {
  border-right: 1px solid #40464d;
  border-bottom: 1px solid #40464d;
}

.matrix-corner {
  display: grid;
  place-items: center;
  min-height: 70px;
  color: #8f98a1;
  background: #171a1d;
  font-weight: 800;
}

.matrix-column-header {
  display: grid;
  place-items: center;
  min-height: 70px;
  background: #25292d;
  font-size: 18px;
  font-weight: 900;
}

.matrix-column-header[data-style="도주"] { color: #ff726d; }
.matrix-column-header[data-style="선행"] { color: #f3c55c; }
.matrix-column-header[data-style="선입"] { color: #76c8ff; }
.matrix-column-header[data-style="추입"] { color: #be8cff; }

.matrix-row-header {
  display: grid;
  place-items: center;
  min-height: 210px;
  padding: 12px;
  color: #151515;
  font-size: 20px;
  font-weight: 950;
  text-align: center;
}

.matrix-row-header[data-distance="단거리"] { background: #ff858d; }
.matrix-row-header[data-distance="마일"] { background: #ffbc7b; }
.matrix-row-header[data-distance="중거리"] { background: #ffe183; }
.matrix-row-header[data-distance="장거리"] { background: #b7ef7a; }
.matrix-row-header[data-distance="더트"] { background: #76d5ec; }

.matrix-slot {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 210px;
  padding: 8px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.025), transparent),
    #17191b;
  transition: background .15s ease, box-shadow .15s ease;
}

.matrix-slot::before {
  content: attr(data-label);
  color: #59616a;
  font-size: 13px;
  font-weight: 800;
}

.matrix-slot.drag-over,
.matrix-slot.selected-target {
  background: rgba(234, 121, 145, .14);
  box-shadow: inset 0 0 0 3px var(--pink);
}

.slot-character {
  position: absolute;
  inset: 7px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
  border: 2px solid var(--pink);
  border-radius: 10px;
  background: #0f1113;
  cursor: grab;
}

.slot-character:active {
  cursor: grabbing;
}

.slot-character img {
  width: 100%;
  height: 154px;
  object-fit: contain;
  object-position: center bottom;
  background:
    radial-gradient(circle at 50% 70%, rgba(255,255,255,.06), transparent 58%),
    #101214;
}

.slot-character strong {
  display: grid;
  place-items: center;
  min-height: 38px;
  padding: 5px 30px 5px 8px;
  background: #23272b;
  font-size: 13px;
  text-align: center;
}

.remove-slot {
  position: absolute;
  right: 5px;
  bottom: 6px;
  z-index: 2;
  width: 25px;
  height: 25px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(216, 70, 70, .92);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.selection-hint {
  margin: 10px 0 0;
  color: #ffc4d1;
  font-size: 13px;
}

.import-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.import-card {
  position: relative;
  padding: 20px;
  border: 1px solid #414850;
  border-radius: 14px;
  background: #202428;
}

.import-card.recommended {
  border-color: rgba(234, 121, 145, .85);
  background: linear-gradient(145deg, rgba(234,121,145,.12), #202428 52%);
}

.import-card h3 {
  margin-bottom: 8px;
}

.import-card p {
  min-height: 48px;
  color: var(--muted);
  line-height: 1.55;
}

.badge {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--pink);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}

.file-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--pink);
  cursor: pointer;
  font-weight: 900;
}

.file-button.secondary {
  border: 1px solid #59616a;
  background: #2d3338;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.import-card .button {
  width: 100%;
  margin-top: 10px;
}

.progress-wrap {
  margin-top: 16px;
  padding: 14px;
  border-radius: 12px;
  background: #111416;
}

.progress-line {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
}

progress {
  width: 100%;
  height: 13px;
  accent-color: var(--pink);
}

.status-box {
  margin-top: 14px;
  padding: 13px 15px;
  border-left: 4px solid var(--pink);
  border-radius: 8px;
  background: #111416;
  color: #d5d9dd;
  white-space: pre-wrap;
  line-height: 1.55;
}

.pool-heading {
  align-items: flex-end;
}

.pool-tools {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid #4a5158;
  border-radius: 9px;
  background: #121517;
}

.search-box span {
  color: #89929b;
  font-size: 12px;
}

.search-box input,
.pool-tools select,
.custom-form input {
  min-height: 42px;
  border: 1px solid #4a5158;
  border-radius: 9px;
  background: #111416;
  color: #fff;
}

.search-box input {
  min-width: 210px;
  border: 0;
  outline: 0;
  background: transparent;
}

.pool-tools select {
  padding: 0 12px;
}

.character-pool {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 10px;
  min-height: 160px;
  padding: 12px;
  border: 1px solid #363c42;
  border-radius: 13px;
  background: #111315;
}

.character-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 2px solid #3e454c;
  border-radius: 10px;
  background: #202428;
  cursor: grab;
  transition: transform .15s ease, border-color .15s ease, opacity .15s ease;
  user-select: none;
}

.character-card:hover,
.character-card:focus-visible {
  z-index: 1;
  transform: translateY(-3px);
  border-color: var(--pink);
  outline: 0;
}

.character-card.selected {
  border-color: #fff;
  box-shadow: 0 0 0 3px var(--pink);
}

.character-card.assigned {
  opacity: .62;
}

.character-card.assigned:hover,
.character-card.assigned.selected {
  opacity: 1;
}

.card-image-wrap {
  position: relative;
  height: 146px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.04), transparent),
    #111315;
}

.card-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
}

.character-name {
  display: grid;
  place-items: center;
  min-height: 44px;
  padding: 7px 5px;
  border-top: 1px solid #3e454c;
  color: #f4f5f6;
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
  word-break: keep-all;
}

.assigned-badge {
  position: absolute;
  left: 5px;
  top: 5px;
  max-width: calc(100% - 10px);
  overflow: hidden;
  padding: 4px 6px;
  border-radius: 6px;
  background: rgba(15,17,19,.9);
  color: #ffc2cf;
  font-size: 10px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assigned-badge:empty {
  display: none;
}

.delete-character {
  position: absolute;
  right: 5px;
  top: 5px;
  display: none;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(197, 56, 56, .92);
  cursor: pointer;
  font-size: 19px;
  line-height: 1;
}

.character-card[data-kind="custom"] .delete-character {
  display: block;
}

.pool-drop-zone {
  margin-top: 10px;
  padding: 11px;
  border: 1px dashed #58616a;
  border-radius: 10px;
  color: #8f98a1;
  text-align: center;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}

.pool-drop-zone.drag-over {
  border-color: var(--pink);
  background: rgba(234, 121, 145, .12);
  color: #fff;
}

.empty-state {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  min-height: 135px;
  color: #7f8992;
  text-align: center;
}

.empty-state strong {
  color: #c7cdd3;
}

.custom-form {
  align-items: flex-end;
}

.custom-form label {
  display: grid;
  flex: 1;
  gap: 7px;
  color: #cfd4d9;
  font-size: 13px;
  font-weight: 800;
}

.custom-form input {
  width: 100%;
  padding: 0 12px;
}

.small-note {
  margin: 12px 0 0;
  color: #8e979f;
  font-size: 12px;
}

.danger-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-color: rgba(230, 87, 87, .45);
}

.danger-panel h2 {
  margin-bottom: 5px;
  font-size: 18px;
}

.danger-panel p {
  margin-bottom: 0;
  color: var(--muted);
}

@media (max-width: 900px) {
  .hero,
  .section-heading,
  .danger-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .completion-box {
    align-self: stretch;
  }

  .button-row.compact {
    flex-wrap: wrap;
  }

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

  .custom-form {
    align-items: stretch;
    flex-direction: column;
  }

  .pool-heading {
    align-items: stretch;
  }

  .pool-tools {
    justify-content: stretch;
  }

  .search-box,
  .search-box input,
  .pool-tools select {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 18px, 1440px);
    padding-top: 12px;
  }

  .hero,
  .panel {
    padding: 18px;
    border-radius: 14px;
  }

  .character-pool {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 7px;
    padding: 8px;
  }

  .card-image-wrap {
    height: 125px;
  }
}

/* v1.1.0: 빠른 배치표와 적성 툴팁 */
body.is-dragging,
body.is-dragging * {
  cursor: grabbing !important;
}

.quick-matrix-dock {
  position: fixed;
  top: 50%;
  right: 14px;
  z-index: 120;
  width: 316px;
  padding: 12px;
  border: 1px solid rgba(234, 121, 145, .82);
  border-radius: 14px;
  background: rgba(17, 19, 21, .96);
  box-shadow: 0 20px 55px rgba(0, 0, 0, .5);
  transform: translateY(-50%);
  backdrop-filter: blur(12px);
  transition: opacity .18s ease, transform .18s ease, width .18s ease;
}

.quick-matrix-dock[hidden] {
  display: none;
}

.quick-dock-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.quick-dock-header > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.quick-dock-header strong {
  font-size: 15px;
}

.quick-dock-header span {
  color: var(--pink-strong);
  font-size: 12px;
  font-weight: 900;
}

.quick-dock-header button {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid #525960;
  border-radius: 8px;
  background: #292e33;
  cursor: pointer;
  font-size: 18px;
  font-weight: 900;
}

.quick-matrix {
  display: grid;
  grid-template-columns: 52px repeat(4, 1fr);
  overflow: hidden;
  border: 1px solid #424950;
  border-radius: 9px;
  background: #111315;
}

.quick-corner,
.quick-column-header,
.quick-row-header,
.quick-slot {
  min-width: 0;
  border-right: 1px solid #353b41;
  border-bottom: 1px solid #353b41;
}

.quick-corner,
.quick-column-header {
  display: grid;
  place-items: center;
  min-height: 31px;
  background: #25292d;
  font-size: 10px;
  font-weight: 900;
}

.quick-column-header[data-style="도주"] { color: #ff726d; }
.quick-column-header[data-style="선행"] { color: #f3c55c; }
.quick-column-header[data-style="선입"] { color: #76c8ff; }
.quick-column-header[data-style="추입"] { color: #be8cff; }

.quick-row-header {
  display: grid;
  place-items: center;
  min-height: 49px;
  padding: 2px;
  color: #111;
  font-size: 10px;
  font-weight: 950;
  text-align: center;
}

.quick-row-header[data-distance="단거리"] { background: #ff858d; }
.quick-row-header[data-distance="마일"] { background: #ffbc7b; }
.quick-row-header[data-distance="중거리"] { background: #ffe183; }
.quick-row-header[data-distance="장거리"] { background: #b7ef7a; }
.quick-row-header[data-distance="더트"] { background: #76d5ec; }

.quick-slot {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 49px;
  background: #17191b;
  transition: background .12s ease, box-shadow .12s ease;
}

.quick-slot::after {
  content: "+";
  color: #4d555d;
  font-size: 16px;
  font-weight: 900;
}

.quick-slot.drag-over,
.quick-slot.selected-target {
  background: rgba(234, 121, 145, .2);
  box-shadow: inset 0 0 0 2px var(--pink);
}

.quick-slot-character {
  position: absolute;
  inset: 2px;
  overflow: hidden;
  border: 1px solid var(--pink);
  border-radius: 5px;
  background: #0e1012;
  cursor: grab;
}

.quick-slot-character img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
}

.quick-matrix-dock > p {
  margin: 8px 0 0;
  color: #8f98a1;
  font-size: 10px;
  line-height: 1.4;
  text-align: center;
}

.quick-matrix-dock.collapsed {
  width: 54px;
  padding: 9px;
}

.quick-matrix-dock.collapsed .quick-dock-header {
  margin: 0;
}

.quick-matrix-dock.collapsed .quick-dock-header > div,
.quick-matrix-dock.collapsed .quick-matrix,
.quick-matrix-dock.collapsed > p {
  display: none;
}

.quick-matrix-dock.collapsed .quick-dock-header button {
  width: 34px;
  height: 42px;
}

.aptitude-tooltip {
  position: fixed;
  z-index: 500;
  width: min(360px, calc(100vw - 20px));
  padding: 13px;
  border: 1px solid rgba(234, 121, 145, .88);
  border-radius: 12px;
  background: rgba(15, 17, 19, .98);
  box-shadow: 0 16px 42px rgba(0, 0, 0, .55);
  pointer-events: none;
  color: #f6f7f8;
}

.aptitude-tooltip[hidden] {
  display: none;
}

.aptitude-tooltip h3 {
  margin: 0 0 9px;
  color: #fff;
  font-size: 15px;
}

.aptitude-section + .aptitude-section {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #363c42;
}

.aptitude-section-title {
  display: block;
  margin-bottom: 5px;
  color: #9ea7af;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
}

.aptitude-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.aptitude-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 6px;
  border: 1px solid #40474e;
  border-radius: 7px;
  background: #22262a;
  font-size: 11px;
  white-space: nowrap;
}

.aptitude-rank {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  color: #111;
  font-size: 12px;
  font-weight: 950;
}

.aptitude-rank[data-rank="S"] { background: #ff7a95; }
.aptitude-rank[data-rank="A"] { background: #76e39c; }
.aptitude-rank[data-rank="B"] { background: #75c8ff; }
.aptitude-rank[data-rank="C"] { background: #f4d96d; }
.aptitude-rank[data-rank="D"] { background: #f0aa66; }
.aptitude-rank[data-rank="E"] { background: #c79be8; }
.aptitude-rank[data-rank="F"] { background: #9ca4ad; }
.aptitude-rank[data-rank="G"] { background: #6f767d; color: #fff; }

.aptitude-unavailable {
  margin: 0;
  color: #a7afb7;
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 1180px) {
  .quick-matrix-dock {
    top: auto;
    right: 10px;
    bottom: 10px;
    width: 300px;
    transform: none;
  }
}

@media (max-width: 620px) {
  .quick-matrix-dock {
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
  }

  .quick-matrix-dock.collapsed {
    right: 8px;
    left: auto;
    width: 54px;
  }
}
