/* Calculixy — calculator.css
   Calculator chrome: panel, inputs, results, buttons, spinners.
   Loaded ONLY on the 38 core calculator pages.
   Requires shared.css tokens (:root vars) to be loaded first.
   Last updated: 2026-06-20
*/

/* ── CALCULATOR AREA ── */
    .calc-area {
      display: grid;
      grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
      grid-template-areas: "calculator guide";
      gap: 20px;
      align-items: start;
      max-width: 1100px;
      margin: 0 auto;
      padding: 0 24px;
    }

    .calculator-column {
      grid-area: calculator;
      align-self: start;
      min-width: 0;
      max-width: 100%;
      overflow: hidden;
      order: 1;
    }

    .guide-sidebar {
      grid-area: guide;
      align-self: start;
      position: static;
      top: auto;
      display: flex;
      flex-direction: column;
      gap: 16px;
      margin-top: 0;
      order: 2;
    }

    @media (max-width: 680px) {
      .calc-area {
        grid-template-columns: 1fr;
        grid-template-areas: "calculator" "guide";
        padding: 0 16px;
      }
      .calculator-column, .guide-sidebar { width: 100%; }
      .guide-sidebar { position: static !important; }
    }

    .guide-panel {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 24px;
      box-shadow: 0 12px 42px rgba(0,0,0,0.14);
    }

    .guide-eyebrow {
      color: var(--accent);
      font-size: 12px;
      font-weight: 800;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      margin-bottom: 10px;
    }

    .guide-panel h2 {
      color: var(--text);
      font-size: clamp(24px, 3vw, 38px);
      line-height: 0.98;
      letter-spacing: -1.4px;
      margin: 0 0 14px;
    }

    .guide-panel p {
      color: var(--text2);
      font-size: 14px;
      line-height: 1.75;
      margin: 0 0 16px;
    }

    .guide-formula {
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      color: var(--text);
      font-family: var(--font-mono);
      font-size: 13px;
      line-height: 1.6;
      padding: 14px;
      margin: 16px 0;
      overflow-x: auto;
    }

    .guide-list {
      display: grid;
      gap: 10px;
      margin: 16px 0;
      padding: 0;
      list-style: none;
    }

    .guide-list li {
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 12px;
      color: var(--text2);
      font-size: 13px;
      line-height: 1.55;
      padding: 11px 12px;
    }

    .guide-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      margin-top: 18px;
    }

    .guide-actions a, .guide-actions button {
      background: rgba(16,185,129,0.10);
      border: 1px solid rgba(16,185,129,0.35);
      border-radius: 999px;
      color: var(--accent);
      cursor: pointer;
      font-family: var(--font-display);
      font-size: 12px;
      font-weight: 800;
      padding: 10px 14px;
      text-decoration: none;
      width: auto;
    }

    .mini-related {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
      margin-top: 12px;
    }

    .mini-related a {
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 12px;
      color: var(--text2);
      font-size: 12px;
      line-height: 1.35;
      padding: 11px;
      text-decoration: none;
    }

    .mini-related a:hover { color: var(--accent); border-color: var(--accent); }

    /* ── CALC PANEL ── */
    .calc-panel {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      overflow: hidden;
      animation: none;
    }

    @keyframes fadeUp {
      from { opacity: 0; transform: translateY(12px); }
      to { opacity: 1; transform: translateY(0); }
    }

    .calc-header {
      padding: 20px 24px 16px;
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: center;
      gap: 12px;
    }

    .calc-header-icon { font-size: 22px; }

    .calc-title {
      font-size: 18px;
      font-weight: 800;
      letter-spacing: -0.5px;
    }

    .calc-subtitle {
      font-size: 12px;
      color: var(--text3);
      font-weight: 400;
      margin-top: 2px;
    }

    /* ── DISPLAY ── */
    .display {
      background: var(--bg);
      margin: 20px 20px 0;
      border-radius: var(--radius-sm);
      padding: 16px 20px;
      border: 1px solid var(--border);
      text-align: right;
      min-height: 88px;
      display: flex;
      flex-direction: column;
      justify-content: flex-end;
    }

    .display-expr {
      font-family: var(--font-mono);
      font-size: 13px;
      color: var(--text3);
      min-height: 20px;
      word-break: break-all;
    }

    .display-val {
      font-family: var(--font-mono);
      font-size: 36px;
      font-weight: 500;
      color: var(--text);
      letter-spacing: -1px;
      line-height: 1.1;
      word-break: break-all;
      transition: color 0.15s;
    }

    .display-val.updated { color: var(--accent); }

    /* ── BUTTON GRID ── */
    .btn-grid {
      display: grid;
      gap: 8px;
      padding: 16px 20px 20px;
    }

    .btn-grid-standard { grid-template-columns: repeat(4, 1fr); }
    .btn-grid-scientific { grid-template-columns: repeat(5, 1fr); }

    .btn {
      height: 56px;
      border: none;
      border-radius: var(--radius-sm);
      font-family: var(--font-display);
      font-size: 16px;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.1s;
      position: relative;
      overflow: hidden;
      user-select: none;
      -webkit-user-select: none;
      -webkit-tap-highlight-color: transparent;
    }

    .btn:active { transform: scale(0.94); }

    .btn-num {
      background: var(--surface2);
      color: var(--text);
      border: 1px solid var(--border);
    }

    .btn-num:hover { background: #252535; border-color: var(--text3); }

    .btn-op {
      background: rgba(129,140,248,0.12);
      color: var(--accent2);
      border: 1px solid rgba(129,140,248,0.2);
    }

    .btn-op:hover { background: rgba(129,140,248,0.2); }

    .btn-fn {
      background: var(--surface2);
      color: var(--text2);
      border: 1px solid var(--border);
      font-size: 13px;
    }

    .btn-fn:hover { color: var(--text); background: #252535; }

    .btn-clear {
      background: rgba(248,113,113,0.1);
      color: var(--red);
      border: 1px solid rgba(248,113,113,0.2);
    }

    .btn-clear:hover { background: rgba(248,113,113,0.2); }

    .btn-equals {
      background: var(--accent);
      color: #0a0a0f;
      border: none;
      font-size: 20px;
    }

    .btn-equals:hover { background: #0ea271; box-shadow: 0 0 20px rgba(16,185,129,0.3); }

    .btn-zero { grid-column: span 2; }

    /* ── FORM INPUTS (health/age/%) ── */
    .calc-form {
      padding: 20px;
      display: flex;
      flex-direction: column;
      gap: 16px;
    }

    .form-row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 12px;
    }

    .form-group {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .form-group label {
      font-size: 12px;
      font-weight: 600;
      color: var(--text2);
      letter-spacing: 0.5px;
      text-transform: uppercase;
    }

    .form-group input,
    .form-group select {
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      color: var(--text);
      font-family: var(--font-mono);
      font-size: 16px;
      padding: 12px 14px;
      outline: none;
      transition: border-color 0.15s;
      width: 100%;
      -webkit-appearance: none;
    }

    .form-group input:focus,
    .form-group select:focus { border-color: var(--accent); }

    .form-group select option { background: var(--surface2); }

    .calc-btn-primary {
      background: var(--accent);
      color: #0a0a0f;
      border: none;
      border-radius: var(--radius-sm);
      font-family: var(--font-display);
      font-size: 15px;
      font-weight: 700;
      padding: 14px;
      cursor: pointer;
      transition: all 0.15s;
    }

    .calc-btn-primary:hover {
      background: #0ea271;
      box-shadow: 0 0 24px rgba(16,185,129,0.25);
    }

    /* ── RESULT CARDS ── */
    .result-box {
      background: var(--bg);
      border: 1px solid var(--accent);
      border-radius: var(--radius-sm);
      padding: 20px;
      text-align: center;
      box-shadow: 0 0 30px rgba(16,185,129,0.08);
    }

    .result-label {
      font-size: 11px;
      font-weight: 600;
      letter-spacing: 1.5px;
      text-transform: uppercase;
      color: var(--text3);
      margin-bottom: 8px;
    }

    .result-value {
      font-family: var(--font-mono);
      font-size: 32px;
      font-weight: 500;
      color: var(--accent);
      letter-spacing: -1px;
    }

    .result-sub {
      font-size: 13px;
      color: var(--text3);
      margin-top: 6px;
    }

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

    .result-grid .result-box {
      border-color: var(--border);
    }

    .result-grid .result-box .result-value {
      font-size: 22px;
      color: var(--accent2);
    }

    /* ── CURRENCY SPECIFIC ── */
    .currency-swap-row {
      display: flex;
      align-items: flex-end;
      gap: 10px;
    }

    .currency-swap-row .form-group { flex: 1; }

    .swap-btn {
      background: var(--surface, #fff);
      border: 1px solid var(--border, #dfe2f2);
      border-radius: 10px;
      color: var(--text2, #50546a);
      cursor: pointer;
      font-size: 18px;
      height: 46px;
      width: 46px;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: all 0.15s;
      box-shadow: inset 0 1px 0 rgba(255,255,255,.9), 0 2px 0 0 #c8cbdf, 0 1px 3px rgba(9,9,27,.08);
      flex-shrink: 0;
      margin-bottom: 0;
    }

    .swap-btn:hover { color: var(--accent, #10b981); border-color: rgba(16,185,129,.3); }
    .swap-btn:active { transform: translateY(2px); box-shadow: 0 0 0 0 transparent, 0 1px 1px rgba(9,9,27,.06); }

    .swap-btn:hover { color: var(--accent); border-color: var(--accent); transform: rotate(180deg); }

    /* Result-action visibility gate: actions unlock only after validated outputs exist. */
    .calc-action-bar:not([data-cx-results-ready="true"]),
    .cx-action-bar:not([data-cx-results-ready="true"]),
    .result-actions:not([data-cx-results-ready="true"]),
    .calc-action-bar[data-cx-results-ready="false"],
    .cx-action-bar[data-cx-results-ready="false"],
    .result-actions[data-cx-results-ready="false"] {
      display: none !important;
      pointer-events: none;
    }

    .calc-action-bar[data-cx-results-ready="true"],
    .cx-action-bar[data-cx-results-ready="true"],
    .result-actions[data-cx-results-ready="true"] {
      pointer-events: auto;
    }

    /* ── RESULT ACTION BAR ── */
    .calc-action-bar,
    .cx-action-bar,
    .result-actions {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-top: 12px;
      flex-wrap: wrap;
      width: 100%;
    }

    .calc-action-bar .action-btn,
    .cx-action-bar button,
    .result-actions .result-action-btn,
    .result-action-btn {
      appearance: none;
      -webkit-appearance: none;
      background: var(--surface, #fff);
      border: 1px solid var(--border, #dfe2f2);
      border-radius: var(--radius-sm, 10px);
      color: var(--text2, #50546a);
      font-family: var(--font-display, system-ui, sans-serif);
      font-size: 12px;
      font-weight: 700;
      line-height: 1.15;
      min-height: 42px;
      min-width: 104px;
      padding: 8px 14px 9px;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      text-align: center;
      text-decoration: none;
      white-space: nowrap;
      flex: 1 1 112px;
      position: relative;
      transform: translateY(0);
      user-select: none;
      -webkit-user-select: none;
      box-shadow:
        inset 0 1px 0 rgba(255,255,255,.9),
        0 3px 0 0 #c8cbdf,
        0 2px 6px rgba(9,9,27,.08);
      transition:
        transform .1s ease,
        box-shadow .1s ease,
        background .15s ease,
        color .15s ease,
        border-color .15s ease;
    }

    .calc-action-bar .action-btn:hover,
    .cx-action-bar button:hover,
    .result-actions .result-action-btn:hover,
    .result-action-btn:hover {
      color: var(--text, #09091b);
      border-color: rgba(9,9,27,.18);
      box-shadow:
        inset 0 1px 0 rgba(255,255,255,.9),
        0 4px 0 0 #b8bbcf,
        0 4px 10px rgba(9,9,27,.10);
      transform: translateY(-1px);
    }

    .calc-action-bar .action-btn:focus-visible,
    .cx-action-bar button:focus-visible,
    .result-actions .result-action-btn:focus-visible,
    .result-action-btn:focus-visible {
      outline: none;
      color: var(--text, #09091b);
      border-color: var(--accent, #10b981);
      box-shadow:
        0 0 0 3px rgba(16,185,129,.18),
        inset 0 1px 0 rgba(255,255,255,.9),
        0 3px 0 0 #c8cbdf,
        0 2px 6px rgba(9,9,27,.08);
    }

    .calc-action-bar .action-btn:active,
    .cx-action-bar button:active,
    .result-actions .result-action-btn:active,
    .result-action-btn:active {
      opacity: 1;
      transform: translateY(2px);
      box-shadow:
        inset 0 1px 0 rgba(255,255,255,.7),
        0 1px 0 0 #c8cbdf,
        0 1px 3px rgba(9,9,27,.06);
    }

    .calc-action-bar .action-btn.done,
    .cx-action-bar button.cx-done,
    .result-action-btn.copied {
      color: var(--accent, #10b981);
      border-color: var(--accent, #10b981);
      background: rgba(16,185,129,0.08);
    }

    @media (max-width: 520px) {
      .calc-action-bar .action-btn,
      .cx-action-bar button,
      .result-actions .result-action-btn,
      .result-action-btn {
        flex-basis: calc(50% - 8px);
        min-width: 0;
        padding-inline: 10px;
      }
    }

    @media (max-width: 360px) {
      .calc-action-bar .action-btn,
      .cx-action-bar button,
      .result-actions .result-action-btn,
      .result-action-btn {
        flex-basis: 100%;
      }
    }


    /* ── LOCAL SAVED RESULTS ── */
    .cx-saved-results {
      margin: 16px 0;
      padding: 14px;
      background: var(--surface, #fff);
      border: 1px solid var(--border, #dfe2f2);
      border-radius: var(--radius, 14px);
      box-shadow: 0 4px 16px rgba(9,9,27,.06);
    }

    .cx-saved-results[hidden] {
      display: none !important;
    }

    .cx-saved-results-title {
      margin: 0 0 10px;
      color: var(--text, #09091b);
      font-family: var(--font-display, system-ui, sans-serif);
      font-size: 15px;
      font-weight: 800;
      letter-spacing: -0.01em;
    }

    .cx-saved-results-list {
      display: grid;
      gap: 10px;
    }

    .cx-saved-result-card {
      padding: 12px;
      background: var(--surface2, rgba(9,9,27,.025));
      border: 1px solid var(--border, #dfe2f2);
      border-radius: var(--radius-sm, 10px);
    }

    .cx-saved-result-meta {
      margin-bottom: 6px;
      color: var(--text3, #777b91);
      font-family: var(--font-display, system-ui, sans-serif);
      font-size: 12px;
      font-weight: 700;
    }

    .cx-saved-result-preview {
      margin: 0;
      color: var(--text2, #50546a);
      font-size: 13px;
      line-height: 1.45;
      max-height: 5.8em;
      overflow: hidden;
    }

    .cx-saved-results-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-top: 10px;
    }

    .cx-saved-results-actions .result-action-btn {
      flex: 0 1 auto;
      min-height: 36px;
      min-width: 86px;
      padding: 7px 12px 8px;
    }
    #back-to-top {
      position: fixed; bottom: 80px; right: 20px; z-index: 200;
      background: var(--surface); border: 1px solid var(--border);
      border-radius: 50%; width: 44px; height: 44px;
      display: flex; align-items: center; justify-content: center;
      cursor: pointer; font-size: 18px; color: var(--text2);
      opacity: 0; transform: translateY(12px);
      transition: all 0.25s; pointer-events: none;
      box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    }
    #back-to-top.visible { opacity: 1; transform: translateY(0); pointer-events: all; }
    #back-to-top:hover { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 16px rgba(16,185,129,0.2); }

    /* ── INPUT VALIDATION ── */
    input.input-error { border-color: var(--red) !important; box-shadow: 0 0 0 2px rgba(248,113,113,0.15); }
    .input-error-msg { font-size: 13px; color: var(--red); margin-top: 4px; font-weight: 600; }

    /* ── SPINNER ── */
    .cur-loading { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text3); padding: 12px 0; }
    .spinner { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; flex-shrink: 0; }
    @keyframes spin { to { transform: rotate(360deg); } }

    /* ── HIDDEN SECTIONS ── */
    .tool-section { display: none; }
    .tool-section.active { display: block; animation: none; }

    /* ── RADIO TABS ── */
    .tab-row {
      display: flex;
      gap: 6px;
      padding: 0 20px 16px;
    }

    .tab-btn {
      background: var(--surface, #fff);
      border: 1px solid var(--border, #dfe2f2);
      border-radius: 9px;
      color: var(--text2, #50546a);
      font-family: var(--font-display, system-ui, sans-serif);
      font-size: 12px;
      font-weight: 700;
      padding: 7px 15px;
      cursor: pointer;
      transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.15s, color 0.15s, border-color 0.15s;
      box-shadow: inset 0 1px 0 rgba(255,255,255,.9), 0 2px 0 0 #c8cbdf, 0 1px 2px rgba(9,9,27,.07);
      user-select: none;
      -webkit-user-select: none;
      position: relative;
    }

    .tab-btn:hover {
      color: var(--text, #09091b);
      border-color: rgba(9,9,27,.18);
      box-shadow: inset 0 1px 0 rgba(255,255,255,.9), 0 3px 0 0 #b8bbcf, 0 2px 4px rgba(9,9,27,.1);
    }

    .tab-btn:active {
      transform: translateY(2px);
      box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 0 0 0 transparent, 0 1px 1px rgba(9,9,27,.08);
    }

    .tab-btn.active {
      background: rgba(16,185,129,.1);
      border-color: rgba(16,185,129,.4);
      color: var(--accent, #10b981);
      box-shadow: inset 0 1px 0 rgba(255,255,255,.9), 0 2px 0 0 rgba(16,185,129,.25), 0 1px 2px rgba(9,9,27,.06);
    }

    .tab-btn.active:active {
      transform: translateY(2px);
      box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 0 0 0 transparent;
    }

    