:root {
  color-scheme: light;
  --paper: #f6f3eb;
  --surface: #fffdf8;
  --ink: #1b3329;
  --muted: #475a4d;
  --line: #d8ddd0;
  --green: #254438;
  --serif: Georgia, "Noto Serif KR", Batang, serif;
  --sans: system-ui, "Malgun Gothic", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(ellipse at 5% 1%, #e5eadc, transparent 35rem) var(--paper);
  color: var(--ink);
  font: 1rem/1.6 var(--sans);
}

a { color: inherit; }
button, input, select { font: inherit; }
button, summary, select { cursor: pointer; }
:focus-visible { outline: 2px solid #526c54; outline-offset: 3px; }
[hidden] { display: none !important; }

.shell {
  width: min(100% - 3.5rem, 73rem);
  margin-inline: auto;
}

main.shell { padding-bottom: 2.25rem; }

.site-bar {
  background: var(--green);
  color: #f9f6ee;
}

.site-bar-inner {
  min-height: 3.6rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .35rem 1.1rem;
}

.brand {
  font-weight: 750;
  text-decoration: none;
}

.site-bar nav { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; }
.site-bar nav a { font-size: .9rem; text-decoration: none; }
.site-bar nav a:hover, .site-bar [aria-current] { text-decoration: underline; text-underline-offset: .28em; }
.site-bar :focus-visible { outline-color: #f9f6ee; }

.hero { margin: clamp(1.65rem, 4.5vw, 3.8rem) 0 clamp(1.6rem, 3.4vw, 2.6rem); }
.hero h1 {
  margin: 0;
  font: 500 clamp(2.35rem, 6vw, 4.25rem)/1.12 var(--serif);
  letter-spacing: -.055em;
}
.hero p { margin: .75rem 0 0; color: var(--muted); word-break: keep-all; }

.catalog-layout {
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr);
  align-items: start;
  gap: clamp(1.25rem, 4vw, 3rem);
}

.index {
  position: sticky;
  top: 1.25rem;
  max-height: calc(100dvh - 2.5rem);
  overflow: auto;
  padding: .85rem;
  background: #eef0e7;
  border: 1px solid var(--line);
  border-radius: .9rem;
}
.index-toggle { display: none; }

.index-group { margin-top: 1.2rem; }
.index-label {
  margin: 0 .45rem .35rem;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 750;
}
.index-buttons { display: grid; gap: .125rem; }
.set-button {
  width: 100%;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem;
  min-height: 2.6rem;
  padding: .4rem .6rem;
  border: 1px solid transparent;
  border-radius: .45rem;
  background: transparent;
  color: var(--ink);
  font-size: .9rem;
  font-weight: 650;
  line-height: 1.35;
  text-align: left;
  word-break: keep-all;
}
.set-button:hover { background: #fffdf8; }
.set-button[aria-pressed="true"] { background: var(--green); color: #fffdf8; }
.set-count { font-size: .8rem; font-variant-numeric: tabular-nums; font-weight: 550; }
#set-index > .set-button + .set-button { margin-top: .3rem; }

.filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(10rem, .48fr);
  grid-template-areas: "search-label edition-label" "search edition";
  gap: .4rem .85rem;
  padding: 1rem 1.1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .9rem;
}
.filters label { font-size: .875rem; font-weight: 700; }
.filters label[for="card-search"] { grid-area: search-label; }
.filters label[for="edition-filter"] { grid-area: edition-label; }
.filters input, .filters select {
  width: 100%;
  min-width: 0;
  min-height: 2.75rem;
  padding: .46rem .65rem;
  border: 1px solid #aebaaa;
  border-radius: .42rem;
  color: var(--ink);
  background: #fff;
}
.filters input { grid-area: search; }
.filters select {
  grid-area: edition;
  appearance: none;
  padding-right: 2rem;
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) right 1.02rem center / .33rem .33rem no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) right .7rem center / .33rem .33rem no-repeat,
    #fff;
}

.results-bar {
  min-height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.results-bar p { color: var(--muted); font-size: .9rem; font-weight: 650; }
.results-bar button {
  min-height: 2.25rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: .25rem .1rem;
  font-size: .875rem;
  text-decoration: underline;
  text-underline-offset: .2em;
}

.category + .category { margin-top: clamp(2rem, 6vw, 4rem); }
.category + .editable-cards { margin-top: clamp(2.5rem, 7vw, 5rem); }
.editable-cards > h2 {
  margin: 0;
  font: 600 clamp(1.8rem, 4vw, 2.4rem)/1.3 var(--serif);
}
.editable-intro { margin: .4rem 0 1.45rem; color: var(--muted); }
.category-heading {
  margin: 0 0 .8rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid #9daa99;
  font: 600 clamp(1.45rem, 3vw, 1.85rem)/1.4 var(--serif);
}
.set-area + .set-area { margin-top: 2rem; }
.set-area {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: .9rem;
  background: var(--surface);
}
.set-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .2rem .8rem;
  padding: .8rem 1.15rem;
  background: #e9eee3;
}
.set-header :is(h3, h4) { margin: 0; font-size: 1.2rem; line-height: 1.4; }
.edition-label { color: var(--muted); font-size: .82rem; }
.card-subsection :is(h4, h5) {
  margin: 0;
  padding: .55rem 1.15rem;
  border-top: 1px solid var(--line);
  background: #f6f6ef;
  color: #3d5347;
  font-size: .875rem;
}

.catalog-card { border-top: 1px solid var(--line); }
.card-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  padding: .62rem 1.15rem;
  list-style: none;
}
.card-summary::-webkit-details-marker { display: none; }
.card-summary:hover, .catalog-card[open] .card-summary { background: #f4f6ee; }
.card-summary:focus-visible { outline-offset: -3px; }
.card-title { min-width: 0; display: grid; gap: .02rem; }
.card-title strong { line-height: 1.42; overflow-wrap: anywhere; }
.card-traits { color: var(--muted); font-size: .82rem; }
.card-preview { display: flex; flex: 0 0 auto; align-items: center; gap: .75rem; }
.cost {
  white-space: nowrap;
  padding: .13rem .46rem;
  border-radius: .35rem;
  background: #e9eee4;
  color: #244837;
  font-size: .8rem;
  font-weight: 750;
}
.cost[data-aspect="체력"] { background: #f6e8e4; color: #7b3028; }
.cost[data-aspect="집중력"] { background: #e8eaf6; color: #344078; }
.cost[data-aspect="정신력"] { background: #f6ebd6; color: #73480b; }
.caret {
  width: .47rem;
  height: .47rem;
  margin-inline: .15rem .12rem;
  border: solid var(--muted);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg) translateY(-2px);
}
.catalog-card[open] .caret { transform: rotate(225deg) translate(-1px, -1px); }

.card-body {
  padding: .95rem 1.15rem 1.2rem;
  border-top: 1px solid var(--line);
}
.card-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(9.2rem, 100%), 1fr));
  gap: .7rem 1.05rem;
  padding: .85rem;
  margin: 0;
  background: #f4f4ed;
  border-radius: .45rem;
}
.card-fact dt { font-size: .82rem; color: var(--muted); }
.card-fact dd { margin: .12rem 0 0; font-size: .92rem; font-weight: 650; overflow-wrap: anywhere; }
.ability-heading { margin: .95rem 0 .22rem; font-size: .95rem; font-weight: 750; }
.abilities { margin: 0; padding-left: 1.2em; }
.abilities li + li { margin-top: .28em; }
.ability-empty { margin: 0; color: var(--muted); }
.edit-card-button,
.editor-actions button {
  min-height: 2.5rem;
  padding: .35rem .75rem;
  border: 1px solid #aebaaa;
  border-radius: .42rem;
  background: var(--surface);
  color: var(--ink);
  font-weight: 650;
}
.edit-card-button { margin-top: 1rem; }
.edit-card-button:hover, .editor-actions button:hover { border-color: var(--green); }
.edit-status {
  margin: 0 0 .9rem;
  padding: .5rem .75rem;
  border-left: .2rem solid var(--green);
  background: #e9eee3;
}
.card-editor {
  width: min(100% - 1.5rem, 40rem);
  max-height: calc(100dvh - 1.5rem);
  padding: clamp(.9rem, 3vw, 1.5rem);
  border: 1px solid var(--line);
  border-radius: .9rem;
  background: var(--surface);
  color: var(--ink);
}
.card-editor::backdrop { background: #152b20a8; }
.card-editor h2 { margin: 0; font-size: 1.45rem; }
#editor-description { margin: .3rem 0 1rem; color: var(--muted); font-size: .9rem; }
.editor-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .8rem 1rem;
}
.editor-fields label, .editor-fields legend { font-size: .9rem; font-weight: 650; }
.editor-fields > label { display: flex; flex-direction: column; gap: .24rem; }
.editor-wide { grid-column: 1 / -1; }
.editor-fields :is(input, textarea, select) {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 2.55rem;
  margin-top: .26rem;
  padding: .38rem .55rem;
  border: 1px solid #aebaaa;
  border-radius: .42rem;
  background: #fff;
  color: inherit;
  font: 1rem/1.5 var(--sans);
}
.editor-fields > label > :is(input, textarea, select) { margin-top: auto; }
.editor-fields textarea { resize: vertical; }
.editor-icons {
  min-width: 0;
  margin: 0;
  padding: .45rem .75rem .7rem;
  border: 1px solid var(--line);
  border-radius: .42rem;
}
.editor-icons > div { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .55rem; }
.field-hint { color: var(--muted); font-size: .8rem; font-weight: 400; }
.editor-error { margin: .75rem 0 0; color: #8a2a24; }
.editor-actions {
  position: sticky;
  z-index: 1;
  bottom: 0;
  display: flex;
  justify-content: end;
  gap: .5rem;
  margin-top: 1rem;
  padding-top: .65rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.editor-actions .editor-save { border-color: var(--green); background: var(--green); color: #fff; }
.empty-state {
  margin: 0;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .9rem;
  color: var(--muted);
}

@media (max-width: 48rem) {
  .shell { width: min(100% - 2rem, 73rem); }
  .catalog-layout { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .index { position: static; max-height: none; padding: .65rem; }
  .index-toggle {
    display: list-item;
    padding: .2rem .45rem;
    font-size: .9rem;
    font-weight: 700;
  }
  #active-set { float: right; color: var(--muted); font-weight: 550; }
  #set-index { margin-top: .55rem; }
  .index-buttons { grid-template-columns: repeat(auto-fit, minmax(7.2rem, 1fr)); gap: .25rem; }
  .index-group { margin-top: .65rem; }
  .set-button { min-height: 2.45rem; padding: .3rem .45rem; }
}

@media (max-width: 26rem) {
  .site-bar-inner { padding-block: .5rem; }
  .filters { grid-template-columns: minmax(0, 1fr); grid-template-areas: "search-label" "search" "edition-label" "edition"; }
  .filters label[for="edition-filter"] { margin-top: .25rem; }
  .card-summary, .set-header, .card-body { padding-inline: .78rem; }
  .card-subsection :is(h4, h5) { padding-inline: .78rem; }
  .card-preview { gap: .4rem; }
  .editor-fields { gap: .6rem; }
}
