:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c1f24;
  --muted: #646b76;
  --border: #d9dde3;
  --field: #ffffff;
  --accent: #1f6feb;
  --accent-soft: #e8f0fe;
  --ok: #1a7f37;
  --bad: #c62828;
  --warn-bg: #fff4e5;
  --warn-text: #8a4b00;
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --card: #1a1d22;
    --text: #e6e8eb;
    --muted: #9aa1ab;
    --border: #2e333b;
    --field: #14171b;
    --accent: #5b9cff;
    --accent-soft: #1b2a42;
    --ok: #4cc26b;
    --bad: #ff6b6b;
    --warn-bg: #3a2a12;
    --warn-text: #ffc978;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 115%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 0.9375rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 16px 40px; }

/* Header: logo | title | language on the first row; the note under the title (full width on phones) */
.head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "logo title lang" ". sub sub";
  align-items: center;
  column-gap: 12px;
  row-gap: 4px;
}
/* Logo, title line and language dropdown share one height */
.head { --head-h: 36px; }
.head .logo { grid-area: logo; width: var(--head-h); height: var(--head-h); color: var(--accent); }
.head h1 {
  grid-area: title;
  margin: 0;
  font-size: 1.5rem;
  font-weight: 400;
  line-height: var(--head-h);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.head .sub { grid-area: sub; align-self: start; margin: 0; color: var(--muted); font-size: 0.8rem; opacity: 0.8; }
.head .lang { grid-area: lang; height: var(--head-h); }
@media (max-width: 559px) {
  .head { grid-template-areas: "logo title lang" "sub sub sub"; row-gap: 8px; }
  .head h1 { font-size: 1rem; }
}

.head .lang { width: auto; padding: 0 8px; font-size: 0.85rem; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
.btn.done { border-color: var(--ok); color: var(--ok); }

.layout { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr) 360px; }
  .results { position: sticky; top: 16px; }
}

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

/* Form */
.form { display: grid; gap: 14px 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 560px) {
  .form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field.full { grid-column: 1 / -1; }
}

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-weight: 600; font-size: 0.9rem; }
.hint { color: var(--muted); font-size: 0.8rem; font-weight: 400; }

input, select {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--field);
  color: inherit;
  font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
input:disabled, select:disabled { opacity: 0.5; }

.combo { display: flex; gap: 8px; }
.combo > :first-child { flex: 1; }
.combo > select:last-child { width: auto; }
.combo > .short { flex: 0 0 90px; }

/* Results */
.primary {
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--accent-soft);
}
.primary-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.primary-head .label { min-width: 0; }
.primary-head .btn { padding: 4px 10px; font-size: 0.8rem; }

.share { position: relative; flex: none; }
.share-msg {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 1;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
}
.share-msg[hidden] { display: none; }
.primary .label { font-size: 0.85rem; color: var(--muted); }
.primary .big { font-size: 2rem; font-weight: 700; color: var(--accent); line-height: 1.2; }
.primary .note { font-size: 0.85rem; color: var(--muted); }

.msg {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 7px;
  background: var(--warn-bg);
  color: var(--warn-text);
  font-size: 0.85rem;
  white-space: pre-line;
}

.stats { display: grid; gap: 8px; margin: 14px 0 0; }
.stats > div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  column-gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.stats dt { font-size: 0.85rem; color: var(--muted); }
.stats dd { margin: 0; text-align: right; font-size: 1.05rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.stats small { grid-column: 1 / -1; text-align: right; color: var(--muted); font-size: 0.78rem; }

details { margin-top: 14px; }
summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; }
.table-wrap { overflow-x: auto; margin-top: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
th, td { padding: 4px 6px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
tr.pick td { background: var(--accent-soft); font-weight: 700; }
.bad { color: var(--bad); }
.legend { margin: 8px 0 0; color: var(--muted); font-size: 0.75rem; }

