/* Ramen Journal */

@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url('fonts/fraunces-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---- Tokens ---- */

:root {
  color-scheme: light;
  --bg: #faf6f1;
  --surface: #ffffff;
  --surface-2: #f4eee7;
  --surface-3: #ebe3d9;
  --border: #e8dfd4;
  --border-strong: #d6cabd;
  --text: #221a16;
  --text-2: #5d524b;
  --text-3: #716560;
  --border-input: #9d8f82;
  --accent: #c8402a;
  --accent-hover: #ae3420;
  --accent-soft: #fbe9e4;
  --accent-text: #a9331f;
  --on-accent: #ffffff;
  --gold: #c38a12;
  --gold-soft: #fbf1dc;
  --grade-a: #2e7d4f;
  --grade-b: #5c7f1f;
  --grade-c: #a87406;
  --grade-d: #c2551b;
  --grade-f: #b3261e;
  --scrim: rgba(28, 20, 16, 0.45);
  --header-bg: rgba(250, 246, 241, 0.86);
  --shadow-sm: 0 1px 2px rgba(34, 26, 22, 0.05), 0 1px 3px rgba(34, 26, 22, 0.05);
  --shadow-md: 0 6px 20px rgba(34, 26, 22, 0.08), 0 2px 6px rgba(34, 26, 22, 0.05);
  --shadow-lg: 0 24px 60px rgba(34, 26, 22, 0.22);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235d524b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");

  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --header-h: 60px;
  --tabbar-h: 64px;
  --content-w: 1120px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #16110f;
  --surface: #211a17;
  --surface-2: #2b2320;
  --surface-3: #372d29;
  --border: #352c27;
  --border-strong: #4b403a;
  --text: #f5eee8;
  --text-2: #c6bab0;
  --text-3: #a3978d;
  --border-input: #75665e;
  --accent: #ea6550;
  --accent-hover: #f27b67;
  --accent-soft: rgba(234, 101, 80, 0.16);
  --accent-text: #f39280;
  --on-accent: #1d110d;
  --gold: #eab145;
  --gold-soft: rgba(234, 177, 69, 0.15);
  --grade-a: #61c58f;
  --grade-b: #a9cb5e;
  --grade-c: #e6b444;
  --grade-d: #ef8d52;
  --grade-f: #f2735f;
  --scrim: rgba(0, 0, 0, 0.6);
  --header-bg: rgba(22, 17, 15, 0.84);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.55);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c6bab0' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #16110f;
    --surface: #211a17;
    --surface-2: #2b2320;
    --surface-3: #372d29;
    --border: #352c27;
    --border-strong: #4b403a;
    --text: #f5eee8;
    --text-2: #c6bab0;
    --text-3: #a3978d;
    --border-input: #75665e;
    --accent: #ea6550;
    --accent-hover: #f27b67;
    --accent-soft: rgba(234, 101, 80, 0.16);
    --accent-text: #f39280;
    --on-accent: #1d110d;
    --gold: #eab145;
    --gold-soft: rgba(234, 177, 69, 0.15);
    --grade-a: #61c58f;
    --grade-b: #a9cb5e;
    --grade-c: #e6b444;
    --grade-d: #ef8d52;
    --grade-f: #f2735f;
    --scrim: rgba(0, 0, 0, 0.6);
    --header-bg: rgba(22, 17, 15, 0.84);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.55);
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c6bab0' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  }
}

/* ---- Base ---- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 12px);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p { margin: 0; }

.card-title, .sheet-title, .compare-card .card-name, .merge-item-name, .merge-confirm-label, .done-rank {
  overflow-wrap: anywhere;
}

.page-title, .section-title, .sheet-title, .empty-state h2 { text-wrap: balance; }

.nw { white-space: nowrap; }

body.modal-open { overflow: hidden; }

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hidden { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 300;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
}
.skip-link:focus { top: 12px; }

/* ---- Header & navigation ---- */

#app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--content-w);
  height: 100%;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  min-width: 0;
  margin-right: auto;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 34px;
  height: 34px;
  flex: none;
  color: var(--accent);
}

.brand-text { display: flex; flex-direction: column; min-width: 0; }

