:root {
  --bg: #0f1115;
  --bg-elev: #181b22;
  --bg-card: #1d2129;
  --border: #2a2f3a;
  --text: #e8eaed;
  --text-dim: #9aa0ad;
  --accent: #d4af37; /* FAB 골드 느낌 */
  --red: #d8453b;
  --yellow: #e0b53d;
  --blue: #3d7fe0;
  --radius: 12px;
  --maxw: 1100px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic",
    system-ui, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px;
}

/* 헤더 */
.site-header {
  background: linear-gradient(135deg, #1a1d24 0%, #12141a 100%);
  border-bottom: 1px solid var(--border);
  padding: 28px 0 22px;
}
.site-header h1 {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
}
.site-header h1::before {
  content: "⚔️ ";
}
.tagline {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 0.95rem;
}

/* 싱글 주문 홍보 바 */
.promo {
  background: rgba(212, 175, 55, 0.1);
  border-bottom: 1px solid rgba(212, 175, 55, 0.25);
  padding: 9px 0;
  font-size: 0.9rem;
  color: var(--text);
  text-align: center;
}
.promo a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.promo a:hover {
  text-decoration: underline;
}

/* 검색 */
.search-bar {
  margin: 24px 0 14px;
}
#search {
  width: 100%;
  padding: 15px 18px;
  font-size: 1.05rem;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}
#search::placeholder {
  color: var(--text-dim);
}

