/* deal-edge app styles — components only. Every color/size comes from tokens.css;
   nothing here may hardcode a hex or know about themes.
   Layout: mobile = flat full-bleed list; desktop (≥1024px) = feed panel +
   sidebar (TOP5 ranking, keyword card) on a sunken ground. */

* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--text-primary);
  font: var(--text-body);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.container { max-width: 1120px; margin-inline: auto; padding-inline: 20px; }
.app { min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------------- app bar ---------------- */
.appbar { position: sticky; top: 0; z-index: var(--z-nav);
  background: var(--bg); border-bottom: 1px solid var(--divider);
  padding-top: env(safe-area-inset-top); }
.appbar-inner { display: flex; align-items: center; justify-content: space-between;
  padding-top: 14px; }
.logo { display: flex; align-items: center; gap: 9px;
  font-weight: 800; font-size: 1.25rem; letter-spacing: -0.02em;
  color: var(--text-primary); text-decoration: none; }
.logo-mark { width: 26px; height: 26px; border-radius: 7px; display: block; }
.appbar-actions { display: flex; gap: 8px; }
.iconbtn { width: 36px; height: 36px; border-radius: var(--radius-pill);
  background: var(--surface-sunken); border: none; color: var(--text-secondary);
  font-size: 1rem; cursor: pointer; transition: background var(--duration-fast) var(--ease); }
.iconbtn:hover { background: var(--interactive-tint); }

.tabs { display: flex; gap: 22px; padding-top: 4px; }
.tab { font: 500 0.9375rem/1 var(--font-sans); color: var(--text-tertiary);
  padding: 10px 2px 12px; border: none; background: none; cursor: pointer;
  position: relative; }
.tab[aria-selected="true"] { color: var(--text-primary); font-weight: 800; }
.tab[aria-selected="true"]::after { content: ""; position: absolute;
  left: 0; right: 0; bottom: 0; height: 3px; border-radius: 3px 3px 0 0;
  background: var(--interactive); }

.chips { display: flex; gap: 8px; padding: 10px 0 12px; overflow-x: auto;
  scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; font: 500 0.8125rem/1 var(--font-sans);
  letter-spacing: var(--tracking-label);
  padding: 8px 14px; border-radius: var(--radius-pill); cursor: pointer;
  background: var(--surface-sunken); color: var(--text-secondary);
  border: 1px solid transparent;
  transition: background var(--duration-fast) var(--ease); }
.chip:hover { background: var(--interactive-tint); }
.chip[aria-pressed="true"] { background: var(--interactive);
  color: var(--text-inverse); font-weight: 700; }

/* ---------------- layout ---------------- */
.layout { flex: 1; width: 100%; display: grid; grid-template-columns: minmax(0, 1fr); }
.container.layout { padding-inline: 0; }   /* mobile: feed is full-bleed */
.side { display: none; }

/* ---------------- banner ---------------- */
.banner { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 14px 16px 2px; padding: 13px 16px;
  background: var(--interactive-tint); border-radius: var(--radius-lg); }
.banner b { font-size: 0.875rem; font-weight: 600; display: block; }
.banner span { display: block; font-size: 0.75rem; color: var(--text-secondary);
  margin-top: 2px; }

/* ---------------- feed rows ---------------- */
.feed { list-style: none; margin: 4px 0 0; padding: 0; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 14px 20px; cursor: pointer; border: none; background: transparent;
  transition: background var(--duration-fast) var(--ease);
  font-family: inherit; color: inherit; }
li + li > .row { border-top: 1px solid var(--border-subtle); }
.row:hover { background: var(--surface-sunken); }
.row:hover .row-title { color: var(--interactive); }

.row-rank { flex: none; width: 22px; text-align: center;
  font: 800 1rem/1 var(--font-num); color: var(--text-tertiary);
  font-variant-numeric: tabular-nums; }
.row-rank.is-top { color: var(--price); }

.row-main { flex: 1; min-width: 0; align-self: flex-start; padding-top: 2px; }
.row-thumb { flex: none; width: 68px; height: 68px; border-radius: var(--radius-md);
  object-fit: cover; background: var(--surface-sunken);
  border: 1px solid var(--border-subtle); }
.thumb-ph { display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; opacity: 0.75; }
.thumb-ph-ppomppu    { background: var(--site-ppomppu-bg); }
.thumb-ph-quasarzone { background: var(--site-quasarzone-bg); }
.thumb-ph-ruliweb    { background: var(--site-ruliweb-bg); }
.thumb-ph-arcalive   { background: var(--site-arcalive-bg); }

.row-title { font: 600 1rem/1.4 var(--font-sans); margin: 0 0 6px;
  transition: color var(--duration-fast) var(--ease);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; }
.row-meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  font: 400 0.75rem/1.3 var(--font-sans); color: var(--text-tertiary); }
.row-price-block { flex: none; display: flex; flex-direction: column; gap: 4px;
  align-items: flex-end; text-align: right; align-self: flex-start; padding-top: 4px; }