.brand-name {
  white-space: nowrap;
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 1.25rem;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.brand-credit {
  font-size: 0.75rem;
  color: var(--text-3);
  white-space: nowrap;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-2);
  transition: background-color 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .icon { width: 22px; height: 22px; }
.icon-btn-sm { width: 32px; height: 32px; }
.icon-btn-sm .icon { width: 18px; height: 18px; }

#tab-nav {
  display: flex;
  gap: 4px;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-2);
  font-weight: 600;
  font-size: 0.9375rem;
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s;
}
.tab-btn:hover { color: var(--text); background: var(--surface-2); }
.tab-btn.active { color: var(--accent-text); background: var(--accent-soft); }
.tab-btn .tab-label { max-width: 16ch; overflow: hidden; text-overflow: ellipsis; }

/* ---- Layout ---- */

#app-main {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.view { display: none; }
.view.active { display: block; animation: fade-in 0.2s var(--ease); }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.page-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-bottom: 16px;
}

.page-head-split { justify-content: space-between; align-items: center; }

.page-title {
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 1.875rem;
  line-height: 1.15;
  letter-spacing: -0.015em;
}

.page-count { color: var(--text-3); font-size: 0.9375rem; }

.page-head-hero { display: block; margin: 8px 0 20px; }
.page-head-hero .page-title { font-size: 2.125rem; }
.page-lede { margin-top: 6px; max-width: 38rem; color: var(--text-2); font-size: 1.0625rem; }

.section-head .link-btn { white-space: nowrap; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 32px 0 12px;
}

.section-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1.25;
}

.app-footer {
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 0.8125rem;
  text-align: center;
}

/* ---- Search & filters ---- */

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 52px;
  padding: 0 6px 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-icon { color: var(--text-3); }

.search-box input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 6px;
  border: 0;
  background: transparent;
  font-size: 1rem;
  outline: none;
}
.search-box input::placeholder { color: var(--text-3); }
.search-box input::-webkit-search-cancel-button { display: none; }

.search-clear, .barcode-scan-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-3);
}
.search-clear:hover, .barcode-scan-btn:hover { background: var(--surface-2); color: var(--text); }
.barcode-scan-btn { color: var(--text-2); }

.search-box-compact { height: 46px; margin: 14px 0 10px; box-shadow: none; }

.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px -16px 0;
  padding: 2px 16px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }

.pill-select, .pill-btn, .pill-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  flex: none;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  transition: border-color 0.15s, background-color 0.15s;
}

.pill-select {
  field-sizing: content;
  max-width: 12rem;
  padding-right: 34px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface) var(--chevron) no-repeat right 10px center / 16px;
  text-overflow: ellipsis;
  cursor: pointer;
}
.pill-select:hover, .pill-btn:hover, .pill-toggle:hover { border-color: var(--text-3); }
.pill-select.is-active {
  border-color: var(--accent);
  background-color: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}

.pill-btn .icon { width: 16px; height: 16px; }
.btn-clear-filters { order: -1; border-color: transparent; background: transparent; color: var(--accent-text); font-weight: 600; }
.btn-clear-filters:hover { background: var(--accent-soft); border-color: transparent; }
.btn-reorder { margin-left: auto; }
.btn-reorder-active { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }

.pill-toggle { cursor: pointer; user-select: none; }
.pill-toggle input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.pill-toggle:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }

/* ---- Cards ---- */

.card-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 16px;
}

.ramen-card {
  position: relative;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) auto;
  min-height: 112px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), border-color 0.18s;
}
.ramen-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.ramen-card:active { transform: translateY(0); }
.ramen-card:focus-visible { outline-offset: 3px; }

.card-photo {
  position: relative;
  background: var(--surface-2);
  overflow: hidden;
}
.card-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-3);
}
.photo-placeholder .icon { width: 44%; height: 44%; stroke-width: 1.5; opacity: 0.6; }

.card-rank {
  position: absolute;
  top: 6px;
  left: 6px;
  min-width: 28px;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: rgba(20, 14, 12, 0.78);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.card-trophy {
  position: absolute;
  left: 6px;
  bottom: 6px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px 2px 5px;
  border-radius: var(--radius-pill);
  background: rgba(20, 14, 12, 0.78);
  color: #f5c35c;
  font-size: 0.75rem;
  font-weight: 700;
}
.card-trophy .icon { width: 14px; height: 14px; stroke-width: 2; }

.card-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  padding: 12px 8px 12px 14px;
}

