/* ====================================================
   NORMS Card Platform — style.css
   ธีม: Dark + ส้มแดง NORMS
   ==================================================== */

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* โทนเทา-ดำนุ่ม แบบ Notion / Linear (ไม่ใช่ดำสนิท) */
  --bg:        #1a1a1c;
  --panel:     #212225;
  --panel-2:   #292a2e;
  --border:    #2c2d31;
  --border-soft:#26272a;
  --text:      #e9e9ec;
  --muted:     #9a9ba3;
  --faint:     #6c6d75;
  --orange:    #e8814f;
  --orange-lt: #f3a37c;
  --green:     #4ec77a;
  --red:       #e25555;
  --radius:    10px;
  --radius-sm: 7px;
  --header-h:  60px;
  --nav-h:     56px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
               "Sukhumvit Set", "Thonburi", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.003em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- ไอคอนเส้น (แทน emoji) ---- */
.ic { width: 1.05em; height: 1.05em; display: inline-block; vertical-align: -0.16em;
      stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
      fill: none; flex-shrink: 0; }
.ic-sm { width: 16px; height: 16px; }
.game-tab.active .ic, .mode-btn.active .ic { stroke: #fff; }

/* ====================================================
   HEADER
   ==================================================== */
#app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  z-index: 100;
}

.logo {
  font-size: 17px;
  font-weight: 700;
  color: var(--orange);
  white-space: nowrap;
  flex-shrink: 0;
}

/* แท็บเกม */
.game-tabs {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.game-tab {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.game-tab.active {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
  font-weight: 600;
}
.game-tab:disabled {
  opacity: .4;
  cursor: not-allowed;
}

/* ช่องค้นหา */
.search-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
}
.search-wrap input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 36px 7px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.search-wrap input:focus { border-color: var(--orange); }
.search-wrap input::placeholder { color: var(--muted); }
.search-icon {
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  font-size: 14px;
}

/* ตัวเลือกสกุลเงิน */
.currency-select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  flex-shrink: 0;
}

/* ปุ่ม Settings */
.btn-settings {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
  transition: color .15s, border-color .15s;
}
.btn-settings:hover { color: var(--orange); border-color: var(--orange); }

/* ====================================================
   MAIN CONTENT AREA
   ==================================================== */
#main-content {
  /* desktop: #desktop-nav (มี margin-top เท่า header) ดันเนื้อหาลงให้แล้ว */
  padding-top: 0;
  padding-bottom: calc(var(--nav-h) + 8px);
  min-height: 100vh;
}

/* ====================================================
   BOTTOM NAV (mobile)
   ==================================================== */
/* เมนูล่าง liquid glass — อยู่นิ่ง = เต็มล่าง · เลื่อน = หดเป็นแคปซูลลอย */
#bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  padding: 0;
  background: rgba(28,29,32,.78);
  -webkit-backdrop-filter: saturate(170%) blur(22px);
  backdrop-filter: saturate(170%) blur(22px);
  border-top: 1px solid rgba(255,255,255,.07);
  padding-bottom: env(safe-area-inset-bottom);
  transition: left .32s cubic-bezier(.4,.0,.2,1), right .32s cubic-bezier(.4,.0,.2,1),
              bottom .32s cubic-bezier(.4,.0,.2,1), border-radius .32s cubic-bezier(.4,.0,.2,1),
              box-shadow .32s ease, background .2s ease;
}
.nav-items {
  display: flex;
  height: var(--nav-h);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: color .15s;
  padding: 0;
}
.nav-item .nav-icon { display: inline-flex; }
.nav-item .nav-icon .ic { width: 23px; height: 23px; stroke-width: 1.7; }
.nav-item .nav-label { line-height: 1; }
.nav-item.active { color: var(--orange); }
.nav-item.active .nav-icon .ic { stroke: var(--orange); }
.nav-item:active { transform: scale(.94); }

/* สถานะหด: แคปซูลลอยติดจอ */
#bottom-nav.floating {
  left: 14px; right: 14px; bottom: 14px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 26px;
  box-shadow: 0 10px 34px rgba(0,0,0,.45);
  background: rgba(32,33,37,.62);
}
#bottom-nav.floating .nav-items { height: 50px; }
#bottom-nav.floating .nav-label {
  font-size: 0;
  opacity: 0;
  height: 0;
}
#bottom-nav.floating .nav-item .nav-icon .ic { width: 24px; height: 24px; }