.price { font: 800 1.0625rem/1.2 var(--font-num); color: var(--text-primary);
  font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.row-votes { font-size: 0.75rem; color: var(--text-tertiary);
  font-variant-numeric: tabular-nums; }
.row-buy { margin-top: 4px; font: 700 0.75rem/1 var(--font-sans);
  padding: 7px 12px; border-radius: var(--radius-pill); text-decoration: none;
  transition: background var(--duration-fast) var(--ease); }
.row-buy.buy-direct { background: var(--interactive); color: var(--text-inverse); }
.row-buy.buy-direct:hover { background: var(--interactive-hover); }
.row-buy.buy-post { background: var(--interactive-tint); color: var(--interactive); }
.row-buy.buy-post:hover { background: var(--border-subtle); }
.row.is-closed .row-title, .row.is-closed .row-meta { color: var(--text-tertiary); }
.row.is-closed .price { color: var(--price-original); text-decoration: line-through; }
.row.is-closed .row-thumb { opacity: 0.55; }

.tag, .badge { display: inline-block; font: 700 0.6875rem/1 var(--font-sans);
  padding: 4px 8px; border-radius: var(--radius-sm);
  letter-spacing: var(--tracking-label); }
.tag-ppomppu    { background: var(--site-ppomppu-bg);    color: var(--site-ppomppu-text); }
.tag-quasarzone { background: var(--site-quasarzone-bg); color: var(--site-quasarzone-text); }
.tag-ruliweb    { background: var(--site-ruliweb-bg);    color: var(--site-ruliweb-text); }
.tag-arcalive   { background: var(--site-arcalive-bg);   color: var(--site-arcalive-text); }
.badge-alltime { background: var(--badge-alltime-bg); color: var(--badge-alltime-text); }
.badge-hot     { background: var(--badge-hot-bg);     color: var(--badge-hot-text); }
.badge-ended   { background: var(--badge-ended-bg);   color: var(--badge-ended-text); }

/* ---------------- buttons / inputs ---------------- */
.btn { font: 700 0.875rem/1 var(--font-sans); border: none; cursor: pointer;
  border-radius: var(--radius-md); padding: 12px 18px;
  transition: background var(--duration-fast) var(--ease); }
.btn-sm { padding: 10px 14px; font-size: 0.8125rem; }
.btn-block { width: 100%; padding: 13px; }
.btn-primary { background: var(--interactive); color: var(--text-inverse); }
.btn-primary:hover { background: var(--interactive-hover); }
.btn-primary:active { background: var(--interactive-pressed); }
.btn-secondary { background: var(--interactive-tint); color: var(--interactive); }
.input { font: 400 0.9375rem/1.4 var(--font-sans); color: var(--text-primary);
  background: var(--surface-sunken); border: 1px solid transparent;
  border-radius: var(--radius-md); padding: 12px 14px; min-width: 0; }
.input:focus { outline: none; border-color: var(--focus-ring);
  background: var(--surface); }
.input::placeholder { color: var(--text-tertiary); }

/* ---------------- states / skeleton ---------------- */
.state { padding: 40px 20px; text-align: center; }
.state-quiet { padding: 24px 20px 40px; }
.state-title { font: 700 1.0625rem/1.4 var(--font-sans); margin: 0 0 6px; }
.state-desc { font-size: 0.875rem; color: var(--text-tertiary); margin: 0 0 16px; }
.state-quiet .state-desc { margin: 0; }

.skeleton-group { padding: 4px 0; }
.sk-row { display: flex; gap: 12px; padding: 14px 20px; }
.sk { border-radius: var(--radius-sm); background: var(--surface-sunken);
  position: relative; overflow: hidden; }
.sk::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent,
    color-mix(in srgb, var(--text-tertiary) 8%, transparent), transparent);
  animation: shimmer 1.4s infinite; }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.sk-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.sk-thumb { width: 68px; height: 68px; border-radius: var(--radius-md); flex: none; }
.sk-title { height: 16px; width: 85%; }
.sk-meta { height: 12px; width: 55%; }
.sk-price { height: 17px; width: 76px; }

#sentinel { height: 1px; }