.card-title {
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-sub {
  color: var(--text-2);
  font-size: 0.875rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.card-tiers {
  margin-top: 6px;
  color: var(--text-3);
  font-size: 0.8125rem;
  line-height: 1.35;
}
.card-tiers b { color: var(--text-2); font-weight: 600; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.tag .icon { width: 13px; height: 13px; stroke-width: 2.2; }
.tag-accent { background: var(--accent-soft); color: var(--accent-text); }
.tag-gold { background: var(--gold-soft); color: var(--gold); }

.rater-score {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.rater-score .icon { width: 15px; height: 15px; fill: var(--gold); stroke: var(--gold); stroke-width: 1.2; }

.card-grade {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 0 14px 0 4px;
  text-align: center;
}

.grade-letter {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.75rem;
  line-height: 1;
  letter-spacing: -0.02em;
}

.grade-caption {
  margin-top: 4px;
  color: var(--text-3);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.grade-a { color: var(--grade-a); }
.grade-b { color: var(--grade-b); }
.grade-c { color: var(--grade-c); }
.grade-d { color: var(--grade-d); }
.grade-f { color: var(--grade-f); }

/* Compact cards */
body[data-card-size='compact'] .card-list { gap: 8px; }
body[data-card-size='compact'] .ramen-card { grid-template-columns: 76px minmax(0, 1fr) auto; min-height: 76px; border-radius: var(--radius); }
body[data-card-size='compact'] .card-body { padding: 8px 6px 8px 12px; }
body[data-card-size='compact'] .card-title { font-size: 0.9375rem; -webkit-line-clamp: 1; }
body[data-card-size='compact'] .card-meta { margin-top: 3px; }
body[data-card-size='compact'] .card-tiers { display: none; }
body[data-card-size='compact'] .card-trophy { left: 4px; bottom: 4px; padding: 1px 5px 1px 3px; }
body[data-card-size='compact'] .card-rank { top: 4px; left: 4px; }
body[data-card-size='compact'] .grade-letter { font-size: 1.375rem; }

/* Want to Try: remove button on the card */
.wishlist-card-wrap { position: relative; }
.wishlist-card-wrap .card-body { padding-right: 52px; }
.wishlist-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-3);
  opacity: 0.9;
}
.wishlist-remove:hover { color: var(--accent-text); border-color: var(--accent); }
.wishlist-remove .icon { width: 18px; height: 18px; }

/* Reordering */
.drag-handle {
  display: grid;
  place-items: center;
  width: 36px;
  color: var(--text-3);
  cursor: grab;
  touch-action: none;
}
.drag-handle .icon { width: 22px; height: 22px; }
.ramen-card.reorderable { grid-template-columns: 36px 76px minmax(0, 1fr) auto auto; min-height: 88px; cursor: default; }
.ramen-card.reorderable .card-tiers { display: none; }
.reorder-moves { display: flex; flex-direction: column; justify-content: center; gap: 2px; padding-right: 8px; }
.reorder-moves .icon-btn { width: 40px; height: 40px; }
.reorder-moves .icon-btn:disabled { opacity: 0.3; cursor: default; background: transparent; }
.reorder-moves .move-down .icon { transform: rotate(180deg); }
.ramen-card.reorderable:hover { transform: none; }
.sortable-ghost { opacity: 0.35; }
.sortable-chosen { box-shadow: var(--shadow-lg); }

/* ---- Rate tab ---- */

.rate-welcome .quick-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
@media (pointer: fine) { .rate-welcome .quick-actions { display: none; } }

.add-custom-link {
  margin-top: 20px;
  color: var(--text-3);
  font-size: 0.9375rem;
  text-align: center;
}
.add-custom-link a { font-weight: 600; }

/* ---- Empty & loading states ---- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 26rem;
  margin: 40px auto;
  text-align: center;
}
.empty-state h2 {
  margin-top: 12px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.375rem;
}
.empty-state p { margin-top: 6px; color: var(--text-2); }
.empty-state .btn { margin-top: 20px; }

.empty-art {
  width: 84px;
  height: 84px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.85;
}

.loading-indicator, .no-results {
  margin: 32px 0;
  color: var(--text-3);
  text-align: center;
}
.loading-indicator .btn { margin-top: 12px; }

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

.btn-danger { background: transparent; border-color: var(--grade-f); color: var(--grade-f); }
.btn-danger:hover { background: var(--grade-f); color: #fff; }

.btn-sm { min-height: 40px; padding: 0 14px; font-size: 0.875rem; border-radius: var(--radius-sm); }
.btn-block { width: 100%; }
.btn-icon { width: 46px; padding: 0; flex: none; }

.btn-float {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  z-index: 40;
  transform: translateX(-50%);
  box-shadow: var(--shadow-lg);
}
.btn-float:active { transform: translateX(-50%) scale(0.98); }

.link-btn {
  min-height: 32px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font-weight: 600;
  font-size: inherit;
}
.link-btn:hover { text-decoration: underline; text-underline-offset: 2px; }
.link-danger { color: var(--grade-f); }

.button-row { display: flex; gap: 10px; margin-top: 16px; }
.button-row .btn { flex: 1; }
.button-row-wrap { flex-wrap: wrap; }
.button-row-wrap .btn { flex: 1 1 auto; }

/* ---- Dialogs: bottom sheets on phones, centered on larger screens ---- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--scrim);
  animation: fade 0.2s ease;
}

.modal-content {
  position: relative;
  width: 100%;
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: sheet-up 0.28s var(--ease);
}

@keyframes fade { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
}

.sheet-title {
  padding-right: 40px;
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 1.5rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.sheet-meta { margin-top: 6px; color: var(--text-2); }
.sheet-facts { margin-top: 2px; color: var(--text-3); font-size: 0.875rem; }
.sheet-facts:empty { display: none; }

.sheet-actions {
  position: sticky;
  bottom: calc(-24px - env(safe-area-inset-bottom));
  z-index: 1;
  margin: 22px -20px 0;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}

/* Rating sheet */
.rating-header { display: grid; gap: 18px; }

.rating-header-image {
  position: relative;
  aspect-ratio: 4 / 3;
  max-height: 280px;
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
  cursor: zoom-in;
}
.rating-header-image img { width: 100%; height: 100%; object-fit: contain; }
.rating-header-image.add-photo { cursor: pointer; }
.rating-header-image .photo-placeholder { gap: 6px; font-size: 0.875rem; font-weight: 600; }

.rating-change-photo-btn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: var(--radius-pill);
  background: rgba(20, 14, 12, 0.72);
  color: #fff;
}

.rating-details { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.detail-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.8125rem;
  font-weight: 600;
}
.detail-chip .icon { width: 15px; height: 15px; }
.detail-chip .rater-score { font-size: inherit; }
.detail-grade { background: var(--surface-2); }
.detail-user-grade { background: var(--accent-soft); color: var(--accent-text); }
.detail-user-grade b { font-family: var(--font-display); font-size: 1rem; color: inherit; }

.topten-list {
  display: grid;
  gap: 6px;
  width: 100%;
  margin: 2px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--gold-soft);
  list-style: none;
}
.topten-list li { display: flex; gap: 8px; align-items: baseline; font-size: 0.8125rem; color: var(--text-2); }
.topten-list .icon { width: 15px; height: 15px; color: var(--gold); flex: none; transform: translateY(2px); }
.topten-list b { color: var(--text); }
.topten-more { color: var(--text-3); }

.rating-also { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; }
.rating-also-label { color: var(--text-3); font-size: 0.8125rem; font-weight: 600; }
.rating-also-btn {
  min-height: 36px;
  padding: 4px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 600;
}
.rating-also-btn:hover { border-color: var(--accent); color: var(--accent-text); }

.rating-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-top: 16px;
}

