:root {
  color-scheme: light dark;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-muted: #f5f5f7;
  --surface-pressed: #ececf0;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: #d2d2d7;
  --blue: #0071e3;
  --blue-pressed: #0064c8;
  --blue-soft: #e8f2fc;
  --green: #248a3d;
  --red: #d70015;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  --radius-sm: 12px;
  --radius: 16px;
  --radius-lg: 20px;
  --safe-bottom: max(18px, env(safe-area-inset-bottom));
  --tabbar-bottom: max(8px, env(safe-area-inset-bottom));
  --selection-bg: var(--ink);
  --selection-ink: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { min-width: 320px; min-height: 100%; margin: 0; background: var(--bg); color: var(--ink); }
button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgba(0, 113, 227, 0.3); outline-offset: 2px; }
[hidden] { display: none !important; }

.app { width: min(100%, 620px); min-height: 100dvh; margin: 0 auto; padding-bottom: calc(80px + var(--safe-bottom)); }
.app-loading { display: grid; min-height: 100dvh; place-items: center; color: var(--muted); font-size: 15px; }
.screen { min-height: 100dvh; }
.screen-content { padding: max(20px, env(safe-area-inset-top)) 18px 28px; }
.home-credit { margin: 46px 0 12px; color: var(--muted); font-size: 11px; letter-spacing: .01em; text-align: center; }
.app-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 2px 0 22px; }
.app-title { margin: 0; font-size: 32px; letter-spacing: -0.055em; line-height: 1.05; }
.eyebrow { margin: 0 0 5px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.02em; }
.icon-button, .back-button { display: inline-grid; min-width: 44px; height: 44px; place-items: center; border: 0; border-radius: 50%; background: var(--surface); color: var(--blue); box-shadow: 0 1px 0 rgba(0,0,0,.04); }
.icon-button { font-size: 23px; line-height: 1; }
.back-button { width: auto; padding: 0 15px; border-radius: 999px; font-size: 15px; font-weight: 600; }
.section { margin-top: 30px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.section-heading h2 { margin: 0; font-size: 20px; letter-spacing: -0.03em; }
.section-action { border: 0; background: transparent; color: var(--blue); font-size: 14px; font-weight: 600; }

.search-trigger { display: flex; width: 100%; height: 48px; align-items: center; justify-content: space-between; margin-top: 16px; border: 0; border-radius: var(--radius-sm); background: var(--surface); color: var(--muted); padding: 0 15px; text-align: left; box-shadow: 0 1px 1px rgba(0,0,0,.03); }
.search-trigger span:last-child { border-radius: 6px; background: var(--surface-muted); padding: 3px 6px; color: var(--muted); font-size: 11px; }
.inline-search { margin-top: 16px; }
.inline-search .search-input-wrap { box-shadow: 0 1px 1px rgba(0,0,0,.03); }
.inline-search .text-button { flex: 0 0 auto; }
.search-empty { margin: 14px 0 0; color: var(--muted); font-size: 14px; }
.chip { flex: 0 0 auto; min-height: 36px; border: 0; border-radius: 999px; background: var(--surface); color: var(--ink); padding: 0 14px; font-size: 14px; font-weight: 600; }
.chip.is-active { background: var(--selection-bg); color: var(--selection-ink); }

.product-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.product-card { display: flex; min-height: 216px; overflow: hidden; border: 0; border-radius: var(--radius); background: var(--surface); color: var(--ink); padding: 14px; text-align: left; flex-direction: column; justify-content: space-between; box-shadow: 0 1px 1px rgba(0,0,0,.025); }
.product-visual { position: relative; display: grid; height: 111px; place-items: center; overflow: hidden; border-radius: 12px; background: linear-gradient(150deg, #f2f4f8, #e3e8ed); }
.product-visual.has-official-image { background: #f5f5f7; }
.product-visual.has-official-image::before, .product-visual.has-official-image::after { display: none; }
.product-visual img { width: 100%; height: 100%; object-fit: contain; object-position: center; transform: scale(1.22); }
.config-visual.has-official-image img { transform: none; }
.config-visual.accessory-visual.pencil img { transform: scale(1.08); }
.product-visual::before, .product-visual::after { position: absolute; content: ""; }
.product-visual.laptop::before { width: 96px; height: 61px; border: 4px solid #303235; border-bottom-width: 6px; border-radius: 5px 5px 3px 3px; background: linear-gradient(140deg, #a8c4db, #f5e6e0); transform: perspective(130px) rotateX(-4deg); }
.product-visual.laptop::after { bottom: 19px; width: 110px; height: 6px; border-radius: 2px 2px 7px 7px; background: #9fa2a4; }
.product-visual.tablet { background: linear-gradient(135deg, #eef0f4, #dfeaff); }
.product-visual.tablet::before { width: 72px; height: 99px; border: 4px solid #35383d; border-radius: 10px; background: linear-gradient(150deg, #c3d8fd, #f0d3f8 52%, #fff3cb); }
.product-visual.pencil { background: linear-gradient(145deg, #fbfbfc, #e5e6e9); }
.product-visual.pencil::before { width: 12px; height: 93px; border-radius: 12px; background: linear-gradient(90deg, #d8d9dd, #fff, #d5d6da); transform: rotate(45deg); }
.product-visual.keyboard::before { width: 104px; height: 56px; border-radius: 7px; background: repeating-linear-gradient(90deg, #3a3a3c 0 8px, #57575b 8px 10px), repeating-linear-gradient(0deg, transparent 0 10px, rgba(255,255,255,.14) 10px 11px); transform: perspective(110px) rotateX(32deg); }
.product-name { display: block; margin-top: 13px; font-size: 17px; font-weight: 650; letter-spacing: -0.03em; }
.product-meta { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.product-price { display: block; margin-top: 13px; color: var(--blue); font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; }

.recent-list, .history-list, .saved-list { display: grid; gap: 9px; }
.recent-card, .history-card, .saved-card { width: 100%; border: 0; border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); padding: 14px; text-align: left; }
.recent-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; }
.line-title { display: block; font-size: 15px; font-weight: 650; letter-spacing: -0.015em; }
.line-subtitle { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.line-price { color: var(--ink); font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }

.tabbar { position: fixed; z-index: 10; right: 0; bottom: 0; left: 0; display: flex; height: calc(64px + var(--tabbar-bottom)); align-items: flex-start; justify-content: center; border-top: 1px solid rgba(210,210,215,.8); background: color-mix(in srgb, var(--bg) 90%, transparent); padding: 7px max(14px, env(safe-area-inset-right)) var(--tabbar-bottom) max(14px, env(safe-area-inset-left)); backdrop-filter: blur(18px); }
.tabbar-inner { display: grid; width: min(100%, 620px); grid-template-columns: repeat(4, 1fr); }
.tab-button { display: grid; min-height: 50px; place-items: center; border: 0; border-radius: 10px; background: transparent; color: var(--muted); padding: 0 4px; font-size: 11px; font-weight: 600; }
.tab-button.is-active { color: var(--blue); }
.tab-button::before { width: 7px; height: 7px; margin-bottom: 2px; border-radius: 50%; background: currentColor; content: ""; }

.config-hero { display: grid; overflow: hidden; border-radius: var(--radius-lg); background: var(--surface); }
.config-visual { min-height: 220px; }
.config-copy { padding: 19px; }
.config-copy h1 { margin: 0; font-size: 30px; line-height: 1; letter-spacing: -0.06em; }
.config-copy p { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.config-section { margin-top: 28px; }
.config-section h2 { margin: 0 0 11px; font-size: 15px; }
.chip-row { display: flex; overflow-x: auto; margin: 0 -18px; padding: 0 18px 4px; gap: 8px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.accessory-recommendation .section-heading { display: block; margin-bottom: 10px; }
.accessory-recommendation .section-heading p { margin: -5px 0 0; color: var(--muted); font-size: 13px; }
.recommendation-card { display: grid; width: 100%; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; border: 0; border-radius: var(--radius); background: var(--surface); color: var(--ink); padding: 15px; text-align: left; }
.recommendation-card strong { display: block; font-size: 15px; letter-spacing: -0.02em; }
.recommendation-card small { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
.recommendation-cta { display: grid; justify-items: end; gap: 4px; color: var(--blue); white-space: nowrap; }
.recommendation-cta strong { color: var(--blue); font-variant-numeric: tabular-nums; }
.recommendation-cta small { margin: 0; color: var(--blue); font-weight: 600; }
.config-content { padding-bottom: 118px; }
.quote-summary { position: fixed; z-index: 8; right: 12px; bottom: calc(12px + var(--safe-bottom)); left: 12px; border: 1px solid rgba(255,255,255,.4); border-radius: 18px; background: color-mix(in srgb, var(--surface) 94%, transparent); box-shadow: 0 8px 20px rgba(0,0,0,.11); backdrop-filter: blur(22px); }
.quote-summary-main { display: flex; min-height: 66px; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 11px 10px 15px; }
.quote-summary-details { min-width: 0; flex: 1; border: 0; background: transparent; color: var(--ink); padding: 0; text-align: left; }
.quote-summary-details span { display: block; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.quote-summary-details strong { display: block; margin-top: 2px; font-size: 23px; letter-spacing: -0.045em; line-height: 1; font-variant-numeric: tabular-nums; }
.primary-button { min-height: 44px; border: 0; border-radius: 999px; background: var(--blue); color: #fff; padding: 0 17px; font-size: 14px; font-weight: 650; }
.primary-button:active { background: var(--blue-pressed); transform: scale(.98); }

.segmented { display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; border-radius: 10px; background: #e4e4e8; padding: 2px; }
.segmented button { min-height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; }
.segmented button.is-active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.sheet-layer, .presentation { position: fixed; z-index: 30; inset: 0; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.3); }
.sheet { position: absolute; right: 0; bottom: 0; left: 0; max-height: min(84dvh, 680px); overflow: auto; border-radius: 22px 22px 0 0; background: var(--surface); padding: 10px 18px calc(24px + var(--safe-bottom)); box-shadow: 0 -18px 48px rgba(0,0,0,.16); }
.sheet-handle { width: 38px; height: 5px; margin: 0 auto 18px; border-radius: 999px; background: #c7c7cc; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-header h2 { margin: 0; font-size: 22px; letter-spacing: -0.04em; }
.close-button, .text-button { border: 0; background: transparent; color: var(--blue); font-size: 15px; font-weight: 600; }
.quote-result { margin-top: 19px; border-radius: var(--radius); background: var(--surface-muted); padding: 18px; }
.quote-result > span { color: var(--muted); font-size: 13px; }
.quote-result > strong { display: block; margin-top: 6px; font-size: 42px; letter-spacing: -0.06em; font-variant-numeric: tabular-nums; }
.quote-result > p { margin: 7px 0 0; color: var(--green); font-size: 14px; font-weight: 600; }
.result-details { display: grid; margin: 13px 0 0; border-top: 1px solid var(--line); }
.result-details div { display: flex; justify-content: space-between; gap: 15px; border-bottom: 1px solid var(--line); padding: 12px 0; }
.result-details dt { color: var(--muted); font-size: 14px; }
.result-details dd { margin: 0; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.quote-items dt { min-width: 0; }
.quote-items dt strong { display: block; color: var(--ink); font-size: 14px; }
.quote-items dt small { display: block; overflow: hidden; margin-top: 3px; text-overflow: ellipsis; white-space: nowrap; }
.quote-items dd { display: grid; justify-items: end; gap: 5px; }
.quote-item-remove { border: 0; background: transparent; color: var(--blue); padding: 0; font-size: 12px; font-weight: 600; }
.disclosure { margin-top: 14px; border: 0; border-radius: var(--radius-sm); background: var(--surface-muted); color: var(--ink); padding: 14px; text-align: left; }
.disclosure summary { color: var(--blue); font-size: 14px; font-weight: 600; cursor: pointer; }
.disclosure p { margin: 11px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.field { display: grid; margin-top: 14px; gap: 7px; }
.field label { font-size: 13px; font-weight: 600; }
.field input, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-muted); color: var(--ink); padding: 12px; }
.field textarea { min-height: 74px; resize: vertical; }
.wide-button { width: 100%; min-height: 48px; margin-top: 20px; border: 0; border-radius: 13px; background: var(--blue); color: #fff; font-size: 16px; font-weight: 650; }
.secondary-button { width: 100%; min-height: 47px; margin-top: 10px; border: 0; border-radius: 13px; background: var(--surface-muted); color: var(--blue); font-size: 15px; font-weight: 600; }

.history-group { margin-top: 25px; }
.history-group h2 { margin: 0 0 10px; color: var(--muted); font-size: 13px; font-weight: 650; }
.history-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 0; }
.history-card + .history-card { margin-top: 2px; }
.history-card-main { display: grid; width: 100%; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 16px; border: 0; background: transparent; color: var(--ink); padding: 16px; text-align: left; }
.history-card-main:active { background: var(--surface-muted); }
.history-entry-copy { min-width: 0; }
.history-entry-copy .line-title { font-size: 16px; }
.history-entry-price { display: grid; justify-items: end; gap: 5px; padding-top: 1px; text-align: right; }
.history-entry-price strong { color: var(--ink); font-size: 17px; font-variant-numeric: tabular-nums; }
.history-entry-price small { color: var(--muted); font-size: 11px; white-space: nowrap; }
.mode-tag { display: inline-block; border-radius: 999px; background: var(--blue-soft); color: var(--blue); padding: 4px 8px; font-size: 11px; font-weight: 650; line-height: 1; white-space: nowrap; }
.history-actions { display: flex; align-items: center; gap: 2px; border-top: 1px solid var(--line); padding: 9px 10px; }
.history-actions .mode-tag { margin-right: auto; }
.history-actions button { min-height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--blue); padding: 0 9px; font-size: 12px; font-weight: 600; }
.history-actions button:active { background: var(--blue-soft); }
.history-actions .history-delete { color: #d14242; }
.history-actions .history-delete:active { background: #fff0f0; }
.empty-state { display: grid; min-height: 300px; place-items: center; border-radius: var(--radius-lg); background: var(--surface); padding: 36px 26px; text-align: center; }
.empty-state h2 { margin: 0; font-size: 20px; letter-spacing: -0.04em; }
.empty-state p { max-width: 250px; margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.saved-card { display: grid; gap: 11px; }
.saved-card-top { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.saved-total { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
.saved-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.saved-actions button { min-height: 34px; border: 0; border-radius: 9px; background: var(--surface-muted); color: var(--blue); font-size: 12px; font-weight: 600; }

.settings-list { overflow: hidden; border-radius: var(--radius); background: var(--surface); }
.settings-row { display: flex; min-height: 56px; align-items: center; justify-content: space-between; gap: 15px; border-bottom: 1px solid var(--line); padding: 0 14px; }
.settings-row:last-child { border-bottom: 0; }
.settings-row strong { display: block; font-size: 15px; }
.settings-row small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.setting-control { display: flex; gap: 5px; }
.setting-control button { min-height: 32px; border: 0; border-radius: 7px; background: var(--surface-muted); color: var(--muted); padding: 0 9px; font-size: 12px; font-weight: 600; }
.setting-control button.is-active { background: var(--blue); color: #fff; }
.switch { width: 45px; height: 27px; border: 0; border-radius: 999px; background: #c7c7cc; padding: 3px; }
.switch span { display: block; width: 21px; height: 21px; border-radius: 50%; background: #fff; transition: transform .16s ease; }
.switch.is-on { background: var(--green); }
.switch.is-on span { transform: translateX(18px); }

.search-layer { position: fixed; z-index: 35; inset: 0; background: var(--bg); padding: max(18px, env(safe-area-inset-top)) 18px var(--safe-bottom); }
.search-input-wrap { display: flex; height: 50px; align-items: center; border-radius: 12px; background: var(--surface); padding: 0 12px; gap: 9px; }
.search-input-wrap input { width: 100%; border: 0; background: transparent; color: var(--ink); outline: 0; font-size: 16px; }
.search-results { display: grid; margin-top: 20px; gap: 8px; }
.search-result { display: grid; grid-template-columns: 1fr auto; align-items: center; border: 0; border-radius: 12px; background: var(--surface); color: var(--ink); padding: 14px; text-align: left; }
.search-result span { color: var(--muted); font-size: 12px; }

.presentation { display: grid; overflow: auto; background: var(--surface); padding: max(24px, env(safe-area-inset-top)) 22px calc(24px + var(--safe-bottom)); align-content: space-between; }
.presentation header { display: flex; align-items: center; justify-content: space-between; }
.presentation h1 { margin: 0; font-size: 17px; }
.presentation-product { margin: 30px 0; }
.presentation-product p { margin: 0; color: var(--muted); font-size: 15px; }
.presentation-product h2 { margin: 8px 0 0; font-size: 37px; line-height: 1.04; letter-spacing: -0.065em; }
.presentation-price { margin: 38px 0; }
.presentation-price span { color: var(--muted); font-size: 16px; }
.presentation-price strong { display: block; margin-top: 8px; color: var(--blue); font-size: clamp(50px, 17vw, 78px); letter-spacing: -0.08em; line-height: .9; font-variant-numeric: tabular-nums; }
.presentation-price p { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.presentation-summary { display: grid; margin: 0 0 30px; border-top: 1px solid var(--line); }
.presentation-summary div { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); padding: 13px 0; }
.presentation-summary dt { color: var(--muted); font-size: 15px; }
.presentation-summary dd { margin: 0; color: var(--ink); font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.presentation-summary div:nth-child(2) dd { color: var(--green); }
.presentation-summary div:last-child dt, .presentation-summary div:last-child dd { color: var(--blue); font-weight: 700; }
.presentation-details { display: grid; gap: 11px; }
.presentation-details div { display: flex; justify-content: space-between; color: var(--muted); font-size: 15px; }
.presentation-details strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.presentation-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.presentation-actions button { min-height: 48px; border: 0; border-radius: 13px; background: var(--surface-muted); color: var(--blue); font-size: 15px; font-weight: 650; }
.presentation-actions button:first-child { background: var(--blue); color: #fff; }
.toast { position: fixed; z-index: 50; right: 18px; bottom: calc(86px + var(--safe-bottom)); left: 18px; border-radius: 12px; background: rgba(29,29,31,.92); color: #fff; padding: 13px 15px; text-align: center; font-size: 14px; box-shadow: var(--shadow); }
.update-toast { position: fixed; z-index: 55; right: 18px; bottom: calc(90px + var(--safe-bottom)); left: 18px; border-radius: 12px; background: #1d1d1f; color: #fff; padding: 13px 15px; text-align: center; font-size: 14px; }

@media (min-width: 700px) {
  .app { border-right: 1px solid var(--line); border-left: 1px solid var(--line); box-shadow: 0 0 30px rgba(0,0,0,.04); }
  .quote-summary { right: max(calc(50% - 298px), 18px); left: max(calc(50% - 298px), 18px); }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #000; --surface: #1c1c1e; --surface-muted: #2c2c2e; --surface-pressed: #3a3a3c; --ink: #f5f5f7; --muted: #98989d; --line: #3a3a3c; --blue-soft: #002d5a; --selection-bg: #f5f5f7; --selection-ink: #1d1d1f; --shadow: 0 8px 24px rgba(0,0,0,.35); }
  :root:not([data-theme="light"]) .product-visual { filter: saturate(.76) brightness(.83); }
  :root:not([data-theme="light"]) .segmented { background: #3a3a3c; }
  :root:not([data-theme="light"]) .segmented button.is-active { background: #636366; color: #fff; }
}
:root[data-theme="dark"] { color-scheme: dark; --bg: #000; --surface: #1c1c1e; --surface-muted: #2c2c2e; --surface-pressed: #3a3a3c; --ink: #f5f5f7; --muted: #98989d; --line: #3a3a3c; --blue-soft: #002d5a; --selection-bg: #f5f5f7; --selection-ink: #1d1d1f; --shadow: 0 8px 24px rgba(0,0,0,.35); }
:root[data-theme="dark"] .product-visual { filter: saturate(.76) brightness(.83); }
:root[data-theme="dark"] .segmented { background: #3a3a3c; }
:root[data-theme="dark"] .segmented button.is-active { background: #636366; color: #fff; }
:root[data-contrast="high"] { --line: #6e6e73; --muted: #4d4d52; }
:root[data-contrast="high"][data-theme="dark"] { --line: #a1a1a6; --muted: #d1d1d6; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; } }
