:root {
  --bg: #f3f6fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --border: #dbe3ef;
  --primary: #2558ff;
  --primary-hover: #1f44c9;
  --primary-active: #1737a8;
  --secondary-bg: #eef2ff;
  --warning: #8a2d00;
  --danger: #b42318;
  --danger-bg: #fff1f1;
  --note: #2d3a4d;
  --shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
  --shadow-strong: 0 12px 28px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #eef3ff 0%, var(--bg) 38%);
}

.site-shell {
  max-width: 860px;
  margin: 0 auto;
  padding: 14px 16px 0;
}

.topbar {
  margin-bottom: 8px;
}

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(22px, env(safe-area-inset-bottom));
  display: grid;
  gap: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.card.small {
  box-shadow: var(--shadow);
}

.card[aria-live="polite"] {
  border-color: #c9d9f7;
  box-shadow: var(--shadow-strong);
}

h1,
h2 {
  margin: 0 0 10px;
  line-height: 1.2;
}

h1 {
  font-size: clamp(1.55rem, 2.2vw + 0.9rem, 2.2rem);
}

h2 {
  font-size: clamp(1.05rem, 1.2vw + 0.85rem, 1.25rem);
}

h3 {
  margin: 14px 0 6px;
  font-size: 0.98rem;
  line-height: 1.3;
}

h3 + p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

h3:not(:first-of-type) {
  padding-top: 10px;
  border-top: 1px solid #e8edf5;
}

.subtitle {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.45;
}

.trust-bullets {
  margin: 0 0 14px;
  padding-left: 18px;
  color: var(--muted);
  display: grid;
  gap: 4px;
  font-size: 0.92rem;
}

.card > p > a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--muted);
  background: #eef2ff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 600;
  font-size: 0.9rem;
}

.card > p > a:hover {
  color: var(--text);
}

.field {
  margin-bottom: 12px;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

input,
select,
button {
  width: 100%;
  min-height: 46px;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 11px 12px;
  font: inherit;
}

input,
select {
  font-size: 16px;
  background: #fff;
}

input:focus,
select:focus,
button:focus {
  outline: 3px solid rgba(11, 95, 255, 0.2);
  outline-offset: 1px;
}

.input-error {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.input-error:focus {
  outline: 3px solid rgba(180, 35, 24, 0.22);
}

.hint,
.example {
  margin: 6px 2px 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.error {
  margin: 6px 2px 0;
  color: var(--danger);
  font-size: 0.9rem;
  line-height: 1.35;
}

.error.summary {
  padding: 8px 10px;
  border: 1px solid #f0c2c0;
  border-radius: 8px;
  background: var(--danger-bg);
}

.actions {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.preset-btn {
  width: auto;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f7f9fd;
  color: var(--text);
  font-weight: 600;
}

.share-btn {
  margin-top: 8px;
}

button {
  border: none;
  background: var(--primary);
  color: white;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

button:hover {
  background: var(--primary-hover);
}

button:active {
  background: var(--primary-active);
  transform: translateY(1px);
}

button.secondary {
  background: var(--secondary-bg);
  color: var(--text);
  border: 1px solid var(--border);
}

button.secondary:hover {
  background: #e2e8f2;
}

button.secondary:active {
  background: #d7e0ee;
}

button.preset-btn {
  background: #f7f9fd;
  color: var(--text);
  border: 1px solid var(--border);
}

button.preset-btn:hover {
  background: #ebf1fa;
}

button.preset-btn:active {
  background: #e3ebf8;
  transform: none;
}

.result-timestamp {
  margin-top: -2px;
  margin-bottom: 10px;
}

.result-meter {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e8edf5;
  overflow: hidden;
  margin-bottom: 12px;
}

.result-meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2ab673 0%, #1f8f58 100%);
  transition: width 180ms ease;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.result-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.result-value {
  margin: 4px 0 0;
  font-size: clamp(1.16rem, 1.4vw + 0.95rem, 1.38rem);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.note {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #edf3ff;
  color: var(--note);
  font-size: 0.92rem;
  line-height: 1.35;
}

.note.warning {
  background: #fff2eb;
  color: var(--warning);
}

.runtime-wrap {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #e8edf5;
}

.runtime-label {
  margin-bottom: 6px;
}

.hidden {
  display: none;
}

.product-card {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #f9fbff;
}

.product-image {
  width: 100%;
  max-width: 160px;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  object-fit: cover;
}

.product-content {
  display: grid;
  gap: 10px;
}

.product-title {
  margin: 0;
  font-weight: 700;
  line-height: 1.3;
}

.product-message {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.affiliate-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #0a4fd1;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  width: fit-content;
}

.affiliate-button:hover {
  background: #083fa7;
}

.affiliate-button:focus {
  outline: 3px solid rgba(10, 79, 209, 0.2);
  outline-offset: 2px;
}

.affiliate-disclosure {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.35;
}

.affiliate-card {
  background: #fbfdff;
}

.faq-item {
  border: 1px solid #e8edf5;
  border-radius: 10px;
  padding: 0 10px;
  background: #fff;
}

.faq-item + .faq-item {
  margin-top: 8px;
}

.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  padding: 10px 0;
  list-style: none;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "+";
  float: right;
  color: var(--muted);
}

.faq-item[open] summary::after {
  content: "−";
}

.faq-item p {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.45;
}

@media (max-width: 380px) {
  .container {
    padding: max(10px, env(safe-area-inset-top)) 10px max(14px, env(safe-area-inset-bottom));
    gap: 10px;
  }

  .card {
    padding: 12px;
    border-radius: 12px;
  }

  .subtitle {
    margin-bottom: 12px;
  }

  .field {
    margin-bottom: 10px;
  }

  .actions {
    gap: 8px;
    margin-top: 10px;
  }

  .result-grid {
    gap: 8px;
  }
}

@media (min-width: 640px) {
  .container {
    padding: 20px;
    gap: 16px;
  }

  .card {
    padding: 18px;
  }

  .actions {
    grid-template-columns: 1fr 1fr;
  }

  .result-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }

  .product-card {
    grid-template-columns: 170px 1fr;
    align-items: center;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .container {
    gap: 10px;
  }

  .card {
    padding: 12px;
  }

  .actions {
    grid-template-columns: 1fr 1fr;
  }
}