.rater-link { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; font-weight: 600; }
.rater-link .icon { width: 16px; height: 16px; }
.rating-credit { display: flex; flex-wrap: wrap; column-gap: 18px; }
.affiliate-note { margin-top: 6px; color: var(--text-3); font-size: 0.75rem; }

.wishlist-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
}
.wishlist-btn .icon { width: 17px; height: 17px; }
.wishlist-btn:hover { border-color: var(--accent); }
.wishlist-btn.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.wishlist-btn.active .icon { fill: currentColor; }

.rating-form {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.rating-section + .rating-section { margin-top: 18px; }

.rating-label {
  margin-bottom: 8px;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tier-selector {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.tier-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 56px;
  padding: 6px 2px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.8125rem;
  font-weight: 600;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}
.tier-btn .tier-num {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 650;
  color: var(--text);
  line-height: 1.1;
}
.tier-btn:hover { border-color: var(--text-3); }
.tier-btn:active { transform: scale(0.97); }
.tier-btn.selected { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.tier-btn.selected .tier-num { color: inherit; }



.rating-actions-secondary {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 22px;
  margin-top: 8px;
  font-size: 0.875rem;
}
.rating-actions-secondary .link-btn { min-height: 40px; }
.rating-actions-secondary:not(:has(.link-btn:not(.hidden))) { display: none; }

/* Comparisons */
.compare-title { padding-right: 40px; }

.compare-progress { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.compare-counter { color: var(--text-3); font-size: 0.875rem; font-weight: 600; }
.compare-dots { display: flex; gap: 5px; }
.compare-dot { width: 20px; height: 4px; border-radius: 2px; background: var(--surface-3); }
.compare-dot.done { background: var(--accent); opacity: 0.45; }
.compare-dot.current { background: var(--accent); }

.compare-cards {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: 10px;
  margin-top: 20px;
}

.compare-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 10px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s var(--ease), box-shadow 0.15s;
}
.compare-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.compare-card.winner { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.02); }
.compare-card.loser { opacity: 0.45; transform: scale(0.97); }

.compare-card .card-img {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
}
.compare-card .card-img img { width: 100%; height: 100%; object-fit: cover; }
.compare-card .card-name { margin-top: 10px; font-weight: 650; line-height: 1.3; }
.compare-card .card-brand-small { margin-top: 2px; color: var(--text-2); font-size: 0.875rem; }
.compare-card .card-tiers { white-space: normal; text-align: center; }

.compare-vs {
  align-self: center;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-3);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.9375rem;
}

.compare-hint { margin-top: 14px; color: var(--text-3); font-size: 0.875rem; text-align: center; }
.compare-hint .link-btn { margin-left: 6px; }

/* Done */
.done-card { display: flex; flex-direction: column; align-items: center; padding: 8px 0 0; text-align: center; }
.done-image {
  position: relative;
  width: 112px;
  height: 112px;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.done-image img { width: 100%; height: 100%; object-fit: cover; }
.done-kicker {
  margin-top: 18px;
  color: var(--text-3);
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.done-rank {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.75rem;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.done-score { margin-top: 4px; color: var(--text-2); }
.done-note { max-width: 22rem; margin: 6px 0 22px; color: var(--text-3); font-size: 0.875rem; }

/* Matching a custom entry */
.merge-results {
  display: grid;
  gap: 6px;
  max-height: 46vh;
  overflow-y: auto;
  margin-bottom: 12px;
}
.merge-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
.merge-item:hover { border-color: var(--accent); }
.merge-item-img {
  position: relative;
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
}
.merge-item-img img { width: 100%; height: 100%; object-fit: cover; }
.merge-item-info { display: flex; flex-direction: column; min-width: 0; }
.merge-item-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.merge-item-meta { color: var(--text-3); font-size: 0.8125rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.merge-confirm-images {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 20px 0 8px;
}
.merge-confirm-card { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 120px; text-align: center; }
.merge-confirm-img {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
}
.merge-confirm-img img { width: 100%; height: 100%; object-fit: cover; }
.merge-confirm-label { font-size: 0.8125rem; font-weight: 600; line-height: 1.3; }
.merge-confirm-arrow { color: var(--text-3); }

.notice {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 0.875rem;
}
.notice-warn { background: var(--gold-soft); color: var(--text); }

/* ---- Forms ---- */

.custom-form { display: grid; gap: 14px; margin-top: 18px; }

.form-label {
  display: grid;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-2);
}
.optional { color: var(--text-3); font-weight: 500; }

.form-input {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-weight: 400;
}
.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select.form-input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background: var(--surface) var(--chevron) no-repeat right 12px center / 16px;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.barcode-input-row { display: flex; gap: 8px; }

.photo-pick {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 10px 12px;
  border: 1.5px dashed var(--border-input);
  border-radius: var(--radius);
  color: var(--text-2);
  font-weight: 600;
  cursor: pointer;
}
.photo-pick:hover, #custom-image:focus-visible + .photo-pick, .photo-pick:focus-within { border-color: var(--accent); color: var(--accent-text); }
.photo-pick-label { display: inline-flex; align-items: center; gap: 8px; }
.image-preview:empty { display: none; }
.image-preview img { width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius-sm); }
.image-preview:not(:empty) + .photo-pick-label span::after { content: ' (change)'; font-weight: 500; color: var(--text-3); }

.form-error { color: var(--grade-f); font-size: 0.875rem; font-weight: 600; }
.form-error:empty { display: none; }

/* ---- Settings ---- */

.settings-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
#settings-heading + .settings-section { margin-top: 16px; border-top: 0; padding-top: 0; }

.settings-heading {
  margin-bottom: 12px;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.settings-note { color: var(--text-2); margin-bottom: 14px; }
.settings-hint { margin-top: 10px; color: var(--text-3); font-size: 0.8125rem; }
.settings-status { margin-top: 8px; font-size: 0.875rem; font-weight: 600; color: var(--text-2); }
.settings-status:empty { display: none; }
.settings-section > .btn { width: 100%; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
}
.setting-row + .setting-row { border-top: 1px solid var(--border); }
.setting-row small { display: block; color: var(--text-3); font-size: 0.8125rem; }
.setting-switch { cursor: pointer; }

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius);
  background: var(--surface-2);
}
.segmented button {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-2);
  font-size: 0.875rem;
  font-weight: 600;
}
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 46px;
  height: 28px;
  flex: none;
  margin: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--border-input);
  cursor: pointer;
  transition: background-color 0.2s;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s var(--ease);
}
.switch:checked { background: var(--accent); box-shadow: none; }
.switch:checked::after { transform: translateX(18px); }

