:root {
  --paper: #FAF7F0;
  --paper-dark: #F0EAD8;
  --ink: #1C1007;
  --ink-mid: #5C4A32;
  --ink-light: #9C8B73;
  --border: #D8CCBA;
  --seal: #8B1A1A;
  --card-bg: #FFFDF8;
  --shadow: rgba(90, 60, 20, 0.12);
  --frame-gold: #B5A07A;
  --font-serif: 'Noto Serif SC', 'SimSun', serif;
  --font-sans: 'Noto Sans SC', 'PingFang SC', sans-serif;
  --font-english: 'Lora', 'Georgia', serif;
}

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

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
}

/* ── APP SHELL ─────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
}

/* ── HEADER ─────────────────────────────────────── */
.header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  background: var(--paper);
  border-bottom: 1.5px solid var(--border);
  position: relative;
  z-index: 10;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.seal-stamp {
  width: 44px;
  height: 44px;
  background: var(--seal);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -1px;
  flex-shrink: 0;
}

.header-titles h1 {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.2;
  color: var(--ink);
}

.header-titles p {
  font-size: 11px;
  color: var(--ink-light);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  line-height: 1.2;
  margin-top: 2px;
}

.header .section-nav {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 4px;
}


.count-badge {
  font-size: 11px;
  color: var(--ink-light);
  flex-shrink: 0;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* ── FILTER BAR ─────────────────────────────────── */
.filter-bar {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  padding: 10px 24px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: var(--paper-dark);
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }

.filter-btn {
  flex-shrink: 0;
  padding: 5px 14px;
  border: 1.5px solid var(--border);
  background: transparent;
  font-family: var(--font-serif);
  font-size: 12px;
  color: var(--ink-mid);
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.filter-btn:hover { border-color: var(--ink-mid); color: var(--ink); }
.filter-btn.active {
  background: var(--seal);
  color: var(--paper);
  border-color: var(--seal);
}

.filter-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}

/* ── MAIN LAYOUT ────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* ── PALETTE PANEL (LEFT) ───────────────────────── */
.palette-panel {
  flex: 0 0 560px;
  overflow-y: auto;
  border-right: 1.5px solid var(--border);
  background: var(--paper);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.palette-panel::-webkit-scrollbar { width: 4px; }
.palette-panel::-webkit-scrollbar-track { background: transparent; }
.palette-panel::-webkit-scrollbar-thumb { background: var(--border); }

.color-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.color-card {
  position: relative;
  cursor: pointer;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  overflow: hidden;
  transition: background 0.15s;
  outline: none;
  min-height: 84px;
}
.color-card:hover { background: var(--paper-dark); z-index: 2; }
.color-card.selected {
  background: var(--paper-dark);
  z-index: 3;
}

.color-card-info {
  flex: 1;
  padding: 11px 14px 11px 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.color-card-name {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.color-card-name-en {
  font-family: var(--font-english);
  font-size: 10px;
  color: var(--ink-mid);
  margin-top: 2px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.color-card-hex {
  font-family: var(--font-english);
  font-size: 10px;
  color: var(--ink-light);
  margin-top: 4px;
  letter-spacing: 0.04em;
}

.color-card-strip {
  width: 22px;
  flex-shrink: 0;
  align-self: stretch;
}

/* ── DETAIL PANEL (RIGHT) ───────────────────────── */
.detail-panel {
  flex: 1;
  overflow-y: auto;
  background: var(--card-bg);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  position: relative;
}
.detail-panel::-webkit-scrollbar { width: 4px; }
.detail-panel::-webkit-scrollbar-thumb { background: var(--border); }

/* Welcome screen */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px;
  text-align: center;
  color: var(--ink-light);
}
.welcome-seal {
  font-family: var(--font-serif);
  font-size: 72px;
  color: var(--border);
  line-height: 1;
  margin-bottom: 20px;
  user-select: none;
}
.welcome h2 {
  font-family: var(--font-serif);
  font-size: 20px;
  color: var(--ink-mid);
  font-weight: 400;
  margin-bottom: 10px;
}
.welcome p {
  font-size: 13px;
  max-width: 320px;
  line-height: 1.7;
}

/* Detail content */
.detail-content { display: none; }
.detail-content.visible { display: block; }

/* Color block */
.detail-swatch-block {
  width: 100%;
  height: 220px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 24px 28px;
}

.detail-color-name {
  font-family: var(--font-serif);
  font-size: 36px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.2;
  text-shadow: 0 1px 8px rgba(0,0,0,0.2);
}

.detail-color-name-en {
  font-family: var(--font-english);
  font-size: 13px;
  letter-spacing: 0.06em;
  margin-top: 4px;
  opacity: 0.75;
  text-shadow: 0 1px 4px rgba(0,0,0,0.15);
  text-transform: uppercase;
}

.detail-hex-code {
  font-family: 'Courier New', monospace;
  font-size: 14px;
  letter-spacing: 0.15em;
  margin-top: 6px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.15);
  opacity: 0.85;
}

/* Color values section */
.detail-values {
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.value-item {
  padding: 10px 0;
  border-right: 1px solid var(--border);
}
.value-item:last-child { border-right: none; }
.value-item:nth-child(2) { padding-left: 20px; }

.value-label {
  font-size: 10px;
  color: var(--ink-light);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.value-nums {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: var(--ink-mid);
  letter-spacing: 0.08em;
}

/* Artifact section */
.artifact-section {
  padding: 24px 28px;
}

.artifact-section-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.artifact-section-title span:first-child {
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--ink);
  letter-spacing: 0.08em;
}

.artifact-section-title span:last-child {
  font-size: 11px;
  color: var(--ink-light);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.artifact-card {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.artifact-illustration {
  flex: 0 0 120px;
  height: 140px;
  position: relative;
  overflow: hidden;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: var(--paper-dark);
}

.artifact-illustration img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.artifact-info { flex: 1; }

.artifact-name-cn {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.06em;
  line-height: 1.4;
  margin-bottom: 2px;
}

.artifact-name-en {
  font-size: 11px;
  color: var(--ink-light);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.artifact-meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

.artifact-meta-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
}

.artifact-meta-key {
  color: var(--ink-light);
  flex-shrink: 0;
  min-width: 36px;
}

.artifact-meta-val {
  color: var(--ink-mid);
}

.artifact-desc {
  font-size: 13px;
  line-height: 1.85;
  color: var(--ink-mid);
  font-family: var(--font-sans);
  border-left: 2px solid var(--border);
  padding-left: 12px;
}

.artifact-color-note {
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--paper-dark);
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink-mid);
  border-left: 3px solid var(--seal);
}

/* Tags */
.artifact-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.tag {
  padding: 2px 8px;
  border: 1px solid var(--border);
  font-size: 10px;
  color: var(--ink-light);
  letter-spacing: 0.06em;
}

/* ── MOBILE OVERLAY ─────────────────────────────── */
.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(30, 18, 7, 0.5);
  z-index: 100;
  backdrop-filter: blur(2px);
}
.mobile-overlay.open { display: flex; align-items: flex-end; }

.mobile-sheet {
  width: 100%;
  max-height: 85vh;
  background: var(--card-bg);
  overflow-y: auto;
  position: relative;
  border-top: 2px solid var(--border);
}

.mobile-close {
  position: absolute;
  top: 12px;
  right: 16px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper-dark);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 18px;
  color: var(--ink-mid);
  z-index: 1;
  border-radius: 50%;
}

/* ── EMPTY STATE ────────────────────────────────── */
.no-results {
  padding: 60px 20px;
  text-align: center;
  color: var(--ink-light);
  font-family: var(--font-serif);
  font-size: 15px;
}

/* ── RESPONSIVE ─────────────────────────────────── */
@media (max-width: 768px) {
  html, body { overflow: auto; }

  .app { height: auto; max-height: none; overflow: visible; }

  .header { padding: 12px 16px; gap: 10px; flex-wrap: wrap; }
  .header-titles h1 { font-size: 16px; }
  .header .section-nav { margin-left: 0; order: 3; width: 100%; }
  .section-tab { padding: 5px 10px; font-size: 12px; }
  .section-tab-sub { font-size: 9px; }
  .search-wrap { max-width: 200px; margin-left: auto; }
  .count-badge { display: none; }

  .filter-bar { padding: 8px 16px; }

  .main { flex-direction: column; overflow: visible; }

  .palette-panel {
    flex: none;
    height: auto;
    overflow: visible;
    border-right: none;
    border-bottom: 1.5px solid var(--border);
  }

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

  .color-card { min-height: 72px; }
  .color-card-name { font-size: 13px; }

  .detail-panel {
    flex: none;
    overflow: visible;
    height: auto;
    display: none;
  }

  .mobile-overlay.open { display: flex; }
}

@media (max-width: 480px) {
  .color-grid { grid-template-columns: repeat(2, 1fr); }
  .header-titles p { display: none; }
  .search-wrap { max-width: 150px; }
}

@media (min-width: 769px) and (max-width: 1100px) {
  .palette-panel { flex: 0 0 420px; }
  .color-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1200px) {
  .palette-panel { flex: 0 0 640px; }
  .color-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ── SCROLLBAR GLOBAL ───────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }


/* ── SECTION NAVIGATION ─────────────────────────── */
.section-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 4px;
}
.section-tab {
  flex: 0 0 auto;
  padding: 6px 14px;
  border: none;
  background: transparent;
  font-family: var(--font-serif);
  font-size: 13px;
  color: var(--ink-light);
  cursor: pointer;
  letter-spacing: 0.06em;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.section-tab.active { color: var(--seal); border-bottom-color: var(--seal); }
.section-tab:hover:not(.active) { color: var(--ink-mid); }

/* ── MONTHLY VIEW ────────────────────────────────── */
.main.hide { display: none; }
.filter-bar.hide { display: none; }

.monthly-view {
  display: none;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
.monthly-view.visible { display: flex; }

.monthly-month-panel {
  flex: 0 0 210px;
  overflow-y: auto;
  border-right: 1.5px solid var(--border);
  background: var(--paper);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.monthly-month-panel::-webkit-scrollbar { width: 4px; }
.monthly-month-panel::-webkit-scrollbar-thumb { background: var(--border); }

.month-item {
  padding: 13px 18px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.month-item:hover { background: var(--paper-dark); }
.month-item.active { background: var(--paper-dark); }

.month-item-num {
  font-size: 9px;
  color: var(--ink-light);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.month-item-name {
  font-family: var(--font-serif);
  font-size: 15px;
  color: var(--ink);
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.month-item-strip {
  display: flex;
  gap: 2px;
}
.month-item-chip {
  height: 5px;
  flex: 1;
}

.monthly-color-panel {
  flex: 1;
  overflow-y: auto;
  background: var(--paper);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.monthly-color-panel::-webkit-scrollbar { width: 4px; }
.monthly-color-panel::-webkit-scrollbar-thumb { background: var(--border); }

.monthly-color-header {
  padding: 20px 28px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
}
.monthly-color-header-month {
  font-family: var(--font-serif);
  font-size: 22px;
  color: var(--ink);
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.monthly-color-header-sub {
  font-size: 11px;
  color: var(--ink-light);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.monthly-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

@media (max-width: 768px) {
  .monthly-view { flex-direction: column; }
  .monthly-month-panel {
    flex: 0 0 auto;
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: none;
    border-bottom: 1.5px solid var(--border);
    scrollbar-width: none;
  }
  .monthly-month-panel::-webkit-scrollbar { display: none; }
  .month-item {
    flex-shrink: 0;
    border-bottom: none;
    border-right: 1px solid var(--border);
    min-width: 110px;
  }
  .monthly-color-panel { flex: 1; }
  .monthly-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 769px) and (max-width: 1100px) {
  .monthly-month-panel { flex: 0 0 180px; }
  .monthly-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ── COLOR BARS ──────────────────────────────────── */
.color-bars-section { padding: 20px 28px 24px; }
.color-bars-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 28px;
}
.bars-group { padding: 8px 0; }
.bars-group-cmyk {
  border-left: 1px solid var(--border);
  padding-left: 20px;
}
.bars-group-title {
  font-size: 10px;
  color: var(--ink-light);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.bar-label {
  font-size: 10px;
  color: var(--ink-light);
  font-family: 'Courier New', monospace;
  min-width: 12px;
}
.bar-track {
  flex: 1;
  height: 7px;
  background: var(--paper-dark);
  border: 1px solid var(--border);
  overflow: hidden;
}
.bar-fill { height: 100%; transition: width 0.35s ease; }
.bar-r { background: #C05050; }
.bar-g { background: #50A068; }
.bar-b { background: #5070C0; }
.bar-c { background: #00A8C8; }
.bar-m { background: #D03880; }
.bar-y { background: #C8A800; }
.bar-k { background: #5C4A32; }
.bar-value {
  font-size: 10px;
  color: var(--ink-mid);
  font-family: 'Courier New', monospace;
  min-width: 28px;
  text-align: right;
}
