/* PokéPrice – lightweight dark UI (Pikachu yellow + Poké Ball red, subtle holo) */
:root {
 --bg: #0f1117;
 --bg2: #161a23;
 --card: #1b202c;
 --card2: #242a3a;
 --line: #2d3446;
 --fg: #f0f3f9;
 --muted: #9aa3b8;
 --acc: #FFCB05;
 --red: #E3350D;
 --blue: #3B4CCA;
 --link: #7c9aff;
 --green: #3fb950;
 --amber: #f59e0b;
 --radius: 14px;
 --shadow: 0 6px 20px rgba(0, 0, 0, .38);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
 margin: 0;
 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
 background: radial-gradient(900px 420px at 50% -120px, rgba(59, 76, 202, .14), transparent 70%), var(--bg);
 color: var(--fg);
 line-height: 1.45;
 padding-bottom: 64px;
 overflow-x: clip;
 -webkit-tap-highlight-color: transparent;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
header {
 position: sticky;
 top: 0;
 z-index: 10;
 background: #131722;
 border-bottom: 1px solid var(--line);
}
@supports (backdrop-filter: blur(10px)) {
 header { background: rgba(19, 23, 34, .86); backdrop-filter: blur(10px); }
}
.header-in {
 max-width: 1120px;
 margin: 0 auto;
 padding: 10px 14px;
 display: flex;
 align-items: center;
 justify-content: space-between;
 gap: 8px;
}
.brand {
 margin: 0;
 display: flex;
 align-items: center;
 gap: 8px;
 font-size: 20px;
 font-weight: 800;
 letter-spacing: -.02em;
 color: var(--acc);
 flex-shrink: 0;
}
.brand .logo { flex-shrink: 0; display: block; }
.controls { display: flex; gap: 6px; min-width: 0; }
.controls select {
 border-radius: 999px;
 padding: 0 12px;
 min-height: 40px;
 font-size: 14px;
 font-weight: 600;
 background: var(--card2);
 border: 1px solid var(--line);
 max-width: 130px;
}

/* Base controls */
select, input, button, .btnlike {
 font: inherit;
 color: var(--fg);
 background: var(--card2);
 border: 1px solid var(--line);
 border-radius: 12px;
 padding: 10px 12px;
 min-height: 44px;
 transition: transform .16s ease, opacity .16s ease, border-color .16s ease, background-color .16s ease;
}
button, .btnlike, select { cursor: pointer; }
button:hover, .btnlike:hover, select:hover { border-color: var(--acc); }
button:active, .btnlike:active { transform: scale(.98); }
button:focus-visible, input:focus-visible, select:focus-visible, .btnlike:focus-visible {
 outline: 2px solid var(--acc);
 outline-offset: 2px;
}

/* Tabs segmented control */
.tabs {
 position: sticky;
 top: 61px;
 z-index: 9;
 padding: 8px 14px;
 background: rgba(15, 17, 23, .92);
}
@supports (backdrop-filter: blur(8px)) {
 .tabs { background: rgba(15, 17, 23, .82); backdrop-filter: blur(8px); }
}
.tabs-track {
 max-width: 1120px;
 margin: 0 auto;
 display: flex;
 gap: 4px;
 padding: 4px;
 background: var(--bg2);
 border: 1px solid var(--line);
 border-radius: 14px;
}
.tabs button {
 flex: 1;
 min-height: 44px;
 padding: 8px 10px;
 border: 0;
 border-radius: 10px;
 background: transparent;
 color: var(--muted);
 font-size: 14px;
 font-weight: 600;
 white-space: nowrap;
}
.tabs button:hover { color: var(--fg); }
.tabs button.active {
 background: var(--acc);
 color: #111318;
 font-weight: 700;
 box-shadow: 0 2px 10px rgba(255, 203, 5, .28);
}

/* Main */
main { padding: 10px 14px 20px; max-width: 1120px; margin: 0 auto; }
.tab { display: none; }
.tab.active { display: block; }
.hint, .muted { color: var(--muted); font-size: 13px; }
.hint { margin: 10px 2px; }
.notice {
 background: var(--bg2);
 border: 1px solid var(--line);
 border-left: 3px solid var(--acc);
 border-radius: 10px;
 padding: 10px 12px;
 color: var(--fg);
}
.notice a { color: var(--acc); font-weight: 600; }

/* Search box & autocomplete */
#search-form, #scan-fix { display: flex; gap: 8px; align-items: stretch; }
#search-form input, #scan-fix input { flex: 1; min-width: 0; font-size: 16px; }
.search-wrap { position: relative; flex: 1; min-width: 0; }
.search-ico {
 position: absolute;
 left: 14px;
 top: 50%;
 transform: translateY(-50%);
 color: var(--muted);
 pointer-events: none;
}
.search-wrap input {
 width: 100%;
 min-height: 48px;
 padding: 10px 14px 10px 42px;
 border-radius: 14px;
 background: var(--bg2);
 border: 1.5px solid var(--line);
}
.search-wrap input:focus {
 outline: none;
 border-color: var(--acc);
 box-shadow: 0 0 0 3px rgba(255, 203, 5, .22);
}
.search-btn {
 min-height: 48px;
 padding: 0 20px;
 border-radius: 14px;
 background: var(--acc);
 color: #111318;
 border-color: var(--acc);
 font-weight: 700;
 flex-shrink: 0;
}
.search-btn:hover { opacity: .92; }

.ac-list {
 position: absolute;
 left: 0;
 right: 0;
 top: calc(100% + 6px);
 z-index: 25;
 background: var(--card);
 border: 1px solid var(--line);
 border-radius: var(--radius);
 box-shadow: 0 12px 32px rgba(0, 0, 0, .55);
 max-height: min(360px, 46vh);
 overflow-y: auto;
 -webkit-overflow-scrolling: touch;
}
.ac-head {
 display: flex;
 align-items: center;
 justify-content: space-between;
 padding: 8px 14px;
 font-size: 12px;
 font-weight: 600;
 text-transform: uppercase;
 letter-spacing: .04em;
 color: var(--muted);
 border-bottom: 1px solid var(--line);
}
.ac-clear {
 background: transparent;
 border: 0;
 color: var(--acc);
 font-size: 12px;
 font-weight: 600;
 text-transform: none;
 letter-spacing: 0;
 padding: 4px 8px;
 min-height: 32px;
}
.ac-item {
 display: flex;
 align-items: center;
 gap: 8px;
 min-height: 44px;
 padding: 8px 14px;
 cursor: pointer;
 font-size: 15px;
 border-bottom: 1px solid rgba(45, 52, 70, .55);
 transition: background-color .14s ease;
}
.ac-item:last-child { border-bottom: 0; }
.ac-item:hover, .ac-item.active { background: var(--card2); box-shadow: inset 3px 0 0 var(--acc); }
.ac-ico { flex-shrink: 0; font-size: 14px; }
.ac-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-label mark { background: transparent; color: var(--acc); font-weight: 700; }
.ac-sub { color: var(--muted); font-size: 12px; margin-left: 6px; }
.ac-tag {
 font-size: 11px;
 color: var(--muted);
 background: var(--bg2);
 border: 1px solid var(--line);
 border-radius: 999px;
 padding: 2px 8px;
 flex-shrink: 0;
}
.ac-del {
 background: transparent;
 border: 0;
 color: var(--muted);
 padding: 4px 8px;
 font-size: 14px;
 line-height: 1;
 min-width: 36px;
 min-height: 36px;
 border-radius: 8px;
 flex-shrink: 0;
}
.ac-del:hover { color: var(--red); background: rgba(227, 53, 13, .14); }

/* Card tile grid + subtle holo sheen */
.grid {
 display: grid;
 grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
 gap: 12px;
 margin-top: 12px;
}
@media (min-width: 768px) {
 .grid { grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 14px; }
}
.tile {
 position: relative;
 overflow: hidden;
 background: linear-gradient(180deg, var(--card), var(--bg2));
 border: 1px solid var(--line);
 border-radius: var(--radius);
 padding: 8px;
 cursor: pointer;
 text-align: center;
 box-shadow: var(--shadow);
 transition: transform .22s ease, border-color .22s ease;
}
.tile::after {
 content: "";
 position: absolute;
 inset: -20%;
 background: linear-gradient(
   115deg,
   transparent 24%,
   rgba(255, 255, 255, .14) 38%,
   rgba(255, 203, 5, .16) 47%,
   rgba(59, 76, 202, .18) 56%,
   rgba(227, 53, 13, .13) 65%,
   transparent 78%
 );
 opacity: 0;
 transform: translateX(-110%);
 transition: transform .28s ease, opacity .22s ease;
 pointer-events: none;
}
.tile:hover, .tile:active {
 transform: translateY(-2px);
 border-color: rgba(255, 203, 5, .55);
}
.tile:hover::after, .tile:active::after {
 opacity: 1;
 transform: translateX(110%);
}
.tile img {
 width: 100%;
 aspect-ratio: 63 / 88;
 object-fit: contain;
 background: #0b0d13;
 border-radius: 10px;
 display: block;
}
.noimg {
 display: flex;
 align-items: center;
 justify-content: center;
 aspect-ratio: 63 / 88;
 background: #0b0d13;
 border-radius: 10px;
 color: var(--muted);
 font-size: 12px;
}
.tile .n {
 font-size: 14px;
 font-weight: 700;
 margin-top: 8px;
 white-space: nowrap;
 overflow: hidden;
 text-overflow: ellipsis;
}
.tile .s {
 font-size: 11px;
 color: var(--muted);
 margin-top: 2px;
 white-space: nowrap;
 overflow: hidden;
 text-overflow: ellipsis;
}
.tile .p {
 display: inline-block;
 margin-top: 7px;
 padding: 3px 10px;
 min-height: 24px;
 border-radius: 999px;
 background: rgba(255, 203, 5, .14);
 border: 1px solid rgba(255, 203, 5, .34);
 color: var(--acc);
 font-size: 13px;
 font-weight: 700;
 font-variant-numeric: tabular-nums;
}
.tile.best-match {
 border-color: var(--acc);
 box-shadow: 0 0 0 1px var(--acc), var(--shadow);
}
.tile .badge {
 font-size: 11px;
 font-weight: 700;
 padding: 3px 9px;
 border-radius: 999px;
 margin-bottom: 6px;
 display: inline-block;
}
.tile .badge.high { background: var(--acc); color: #111318; }
.tile .badge.low {
 background: rgba(245, 158, 11, .18);
 color: #fbbf24;
 border: 1px solid rgba(245, 158, 11, .45);
}
.scan-sep {
 grid-column: 1 / -1;
 font-size: 13px;
 font-weight: 600;
 color: var(--muted);
 margin-top: 8px;
 padding-top: 10px;
 border-top: 1px solid var(--line);
}

/* Scan tab */
.bigbtn {
 display: flex;
 flex-direction: column;
 align-items: center;
 justify-content: center;
 gap: 6px;
 text-align: center;
 padding: 28px 18px;
 border: 2px dashed #3b445e;
 border-radius: 16px;
 background: linear-gradient(180deg, rgba(255, 203, 5, .05), rgba(59, 76, 202, .06));
 margin: 12px 0;
 cursor: pointer;
 font-size: 17px;
 font-weight: 700;
}
.bigbtn:hover { border-color: var(--acc); }
.bigbtn .cam-ico { color: var(--acc); }
.bigbtn small { font-weight: 400; font-size: 12px; }
#scan-preview {
 max-width: 100%;
 max-height: 260px;
 display: block;
 margin: 10px auto;
 border-radius: 12px;
 border: 1px solid var(--line);
}

/* Detail dialog (bottom sheet on mobile) */
dialog {
 background: var(--card);
 color: var(--fg);
 border: 1px solid var(--line);
 border-radius: 18px;
 max-width: 600px;
 width: min(94vw, 600px);
 max-height: 90vh;
 overflow-y: auto;
 padding: 18px;
 box-shadow: 0 20px 50px rgba(0, 0, 0, .65);
}
dialog::backdrop { background: rgba(7, 9, 14, .78); }
@media (max-width: 600px) {
 dialog {
   margin: auto 0 0 0;
   width: 100%;
   max-width: 100%;
   max-height: 88dvh;
   border-radius: 20px 20px 0 0;
   border-left: 0;
   border-right: 0;
   border-bottom: 0;
   padding: 16px 14px calc(18px + env(safe-area-inset-bottom, 0px));
 }
}
.detail { display: flex; gap: 16px; flex-wrap: wrap; }
.detail img {
 width: 200px;
 max-width: 45%;
 height: auto;
 aspect-ratio: 63 / 88;
 object-fit: contain;
 align-self: flex-start;
 border-radius: 12px;
 background: #0b0d13;
}
.detail .noimg { width: 200px; max-width: 45%; align-self: flex-start; }
@media (max-width: 480px) {
 .detail img, .detail .noimg { width: 100%; max-width: 220px; margin: 0 auto; }
}
.detail .info { flex: 1; min-width: 210px; }
.detail h2 { margin: 0 0 4px; font-size: 20px; line-height: 1.25; }
table {
 width: 100%;
 border-collapse: collapse;
 font-size: 13px;
 margin: 10px 0;
 border-radius: 10px;
 overflow: hidden;
 border: 1px solid var(--line);
}
th {
 background: var(--bg2);
 color: var(--fg);
 font-weight: 700;
 padding: 7px 10px;
 text-align: left;
 border-bottom: 1px solid var(--line);
}
td {
 padding: 6px 10px;
 border-bottom: 1px solid rgba(45, 52, 70, .6);
 text-align: left;
}
tr:nth-child(even) td { background: rgba(255, 255, 255, .025); }
tr:last-child td { border-bottom: 0; }
td.v { text-align: right; font-variant-numeric: tabular-nums; }
td:nth-child(2) { color: var(--muted); }
td:nth-child(3) { color: var(--acc); font-weight: 700; }

.addrow { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.addrow select { flex: 1; min-width: 120px; font-size: 16px; }
.addrow input { width: 74px; font-size: 16px; }
.primary {
 background: var(--red);
 color: #fff;
 border-color: var(--red);
 font-weight: 700;
 padding: 10px 16px;
}
.primary:hover { opacity: .92; border-color: #ff5b35; }

/* Collection */
.coll-head {
 display: flex;
 flex-direction: column;
 gap: 10px;
 margin: 4px 0 14px;
}
@media (min-width: 640px) {
 .coll-head { flex-direction: row; align-items: stretch; justify-content: space-between; }
}
.coll-stat {
 flex: 1;
 background: linear-gradient(135deg, rgba(255, 203, 5, .18), rgba(255, 203, 5, .05) 60%, var(--card));
 border: 1px solid rgba(255, 203, 5, .45);
 border-radius: 16px;
 padding: 14px 18px;
 display: flex;
 flex-direction: column;
 gap: 2px;
 box-shadow: var(--shadow);
}
.coll-lbl {
 font-size: 12px;
 font-weight: 600;
 text-transform: uppercase;
 letter-spacing: .04em;
 color: var(--muted);
}
#coll-total {
 font-size: 28px;
 font-weight: 800;
 color: var(--acc);
 font-variant-numeric: tabular-nums;
 line-height: 1.2;
}
.coll-actions {
 display: flex;
 flex-wrap: wrap;
 gap: 8px;
 align-items: center;
}
.coll-actions button, .coll-actions .btnlike {
 border-radius: 999px;
 padding: 8px 14px;
 font-size: 13px;
 font-weight: 600;
 display: inline-flex;
 align-items: center;
}
.row {
 display: flex;
 gap: 10px;
 align-items: center;
 background: var(--card);
 border: 1px solid var(--line);
 border-radius: var(--radius);
 padding: 10px;
 margin-bottom: 8px;
 box-shadow: 0 3px 10px rgba(0, 0, 0, .24);
}
.row img { width: 52px; aspect-ratio: 63 / 88; object-fit: contain; border-radius: 6px; cursor: pointer; background: #0b0d13; }
.row .meta { flex: 1; min-width: 0; }
.row .meta .n { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--acc); font-weight: 700; font-size: 14px; }
.row input { width: 58px; font-size: 16px; text-align: center; padding: 6px; }
.row button { min-width: 40px; min-height: 40px; padding: 6px 10px; }
.up { color: var(--green); }
.down { color: var(--red); }

/* Toast, spinner, footer */
#toast {
 background: var(--card2) !important;
 color: var(--fg) !important;
 border: 1px solid var(--acc) !important;
 border-radius: 12px !important;
 box-shadow: 0 10px 28px rgba(0, 0, 0, .55) !important;
 font-weight: 600 !important;
}
.spinner {
 display: inline-block;
 width: 15px;
 height: 15px;
 border: 2px solid var(--line);
 border-top-color: var(--acc);
 border-radius: 50%;
 animation: spin .8s linear infinite;
 vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
footer { text-align: center; padding: 20px 14px; font-size: 12px; opacity: .85; }

@media (prefers-reduced-motion: reduce) {
 *, *::before, *::after {
   transition: none !important;
   animation: none !important;
 }
 .tile:hover, .tile:active { transform: none; }
 .tile::after { display: none; }
}

/* Time-of-day Meowth theme */
:root[data-period="morning"] {
 --bg: #171422;
 --bg2: #201b30;
 --card: #26203a;
 --card2: #31294a;
 --line: #433961;
 --fg: #f6f3fc;
 --muted: #bdb4d1;
 --hero-glow: rgba(235, 168, 255, .24);
 --hero-bg: linear-gradient(125deg, rgba(255, 203, 5, .14), rgba(236, 152, 255, .18) 52%, rgba(124, 154, 255, .14));
}
:root[data-period="afternoon"] {
 --bg: #121a24;
 --bg2: #182330;
 --card: #1e2c3c;
 --card2: #27394d;
 --line: #364c64;
 --fg: #f6f3eb;
 --muted: #adc0d4;
 --hero-glow: rgba(120, 198, 255, .22);
 --hero-bg: linear-gradient(125deg, rgba(110, 192, 255, .18), rgba(255, 224, 168, .16) 55%, rgba(255, 203, 5, .12));
}
:root[data-period="night"] {
 --bg: #0c101a;
 --bg2: #131927;
 --card: #182032;
 --card2: #212c42;
 --line: #2c3854;
 --fg: #f0f3fa;
 --muted: #9aa6c0;
 --hero-glow: rgba(245, 176, 65, .22);
 --hero-bg: linear-gradient(125deg, rgba(59, 76, 202, .22), rgba(245, 176, 65, .16) 65%, rgba(227, 53, 13, .10));
}
.theme-bg {
 position: fixed;
 inset: 0;
 z-index: 0;
 background: var(--bg) var(--bg-l) center 30% / cover no-repeat;
 pointer-events: none;
}
@media (orientation: portrait) { .theme-bg { background-image: var(--bg-p); background-position: center top; } }
.theme-bg::after {
 content: "";
 position: absolute;
 inset: 0;
 background: linear-gradient(to bottom, rgba(0,0,0,.28), rgba(0,0,0,.08) 30%, rgba(0,0,0,.12) 70%, rgba(0,0,0,.3));
}
:root[data-period] body { background: var(--bg); }
:root[data-period] .tile, :root[data-period] .meowth-hero { box-shadow: 0 6px 18px rgba(0,0,0,.35); }
:root[data-period] .meowth-hero { background: rgba(14,18,28,.72); }
@supports (backdrop-filter: blur(6px)) { :root[data-period] .meowth-hero { backdrop-filter: blur(6px); } }
:root[data-period] footer { background: rgba(12,15,24,.72); border-radius: 10px; width: fit-content; max-width: calc(100% - 24px); margin: 16px auto; padding: 8px 12px; }
:root[data-period] .hint:not(:empty), :root[data-period] .empty { background: rgba(12,15,24,.72); border-radius: 10px; padding: 6px 10px; display: inline-block; }
:root[data-period] .hero-greet, :root[data-period] .hero-cap { text-shadow: 0 1px 3px rgba(0,0,0,.75); }
header, .tabs, main, footer { position: relative; z-index: 1; }
header { position: sticky; z-index: 10; }
.tabs { position: sticky; z-index: 9; }
.theme-btn {
 border-radius: 999px;
 padding: 0 10px;
 min-height: 40px;
 min-width: 40px;
 font-size: 13px;
 font-weight: 600;
 display: inline-flex;
 align-items: center;
 justify-content: center;
 gap: 4px;
 white-space: nowrap;
}
@media (max-width: 430px) {
 .theme-btn .t-lbl { display: none; }
 .controls select { padding: 0 8px; max-width: 96px; font-size: 13px; }
}
.meowth-hero {
 display: flex;
 align-items: center;
 gap: 14px;
 padding: 10px 14px;
 margin: 0 0 12px;
 border-radius: 16px;
 background: var(--hero-bg, var(--card));
 border: 1px solid var(--line);
 box-shadow: var(--shadow);
 max-height: 140px;
 overflow: hidden;
}
.hero-card {
 position: relative;
 overflow: hidden;
 padding: 0;
 min-height: 0;
 border: 1.5px solid rgba(255, 203, 5, .55);
 border-radius: 10px;
 background: #0b0d13;
 flex-shrink: 0;
 transform: rotate(-3deg);
 box-shadow: 0 6px 16px rgba(0, 0, 0, .45);
 transition: transform .22s ease;
}
.hero-card img {
 display: block;
 width: 84px;
 height: 117px;
 object-fit: cover;
 border-radius: 8px;
}
.hero-card::after {
 content: "";
 position: absolute;
 inset: -20%;
 background: linear-gradient(115deg, transparent 24%, rgba(255, 255, 255, .18) 40%, rgba(255, 203, 5, .20) 50%, rgba(59, 76, 202, .18) 60%, transparent 78%);
 opacity: 0;
 transform: translateX(-110%);
 transition: transform .28s ease, opacity .22s ease;
 pointer-events: none;
}
.hero-card:hover, .hero-card:active { transform: rotate(0deg) scale(1.03); }
.hero-card:hover::after, .hero-card:active::after { opacity: 1; transform: translateX(110%); }
.hero-copy { min-width: 0; flex: 1; }
.hero-greet { font-size: 18px; font-weight: 800; color: var(--fg); line-height: 1.25; }
.hero-cap { font-size: 12px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-cta { font-size: 12px; color: var(--acc); font-weight: 600; margin-top: 6px; }
@media (prefers-reduced-motion: reduce) {
 .hero-card, .hero-card:hover, .hero-card:active { transform: none; }
 .hero-card::after { display: none; }
}
.coll-upd { font-size: 12px; color: var(--muted); margin-top: 2px; }