.paste-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  margin-top: 12px;
  padding: 10px 14px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-3);
  font-size: 0.875rem;
  text-align: center;
  caret-color: transparent;
  outline: none;
}
.paste-zone:focus { border-color: var(--accent); color: var(--text-2); }

.settings-credit { margin-top: 28px; color: var(--text-3); font-size: 0.8125rem; text-align: center; }

/* Share */
.share-step { margin-top: 4px; }
.share-step .form-label { margin: 16px 0; }
.share-url-box { display: flex; gap: 8px; margin-top: 16px; }
.share-url-input { flex: 1; font-size: 0.875rem; color: var(--text-2); }
.share-copy-status { min-height: 20px; margin-top: 8px; font-size: 0.875rem; font-weight: 600; color: var(--grade-a); }

/* ---- Toasts ---- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(560px, calc(100% - 24px));
  padding: 10px 8px 10px 16px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  transform: translateX(-50%);
  animation: toast-in 0.3s var(--ease);
}
.toast p { flex: 1; }
.toast .link-btn { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.toast .icon-btn { color: inherit; opacity: 0.7; }
.toast .icon-btn:hover { background: rgba(127, 127, 127, 0.2); opacity: 1; }
.toast code { font-size: 0.8125rem; }
.toast-accent { background: var(--accent); color: var(--on-accent); }

@keyframes toast-in { from { transform: translate(-50%, 16px); opacity: 0; } }

/* ---- Photo viewer & add photo ---- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 8, 7, 0.92);
  cursor: zoom-out;
  animation: fade 0.2s ease;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--radius); }

.photo-popup { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; padding: 16px; }
.photo-popup-backdrop { position: absolute; inset: 0; background: var(--scrim); }
.photo-popup-content {
  position: relative;
  width: min(360px, 100%);
  padding: 22px 20px 20px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.photo-popup-title { margin-bottom: 14px; font-family: var(--font-display); font-weight: 650; font-size: 1.25rem; }
.photo-popup-close { position: absolute; top: 10px; right: 10px; }

/* ---- Barcode scanner ---- */