/* Desktop side nav / top tab nav */
#desktop-nav {
  display: flex;
  gap: 4px;
  padding: 12px 16px 0;
  margin-top: var(--header-h); /* header เป็น fixed ลอยทับหน้า — ดันเมนูลงมาให้พ้น */
}
.desktop-nav-item {
  padding: 8px 18px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  background: var(--panel);
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: all .15s;
}
.desktop-nav-item.active {
  background: var(--bg);
  color: var(--orange);
  border-bottom: 1px solid var(--bg);
  margin-bottom: -1px;
}
.desktop-nav-item:hover:not(.active) { color: var(--text); }

/* ====================================================
   PAGE CONTAINER
   ==================================================== */
.page {
  display: none;
  padding: 16px;
}
.page.active { display: block; }

.page-inner {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 16px;
}

/* ====================================================
   SECTION TITLE
   ==================================================== */
.section-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ====================================================
   FILTER BAR
   ==================================================== */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  align-items: flex-end;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.filter-group label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.filter-select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 10px;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  min-width: 160px;
}
.filter-select:focus { border-color: var(--orange); }

/* กลุ่มกรองชิป — ย่อได้ (กันรก) */
.filter-group-chips { width: 100%; }
.filter-group-chips label { display: flex; align-items: center; gap: 8px; }
.chips-toggle {
  border: none; background: none; color: var(--orange-lt);
  font-size: 11px; font-weight: 600; cursor: pointer; padding: 0;
  text-transform: none; letter-spacing: 0;
}
.chips-toggle:hover { text-decoration: underline; }

/* Toggle buttons (rarity / color) — ชิปแถบสีจริง ไม่มี emoji */
.toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.toggle-group.collapsed { max-height: 70px; overflow: hidden; }
.toggle-group.open { max-height: none; }
.toggle-btn {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
  white-space: nowrap;
}
.toggle-btn .sw {
  width: 9px; height: 9px; border-radius: 50%;
  margin-right: 7px; flex: 0 0 auto;
  box-shadow: 0 0 0 1px rgba(0,0,0,.25) inset;
}
.toggle-btn.active {
  border-color: var(--c, var(--orange));
  background: var(--panel-2);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--c, var(--orange));
}
.toggle-btn:hover:not(.active) { border-color: var(--faint); color: var(--text); }

/* ====================================================
   CARD GRID
   ==================================================== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

/* การ์ดแต่ละใบ */
.card-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s;
}
.card-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(242, 126, 83,.18);
  border-color: rgba(242, 126, 83,.4);
}
.card-img-wrap {
  aspect-ratio: 6/8.5;
  background: #111215;
  overflow: hidden;
}
.card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity .3s;
}
.card-img-wrap img[data-loaded="false"] { opacity: 0; }
.card-img-wrap .img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: var(--border);
}
.card-info {
  padding: 8px;
}
.card-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
.card-id {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 5px;
}
.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--orange-lt);
}
.card-price.no-price { color: var(--muted); }

/* ====================================================
   RARITY BADGE
   ==================================================== */
