:root {
  --bg: #f8f9fb;
  --surface: #ffffff;
  --text: #1a1d23;
  --muted: #5b6574;
  --accent: #2b6cb0;
  --accent-light: #ebf4ff;
  --success: #276749;
  --danger: #c53030;
  --warning: #c05621;
  --border: #d1d5db;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
  --radius: 12px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.skip-link {
  position: absolute;
  left: -9999px;
  z-index: 100;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: white;
  text-decoration: none;
  border-radius: 0 0 4px 0;
}

.skip-link:focus {
  left: 0;
}

header.site {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.1rem;
}

.brand small {
  display: block;
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--muted);
}

.mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) 0deg 270deg, var(--border) 270deg);
  display: inline-block;
}

.privacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--success);
  background: #e8f5e9;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-weight: 600;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.intro h1 {
  font-size: 1.75rem;
  line-height: 1.2;
  margin: 0 0 0.5rem;
}

.intro p {
  color: var(--muted);
  margin: 0;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
}

.card h3 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1rem;
}

.field {
  margin-bottom: 1.25rem;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
}

.dropzone {
  display: block;
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  color: var(--muted);
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.dropzone input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.35rem 0 0;
}

input[type="number"] {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}

.consent {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

.consent input {
  margin-top: 0.25rem;
  flex-shrink: 0;
}

.consent label {
  margin: 0;
  font-weight: 500;
  line-height: 1.4;
}

.row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

button {
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#estimate {
  background: var(--accent);
  color: white;
}

#estimate:hover:not(:disabled) {
  background: #1e4e8c;
}

.secondary {
  background: #e5e7eb;
  color: var(--text);
}

.secondary:hover:not(:disabled) {
  background: #d1d5db;
}

.sample-row select {
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 1rem;
}

.recommendation {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.size-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--accent-light);
  border: 2px solid var(--accent);
  border-radius: 12px;
  min-width: 110px;
  padding: 0.75rem 1.25rem;
}

.size-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.size-value {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}

.confidence {
  flex: 1;
  min-width: 160px;
}

.confidence-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}

.confidence-bar {
  height: 10px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.confidence-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--warning), var(--success));
  border-radius: 999px;
  transition: width 0.4s ease;
}

.measure-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

.measure-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border-radius: 8px;
  gap: 0.75rem;
}

.measure-name {
  font-weight: 600;
  flex: 1;
}

.measure-value {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.1rem;
}

.measure-value .unit {
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--muted);
  margin-left: 0.15rem;
}

.measure-range {
  font-size: 0.85rem;
  color: var(--muted);
  min-width: 110px;
  text-align: right;
}

.explain p {
  margin: 0;
  color: var(--muted);
}

.result-error {
  border-left: 4px solid var(--danger);
  background: #fff5f5;
  padding: 1rem;
  border-radius: 0 8px 8px 0;
}

.result-error strong {
  color: var(--danger);
  display: block;
  margin-bottom: 0.25rem;
}

.result-error p {
  margin: 0;
  color: var(--muted);
}

.learn-state {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.75rem 0 0;
}

footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.toast {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 50;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 480px) {
  .recommendation {
    flex-direction: column;
    align-items: flex-start;
  }
  .size-card {
    width: 100%;
  }
  .measure-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
  .measure-range {
    text-align: left;
  }
}