#barcode-reader {
  position: relative;
  margin-top: 16px;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-lg);
  background: #000;
  overflow: hidden;
}
#barcode-video { width: 100%; height: 100%; object-fit: cover; }
#barcode-reader::after {
  content: '';
  position: absolute;
  inset: 22% 10%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: var(--radius);
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.35);
}
#barcode-scan-line {
  position: absolute;
  left: 12%;
  right: 12%;
  top: 50%;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
  animation: scan 2s ease-in-out infinite;
}
@keyframes scan {
  0%, 100% { transform: translateY(-40px); }
  50% { transform: translateY(40px); }
}

.barcode-status { margin-top: 14px; color: var(--text-2); font-size: 0.9375rem; text-align: center; }
.barcode-not-found { text-align: left; color: var(--text); }
.barcode-error { color: var(--grade-f); }
.barcode-code {
  display: inline-block;
  margin: 4px 0;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  user-select: all;
}
.barcode-hint { margin: 6px 0 12px; color: var(--text-3); font-size: 0.875rem; }
.barcode-actions { display: grid; gap: 8px; }

/* ---- Back to top ---- */

.scroll-top-btn {
  position: fixed;
  right: 16px;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  z-index: 30;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-md);
  transition: opacity 0.2s, transform 0.2s var(--ease);
}
.scroll-top-btn:hover { color: var(--accent-text); }
.scroll-top-btn.hidden { display: grid !important; opacity: 0; pointer-events: none; transform: translateY(12px); }

