*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3250;
  --text: #e8eaf0;
  --text-muted: #7b8099;
  --accent: #e8b84b;
  --accent-dim: #c49a2a;
  --radius: 8px;
  --font: 'Segoe UI', 'Apple SD Gothic Neo', sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.site-title {
  color: var(--accent);
  font-weight: 700;
  font-size: 16px;
  text-decoration: none;
  letter-spacing: 0.02em;
}

.site-nav { display: flex; gap: 20px; }

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* ── News ─────────────────────────────── */
.news-container {
  max-width: 720px;
  margin: 0 auto;
}

.news-heading {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 28px;
  color: var(--accent);
}

.post-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
}

.post-card:hover { border-color: var(--accent); }

.post-card-link {
  display: block;
  padding: 20px 24px;
  text-decoration: none;
  color: inherit;
}

.post-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.post-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.post-preview {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

.no-posts {
  color: var(--text-muted);
  font-size: 14px;
}

.back-link {
  display: inline-block;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  margin-bottom: 24px;
  transition: color 0.15s;
}

.back-link:hover { color: var(--accent); }

.post-header { margin-bottom: 28px; }

.post-header .post-title { font-size: 26px; margin-top: 8px; }

.post-content {
  line-height: 1.8;
  font-size: 15px;
  color: var(--text);
}

.post-content h2 { font-size: 18px; margin: 28px 0 12px; color: var(--accent); }
.post-content h3 { font-size: 15px; margin: 20px 0 8px; }
.post-content p  { margin-bottom: 16px; }
.post-content ul, .post-content ol { margin: 0 0 16px 20px; }
.post-content li { margin-bottom: 6px; }
.post-content a  { color: var(--accent); }
.post-content strong { color: var(--text); }
.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 13px;
}
.post-content th, .post-content td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
}
.post-content th { background: var(--surface2); color: var(--accent); }
.post-content code {
  background: var(--surface2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

main { padding: 24px; max-width: 1400px; margin: 0 auto; }

/* Toolbar */
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar select,
.toolbar input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s;
}

.toolbar select { min-width: 280px; cursor: pointer; }
.toolbar input  { flex: 1; min-width: 200px; }

.toolbar select:focus,
.toolbar input:focus { border-color: var(--accent); }

.result-count {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 16px;
}

/* Card Grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.card-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
}

.card-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.card-img-wrap {
  aspect-ratio: 3/4;
  background: var(--surface2);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-info {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  min-height: 20px;
}

.card-number { font-size: 11px; color: var(--text-muted); }
.card-name   { font-size: 13px; font-weight: 600; line-height: 1.3; margin-top: 2px; }
.card-price  { font-size: 13px; font-weight: 600; color: var(--accent); margin-top: 4px; }
.card-price:empty { display: none; }

/* Rarity badges */
.card-rarity {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.04em;
  background: var(--surface2);
  color: var(--text-muted);
  align-self: center;
  width: fit-content;
}

.rarity-L   { background: #e53935; color: #fff; }
.rarity-SEC { background: #ff6b35; color: #fff; }
.rarity-SP  { background: linear-gradient(120deg, #ffe066, #fff8c0, #ffd700); color: #111; }
.rarity-P   { background: #fd79a8; color: #fff; }
.rarity-SR  { background: #9b59b6; color: #fff; }
.rarity-R   { background: #2980b9; color: #fff; }
.rarity-UC  { background: #27ae60; color: #fff; }
.rarity-C   { background: #e8eaf0; color: #1a1d27; }

/* Card Detail */
.card-detail { max-width: 960px; }

.back-link {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  margin-bottom: 20px;
  font-size: 13px;
}
.back-link:hover { text-decoration: underline; }

.detail-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 32px;
  align-items: flex-start;
}

@media (max-width: 640px) {
  .detail-layout { grid-template-columns: 1fr; }

  /* Toolbar: 2x2 grid on mobile */
  .toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .toolbar select { min-width: 0; }
  .toolbar input  { grid-column: 1 / -1; min-width: 0; }

  /* Card grid: always 2 columns on small screens */
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.detail-img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: block;
}

.detail-img-placeholder {
  aspect-ratio: 3/4;
  background: var(--surface2);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.detail-name   { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.detail-number { color: var(--text-muted); font-size: 14px; margin-bottom: 20px; }

.detail-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

.detail-table th,
.detail-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.detail-table th {
  width: 110px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.detail-effect {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 24px;
}

.detail-effect h3,
.detail-prices h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.detail-effect p { line-height: 1.7; font-size: 14px; }

.detail-prices { margin-top: 8px; }

/* Price summary stats */
.price-summary {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.price-stat {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  flex: 1;
  min-width: 120px;
}

.price-stat-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.price-stat-value {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
}

/* Price entry form */
.price-form {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.price-form-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.price-form-row {
  display: flex;
  align-items: center;
  gap: 0;
  max-width: 280px;
}

.price-input-prefix {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  padding: 8px 10px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
}

.price-form-row input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-right: none;
  color: var(--text);
  font-size: 14px;
  padding: 8px 10px;
  outline: none;
  border-radius: 0;
  -moz-appearance: textfield;
}

.price-form-row input:focus { border-color: var(--accent); }
.price-form-row input::-webkit-outer-spin-button,
.price-form-row input::-webkit-inner-spin-button { -webkit-appearance: none; }

.price-form-row button {
  background: var(--accent);
  color: #111;
  border: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.price-form-row button:hover { background: var(--accent-dim); }

.price-url-input {
  display: block;
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  padding: 8px 10px;
  margin-top: 10px;
  outline: none;
  transition: border-color 0.15s;
}

.price-url-input:focus { border-color: var(--accent); }

.price-url-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 5px;
}

.price-success {
  font-size: 13px;
  color: #27ae60;
  margin: 10px 0 0;
}

.price-error {
  font-size: 13px;
  color: #e53935;
  margin: 10px 0 0;
}

.source-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
}

.source-link:hover { text-decoration: underline; }

.price-table {
  width: 100%;
  border-collapse: collapse;
}

.price-table th,
.price-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.price-table th { color: var(--text-muted); font-weight: 500; }

.no-price {
  color: var(--text-muted);
  font-style: italic;
  padding: 12px 0;
}

/* Empty state */
.empty-state {
  grid-column: 1/-1;
  text-align: center;
  padding: 60px 0;
  color: var(--text-muted);
}

/* ── Admin ─────────────────────────────── */
.admin-login-wrap {
  max-width: 360px;
  margin: 80px auto;
}

.admin-wrap {
  max-width: 1000px;
  margin: 0 auto;
}

.admin-heading {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 24px;
}

.admin-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.admin-header-row .admin-heading { margin-bottom: 0; }

.admin-logout {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
}

.admin-logout:hover { color: var(--text); }

.admin-login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
}

.admin-input:focus { border-color: var(--accent); }

.admin-btn {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  padding: 10px;
  cursor: pointer;
}

.admin-btn:hover { background: var(--accent-dim); }

.admin-error {
  color: #e53935;
  font-size: 13px;
  margin-bottom: 12px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--surface2);
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.admin-table tr:hover td { background: var(--surface); }

.admin-card-link {
  color: var(--accent);
  text-decoration: none;
}

.admin-card-link:hover { text-decoration: underline; }

.admin-delete-btn {
  background: transparent;
  border: 1px solid #e53935;
  color: #e53935;
  border-radius: 4px;
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
}

.admin-delete-btn:hover { background: #e53935; color: #fff; }

.admin-import-form { display: flex; flex-direction: column; gap: 12px; max-width: 400px; }
.import-results { margin-top: 24px; }
.import-success { color: #27ae60; font-size: 15px; font-weight: 600; }
.import-skip-list { margin: 8px 0 0 16px; font-size: 12px; color: var(--text-muted); }
.import-skip-list li { margin-bottom: 4px; }
