:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --surface: #11151d;
  --surface-2: #171c25;
  --surface-3: #202631;
  --line: #29313d;
  --text: #f6f7f9;
  --muted: #8f98a7;
  --accent: #f2a900;
  --accent-soft: rgba(242, 169, 0, .12);
  --blue: #69aef5;
  --green: #5ed38b;
  --red: #f07b78;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
button, input { font: inherit; }
input[type="radio"], input[type="checkbox"] { accent-color: var(--accent); }
button { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

.app-shell { min-height: 100dvh; background: radial-gradient(circle at 70% -10%, rgba(47, 80, 120, .2), transparent 34%), var(--bg); }
.topbar {
  position: sticky; top: 0; z-index: 30; height: calc(56px + var(--safe-top));
  padding: var(--safe-top) 16px 0; display: flex; align-items: center;
  background: rgba(11, 13, 18, .9); border-bottom: 1px solid rgba(41, 49, 61, .75);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand-mark { width: 29px; height: 29px; border-radius: 8px; object-fit: cover; background: #0d1017; }
.brand div { display: flex; align-items: baseline; gap: 6px; }
.brand strong { letter-spacing: .01em; font-size: 13px; }
.brand small { color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; background: transparent; color: var(--text); border: 0; padding: 0; margin-left: -9px; margin-right: 5px; }
.icon-button svg { width: 23px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.main { min-height: calc(100dvh - 56px - var(--safe-top)); padding: 18px 16px calc(92px + var(--safe-bottom)); }
.main.login-main { display: flex; align-items: center; padding-bottom: calc(28px + var(--safe-bottom)); }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 11px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(28px, 8vw, 38px); line-height: 1.2; letter-spacing: -.035em; }
h2 { margin-bottom: 5px; font-size: 18px; letter-spacing: -.015em; }
.lead { color: #aab2bf; font-size: 14px; line-height: 1.75; }

.login-wrap { width: 100%; max-width: 460px; margin: auto; }
.compact-title { margin: 0 0 12px; font-size: 22px; }
.hero-orbit { position: relative; width: 92px; height: 92px; margin: 4px 0 24px; border: 1px solid #313947; border-radius: 28px; display: grid; place-items: center; background: linear-gradient(145deg, #1b222e, #10141b); box-shadow: 0 22px 60px rgba(0,0,0,.35); }
.hero-orbit::after { content: ""; position: absolute; right: -8px; top: -8px; width: 25px; height: 25px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 28px rgba(242,169,0,.45); }
.hero-orbit strong { font-size: 42px; letter-spacing: -.08em; }
.form-card, .panel-card { border: 1px solid var(--line); border-radius: 18px; background: rgba(17, 21, 29, .9); box-shadow: 0 18px 50px rgba(0,0,0,.18); }
.form-card { margin-top: 12px; padding: 16px; }
.field { display: block; margin-bottom: 13px; }
.field > span { display: block; color: #b6bdc8; font-size: 12px; margin-bottom: 7px; }
.field input, .search-box input {
  width: 100%; height: 50px; border-radius: 13px; border: 1px solid #303846;
  background: #0d1117; color: var(--text); padding: 0 14px; font-size: 16px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(242,169,0,.1); }
.primary-button, .secondary-button, .amazon-button {
  min-height: 50px; border: 0; border-radius: 13px; font-weight: 750; cursor: pointer;
}
.primary-button { width: 100%; background: var(--accent); color: #17130a; }
.primary-button:disabled { opacity: .55; }
.secondary-button { background: var(--surface-3); color: var(--text); border: 1px solid #343d4a; padding: 0 16px; }
.text-button { border: 0; background: transparent; color: var(--muted); padding: 12px; width: 100%; font-size: 12px; }
.form-error { min-height: 18px; margin: 2px 0 8px; color: var(--red); font-size: 12px; }

.home-head { padding: 4px 2px 12px; }
.home-head h1 { margin-bottom: 10px; font-size: 20px; }
.search-box { position: relative; display: flex; gap: 8px; }
.search-box input { padding-right: 48px; }
.search-box button { position: absolute; right: 5px; top: 5px; width: 40px; height: 40px; border: 0; border-radius: 10px; background: var(--accent); color: #151109; display: grid; place-items: center; }
.search-box svg, .bottom-nav svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.search-hint { margin: 8px 2px 0; color: var(--muted); font-size: 11px; }
.section-label { display: flex; align-items: center; justify-content: space-between; margin: 16px 2px 8px; color: #c4cad2; font-size: 12px; }
.recent-list { display: grid; gap: 8px; }
.recent-item { width: 100%; display: flex; gap: 11px; align-items: center; padding: 11px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--text); text-align: left; }
.recent-item img, .recent-placeholder { width: 46px; height: 46px; border-radius: 10px; object-fit: contain; background: white; flex: 0 0 auto; }
.recent-placeholder { display: grid; place-items: center; color: #3b4350; font-weight: 800; }
.recent-item div { min-width: 0; }
.recent-item strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.recent-item small { color: var(--muted); font-size: 11px; }
.home-tip { margin-top: 20px; padding: 15px; border: 1px solid rgba(105,174,245,.25); border-radius: 15px; background: rgba(105,174,245,.06); color: #b8cce0; font-size: 12px; line-height: 1.65; }

.loading-view { min-height: 60vh; display: grid; place-items: center; text-align: center; }
.pulse-mark { width: 56px; height: 56px; margin: 0 auto 17px; border-radius: 18px; border: 1px solid var(--accent); display: grid; place-items: center; color: var(--accent); font-weight: 800; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 13px rgba(242,169,0,0); background: rgba(242,169,0,.12); } }
.loading-view p { color: var(--muted); font-size: 13px; }

.choice-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.choice-head h1 { margin: 0; font-size: 20px; }
.choice-head span { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.choice-list { display: grid; gap: 7px; }
.choice-item { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); text-align: left; }
.choice-item strong { display: block; font-size: 13px; line-height: 1.45; }
.choice-item span { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }

.product-hero { display: grid; grid-template-columns: 76px 1fr; gap: 13px; align-items: start; padding: 2px 0 15px; }
.product-image { width: 76px; height: 76px; border-radius: 14px; object-fit: contain; background: #fff; border: 1px solid #2c333e; }
.product-image-placeholder { width: 76px; height: 76px; display: grid; place-items: center; border-radius: 14px; background: var(--surface-2); color: #475160; font-weight: 800; }
.product-copy { min-width: 0; }
.product-title { margin: 0 0 8px; font-size: 15px; line-height: 1.45; font-weight: 750; }
.product-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--muted); font-size: 11px; }
.rank { color: #f2ce7e; font-weight: 750; }
.freshness { display: inline-flex; align-items: center; gap: 4px; }
.freshness::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--green); }
.product-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.product-actions a, .product-actions button { padding: 0; border: 0; background: transparent; color: var(--accent); text-decoration: none; font-size: 11px; }
.product-actions button.active { text-decoration: underline; }
.offer-filters { margin-bottom: 10px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.filter-row { display: flex; align-items: center; flex-wrap: wrap; gap: 7px 10px; min-height: 23px; font-size: 10px; }
.filter-row > span { width: 34px; flex: 0 0 34px; color: var(--muted); }
.filter-row label { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.filter-row input { width: 13px; height: 13px; margin: 0; }
.filter-sub { padding-left: 44px; }
.history-summary { display: flex; align-items: end; justify-content: space-between; margin: 4px 2px 10px; }
.history-summary strong { font-size: 14px; }
.history-summary span { color: var(--muted); font-size: 11px; }
.offer-list { display: grid; gap: 9px; }
.offer-card { position: relative; display: grid; grid-template-columns: 114px minmax(0,1fr); gap: 10px; padding: 13px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); overflow: hidden; }
.offer-card.watched::before { content: ""; position: absolute; left: 0; top: 13px; bottom: 13px; width: 2px; background: var(--accent); border-radius: 2px; }
.offer-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.offer-condition { color: #f0f2f5; font-size: 11px; font-weight: 700; line-height: 1.35; }
.offer-price { margin: 3px 0 7px; font-size: 20px; font-weight: 820; letter-spacing: -.035em; }
.offer-tags { display: flex; gap: 5px; }
.tag { display: inline-flex; align-items: center; min-height: 21px; padding: 0 7px; border-radius: 6px; background: #2a3039; color: #c4c9d0; font-size: 9px; font-weight: 700; }
.tag.fba { color: #bcd9f7; background: #1b3b5a; }
.price-reference { display: inline-flex; align-items: center; gap: 4px; margin-top: 8px; color: #d7af50; font-size: 9px; white-space: nowrap; }
.price-reference input { width: 13px; height: 13px; margin: 0; }
.offer-side { min-width: 0; display: flex; flex-direction: column; justify-content: space-between; }
.seller-line { display: flex; align-items: center; gap: 5px; min-width: 0; color: var(--blue); font-size: 11px; font-weight: 700; }
.seller-line.watched::before { content: ""; width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: var(--accent); }
.seller-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; text-decoration: none; }
.seller-button { flex: 0 0 auto; height: 23px; padding: 0 7px; border-radius: 6px; border: 1px solid #3b4654; background: transparent; color: #b4bdc8; font-size: 9px; }
.seller-button.active { border-color: rgba(242,169,0,.45); color: #e7bd5a; }
.offer-note { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 9px; color: #9ca5b2; font-size: 10px; line-height: 1.5; }
.offer-note.open { display: block; overflow: visible; }
.note-toggle { align-self: flex-start; margin: 2px 0 7px; padding: 0; border: 0; background: transparent; color: #8b909a; font-size: 9px; }
.note-toggle:active { color: var(--blue); }
.empty-card { padding: 28px 20px; text-align: center; border: 1px dashed #323b48; border-radius: 17px; color: var(--muted); font-size: 12px; line-height: 1.7; }

.variations-panel { padding-top: 2px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.panel-heading strong { font-size: 14px; }
.panel-heading button { border: 0; background: transparent; color: var(--muted); font-size: 11px; }
.variation-list { display: grid; gap: 8px; }
.variation-item { width: 100%; min-height: 66px; display: grid; grid-template-columns: 50px minmax(0,1fr) 12px; gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); color: var(--text); text-align: left; }
.variation-item.current { border-color: rgba(242,169,0,.55); background: var(--accent-soft); }
.variation-item img, .variation-placeholder { width: 50px; height: 50px; border-radius: 9px; object-fit: contain; background: white; }
.variation-placeholder { display: grid; place-items: center; color: #4b5564; font-weight: 800; }
.variation-item strong { display: block; font-size: 12px; line-height: 1.4; }
.variation-item small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.variation-item i { color: var(--muted); font-size: 19px; font-style: normal; }

.amazon-panel { padding-top: 2px; }
.amazon-visual { height: 180px; margin-bottom: 16px; border: 1px solid #293341; border-radius: 24px; display: grid; place-items: center; background: radial-gradient(circle at 50% 30%, rgba(242,169,0,.15), transparent 45%), linear-gradient(155deg, #19212c, #10141b); overflow: hidden; }
.amazon-visual div { text-align: center; }
.amazon-visual strong { display: block; font-size: 36px; letter-spacing: -.07em; }
.amazon-visual span { color: var(--accent); font-size: 11px; letter-spacing: .12em; }
.amazon-panel h2 { font-size: 22px; }
.amazon-button { width: 100%; min-height: 52px; margin: 2px 0 7px; display: flex; align-items: center; justify-content: center; gap: 9px; background: var(--accent); color: #17130a; text-decoration: none; }
.amazon-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 2; }
.product-link { display: flex; justify-content: center; padding: 10px; color: var(--blue); font-size: 12px; text-decoration: none; }
.flow-steps { display: grid; gap: 0; margin-top: 22px; }
.flow-step { position: relative; display: grid; grid-template-columns: 28px 1fr; gap: 11px; min-height: 52px; color: #aab2be; font-size: 12px; line-height: 1.55; }
.flow-step:not(:last-child)::after { content: ""; position: absolute; left: 13px; top: 29px; bottom: 2px; width: 1px; background: #323a46; }
.flow-step i { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--accent); font-size: 11px; font-style: normal; font-weight: 800; }

.calc-mode { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 13px; background: #11151c; border: 1px solid var(--line); margin-bottom: 15px; }
.calc-mode button { height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; }
.calc-mode button.active { background: var(--surface-3); color: var(--text); box-shadow: 0 3px 10px rgba(0,0,0,.25); }
.calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.calc-grid .wide { grid-column: 1 / -1; }
.calc-field { display: block; }
.calc-field span { display: block; margin: 0 0 6px 2px; color: #aab2be; font-size: 10px; }
.money-input { position: relative; }
.money-input b { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #747e8c; font-size: 13px; }
.calc-field input { width: 100%; height: 46px; border: 1px solid #303846; border-radius: 11px; background: #0d1117; color: var(--text); padding: 0 10px; text-align: right; font-size: 16px; outline: none; }
.money-input input { padding-left: 25px; }
.calc-field input:focus { border-color: var(--accent); }
.calc-result { margin-top: 15px; padding: 17px; border: 1px solid var(--line); border-radius: 17px; background: linear-gradient(145deg, #171d26, #10141a); }
.result-label { color: var(--muted); font-size: 11px; }
.result-amount { margin: 2px 0 4px; font-size: 31px; font-weight: 850; letter-spacing: -.045em; }
.result-amount.positive { color: var(--green); }
.result-amount.negative { color: var(--red); }
.result-meta { color: #9da6b2; font-size: 11px; }
.result-target { display: inline-flex; margin-top: 10px; padding: 5px 8px; border-radius: 7px; background: rgba(94,211,139,.1); color: var(--green); font-size: 10px; font-weight: 700; }
.result-target.miss { background: rgba(240,123,120,.1); color: var(--red); }
.auction-result { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 11px; }
.auction-result div { padding: 11px; border-radius: 12px; background: #0e1218; }
.auction-result span { display: block; color: var(--muted); font-size: 9px; }
.auction-result strong { display: block; margin-top: 3px; font-size: 18px; }
.calc-caption { margin: 11px 2px 0; color: #757f8d; font-size: 10px; line-height: 1.55; }

.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: calc(66px + var(--safe-bottom)); padding: 6px 8px var(--safe-bottom); display: grid; grid-template-columns: repeat(3,1fr); border-top: 1px solid rgba(45,53,65,.9); background: rgba(13,16,22,.93); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.bottom-nav button { position: relative; border: 0; background: transparent; color: #737d8b; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 9px; }
.bottom-nav button.active { color: var(--accent); }
.bottom-nav button.active::before { content: ""; position: absolute; top: -6px; width: 30px; height: 2px; background: var(--accent); border-radius: 0 0 2px 2px; box-shadow: 0 4px 14px rgba(242,169,0,.5); }
.bottom-nav svg { width: 22px; height: 22px; }
.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(81px + var(--safe-bottom)); transform: translate(-50%, 20px); width: max-content; max-width: calc(100% - 32px); padding: 10px 14px; border: 1px solid #3a4350; border-radius: 12px; background: #202630; color: var(--text); font-size: 11px; box-shadow: 0 10px 30px rgba(0,0,0,.3); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 600px) {
  .app-shell { max-width: 480px; margin: 0 auto; min-height: 100dvh; border-left: 1px solid #202631; border-right: 1px solid #202631; }
  .bottom-nav { left: 50%; right: auto; width: 480px; transform: translateX(-50%); }
}