.rarity-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.rarity-SEC { background: rgba(255,215,0,.2);   color: #ffd700; border: 1px solid rgba(255,215,0,.4); }
.rarity-SR  { background: rgba(157,78,221,.2);  color: #c77dff; border: 1px solid rgba(157,78,221,.4); }
.rarity-L   { background: rgba(72,191,227,.2);  color: #48bfe3; border: 1px solid rgba(72,191,227,.4); }
.rarity-R   { background: rgba(76,209,126,.2);  color: #39ff3e; border: 1px solid rgba(76,209,126,.4); }
.rarity-UC  { background: rgba(154,151,144,.15); color: #b0ada8; border: 1px solid rgba(154,151,144,.3); }
.rarity-C   { background: rgba(154,151,144,.1);  color: #c9c9c9; border: 1px solid rgba(154,151,144,.2); }
.rarity-PR  { background: rgba(242, 126, 83,.15);  color: var(--orange-lt); border: 1px solid rgba(242, 126, 83,.3); }
.rarity-TR  { background: rgba(255,93,93,.15);   color: #ff8fa3; border: 1px solid rgba(255,93,93,.3); }
.rarity-SP  { background: rgba(255,215,0,.25);   color: #ffe066; border: 1px solid rgba(255,215,0,.5); }

/* ====================================================
   PAGINATION
   ==================================================== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.page-btn {
  min-width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
  padding: 0 8px;
}
.page-btn:hover:not(:disabled) { border-color: var(--orange); color: var(--orange); }
.page-btn.active { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 700; }
.page-btn:disabled { opacity: .3; cursor: not-allowed; }
.page-info {
  font-size: 13px;
  color: var(--muted);
}

/* ====================================================
   MODAL
   ==================================================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 780px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: modal-in .18s ease;
}
@keyframes modal-in {
  from { transform: scale(.95); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 12px; right: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px; height: 32px;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 1;
  transition: color .15s, border-color .15s;
}
.modal-close:hover { color: var(--text); border-color: var(--text); }

.modal-body {
  display: flex;
  gap: 20px;
  padding: 20px;
}
.modal-img-col {
  flex-shrink: 0;
  width: 220px;
}
.modal-card-img {
  width: 100%;
  border-radius: var(--radius-sm);
  display: block;
}
.modal-info-col {
  flex: 1;
  min-width: 0;
}

.modal-card-name {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 4px;
  line-height: 1.2;
}
.modal-card-id {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.modal-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}
.meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.meta-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}
.meta-value {
  font-size: 13px;
  font-weight: 600;
}

.modal-price-main {
  font-size: 28px;
  font-weight: 800;
  color: var(--orange-lt);
  margin-bottom: 4px;
}
.modal-price-sub {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 14px;
}

.modal-card-text {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}

/* กราฟ canvas */
.price-chart-wrap {
  margin-bottom: 14px;
}
.price-chart-title {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}
#price-chart { border-radius: var(--radius-sm); display: block; }

.modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-primary {
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--orange);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn-primary:hover { background: var(--orange-lt); transform: translateY(-1px); }
.btn-secondary {
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.btn-secondary:hover { border-color: var(--orange); color: var(--orange); }
.btn-ghost {
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

/* ====================================================
   SUMMARY CARDS (Watchlist / Collection)
   ==================================================== */
.summary-cards {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.summary-card {
  flex: 1;
  min-width: 140px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.summary-card-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
}
.summary-card-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--orange-lt);
}
.summary-card-value.profit { color: var(--green); }
.summary-card-value.loss   { color: var(--red); }

/* ====================================================
   TABLE
   ==================================================== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(42,45,54,.6);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover td { background: rgba(242, 126, 83,.06); }
.data-table .thumb {
  width: 36px;
  height: 50px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}

/* ====================================================
   COLLECTION PAGE
   ==================================================== */
.collection-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.qty-control {
  display: flex;
  align-items: center;
  gap: 4px;
}
.qty-btn {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
  transition: border-color .15s;
}
.qty-btn:hover { border-color: var(--orange); color: var(--orange); }
.qty-display {
  min-width: 24px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
}
.cost-input {
  width: 80px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12px;
  padding: 4px 7px;
  outline: none;
}
.cost-input:focus { border-color: var(--orange); }
.profit-cell { font-weight: 700; }
.profit-cell.up   { color: var(--green); }
.profit-cell.down { color: var(--red); }

/* Import/Export modal content */
.io-textarea {
  width: 100%;
  height: 200px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12px;
  padding: 10px;
  resize: vertical;
  font-family: monospace;
  outline: none;
  margin: 10px 0;
}
.io-textarea:focus { border-color: var(--orange); }

/* ====================================================
   COMPARE PAGE
   ==================================================== */
.compare-search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
  flex-wrap: wrap;
}
.compare-search-input {
  flex: 1;
  min-width: 180px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
}
.compare-search-input:focus { border-color: var(--orange); }
.compare-search-results {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 200px;
  overflow-y: auto;
  position: absolute;
  z-index: 50;
  min-width: 280px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.compare-search-wrap { position: relative; flex: 1; }
.search-result-item {
  padding: 9px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: rgba(242, 126, 83,.1); }
.search-result-item .sr-id { font-size: 11px; color: var(--muted); }

.compare-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.compare-col {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.compare-col .compare-col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.compare-col img {
  width: 100%;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}
.compare-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 5px 0;
  border-bottom: 1px solid rgba(42,45,54,.5);
  font-size: 12px;
  gap: 6px;
}
.compare-row:last-child { border-bottom: none; }
.compare-row .cr-label { color: var(--muted); flex-shrink: 0; }
.compare-row .cr-val { text-align: right; font-weight: 500; word-break: break-word; }
.compare-row .cr-val.highlight { color: var(--orange-lt); font-weight: 700; }
.compare-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--muted);
  font-size: 13px;
  gap: 8px;
}
.compare-empty .empty-icon { font-size: 36px; opacity: .4; }

/* ====================================================
   SCAN PAGE
   ==================================================== */
.scan-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  gap: 16px;
}
.scan-icon { font-size: 72px; opacity: .3; }
.scan-title { font-size: 18px; font-weight: 700; color: var(--muted); }
.scan-desc { font-size: 14px; color: var(--muted); opacity: .7; max-width: 320px; }

/* ====================================================
   SETTINGS MODAL
   ==================================================== */
.settings-box { padding: 24px; }
.settings-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.settings-row:last-of-type { border-bottom: none; }
.settings-label {
  font-size: 14px;
  color: var(--text);
}
.settings-sublabel {
  font-size: 12px;
  color: var(--muted);
}
.rate-input {
  width: 100px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 10px;
  font-size: 14px;
  text-align: right;
  outline: none;
}
.rate-input:focus { border-color: var(--orange); }
.settings-save {
  margin-top: 16px;
  width: 100%;
  padding: 10px;
  background: var(--orange);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.settings-save:hover { background: var(--orange-lt); }

/* ====================================================
   FOOTER
   ==================================================== */
#app-footer {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

/* ====================================================
   EMPTY STATE
   ==================================================== */
.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 10px; opacity: .4; }

/* ====================================================
   MODE TOGGLE — สลับ ราคา ↔ วิกิ
   ==================================================== */
.mode-toggle{display:flex;gap:2px;background:var(--bg);border:1px solid var(--border);border-radius:99px;padding:3px;flex-shrink:0}
.mode-btn{padding:5px 13px;border-radius:99px;font-size:13px;font-weight:700;color:var(--muted);white-space:nowrap;text-decoration:none}
.mode-btn.active{background:var(--orange);color:#111}
.mode-btn:hover:not(.active){color:var(--text)}
.modal-wiki-link{margin:6px 0 2px}
.modal-wiki-link a{display:inline-block;background:var(--bg);border:1px solid var(--orange);color:var(--orange-lt);
  font-size:12px;font-weight:700;padding:4px 12px;border-radius:99px;text-decoration:none}
.modal-wiki-link a:hover{background:var(--orange);color:#111}
@media (max-width:768px){ .mode-toggle .mode-btn{padding:5px 9px;font-size:12px} }

/* ====================================================
   TRENDING — แถวการ์ดมาแรง (หน้าแรก)
   ==================================================== */
#trending-section { margin-bottom: 18px; }
.trending-head {
  font-size: 15px;
  font-weight: 700;
  color: var(--orange);
  margin-bottom: 10px;
}
.trending-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
}
.trending-row::-webkit-scrollbar { height: 6px; }
.trending-row::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.trending-card {
  flex: 0 0 120px;
  width: 120px;
  cursor: pointer;
  transition: transform .15s;
}
.trending-card:hover { transform: translateY(-3px); }
.trending-card img {
  width: 100%;
  aspect-ratio: 5 / 7;
  object-fit: cover;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
}
.trending-name {
  font-size: 11px;
  color: var(--muted);
  margin-top: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.trending-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--orange-lt);
}

/* ====================================================
   TOAST — กล่องแจ้งผลการกดปุ่ม
   ==================================================== */
#app-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 18px);
  transform: translateX(-50%) translateY(20px);
  background: var(--panel);
  border: 1px solid var(--orange);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 300;
  max-width: 90vw;
}
#app-toast.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
#app-toast button {
  margin-left: 10px;
  background: var(--orange);
  color: #111;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

/* ====================================================
   RESPONSIVE — Mobile (≤768px)
   ==================================================== */
@media (max-width: 768px) {
  #bottom-nav { display: block; }
  #desktop-nav { display: none; }
  /* mobile: หัว + แถบเกมใต้หัว ดันเนื้อหาลงให้พ้น */
  #main-content { padding-top: calc(var(--header-h) + 49px); }

  #app-header {
    gap: 8px;
    padding: 0 10px;
  }
  .logo { font-size: 15px; }
  .logo .ic { width: 17px; height: 17px; }
  .currency-select { display: none; }   /* เลือกสกุลเงินได้ในป๊อปอัปการ์ดอยู่แล้ว */
  .search-wrap { min-width: 80px; }

  /* แถบเลือกเกม: เลื่อนซ้าย-ขวาได้ ใต้แถบหัว (แก้บัคสลับเกมไม่ได้บนมือถือ) */
  .game-tabs {
    display: flex;
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: rgba(26,26,28,.92);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-soft);
    padding: 8px 10px;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .game-tabs::-webkit-scrollbar { display: none; }
  .game-tab { flex: 0 0 auto; }

  .card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .modal-body {
    flex-direction: column;
    padding: 16px;
  }
  .modal-img-col { width: 160px; align-self: center; }

  .compare-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .filter-bar { gap: 8px; }
  .filter-select { min-width: 120px; }

  .data-table th:nth-child(4),
  .data-table td:nth-child(4) { display: none; }
}

@media (max-width: 480px) {
  .compare-grid { grid-template-columns: 1fr 1fr; }
  .modal-meta-grid { grid-template-columns: 1fr 1fr; }
  .summary-cards { flex-direction: column; }
}

/* ====================================================
   MODAL — หัวราคา + ปุ่มสลับสกุลเงิน + ตารางเทียบตลาด
   ==================================================== */
.modal-price-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.modal-curr-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 3px;
  flex-shrink: 0;
}
.modal-curr-toggle button {
  width: 34px;
  height: 30px;
  border: none;
  border-radius: 99px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.modal-curr-toggle button:hover { color: var(--text); }
.modal-curr-toggle button.active {
  background: var(--orange);
  color: #111;
}
#market-table-wrap { margin-bottom: 14px; }
.mkt-region {
  font-size: 10px;
  color: var(--muted);
  margin-left: 4px;
}
.mkt-note {
  font-size: 10px;
  color: var(--muted);
}
.jp-table tr.mkt-grade td {
  background: rgba(242, 126, 83, .08);
}
.jp-table tr.mkt-grade .jp-td-price { color: var(--orange); }

/* ====================================================
   JP PRICES — ราคาญี่ปุ่น Yuyu-tei (modal)
   ==================================================== */
#jp-prices-wrap {
  margin-bottom: 14px;
}
.jp-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: 6px;
}
.jp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.jp-table th {
  text-align: left;
  padding: 5px 8px;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.jp-table td {
  padding: 5px 8px;
  border-bottom: 1px solid rgba(42,45,54,.4);
  vertical-align: middle;
}
.jp-table tr:last-child td { border-bottom: none; }
.jp-td-name  { color: var(--text); }
.jp-td-rarity { color: var(--muted); white-space: nowrap; }
.jp-td-price {
  text-align: right;
  font-weight: 700;
  color: var(--orange-lt);
  white-space: nowrap;
}
.jp-price-jpy {
  font-size: 10px;
  color: var(--muted);
  font-weight: 400;
  margin-left: 4px;
}

/* ====================================================
   SCROLLBAR ทำให้ดูดีขึ้นหน่อย
   ==================================================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ====================================================
   NOTION REFINEMENTS — เลย์เอาต์สะอาด เส้นบาง ไอคอนนั่งกลาง
   ==================================================== */
.logo, .mode-btn, .desktop-nav-item, .game-tab, .section-title,
.btn-settings { display: inline-flex; align-items: center; gap: 7px; }
.logo .ic { width: 19px; height: 19px; stroke-width: 1.9; }

/* แถบหัว/เมนู: นุ่มขึ้น โปร่งขึ้น */
#app-header { background: rgba(26,26,28,.82); backdrop-filter: saturate(140%) blur(12px);
              border-bottom: 1px solid var(--border-soft); gap: 14px; }
.logo { font-weight: 650; letter-spacing: -0.01em; color: var(--text);
        cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; }
.logo:hover { color: var(--orange-lt); }
.logo:active { transform: scale(.96); }
.logo .ic { stroke: var(--orange); }

/* ปุ่มสลับโหมด: แบบ segmented เนียนๆ */
.mode-toggle { background: var(--panel); border-color: var(--border-soft); }
.mode-btn { font-weight: 550; }
.mode-btn.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.mode-btn.active .ic { stroke: var(--orange); }

/* แท็บเกม: pill เรียบ active เป็นพื้นนุ่ม ไม่ใช่ส้มจัด */
.game-tab { font-weight: 500; border-color: var(--border); }
.game-tab.active { background: var(--panel-2); border-color: var(--border);
                   color: var(--text); font-weight: 600; }
.game-tab.active .ic { stroke: var(--orange); }

/* เมนู desktop: เส้นบางลง active เด่นด้วย accent บางๆ */
.desktop-nav-item { border-color: var(--border-soft); font-weight: 500; }
.desktop-nav-item.active { color: var(--text); box-shadow: inset 0 2px 0 var(--orange); }
.desktop-nav-item.active .ic { stroke: var(--orange); }

/* การ์ด: hover นุ่มแบบ Notion ไม่เรืองแสง */
.page-inner { background: var(--panel); border-color: var(--border-soft); }
.card-item { background: var(--panel); border-color: var(--border-soft);
             transition: transform .16s ease, border-color .16s ease, background .16s ease; }
.card-item:hover { transform: translateY(-2px); box-shadow: none;
                   border-color: var(--border); background: var(--panel-2); }
.btn-settings:hover { color: var(--orange); border-color: var(--border); background: var(--panel-2); }

/* ฟิลเตอร์/ปุ่ม: โฟกัสเส้นบางนุ่ม */
.search-wrap input:focus { border-color: var(--faint); }
