* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-page);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  word-break: keep-all;
  overflow-wrap: break-word;
  line-height: 1.6;
  letter-spacing: -0.01em;
}

.num {
  font-variant-numeric: lining-nums tabular-nums;
}

.app-shell {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px) + 20px);
  position: relative;
}

/* Top Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(250, 248, 245, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  flex-shrink: 0;
}

.brand-name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.brand-sub {
  font-size: 11px;
  color: var(--ink-muted);
  display: block;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-pill-btn {
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--ink-primary);
  border-radius: var(--radius-pill);
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.icon-pill-btn:hover {
  border-color: var(--border-strong);
}

/* Flash Ticker Banner */
.flash-banner {
  margin: 14px 16px 10px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #1E2547 0%, #2F45C5 100%);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 8px 20px rgba(47, 69, 197, 0.18);
  cursor: pointer;
}

.flash-banner-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.16);
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  margin-bottom: 5px;
}

.flash-banner-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  margin: 0;
}

.flash-banner-sub {
  font-size: 12px;
  opacity: 0.85;
  margin: 2px 0 0;
}

/* Search & Filters */
.controls-wrap {
  padding: 6px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-row {
  display: flex;
  gap: 8px;
}

.search-input {
  flex: 1;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink-primary);
}

.search-input:focus {
  outline: 2px solid rgba(229, 72, 31, 0.25);
  border-color: var(--accent-hot);
}

.sort-select {
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink-primary);
  font-weight: 600;
}

.chip-scroll {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.chip-scroll::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--ink-secondary);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
}

.chip.active {
  background: var(--bg-ink);
  color: #FFFFFF;
  border-color: var(--bg-ink);
}

.chip.tech-active {
  background: var(--accent-tech);
  color: #FFFFFF;
  border-color: var(--accent-tech);
}

.chip.mall-chip {
  font-size: 12px;
  padding: 5px 10px;
  background: var(--bg-subtle);
  border-color: transparent;
}

.chip.mall-chip.active {
  background: var(--accent-hot-soft);
  color: var(--accent-hot);
  border-color: rgba(229, 72, 31, 0.3);
}

/* Deal Feed */
.feed-list {
  padding: 6px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.deal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.deal-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.deal-card.is-sold-out {
  opacity: 0.65;
}

.deal-card-top {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.deal-thumb {
  width: 88px;
  height: 88px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
}

.deal-main {
  flex: 1;
  min-width: 0;
}

.deal-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 5px;
}

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  line-height: 1.4;
}

.badge-hot {
  background: var(--accent-hot-soft);
  color: var(--accent-hot);
}

.badge-tech {
  background: var(--accent-tech-soft);
  color: var(--accent-tech);
}

.badge-safe {
  background: var(--accent-safe-soft);
  color: var(--accent-safe);
}

.badge-warn {
  background: var(--accent-warn-soft);
  color: var(--accent-warn);
}

.badge-neutral {
  background: var(--bg-subtle);
  color: var(--ink-secondary);
}

.deal-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.02em;
  color: var(--ink-primary);
}

.deal-price-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.deal-discount {
  font-size: 18px;
  font-weight: 800;
  color: var(--accent-hot);
}

.deal-discount.tech {
  color: var(--accent-tech);
}

.deal-price {
  font-size: 19px;
  font-weight: 800;
  color: var(--ink-primary);
  letter-spacing: -0.02em;
}

.deal-list-price {
  font-size: 12px;
  color: var(--ink-muted);
  text-decoration: line-through;
}

.deal-unit-pill {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-safe);
  background: var(--accent-safe-soft);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

.deal-note {
  margin: 0;
  font-size: 13px;
  color: var(--ink-secondary);
  background: var(--bg-page);
  padding: 9px 11px;
  border-radius: 10px;
  line-height: 1.5;
}

.deal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-muted);
}

.comp-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bookmark-btn {
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  border-radius: var(--radius-pill);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
  cursor: pointer;
}

.bookmark-btn.saved {
  background: var(--accent-hot-soft);
  color: var(--accent-hot);
  border-color: rgba(229, 72, 31, 0.35);
}

/* Section Panels (Alerts, Saved, Split Preview) */
.panel {
  margin: 14px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-card);
}

.panel h2 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.panel p.sub {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--ink-secondary);
}

.kw-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}

.kw-chip {
  border: 1px solid var(--border-subtle);
  background: var(--bg-page);
  color: var(--ink-primary);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.kw-chip.subscribed {
  background: var(--accent-hot);
  color: #FFFFFF;
  border-color: var(--accent-hot);
}

.inline-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.primary-btn {
  border: none;
  background: var(--accent-hot);
  color: #FFFFFF;
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}

.primary-btn.tech {
  background: var(--accent-tech);
}

.secondary-btn {
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--ink-primary);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}

/* Modal / Detail Sheet */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(24, 24, 27, 0.52);
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-backdrop[hidden] {
  display: none;
}

.sheet {
  width: 100%;
  max-width: var(--max-width);
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--bg-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 18px 18px calc(24px + env(safe-area-inset-bottom, 0px));
  box-shadow: var(--shadow-sheet);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.sheet-close {
  border: none;
  background: var(--bg-subtle);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
}

.price-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.price-box {
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 10px;
}

.price-box-label {
  font-size: 11px;
  color: var(--ink-muted);
  display: block;
}

.price-box-val {
  font-size: 14px;
  font-weight: 800;
  margin-top: 2px;
  display: block;
}

.sparkline-card {
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px;
  margin: 12px 0;
}

.unit-calc-box {
  background: var(--accent-safe-soft);
  border: 1px solid rgba(21, 122, 75, 0.22);
  border-radius: 12px;
  padding: 12px;
  margin: 12px 0;
}

.tip-box {
  background: var(--accent-warn-soft);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
  color: #78350F;
  margin: 12px 0;
}

.disclosure-box {
  font-size: 11.5px;
  color: var(--ink-muted);
  border-top: 1px dashed var(--border-subtle);
  padding-top: 10px;
  margin-top: 12px;
}

.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.sheet-sub-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Bottom Tabbar */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-width);
  height: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  z-index: 30;
}

.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
}

.tab-btn .tab-ico {
  font-size: 20px;
  line-height: 1;
}

.tab-btn.active {
  color: var(--accent-hot);
  font-weight: 800;
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(var(--tabbar-height) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-ink);
  color: #FFFFFF;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  z-index: 60;
  box-shadow: var(--shadow-sheet);
}

.toast[hidden] {
  display: none;
}

/* Legal & Admin */
.legal-wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.legal-wrap h1 {
  font-size: 24px;
  letter-spacing: -0.03em;
  margin: 14px 0 6px;
}

.legal-meta {
  font-size: 13px;
  color: var(--ink-muted);
  margin-bottom: 24px;
}

.back-link {
  color: var(--accent-hot);
  font-weight: 700;
  text-decoration: none;
  font-size: 14px;
}

.admin-shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 820px) {
  .admin-grid {
    grid-template-columns: 360px 1fr;
    align-items: start;
  }
}

textarea.paste-box {
  width: 100%;
  min-height: 130px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 12px;
  font-family: inherit;
  font-size: 13.5px;
  resize: vertical;
}

.empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--ink-muted);
  font-size: 14px;
}