/* 이미지 로딩 토글 */
.img-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
.img-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.img-toggle .switch {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.img-toggle .switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform 0.15s, background 0.15s;
}
.img-toggle input:checked + .switch {
  background: var(--accent);
  border-color: var(--accent);
}
.img-toggle input:checked + .switch::before {
  transform: translateX(16px);
  background: #111;
}
.img-toggle input:focus-visible + .switch {
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

.status {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin: 4px 0 16px;
}

/* 결과 그리드 */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  padding-bottom: 40px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
  display: flex;
  flex-direction: column;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.card-img {
  width: 100%;
  aspect-ratio: 450 / 628;
  object-fit: cover;
  background: #0a0c10;
  display: block;
}
.card-img.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  text-align: center;
  padding: 8px;
}
.placeholder-btn {
  flex-direction: column;
  gap: 4px;
  border: 1px dashed var(--border);
  background: #0a0c10;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}
.placeholder-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}
.placeholder-btn .reveal-hint {
  font-size: 0.72rem;
  color: var(--accent);
}
.card-info {
  padding: 9px 10px 11px;
}
.card-name {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.3;
}
.card-name-en {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 2px;
}
.card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  font-size: 0.72rem;
  color: var(--text-dim);
}
.pip {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pip-red {
  background: var(--red);
}
.pip-yellow {
  background: var(--yellow);
}
.pip-blue {
  background: var(--blue);
}
.badge-ko {
  margin-left: auto;
  font-size: 0.66rem;
  color: var(--accent);
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 4px;
  padding: 1px 5px;
}

.more {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* 토큰(아이콘) 인라인 표시 */
.tok {
  display: inline-block;
  font-size: 0.78em;
  font-weight: 600;
  padding: 0 5px;
  border-radius: 4px;
  background: #2a2f3a;
  color: var(--text);
  white-space: nowrap;
}
.tok-icon {
  display: inline-block;
  width: 1.15em;
  height: 1.15em;
  vertical-align: -0.22em;
  margin: 0 1px;
}

/* 모달 */
.modal[hidden] {
  display: none;
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(3px);
}
.modal-panel {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 760px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  z-index: 1;
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
}
.modal-close:hover {
  border-color: var(--accent);
}

.detail {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
}
.detail-img {
  width: 100%;
  border-radius: 10px;
  background: #0a0c10;
  aspect-ratio: 450 / 628;
  object-fit: contain;
}
.detail h2 {
  margin: 0 0 2px;
  font-size: 1.5rem;
}
.detail .en {
  color: var(--text-dim);
  margin: 0 0 14px;
}
.detail .type {
  color: var(--accent);
  font-size: 0.95rem;
  margin: 0 0 14px;
}
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}
.stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 11px;
  font-size: 0.85rem;
}
.stat b {
  color: var(--text-dim);
  font-weight: 500;
  margin-right: 5px;
}
.text-block {
  margin: 14px 0;
}
.text-block h4 {
  margin: 0 0 6px;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.text-block .body {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  white-space: pre-wrap;
  font-size: 0.95rem;
}
.text-ko .body {
  border-color: rgba(212, 175, 55, 0.35);
}
.text-en .body {
  color: var(--text-dim);
  font-size: 0.9rem;
}
.untranslated {
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.9rem;
}
.contributors {
  margin: 6px 0 0;
  font-size: 0.82rem;
  color: var(--accent);
}

/* 키워드 용어집 */
.keywords {
  margin-top: 16px;
}
.kw {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 9px 12px;
  margin-bottom: 8px;
  font-size: 0.88rem;
}
.kw b {
  color: var(--accent);
}

/* 번역 제안 버튼/폼 */
.contribute-btn {
  margin-top: 18px;
  width: 100%;
  padding: 10px 14px;
  background: rgba(212, 175, 55, 0.12);
  color: var(--accent);
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}
.contribute-btn:hover {
  background: rgba(212, 175, 55, 0.22);
}

.contribute {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
}
.contribute label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.contribute label .opt {
  color: var(--text-dim);
  font-weight: 400;
}
.contribute input,
.contribute textarea {
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
}
.contribute input:focus,
.contribute textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.contribute-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.btn-primary,
.btn-secondary {
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
}
.btn-primary {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
}
.btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
}
.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
}
.contribute-msg {
  margin: 0;
  font-size: 0.88rem;
  min-height: 1.2em;
}
.contribute-msg.ok {
  color: #7ddc8f;
}
.contribute-msg.err {
  color: #ff8a7a;
}
.contribute-msg a {
  color: var(--accent);
}
.contribute-note {
  margin: 12px 0 0;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.id-line {
  margin-top: 18px;
  font-size: 0.72rem;
  color: var(--text-dim);
  font-family: ui-monospace, monospace;
  word-break: break-all;
}

/* 헤더 우측 링크(용어집 ↔ 검색 이동) */
.header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.header-link,
.back-link {
  flex-shrink: 0;
  color: var(--text-dim);
  font-size: 0.85rem;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  white-space: nowrap;
  transition: border-color 0.12s, color 0.12s;
}
.header-link:hover,
.back-link:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* 키워드 용어집 관리 화면 */
.kw-toolbar {
  display: flex;
  gap: 10px;
  margin: 24px 0 14px;
  flex-wrap: wrap;
}
.kw-toolbar #kw-search {
  flex: 1;
  min-width: 200px;
  padding: 12px 14px;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.kw-toolbar #kw-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

.kw-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 40px;
}
.kw-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.kw-row-main {
  min-width: 0;
  flex: 1;
}
.kw-row-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.kw-row-key {
  color: var(--accent);
  font-size: 0.98rem;
}
.kw-row-ko {
  color: var(--text-dim);
  font-size: 0.88rem;
}
.kw-row-desc {
  margin: 6px 0 0;
  font-size: 0.88rem;
  line-height: 1.5;
}
.kw-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-radius: 999px;
  padding: 3px 9px 3px 8px;
  border: 1px solid;
}
.kw-status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.kw-status-badge.ok {
  color: #7ddc8f;
  background: rgba(125, 220, 143, 0.14);
  border-color: rgba(125, 220, 143, 0.4);
}
.kw-status-badge.ok::before {
  background: #7ddc8f;
}
.kw-status-badge.partial {
  color: var(--yellow);
  background: rgba(224, 181, 61, 0.14);
  border-color: rgba(224, 181, 61, 0.45);
}
.kw-status-badge.partial::before {
  background: var(--yellow);
}
.kw-status-badge.missing {
  color: #ff8a7a;
  background: rgba(255, 138, 122, 0.14);
  border-color: rgba(255, 138, 122, 0.4);
}
.kw-status-badge.missing::before {
  background: #ff8a7a;
}

/* 상태별 카드 좌측 테두리(목록 스캔용) */
.kw-row.status-ok {
  border-left-color: #7ddc8f;
}
.kw-row.status-partial {
  border-left-color: var(--yellow);
}
.kw-row.status-missing {
  border-left-color: #ff8a7a;
}
.kw-edit-btn {
  flex-shrink: 0;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0 40px;
  margin-top: 20px;
}
.site-footer p {
  color: var(--text-dim);
  font-size: 0.82rem;
  margin: 4px 0;
}
.site-footer a {
  color: var(--accent);
}
.disclaimer {
  font-size: 0.75rem;
}

@media (max-width: 560px) {
  .detail {
    grid-template-columns: 1fr;
  }
  .detail-img {
    max-width: 220px;
    margin: 0 auto;
  }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }
}
