/* Calculators and generators. Only theme tokens from style.css, so day and night mode both work. */
.calc .panel-body { padding: 22px; }
.c-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 26px; align-items: start; }
.c-inputs { display: grid; gap: 18px; min-width: 0; }

/* Mode and shape choices: pills that wrap instead of scrolling. */
.c-modes { display: flex; flex-wrap: wrap; gap: 6px; }
.c-modes button {
  min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font-weight: 600; font-size: 0.9rem; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; text-align: left; line-height: 1.2;
}
.c-modes button:hover { color: var(--fg); border-color: var(--accent); }
.c-modes button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--fg); }
.c-modes button svg { width: 18px; height: 18px; flex: none; }
.c-modes.c-small button { min-height: 34px; padding: 0 12px; font-size: 0.86rem; }

/* A sentence with number boxes in it: "What is [ ] % of [ ] ?" */
.c-sentence { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 10px; font-size: 1.12rem; line-height: 1.3; }
.c-sentence > span { white-space: nowrap; }

.c-num {
  display: inline-flex; align-items: center; min-height: 48px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); padding: 0 12px; gap: 6px; min-width: 0;
}
.c-num:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.c-num:has(input[aria-invalid="true"]) { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.c-num input {
  border: 0; outline: none; background: transparent; min-width: 0; width: 7.5ch; font-size: 1.1rem;
  font-variant-numeric: tabular-nums; padding: 0; height: 46px;
}
.c-num.c-wide input { width: 100%; }
.c-num .c-aff { color: var(--muted); font-size: 0.98rem; white-space: nowrap; }
.c-sentence .c-num input { width: 8ch; }

.c-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.c-fields .field { min-width: 0; }
.c-fields .c-num { width: 100%; }
.c-fields .c-num input { width: 100%; }
.c-sym { font-family: var(--font-display); font-style: italic; color: var(--accent-strong); font-weight: 700; }

.c-row2 { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: end; }
.c-row2 .select { min-height: 44px; }

/* Result */
.c-result {
  display: grid; gap: 12px; align-content: start; min-height: 150px; padding: 20px; border-radius: 18px;
  background: var(--accent-soft); border: 1px solid var(--line); min-width: 0;
}
.c-result.is-empty { background: var(--bg); }
.c-result.is-error { background: var(--danger-soft); }
.c-hint { color: var(--muted); }
.c-err { color: var(--danger); font-weight: 600; }
.c-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.c-row + .c-row { padding-top: 10px; border-top: 1px solid var(--line); }
.c-rl { display: grid; gap: 1px; min-width: 0; }
.c-lab { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.c-val { font-variant-numeric: tabular-nums; font-size: 1.15rem; font-weight: 650; overflow-wrap: anywhere; }
.c-main .c-val { font-family: var(--font-display); font-size: clamp(1.7rem, 4vw, 2.2rem); font-weight: 700; color: var(--accent-strong); line-height: 1.15; }
.c-sub { font-size: 0.9rem; color: var(--muted); }
.c-copy { flex: none; }
.c-copy.is-copied { border-color: var(--accent); color: var(--accent-strong); }
.c-formula { font-size: 0.92rem; color: var(--fg); overflow-wrap: anywhere; padding-top: 10px; border-top: 1px solid var(--line); }
.c-formula span { display: inline-block; margin-right: 6px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.c-note { font-size: 0.88rem; color: var(--muted); }
.c-more { font-size: 0.92rem; }
.c-more summary { cursor: pointer; color: var(--accent-strong); font-weight: 600; padding: 4px 0; }
.c-more table { border-collapse: collapse; width: 100%; margin-top: 6px; font-variant-numeric: tabular-nums; }
.c-more td { padding: 5px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.c-more td:last-child { text-align: right; color: var(--muted); padding-left: 10px; }

/* Shape diagrams */
.c-diagram { display: grid; place-items: center; padding: 10px; border-radius: 16px; background: var(--bg); border: 1px solid var(--line); }
.c-diagram svg { width: 100%; max-width: 300px; height: auto; display: block; overflow: visible; }
.d-shape { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2.2; stroke-linejoin: round; }
.d-hole { fill: var(--bg); stroke: var(--accent); stroke-width: 2.2; }
.d-hi { fill: none; stroke: var(--accent-strong); stroke-width: 4; stroke-linecap: round; }
.d-dim { stroke: var(--muted); stroke-width: 1.3; stroke-dasharray: 4 3; fill: none; }
.d-solid { stroke: var(--muted); stroke-width: 1.3; fill: none; }
.d-dot { fill: var(--muted); }
.d-lab { paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round; fill: var(--fg); font-size: 13px; font-family: var(--font-body); font-weight: 600; }
.d-lab .d-v { fill: var(--muted); font-weight: 500; }

/* VAT rate chips */
.c-rates { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.c-rates button {
  display: grid; gap: 0; justify-items: start; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: transparent; cursor: pointer; text-align: left; min-height: 52px; color: var(--fg);
}
.c-rates button strong { font-size: 1.02rem; font-variant-numeric: tabular-nums; }
.c-rates button span { font-size: 0.78rem; color: var(--muted); line-height: 1.25; }
.c-rates button:hover { border-color: var(--accent); }
.c-rates button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }

/* QR code */
.q-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 20px 26px; align-items: start; }
.q-grid > .q-form:first-child { grid-column: 1; grid-row: 1; }
.q-grid > .q-opts { grid-column: 1; grid-row: 2; }
.q-grid > .q-side { grid-column: 2; grid-row: 1 / span 2; }
.q-form { display: grid; gap: 14px; min-width: 0; }
.q-form .input, .q-form textarea { width: 100%; min-width: 0; }
.q-form textarea { min-height: 96px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); resize: vertical; }
.q-form .input:focus, .q-form textarea:focus, .q-form .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.q-form .input[aria-invalid="true"] { border-color: var(--danger); }
.q-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.q-check { display: flex; align-items: center; gap: 9px; font-size: 0.95rem; cursor: pointer; min-height: 32px; }
.q-check input { width: 18px; height: 18px; accent-color: var(--accent); }
.q-opts { border-top: 1px solid var(--line); padding-top: 16px; display: grid; gap: 14px; }
.q-opts h2 { font-size: 1.05rem; font-weight: 650; }
.q-colors { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: end; }
.q-color { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 10px 0 5px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }
.q-color input[type="color"] { width: 32px; height: 32px; border: 0; padding: 0; background: none; cursor: pointer; border-radius: 6px; }
.q-color input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.q-color input[type="color"]::-webkit-color-swatch { border: 1px solid var(--line); border-radius: 6px; }
.q-color code { font-size: 0.88rem; color: var(--muted); }
.q-range { display: flex; align-items: center; gap: 10px; }
.q-range input { width: 140px; accent-color: var(--accent); }
.q-side { display: grid; gap: 14px; position: sticky; top: 14px; min-width: 0; }
.q-preview {
  display: grid; place-items: center; aspect-ratio: 1; width: 100%; max-width: 340px; justify-self: center;
  border-radius: 18px; background: var(--bg); border: 1px solid var(--line); padding: 14px;
}
.q-preview svg { width: 100%; height: 100%; display: block; border-radius: 6px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); }
.q-preview .c-hint { text-align: center; padding: 20px; }
.q-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.q-warn { display: flex; gap: 9px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--danger-soft); color: var(--fg); font-size: 0.9rem; }
.q-warn svg { width: 18px; height: 18px; color: var(--danger); flex: none; margin-top: 2px; }
.q-err { color: var(--danger); font-weight: 600; text-align: center; padding: 20px; }
.q-meta { text-align: center; color: var(--muted); font-size: 0.86rem; }
.q-content summary { cursor: pointer; color: var(--accent-strong); font-weight: 600; font-size: 0.92rem; }
.q-content pre { margin: 8px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); font-size: 0.82rem; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 200px; overflow: auto; }
.q-pw { position: relative; }
.q-pw .input { padding-right: 70px; }
.q-pw button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }

@media (max-width: 800px) {
  .c-grid, .q-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .q-side { position: static; }
  .q-grid > .q-form:first-child, .q-grid > .q-opts, .q-grid > .q-side { grid-column: 1; grid-row: auto; }
}
@media (max-width: 720px) {
  .calc .panel-body { padding: 16px; }
  .c-sentence { font-size: 1.05rem; }
  .c-result { padding: 16px; }
}