/* ---------------- sidebar ---------------- */
.side-card { background: var(--surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); padding: 18px; }
.side-card + .side-card { margin-top: 16px; }
.side-title { font: 700 1rem/1.3 var(--font-sans); margin: 0 0 6px; }
.side-desc { font-size: 0.8125rem; color: var(--text-secondary); margin: 0 0 14px; }
.side-kw-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.side-kw-chips:not(:empty) { margin-bottom: 14px; }
.side-kw-chips .chip { cursor: default; }
.side-top-list { list-style: none; margin: 6px 0 0; padding: 0; }
.side-top-item { display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 0; background: none; border: none; cursor: pointer;
  text-align: left; font-family: inherit; color: inherit; }
li + li > .side-top-item { border-top: 1px solid var(--divider); }
.side-top-item:hover .side-top-title { color: var(--interactive); }
.side-top-rank { flex: none; width: 18px; text-align: center;
  font: 800 0.9375rem/1 var(--font-num); color: var(--text-tertiary); }
.side-top-list li:nth-child(-n+3) .side-top-rank { color: var(--price); }
.side-top-title { flex: 1; min-width: 0; font: 500 0.8125rem/1.4 var(--font-sans);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color var(--duration-fast) var(--ease); }
.side-top-price { flex: none; font: 700 0.8125rem/1 var(--font-num);
  color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* ---------------- bottom sheet / modal ---------------- */
.sheet { border: none; padding: 0; margin: 0 auto auto; width: 100%;
  max-width: 640px; background: var(--surface-raised);
  color: var(--text-primary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--elevation-overlay);
  position: fixed; bottom: 0; top: auto;
  max-height: 88dvh; overflow-y: auto; }
/* fallback literal: ::backdrop custom-property inheritance is newer than our
   floor browsers, so keep a sane dim if var() resolves to nothing */
.sheet::backdrop { background: var(--backdrop, rgba(30, 46, 50, 0.45)); }
.sheet[open] { animation: sheet-up var(--duration-slow) var(--ease); }
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
@keyframes sheet-fade { from { opacity: 0; } to { opacity: 1; } }
.sheet-grab { width: 40px; height: 4px; border-radius: 2px;
  background: var(--border); margin: 10px auto 0; }
.sheet-body { padding: 16px 20px calc(24px + env(safe-area-inset-bottom)); }
.sheet-title { font: 700 1.25rem/1.35 var(--font-sans); margin: 4px 0 8px; }
.sheet-desc { font-size: 0.875rem; color: var(--text-secondary); margin: 0 0 18px; }

/* ---- detail sheet ---- */
.detail-meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  font-size: 0.75rem; color: var(--text-tertiary); margin-bottom: 10px; }
.detail-title { font: 700 1.25rem/1.4 var(--font-sans); margin: 0 0 14px;
  text-wrap: balance; }
.detail-cols { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
.detail-thumb { width: 100%; max-height: 260px; object-fit: contain;
  border-radius: var(--radius-lg); background: var(--surface-sunken); }
.detail-thumb.thumb-ph { height: 140px; font-size: 2rem; }
.detail-info { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.price-card { background: var(--surface-sunken); border-radius: var(--radius-lg);
  padding: 16px; }
.price-card .label { font-size: 0.75rem; color: var(--text-tertiary); }
.price-card .value { font: 800 1.625rem/1.2 var(--font-num); color: var(--text-primary);
  font-variant-numeric: tabular-nums; letter-spacing: -0.01em; margin-top: 2px; }
.price-card .sub { font-size: 0.8125rem; color: var(--text-secondary); margin-top: 6px; }
.detail-cta { display: flex; flex-direction: column; gap: 8px; }
.detail-cta .btn { text-align: center; text-decoration: none; display: block;
  padding: 15px; font-size: 0.9375rem; }
.detail-cta .btn-ghost { padding: 12px; font-size: 0.8125rem; }
.btn-ghost { background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-sunken); }
.detail-brief { font-size: 0.9375rem; color: var(--text-secondary);
  background: var(--surface-sunken); border-radius: var(--radius-lg);
  padding: 14px 16px; margin: 0; }
.detail-stats { display: flex; gap: 16px; font-size: 0.8125rem;
  color: var(--text-tertiary); margin-bottom: 16px;
  font-variant-numeric: tabular-nums; }

/* ---- price history chart ---- */
.chart-wrap { margin: 6px 0 4px; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 6px; }
.chart-head h3 { font: 600 0.9375rem/1.4 var(--font-sans); margin: 0; }
.chart-head span { font-size: 0.75rem; color: var(--text-tertiary); }
.chart { width: 100%; height: auto; display: block; touch-action: pan-y; }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis-text { fill: var(--chart-axis-text); font-size: 10px;
  font-family: var(--font-sans); font-variant-numeric: tabular-nums; }
.chart .line { stroke: var(--chart-line); stroke-width: 2; fill: none;
  stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--chart-area); }