/* ---- Phones: tabs move to the bottom ---- */

@media (max-width: 767px) {
  #app-header {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: var(--bg);
  }

  .ramen-card { grid-template-columns: 96px minmax(0, 1fr) auto; min-height: 104px; }
  .card-grade { min-width: 52px; padding-right: 12px; }
  .grade-letter { font-size: 1.5rem; }
  .section-title { font-size: 1.125rem; }
  .rating-header-image { width: 100%; height: 200px; aspect-ratio: auto; max-height: none; }
  .modal-close { background: var(--surface); box-shadow: var(--shadow-sm); }

  #tab-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding: 0 4px env(safe-area-inset-bottom);
    gap: 0;
    background: var(--bg);
    border-top: 1px solid var(--border);
  }

  .tab-btn {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    padding: 6px 2px;
    border-radius: var(--radius);
    font-size: 0.6875rem;
    background: transparent;
  }
  .tab-btn .icon { width: 24px; height: 24px; }
  .tab-btn:hover { background: transparent; }
  .tab-btn.active { background: transparent; color: var(--accent-text); }
  .tab-btn.active .icon { stroke-width: 2.2; }
  .tab-btn .tab-label { max-width: 100%; }

  #app-main { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 32px); }

  .page-title { font-size: 1.625rem; }
  .page-head-hero .page-title { font-size: 1.875rem; }

  .modal-content { max-height: calc(100dvh - 40px); }
}

@media (max-width: 380px) {
  .brand-credit { display: none; }
  .ramen-card { grid-template-columns: 84px minmax(0, 1fr) auto; }
  .tier-btn { font-size: 0.75rem; }
}

/* ---- Tablets and up ---- */

@media (min-width: 640px) {
  .card-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .filter-bar { flex-wrap: wrap; overflow: visible; margin: 12px 0 0; padding: 0; }
  .modal { align-items: center; padding: 24px; }
  .modal-content {
    width: min(520px, 100%);
    max-height: calc(100dvh - 48px);
    padding: 28px;
    border-radius: 22px;
    animation: dialog-in 0.24s var(--ease);
  }
  .modal-wide { width: min(760px, 100%); }
  .sheet-actions { margin: 22px -28px 0; padding: 14px 28px; bottom: -28px; }
  .rating-header { grid-template-columns: 240px minmax(0, 1fr); align-items: start; gap: 24px; }
  .rating-header-image { aspect-ratio: 1; max-height: none; }
  .rating-header-info { padding-top: 4px; }
  #reorder-done-float { display: none !important; }
}

@keyframes dialog-in { from { transform: translateY(12px) scale(0.98); opacity: 0; } }

@media (min-width: 768px) {
  :root { --header-h: 68px; }
  .header-inner { padding: 0 24px; }
  #app-main { padding: 32px 24px 56px; }
  .toast, .btn-float { bottom: 24px; }
  .scroll-top-btn { right: 24px; bottom: 24px; }
  .page-head-hero { margin: 16px 0 24px; }
  .page-head-hero .page-title { font-size: 2.5rem; }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .brand-credit { display: none; }
}

@media (min-width: 1200px) {
  .card-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  body[data-card-size='large'] .ramen-card { grid-template-columns: 120px minmax(0, 1fr) auto; min-height: 120px; }
}

@media (hover: none) {
  .ramen-card:hover, .compare-card:hover { transform: none; box-shadow: var(--shadow-sm); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
