/* SizePulse — hand-rolled, ~5KB, theme via CSS vars (system + Telegram aware) */
:root {
  --bg: #f2f2f7; --card: #ffffff; --ink: #1c1c1e; --muted: #6b7280;
  --line: #e5e7eb; --accent: #0a84ff; --accent-ink: #ffffff;
  --hit: rgba(10, 132, 255, .12); --radius: 14px;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #1c1c1e; --card: #2c2c2e; --ink: #f2f2f7; --muted: #9ca3af;
  --line: #3a3a3c; --hit: rgba(10, 132, 255, .25);
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0 auto; max-width: 720px; padding: 0 16px calc(env(safe-area-inset-bottom, 0px) + 24px);
  background: var(--bg); color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.app-header { padding: 20px 0 8px; }
.app-header h1 { margin: 0; font-size: 28px; letter-spacing: -.5px; }
.app-header h1 span { color: var(--accent); }
.app-header p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

.chiprow { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 999px; padding: 8px 14px; font-size: 15px; cursor: pointer;
  transition: transform .06s ease, background .15s ease;
}
.chip:active { transform: scale(.96); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.segmented .chip { flex: 1; text-align: center; }
.hidden { display: none !important; }

.measure label { display: block; margin: 8px 0 4px; color: var(--muted); font-size: 14px; }
.measure-controls { display: grid; gap: 10px; align-items: center; grid-template-columns: 90px 1fr; }
.measure input[type="number"] {
  width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--ink); font-size: 18px; text-align: center;
}
.measure input[type="range"] { width: 100%; accent-color: var(--accent); }

.adslot { min-height: 0; margin: 8px 0; }

.result-card {
  position: sticky; bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: 0 8px 24px rgba(0,0,0,.12); margin: 12px 0;
}
.result-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.r-primary { font-size: 44px; font-weight: 700; line-height: 1; letter-spacing: -1px; }
.r-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.copy-btn {
  border: 1px solid var(--line); background: transparent; color: var(--accent);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer;
}
.copy-btn.copied { background: var(--accent); color: var(--accent-ink); }
.res-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 8px; margin-top: 12px; }
.res-cell {
  background: var(--bg); border: none; border-radius: 10px; padding: 8px 4px;
  display: grid; gap: 2px; cursor: copy; color: var(--ink);
}
.res-cell span { font-size: 11px; color: var(--muted); }
.res-cell b { font-size: 17px; }

.cn-callout {
  margin: 12px 0 0; padding: 9px 12px; border-radius: 10px; font-size: 13px;
  background: rgba(255, 159, 10, .14); border: 1px solid rgba(255, 159, 10, .45);
}
[data-theme="dark"] .cn-callout { color: #ffd60a; }

.deals { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.deals-title {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 800; letter-spacing: .01em;
}
.deals-title::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--accent); }
.deal-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 50px;
  border-radius: var(--radius); background: var(--bg); border: 1px solid var(--line);
  color: var(--ink); text-decoration: none; font-weight: 600; font-size: 15px;
  transition: transform .06s ease;
}
.deal-btn::before {
  content: ""; width: 26px; height: 26px; flex: none;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
          mask: var(--icon) center / contain no-repeat;
}
.deal-btn:active { transform: scale(.97); }
.deal-btn::after { content: " →"; color: var(--accent); }
.deal-btn.primary {
  grid-column: 1 / -1; border: none; color: #fff; font-size: 17px; font-weight: 700;
  background: linear-gradient(135deg, #0a84ff, #5e5ce6);
  box-shadow: 0 6px 18px rgba(10, 132, 255, .4);
  animation: deal-pop .45s cubic-bezier(.2, 1.4, .4, 1);
}
.deal-btn.primary::after { color: #fff; }
@keyframes deal-pop { from { transform: scale(.85); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .deal-btn.primary { animation: none; } }

.chart-table { overflow-x: auto; margin: 16px 0; }
.size-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.size-table th, .size-table td {
  border: 1px solid var(--line); padding: 7px 10px; text-align: center; white-space: nowrap;
}
.size-table th { background: var(--card); font-weight: 600; position: sticky; top: 0; }
.size-table tr.hit td { background: var(--hit); font-weight: 700; }

.guides h2, .faq h2 { font-size: 20px; margin: 24px 0 12px; letter-spacing: -.3px; }
.guides figure { margin: 0 0 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.guides img { width: 100%; height: auto; display: block; }
.guides figcaption { padding: 10px 14px; font-size: 14px; color: var(--muted); }
.guides figcaption b { color: var(--ink); }

.faq details { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 8px; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { margin: 8px 0 0; color: var(--muted); font-size: 15px; }

.noscript-note { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.app-footer { margin-top: 32px; color: var(--muted); font-size: 13px; text-align: center; }
.app-footer a { color: var(--muted); }

@media (min-width: 900px) {
  body { max-width: 1080px; }
  #app { display: grid; grid-template-columns: minmax(340px, 5fr) 7fr; gap: 28px; align-items: start; }
  #app > nav, #input, #result, #deals, #adslot { grid-column: 1; }
  .chart-table, .guides, .faq { grid-column: 2; }
  .guides figure img { max-height: 220px; object-fit: cover; }
  .result-card { position: static; }
}