.chart .pt { fill: var(--chart-line); }
.chart .pt-low { fill: var(--chart-marker-low); stroke: var(--surface-raised);
  stroke-width: 2; }
.chart .low-label { fill: var(--chart-marker-low); font-size: 11px; font-weight: 700;
  font-family: var(--font-sans); font-variant-numeric: tabular-nums; }
.chart .crosshair { stroke: var(--text-tertiary); stroke-width: 1;
  stroke-dasharray: 3 3; }
.chart-tip { position: absolute; pointer-events: none;
  background: var(--surface-raised); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 9px; font-size: 0.75rem;
  color: var(--text-secondary); box-shadow: var(--elevation-overlay);
  white-space: nowrap; transform: translate(-50%, -110%); }
.chart-tip b { color: var(--price); font-variant-numeric: tabular-nums; }
.chart-holder { position: relative; }
.chart-table { margin-top: 8px; }
.chart-table summary { font-size: 0.8125rem; color: var(--text-tertiary);
  cursor: pointer; }
.chart-table table { width: 100%; border-collapse: collapse; margin-top: 8px;
  font-size: 0.8125rem; }
.chart-table th { text-align: left; color: var(--text-tertiary); font-weight: 500;
  padding: 6px 0; border-bottom: 1px solid var(--divider); }
.chart-table td { padding: 6px 0; border-bottom: 1px solid var(--divider);
  font-variant-numeric: tabular-nums; }
.chart-table td:last-child, .chart-table th:last-child { text-align: right; }

/* ---- keyword sheet ---- */
.field-row { display: flex; gap: 8px; }
.field-row .input { flex: 1; }
.field-row .input-num { flex: 0 0 128px; }
.hint { font-size: 0.75rem; color: var(--text-tertiary); text-align: center;
  margin: 10px 0 0; }
.kw-list { list-style: none; margin: 16px 0 0; padding: 0; }
.kw-item { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 0; }
.kw-item + .kw-item { border-top: 1px solid var(--divider); }
.kw-name { font-weight: 600; }
.kw-cap { font-size: 0.75rem; color: var(--text-tertiary); margin-left: 8px;
  font-variant-numeric: tabular-nums; }
.kw-del { background: none; border: none; color: var(--text-tertiary);
  font-size: 0.8125rem; cursor: pointer; padding: 6px; border-radius: var(--radius-sm); }
.kw-del:hover { color: var(--danger); background: var(--danger-tint); }

/* ---------------- toast ---------------- */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: var(--z-toast);
  background: var(--text-primary); color: var(--bg);
  font: 500 0.875rem/1.3 var(--font-sans);
  padding: 12px 18px; border-radius: var(--radius-md);
  box-shadow: var(--elevation-overlay); max-width: min(90vw, 480px);
  animation: toast-in var(--duration-base) var(--ease); }
@keyframes toast-in { from { transform: translate(-50%, 8px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ---------------- desktop (PC) ---------------- */
@media (min-width: 1024px) {
  body { background: var(--surface-sunken); }
  .appbar { background: var(--bg); }

  .container.layout { padding-inline: 20px; }
  .layout { grid-template-columns: minmax(0, 1fr) 320px; gap: 24px;
    align-items: start; padding-top: 20px; padding-bottom: 48px; }

  .banner { display: none; }        /* sidebar keyword card replaces it */
  .side { display: block; position: sticky;
    top: calc(140px + env(safe-area-inset-top)); }

  .feed-panel { background: var(--surface); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg); overflow: hidden; }
  .feed { margin: 0; }
  .row { padding: 16px 20px; }
  .row:hover { background: var(--surface-sunken); }
  .row-thumb, .sk-thumb { width: 84px; height: 84px; }
  .row-title { font-size: 1.0625rem; }
  .price { font-size: 1.125rem; }

  /* bottom sheet → centered modal, detail goes two-column */
  .sheet { top: 50%; bottom: auto; transform: translateY(-50%);
    border-radius: var(--radius-xl); max-width: 720px; max-height: 84dvh; }
  .sheet[open] { animation: sheet-fade var(--duration-base) var(--ease); }
  .sheet-grab { display: none; }
  .sheet-body { padding: 28px; }
  #alert-sheet .sheet-body { max-width: 560px; margin-inline: auto; }

  .detail-cols { flex-direction: row; gap: 18px; }
  .detail-cols .detail-thumb { width: 260px; height: 260px; flex: none;
    object-fit: cover; max-height: none; }
  .detail-cols .detail-thumb.thumb-ph { height: 260px; }
  .detail-info { flex: 1; }
}
