/* ==========================================================================
   Theme and app shell
   ========================================================================== */
:root{
      --navy:#0d243f;
      --navy2:#102b4c;
      --gold:#d4a017;
      --cream:#f8f6ef;
      --card:#ffffff;
      --text:#0d243f;
      --muted:#667085;
      --line:#d9d6cc;
      --input:#ffffff;
      --soft:#f3f0e8;
      --green:#15803d;
      --red:#b42318;
    }

    body.dark{
      --cream:#071423;
      --card:#0f2136;
      --text:#f8fafc;
      --muted:#cbd5e1;
      --line:#2f4158;
      --input:#10243b;
      --soft:#122b46;
    }
    body.dark header{
      background:#06111f;
      color:#fff;
    }
    body.dark h2,
    body.dark label{
      color:#f8fafc;
    }
    body.dark input,
    body.dark select,
    body.dark textarea,
    body.dark .calc-display{
      background:#10243b;
      color:#f8fafc;
      border-color:#3d526c;
    }
    body.dark .result,
    body.dark .history-empty{
      background:rgba(255,255,255,.045);
      border-color:#38506b;
      color:#cbd5e1;
    }
    body.dark .history-item{
      background:#0b1a2c;
      color:#f8fafc;
      border-color:#33465f;
    }
    body.dark button.secondary,
    body.dark .preset,
    body.dark .calc-key,
    body.dark .calc-key.clear,
    body.dark .calc-key.op{
      background:#1b3656;
      color:#f8fafc;
      border-color:#38506b;
    }
    body.dark .small,
    body.dark .calc-expression{
      color:#cbd5e1;
    }
    .header-actions{
      display:flex;
      justify-content:flex-end;
      margin-top:18px;
    }

    .theme-switch{
      position:relative;
      display:flex;
      align-items:center;
      gap:10px;
      user-select:none;
      font-weight:700;
      color:#fff;
    }
    .theme-switch input{
      position:absolute;
      width:1px;
      height:1px;
      margin:-1px;
      padding:0;
      border:0;
      overflow:hidden;
      clip:rect(0 0 0 0);
      clip-path:inset(50%);
      white-space:nowrap;
    }
    .theme-switch input:focus-visible + .theme-slider{
      outline:3px solid var(--gold);
      outline-offset:3px;
    }
    .theme-slider{
      position:relative;
      width:52px;
      height:30px;
      border-radius:999px;
      background:rgba(255,255,255,.22);
      border:1px solid rgba(255,255,255,.18);
      transition:.25s ease;
      cursor:pointer;
      flex:0 0 52px;
    }
    .theme-slider::before{
      content:'';
      position:absolute;
      top:3px;
      left:3px;
      width:22px;
      height:22px;
      border-radius:50%;
      background:#fff;
      transition:.25s ease;
      box-shadow:0 2px 6px rgba(0,0,0,.25);
    }
    .theme-switch input:checked + .theme-slider{
      background:var(--gold);
    }
    .theme-switch input:checked + .theme-slider::before{
      transform:translateX(22px);
      background:#fff;
    }
    .theme-label{
      font-size:.95rem;
      color:#f3f4f6;
    }


    /* Calculator cards and shared controls */
    .calc-title{
      display:flex;
      align-items:center;
      gap:10px;
    }
    .calc-icon{
      transition:transform .18s ease;
      width:38px;
      height:38px;
      border-radius:14px;
      background:#f8f6ef;
      color:var(--navy);
      display:inline-flex;
      align-items:center;
      justify-content:center;
      flex:0 0 38px;
      border:1.5px solid #d8d2c5;
      box-shadow:0 2px 8px rgba(13,36,63,.06);
    }
    .calc-icon svg{
      width:21px;
      height:21px;
      stroke:currentColor;
      stroke-width:2;
      fill:none;
      stroke-linecap:round;
      stroke-linejoin:round;
    }
    body.dark .calc-icon{
      background:#10243b;
      border-color:#38506b;
      color:#f8fafc;
    }


    *{box-sizing:border-box}
    body{
      margin:0;
      font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
      background:var(--cream);
      color:var(--text);
    }
    header{
      padding:26px 28px 28px;
      background:var(--navy);
      color:#fff;
      border-bottom:7px solid var(--gold);
    }
    .brand-lockup{
      display:flex;
      align-items:center;
      gap:10px;
      max-width:900px;
      position:relative;
      top:14px;
    }

    @media (max-width:600px){
      .brand-lockup{
        top:6px;
      }
    }
    .header-logo{
      width:60px;
      height:60px;
      flex:0 0 60px;
      display:block;
      object-fit:contain;
      filter:drop-shadow(0 12px 22px rgba(0,0,0,.28));
    }
    h1{
      margin:0;
      font-size:clamp(2rem,4vw,3rem);
      line-height:1.05;
      font-weight:800;
      letter-spacing:-.03em;
    }
    .sub{
      color:#f2efe7;
      margin-top:8px;
      font-size:clamp(.98rem,2.1vw,1.18rem);
      line-height:1.28;
      max-width:900px;
    }
    main{max-width:1180px;margin:0 auto;padding:28px 18px}
    .grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(330px,1fr));gap:18px}
    .card{
      background:
        linear-gradient(180deg, rgba(255,255,255,.72), rgba(255,255,255,0) 38%),
        var(--card);
      border:2px solid var(--line);
      border-radius:22px;
      padding:22px;
      box-shadow:0 10px 28px rgba(13,36,63,.08);
      transition:transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
    }
    .calc-card.calc-keyboard-active{
      border-color:rgba(212,160,23,.72);
      box-shadow:0 0 0 3px rgba(212,160,23,.12),0 12px 30px rgba(13,36,63,.10);
    }
    @media (hover:hover) and (pointer:fine){
      .card:hover{
        transform:translateY(-2px);
        border-color:rgba(212,160,23,.55);
        box-shadow:0 14px 34px rgba(13,36,63,.12);
      }
      .card:hover .calc-icon{
        transform:translateY(-1px) rotate(-3deg) scale(1.03);
      }
    }
    h2{
      font-size:1.35rem;
      margin:0 0 16px;
      padding-bottom:10px;
      border-bottom:4px solid var(--gold);
      color:var(--navy);
      font-weight:850;
      letter-spacing:-.02em;
    }
    label{
      display:block;
      font-size:.95rem;
      color:var(--navy);
      font-weight:750;
      margin-top:13px;
    }
    input,select,textarea{
      width:100%;
      margin-top:7px;
      padding:13px 14px;
      border-radius:14px;
      border:2px solid #c9c9c9;
      background:var(--input);
      color:#111827;
      font-size:1.03rem;
      outline:none;
    }
    input:focus,select:focus,textarea:focus{
      border-color:var(--gold);
      box-shadow:0 0 0 3px rgba(212,160,23,.18);
    }
    input::placeholder,textarea::placeholder{color:#a3a3a3}
    textarea{min-height:96px;resize:vertical}
    .row{display:grid;grid-template-columns:1fr 1fr;gap:12px}
    .btns{display:flex;gap:10px;flex-wrap:wrap;margin-top:16px}

    .calc-mode-toggle{margin-top:12px}
    .btn{
      display:inline-flex;
      align-items:center;
      justify-content:center;
      border:0;
      border-radius:14px;
      padding:12px 16px;
      background:#e9e5da;
      color:var(--navy);
      border:1px solid #d1cabc;
      font-weight:850;
      text-decoration:none;
      box-shadow:none;
      cursor:pointer;
    }
    .btn:hover{filter:brightness(1.05)}
    .btn.primary{
      background:var(--navy);
      color:#fff;
      border-color:var(--navy);
      box-shadow:0 4px 0 rgba(13,36,63,.18);
    }
    body.dark .btn{
      background:#334155;
      color:#f8fafc;
      border-color:#475569;
    }
    body.dark .btn.primary{
      background:#0f5f7c;
      color:#fff;
      border-color:#0f5f7c;
    }
    button{
      border:0;
      border-radius:14px;
      padding:12px 16px;
      background:var(--navy);
      color:#fff;
      font-weight:850;
      cursor:pointer;
      box-shadow:0 4px 0 rgba(13,36,63,.18);
    }
    button:hover{filter:brightness(1.05)}
    button.secondary{
      background:#e9e5da;
      color:var(--navy);
      border:1px solid #d1cabc;
      box-shadow:none;
    }
    #eye_taper_add_step{
      display:inline-block;
      margin-top:14px;
      margin-bottom:4px;
    }
    button.good{background:var(--green);color:#fff}
    button.warn{background:var(--gold);color:#1f1300}

    button.reset-btn{
      background:#7c2d12;
      color:#fff;
    }

    .result{
      margin-top:14px;
      padding:14px;
      border:2px solid #d8d2c5;
      border-radius:16px;
      background:#fbfaf7;
      white-space:pre-wrap;
      line-height:1.38;
      color:#111827;
      min-height:56px;
    }
    .small{font-size:.86rem;color:var(--muted);margin-top:10px;line-height:1.35}

    .result.result-smart{
      white-space:normal;
    }
    .result.result-summary{
      white-space:normal;
      padding:0;
      overflow:hidden;
    }
    .result-summary-header{
      display:flex;
      align-items:flex-start;
      justify-content:space-between;
      gap:12px;
      padding:13px 14px;
      border-bottom:1px solid #e4dfd2;
      background:#f3f0e8;
    }
    .result-summary-title{
      font-size:1.04rem;
      line-height:1.2;
      font-weight:900;
      color:var(--navy);
    }
    .result-summary-meta{
      margin-top:3px;
      font-size:.84rem;
      line-height:1.3;
      color:var(--muted);
    }
    .result-summary-section{
      padding:12px 14px;
      border-bottom:1px solid #eee9dd;
    }
    .result-summary-section:last-child{
      border-bottom:0;
    }
    .result-summary-label{
      margin-bottom:7px;
      font-size:.76rem;
      font-weight:900;
      letter-spacing:.06em;
      text-transform:uppercase;
      color:var(--muted);
    }

    .result-summary-main{
      background:#fbfaf6;
    }
    .result-summary-details{
      display:block;
    }
    .result-summary-details summary{
      cursor:pointer;
      list-style:none;
      font-size:.76rem;
      font-weight:900;
      letter-spacing:.06em;
      text-transform:uppercase;
      color:var(--muted);
    }
    .result-summary-details summary::-webkit-details-marker{display:none}
    .result-summary-details summary::after{
      content:' ▼';
      font-size:.68rem;
      letter-spacing:0;
    }
    .result-summary-details:not([open]) summary::after{content:' ▶'}
    .result-summary-details .result-summary-formula,
    .result-summary-details .result-summary-inputs{
      margin-top:8px;
    }
    .result-summary-inputs{
      display:grid;
      gap:7px;
      margin:0;
    }
    .result-summary-inputs div{
      display:grid;
      grid-template-columns:minmax(0,1fr) auto;
      gap:10px;
      align-items:start;
    }
    .result-summary-inputs dt{
      color:var(--muted);
      font-size:.92rem;
    }
    .result-summary-inputs dd{
      margin:0;
      color:#111827;
      font-size:.92rem;
      font-weight:850;
      text-align:right;
    }
    .result-summary-formula{
      padding:10px 11px;
      border:1px solid #e4dfd2;
      border-radius:12px;
      background:#fff;
      color:#111827;
      font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace;
      font-size:.9rem;
      line-height:1.45;
      overflow-wrap:anywhere;
    }
    .result-summary-result{
      padding:10px 12px;
      border-left:4px solid var(--green);
      border-radius:10px;
      white-space:pre-line;
      background:#ecfdf3;
      color:#14532d;
      font-weight:900;
      line-height:1.35;
    }
    .result-summary-secondary{
      margin-top:6px;
      padding:8px 12px;
      border-left:4px solid var(--amber, #d97706);
      border-radius:10px;
      white-space:pre-line;
      background:#fffbeb;
      color:#78350f;
      font-weight:700;
      font-size:.9rem;
      line-height:1.35;
    }
    .result-summary-reminder{
      padding:10px 11px;
      border:1px solid rgba(212,160,23,.55);
      border-radius:12px;
      background:#fff8df;
      color:#422006;
      font-size:.9rem;
      line-height:1.42;
    }
    .result-primary{
      display:flex;
      flex-direction:column;
      gap:4px;
      padding-bottom:10px;
      margin-bottom:10px;
      border-bottom:1px solid #e4dfd2;
    }
    .result-label{
      font-size:.78rem;
      font-weight:850;
      text-transform:uppercase;
      letter-spacing:.06em;
      color:var(--muted);
    }
    .result-value{
      font-size:1.35rem;
      font-weight:900;
      color:var(--navy);
      line-height:1.15;
    }
    .result-details{
      white-space:pre-wrap;
      font-size:.94rem;
      line-height:1.42;
      color:#111827;
    }
    .rounding-explanation{
      margin-top:12px;
      padding:10px 12px;
      border:1px solid var(--line);
      border-radius:14px;
      background:var(--soft);
      color:var(--text);
      font-size:.88rem;
      line-height:1.38;
    }
    .rounding-explanation summary{
      cursor:pointer;
      font-weight:850;
      color:var(--navy);
    }
    .rounding-explanation div{
      margin-top:8px;
      white-space:normal;
    }
    .calc-note{
      margin-top:10px;
      padding:9px 11px;
      border:1px solid rgba(13,36,63,.12);
      border-radius:14px;
      background:rgba(13,36,63,.045);
      color:var(--muted);
      font-size:.83rem;
      line-height:1.35;
    }
    .result-status-good .result-value{color:var(--green);}
    .result-status-warn .result-value{color:#92400e;}
    .result-status-danger .result-value{color:var(--red);}
    .result-status-info .result-value{color:#2563eb;}
    body.dark .result-value{color:#f8fafc;}
    body.dark .result-details{color:#f8fafc;}
    body.dark .result-primary{border-bottom-color:#33465f;}
    body.dark .result-summary-header{
      background:#122b46;
      border-bottom-color:#33465f;
    }
    body.dark .result-summary-title,
    body.dark .result-summary-inputs dd,
    body.dark .result-summary-formula{
      color:#f8fafc;
    }
    body.dark .result-summary-section{
      border-bottom-color:#33465f;
    }
    body.dark .result-summary-formula{
      background:#10243b;
      border-color:#38506b;
    }
    body.dark .result-summary-result{
      background:#12351f;
      color:#bbf7d0;
    }
    body.dark .result-summary-secondary{
      background:#33270d;
      color:#fde68a;
    }
    body.dark .result-summary-reminder{
      background:#33270d;
      border-color:#765f1b;
      color:#fde68a;
    }
    body.dark .rounding-explanation{
      background:#10243b;
      border-color:#38506b;
      color:#f8fafc;
    }
    body.dark .rounding-explanation summary{color:#bfdbfe;}
    body.dark .calc-note{
      background:rgba(255,255,255,.045);
      border-color:#38506b;
      color:#cbd5e1;
    }
    body.dark .result-status-good .result-value{color:#86efac;}
    body.dark .result-status-warn .result-value{color:#facc15;}
    body.dark .result-status-danger .result-value{color:#fca5a5;}
    body.dark .result-status-info .result-value{color:#93c5fd;}

    footer{
      padding:24px 8px 10px;
      text-align:center;
      color:var(--muted);
      font-size:.86rem;
      line-height:1.35;
    }

    .history{
      margin-top:14px;
      padding-top:12px;
      border-top:1px dashed #d8d2c5;
    }
    .history h3{
      margin:0 0 8px;
      font-size:.9rem;
      color:var(--muted);
      text-transform:uppercase;
      letter-spacing:.04em;
    }

    .history-empty{
      background:#fbfaf7;
      border:1px dashed #e4dfd2;
      border-radius:12px;
      padding:9px 11px;
      color:var(--muted);
      font-size:.88rem;
      line-height:1.35;
    }
    .history-item{
      background:#fbfaf7;
      border:1px solid #e4dfd2;
      border-radius:12px;
      padding:8px 10px;
      margin-bottom:8px;
      font-size:.88rem;
      line-height:1.3;
      white-space:pre-wrap;
    }
    .preset-row{
      display:flex;
      flex-wrap:wrap;
      gap:8px;
      margin-top:12px;
    }
    .preset{
      background:#f3f0e8;
      color:var(--navy);
      border:1px solid #d8d2c5;
      box-shadow:none;
      padding:8px 10px;
      font-size:.85rem;
    }



    .calc-display{
      width:100%;
      min-height:74px;
      padding:14px 18px;
      border:2px solid #cfd3dc;
      border-radius:18px;
      background:#fff;
      color:#111827;
      font-size:2rem;
      font-weight:750;
      text-align:right;
      display:flex;
      align-items:center;
      justify-content:flex-end;
      overflow:hidden;
      white-space:nowrap;
    }
    .calc-expression{
      margin-top:8px;
      min-height:20px;
      color:var(--muted);
      font-size:.86rem;
      text-align:right;
      overflow:hidden;
      white-space:nowrap;
    }
    .calc-keypad{
      display:grid;
      grid-template-columns:repeat(4,1fr);
      gap:8px;
      margin-top:12px;
    }
    .calc-key{
      min-height:44px;
      border-radius:999px;
      background:#f1f1f1;
      color:#1f2937;
      box-shadow:none;
      font-size:1rem;
      font-weight:750;
      padding:10px 0;
    }
    .calc-key.op{
      background:#e9eefc;
      color:var(--navy);
    }
    .calc-key.equals{
      background:#1f5bd8;
      color:#fff;
    }
    .calc-key.clear{
      background:#e9eefc;
      color:var(--navy);
    }
    .calc-hidden-input{
      position:absolute;
      opacity:0;
      height:1px;
      width:1px;
      left:-9999px;
    }
    .calc-card{
      cursor:text;
    }

    .scientific-key{
      display:none;
    }


    .enzyme-card .row > div{
      display:flex;
      flex-direction:column;
    }
    .enzyme-card .row > div label{
      min-height:42px;
      display:flex;
      align-items:flex-end;
    }
    .enzyme-card input,
    .enzyme-card select{
      height:50px;
    }
    .aligned-card .row > div{
      display:flex;
      flex-direction:column;
    }
    .aligned-card .row > div label{
      min-height:42px;
      display:flex;
      align-items:flex-end;
    }
    .aligned-card input,
    .aligned-card select{
      height:50px;
    }

    #gen_titration_mode .row,
    #gen_multi_mode .row{
      align-items:start;
    }
    #gen_titration_mode .row > div,
    #gen_multi_mode .row > div{
      min-width:0;
    }


    /* Day Supply spacing/alignment: tighten simple modes without collapsing fields */
    #gen_units_mode .row > div,
    #gen_liquid_mode .row > div,
    #gen_quantity_mode .row > div,
    #gen_titration_mode .row > div,
    #gen_multi_mode .row > div,
    #gen_pattern_mode .row > div{
      display:flex;
      flex-direction:column;
      justify-content:flex-start;
    }

    #gen_units_mode .row > div label,
    #gen_liquid_mode .row > div label,
    #gen_quantity_mode .row > div label,
    #gen_pattern_mode .row > div label{
      min-height:0;
      display:block;
      margin-top:12px;
    }

    #gen_titration_mode .row > div label,
    #gen_multi_mode .row > div label{
      min-height:42px;
      display:flex;
      align-items:flex-end;
    }

    #gen_units_mode input,
    #gen_liquid_mode input,
    #gen_quantity_mode input,
    #gen_titration_mode input,
    #gen_titration_mode select,
    #gen_multi_mode input,
    #gen_multi_mode select,
    #gen_pattern_mode input,
    #gen_pattern_mode select{
      height:50px;
    }

    .help-link{
      display:inline-flex;
      align-items:center;
      gap:8px;
      margin-top:16px;
      padding:10px 14px;
      border-radius:14px;
      background:rgba(255,255,255,.12);
      color:#fff;
      text-decoration:none;
      font-weight:800;
      border:1px solid rgba(255,255,255,.18);
      transition:.2s ease;
    }
    .help-link:hover{
      background:rgba(255,255,255,.2);
    }


/* Keep form controls inside cards on iPhone/Safari */
html,
body{
  max-width:100%;
  overflow-x:hidden;
}

.card,
.row,
.row > div{
  min-width:0;
}

input,
select,
textarea,
.calc-display,
.result{
  display:block;
  max-width:100%;
  min-width:0;
}

input[type="date"]{
  -webkit-appearance:none;
  appearance:none;
  min-width:0;
}

.checkbox-row{
  display:flex;
  align-items:flex-start;
  gap:12px;
  margin-top:14px;
}

.checkbox-row input[type="checkbox"]{
  width:22px;
  height:22px;
  margin-top:2px;
  flex:0 0 22px;
  accent-color:var(--navy);
}

.checkbox-row span{
  display:block;
  line-height:1.35;
  padding-top:1px;
}



/* Stronger dark-mode action buttons */
body.dark button:not(.secondary):not(.reset-btn):not(.calc-key):not(.quick-tool-btn):not(.tool-list-item):not(.tool-search-fav-btn):not(.favorite-layout-name):not(.favorite-layout-remove):not(.layout-close):not(.tool-modal-close):not(.changelog-close):not(.disclaimer-close):not(.howto-modal-close):not(.command-browse-card){
  background:#2563eb;
  color:#ffffff;
  border:1px solid #60a5fa;
  box-shadow:0 4px 0 rgba(0,0,0,.35), 0 0 0 1px rgba(96,165,250,.18);
}

body.dark button:not(.secondary):not(.reset-btn):not(.calc-key):not(.quick-tool-btn):not(.tool-list-item):not(.tool-search-fav-btn):not(.favorite-layout-name):not(.favorite-layout-remove):not(.layout-close):not(.tool-modal-close):not(.changelog-close):not(.disclaimer-close):not(.howto-modal-close):not(.command-browse-card):hover{
  background:#3b82f6;
  filter:none;
}

body.dark button.secondary{
  background:#1e3a5f;
  color:#ffffff;
  border:1px solid #5b789f;
  box-shadow:0 4px 0 rgba(0,0,0,.25);
}

body.dark button.secondary:hover{
  background:#284b78;
  filter:none;
}

body.dark button.reset-btn{
  background:#b43a1d;
  color:#ffffff;
  border:1px solid #f9735b;
  box-shadow:0 4px 0 rgba(0,0,0,.35);
}

body.dark button.reset-btn:hover{
  background:#c2410c;
  filter:none;
}

body.dark button.good{
  background:#15803d;
  border:1px solid #4ade80;
}

body.dark .checkbox-row input[type="checkbox"]{
  accent-color:#2563eb;
}



/* ==========================================================================
   Splash, footer, and informational modals
   ========================================================================== */
.app-splash{
  position:fixed;
  inset:0;
  z-index:9999;
  display:flex;
  align-items:center;
  justify-content:center;
  background:linear-gradient(145deg,#06111f,#0d243f);
  color:#fff;
  transition:opacity .18s ease, visibility .18s ease;
}
.app-splash.is-hidden{
  opacity:0;
  visibility:hidden;
  pointer-events:none;
}
.splash-card{
  width:min(86vw,360px);
  padding:30px 24px;
  border-radius:28px;
  border:1px solid rgba(255,255,255,.14);
  background:rgba(255,255,255,.08);
  box-shadow:0 24px 70px rgba(0,0,0,.32);
  text-align:center;
  backdrop-filter:blur(12px);
}
.splash-icon{
  width:104px;
  height:104px;
  border-radius:26px;
  margin:0 auto 18px;
  display:block;
  box-shadow:0 12px 30px rgba(0,0,0,.28);
}
.splash-title{
  font-size:1.7rem;
  font-weight:900;
  letter-spacing:-.03em;
  line-height:1.05;
}
.splash-subtitle{
  margin-top:8px;
  color:#f2efe7;
  font-weight:700;
}
.splash-loader{
  height:7px;
  margin:22px auto 0;
  max-width:220px;
  overflow:hidden;
  border-radius:999px;
  background:rgba(255,255,255,.18);
}
.splash-loader span{
  display:block;
  width:42%;
  height:100%;
  border-radius:999px;
  background:var(--gold);
  animation:splashLoad 1.1s ease-in-out infinite;
}
@keyframes splashLoad{
  0%{transform:translateX(-120%)}
  100%{transform:translateX(260%)}
}
.version-footer{
  margin-top:10px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  flex-wrap:wrap;
}
.version-chip{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 10px;
  border-radius:999px;
  background:var(--soft);
  border:1px solid var(--line);
  color:var(--text);
  font-weight:850;
}
.changelog-link,
.support-link{
  border:1px solid var(--line);
  background:var(--card);
  color:var(--text);
  box-shadow:none;
  padding:7px 11px;
  border-radius:999px;
  font-size:.84rem;
}
.support-link{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-weight:850;
  line-height:1.15;
  text-decoration:none;
}
body.dark .changelog-link,
body.dark .support-link,
body.dark .version-chip{
  background:#10243b;
  color:#f8fafc;
  border-color:#38506b;
}
.changelog-modal{
  position:fixed;
  inset:0;
  z-index:9998;
  display:none;
  align-items:center;
  justify-content:center;
  padding:18px;
  background:rgba(2,6,23,.62);
}
.changelog-modal.is-open{display:flex;}
.changelog-panel{
  width:min(92vw,560px);
  max-height:82vh;
  overflow:auto;
  background:var(--card);
  color:var(--text);
  border:2px solid var(--line);
  border-radius:24px;
  box-shadow:0 24px 80px rgba(0,0,0,.34);
  padding:22px;
}
.changelog-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  padding-bottom:12px;
  border-bottom:4px solid var(--gold);
}
.changelog-head h2{
  border:0;
  padding:0;
  margin:0;
}
.changelog-close{
  min-width:42px;
  min-height:42px;
  padding:0;
  border-radius:14px;
  box-shadow:none;
  background:var(--soft);
  color:var(--text);
  border:1px solid var(--line);
}
.changelog-panel ul{
  margin:14px 0 0;
  padding-left:22px;
  line-height:1.5;
}
.changelog-panel li{margin:7px 0;}
.changelog-note{
  margin-top:14px;
  padding:12px 14px;
  border-radius:16px;
  background:var(--soft);
  border:1px solid var(--line);
  font-size:.92rem;
  line-height:1.4;
}
body.dark .changelog-close{
  background:#1b3656;
  color:#f8fafc;
  border-color:#38506b;
}

.layout-modal{
  position:fixed;
  inset:0;
  z-index:9998;
  display:none;
  align-items:center;
  justify-content:center;
  padding:18px;
  background:rgba(2,6,23,.62);
}
.layout-modal.is-open{
  display:flex;
}
.layout-panel{
  width:min(94vw,680px);
  max-height:84vh;
  overflow:hidden;
  background:var(--card);
  color:var(--text);
  border:2px solid var(--line);
  border-radius:24px;
  box-shadow:0 24px 80px rgba(0,0,0,.34);
  padding:22px;
}
.layout-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  padding-bottom:12px;
  border-bottom:4px solid var(--gold);
}
.layout-head h2{
  border:0;
  padding:0;
  margin:0;
}
.layout-close{
  min-width:42px;
  min-height:42px;
  padding:0;
  border-radius:14px;
  box-shadow:none;
  background:var(--soft);
  color:var(--text);
  border:1px solid var(--line);
}
.layout-list{
  display:flex;
  flex-direction:column;
  gap:9px;
  margin-top:14px;
}
.layout-row{
  display:flex;
  align-items:center;
  gap:12px;
  padding:13px 14px;
  border:1px solid var(--line);
  border-radius:16px;
  background:var(--soft);
  touch-action:none;
}
.layout-row.sortable-chosen{
  box-shadow:0 10px 24px rgba(13,36,63,.16);
}
.layout-row.sortable-drag{
  opacity:.92;
}
.layout-ghost{
  opacity:.45;
  border-style:dashed;
}
.layout-drag-handle{
  width:34px;
  height:34px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  flex:0 0 34px;
  border-radius:12px;
  background:rgba(13,36,63,.08);
  color:var(--navy);
  font-weight:950;
  cursor:grab;
  user-select:none;
}
.layout-drag-handle:active{
  cursor:grabbing;
}
.layout-name{
  font-weight:900;
  line-height:1.2;
}
.layout-footer{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  margin-top:16px;
  padding-top:14px;
  border-top:1px solid var(--line);
}
body.dark .layout-panel{
  background:#0f2136;
  color:#f8fafc;
  border-color:#38506b;
}
body.dark .layout-close,
body.dark .layout-row{
  background:#10243b;
  color:#f8fafc;
  border-color:#38506b;
}
body.dark .layout-drag-handle{
  background:#1b3656;
  color:#f8fafc;
}
@media (max-width:560px){
  .layout-row{
    padding:14px;
  }
  .layout-drag-handle{
    width:38px;
    height:38px;
    flex-basis:38px;
  }
}
@media print{
  .layout-modal{
    display:none !important;
  }
}

@media (prefers-reduced-motion:reduce){
  .app-splash{transition:none;}
  .splash-loader span{animation:none;width:100%;}
  .smart-fill-match{animation:none !important;}
}

@media (max-width:560px){
      header{padding:30px 22px}
      main{padding:22px 14px}
      .grid{grid-template-columns:1fr}
      .row{grid-template-columns:1fr}
      .card{padding:20px 18px}
    }
  
.disclaimer-link{
  border:1px solid var(--line);
  background:var(--card);
  color:var(--text);
  box-shadow:none;
  padding:7px 11px;
  border-radius:999px;
  font-size:.84rem;
}
body.dark .disclaimer-link{
  background:#10243b;
  color:#f8fafc;
  border-color:#38506b;
}
.disclaimer-modal{
  position:fixed;
  inset:0;
  z-index:9998;
  display:none;
  align-items:center;
  justify-content:center;
  padding:18px;
  background:rgba(2,6,23,.62);
}
.disclaimer-modal.is-open{display:flex;}
.disclaimer-panel{
  width:min(92vw,620px);
  max-height:82vh;
  overflow:auto;
  background:var(--card);
  color:var(--text);
  border:2px solid var(--line);
  border-radius:24px;
  box-shadow:0 24px 80px rgba(0,0,0,.34);
  padding:22px;
}
.disclaimer-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  padding-bottom:12px;
  border-bottom:4px solid var(--gold);
}
.disclaimer-head h2{
  border:0;
  padding:0;
  margin:0;
}
.disclaimer-close{
  min-width:42px;
  min-height:42px;
  padding:0;
  border-radius:14px;
  box-shadow:none;
  background:var(--soft);
  color:var(--text);
  border:1px solid var(--line);
}
.disclaimer-panel ul{
  margin:14px 0 0;
  padding-left:22px;
  line-height:1.5;
}
.disclaimer-panel li{margin:7px 0;}
.disclaimer-note{
  margin-top:14px;
  padding:12px 14px;
  border-radius:16px;
  background:var(--soft);
  border:1px solid var(--line);
  font-size:.92rem;
  line-height:1.4;
}
body.dark .disclaimer-close{
  background:#1b3656;
  color:#f8fafc;
  border-color:#38506b;
}

.result-hidden{
  display:none !important;
}

.skip-link{
  position:fixed;
  top:10px;
  left:10px;
  z-index:20000;
  padding:11px 15px;
  border:2px solid var(--gold);
  border-radius:10px;
  background:#fff;
  color:var(--navy);
  font-weight:800;
  text-decoration:none;
  transform:translateY(-160%);
  transition:transform .15s ease;
}
.skip-link:focus{
  transform:translateY(0);
  outline:3px solid #fff;
  outline-offset:2px;
}

/* ==========================================================================
   Quick tools, search, and favorites
   ========================================================================== */
.header-actions{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:10px;
  flex-wrap:wrap;
  margin-top:12px;
}
.quick-tool-icons{
  display:inline-flex;
  align-items:center;
  gap:0;
  padding:3px;
  border:1px solid rgba(255,255,255,.16);
  border-radius:16px;
  background:rgba(255,255,255,.055);
}
.quick-tool-btn{
  width:36px;height:34px;padding:0;border-radius:11px;
  display:inline-flex;align-items:center;justify-content:center;
  background:transparent;color:#fff;
  border:0;box-shadow:none;
  font-size:.98rem;
  position:relative;
}
.quick-tool-btn + .quick-tool-btn::before{
  content:'';
  position:absolute;
  left:0;
  top:8px;
  bottom:8px;
  width:1px;
  background:rgba(255,255,255,.18);
}
.quick-tool-btn:hover{background:rgba(255,255,255,.12);}
.favorite-toggle{
  width:38px;height:38px;padding:0;border-radius:999px;
  display:inline-flex;align-items:center;justify-content:center;
  margin-left:auto;flex:0 0 38px;box-shadow:none;
  font-size:1.05rem;line-height:1;background:#e9e5da;
  color:var(--navy);border:1px solid #d1cabc;
}
.favorite-toggle.is-active{
  background:var(--gold);color:#1f1300;border-color:#b8870d;
}
.calc-title{width:100%;}
.tool-modal-backdrop{
  position:fixed;inset:0;z-index:10000;display:none;
  align-items:center;justify-content:center;padding:18px;
  background:rgba(2,6,23,.66);backdrop-filter:blur(5px);
}
.tool-modal-backdrop.is-open{display:flex;}
.tool-modal{
  width:min(92vw,760px);max-height:84vh;overflow:hidden;
  background:var(--card);color:var(--text);border:2px solid var(--line);
  border-radius:24px;box-shadow:0 24px 80px rgba(0,0,0,.35);
}
.tool-modal-head{
  position:sticky;top:0;z-index:1;display:flex;
  align-items:flex-start;justify-content:space-between;gap:12px;
  padding:20px 22px;background:var(--navy);color:#fff;
  border-bottom:6px solid var(--gold);
}
.tool-modal-head h2{margin:0;padding:0;border:0;color:#fff;}
.tool-modal-head p{margin:6px 0 0;color:#f2efe7;line-height:1.35;font-size:.95rem;}
.tool-modal-close{
  min-width:42px;min-height:42px;padding:0;border-radius:14px;
  border:1px solid rgba(255,255,255,.35);background:rgba(255,255,255,.14);
  color:#fff;box-shadow:none;font-size:1.25rem;
}
.tool-modal-body{padding:20px 22px 22px;}
.tool-modal-search{margin-top:0;min-height:48px;}
.tool-list{margin-top:14px;display:grid;gap:10px;}
.tool-list-item{
  width:100%;display:flex;align-items:center;justify-content:space-between;
  gap:12px;text-align:left;padding:13px 14px;border-radius:16px;
  border:1px solid var(--line);background:var(--soft);color:var(--text);
  box-shadow:none;
  transition:transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease;
}
.tool-list-item:hover{filter:none;border-color:var(--gold);transform:translateY(-1px);box-shadow:0 8px 18px rgba(13,36,63,.08);}
.tool-list-main{display:flex;flex-direction:column;gap:3px;}
.tool-list-title-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap;}
.tool-list-title{font-weight:900;color:var(--text);}
.tool-type-badge{
  display:inline-flex;align-items:center;min-height:22px;padding:2px 7px;
  border:1px solid var(--line);border-radius:999px;background:#eef2f7;
  color:#475569;font-size:.68rem;font-weight:900;line-height:1;
  text-transform:uppercase;letter-spacing:0;
}
.tool-type-badge.is-reference{background:#fff8df;border-color:rgba(212,160,23,.55);color:#795800;}
.tool-type-badge.is-utility{background:#ecfdf3;border-color:#86d5a3;color:#166534;}
.tool-list-meta{color:var(--muted);font-size:.84rem;line-height:1.3;}
.tool-search-row{
  display:grid;
  grid-template-columns:1fr auto;
  gap:8px;
  align-items:stretch;
}
.tool-search-main{
  width:100%;
}
.tool-search-fav-btn{
  min-width:48px;
  padding:10px 12px;
  border-radius:16px;
  box-shadow:none;
  background:var(--soft);
  color:#b8870d;
  border:1px solid var(--line);
  font-size:1.25rem;
  line-height:1;
}
.tool-search-fav-btn.is-active{
  background:var(--gold);
  color:#1f1300;
  border-color:var(--gold);
}
.tool-search-fav-btn:hover{
  filter:brightness(1.05);
}
body.dark .tool-search-fav-btn{
  background:#1b3656;
  color:#facc15;
  border-color:#38506b;
}
body.dark .tool-search-fav-btn.is-active{
  background:var(--gold);
  color:#1f1300;
  border-color:var(--gold);
}

.tool-empty{
  display:none;margin-top:14px;padding:16px;border-radius:16px;
  border:2px dashed var(--line);color:var(--muted);font-weight:800;text-align:center;
}
.tool-empty.is-visible{display:block;}
.tool-empty-title{display:block;color:var(--text);font-size:.95rem;margin-bottom:8px;}
.tool-empty-suggestions{display:flex;flex-wrap:wrap;justify-content:center;gap:8px;margin-top:10px;}
.tool-empty-suggestion{
  border:1px solid var(--line);
  background:var(--soft);
  color:var(--navy);
  border-radius:999px;
  padding:7px 10px;
  font-size:.82rem;
  font-weight:850;
  box-shadow:none;
}
.tool-empty-suggestion:hover{border-color:var(--gold);filter:none;}
.resource-modal{width:min(92vw,680px);}
.reference-list{display:grid;border-top:1px solid var(--line);}
.reference-row{
  display:grid;grid-template-columns:minmax(0,1fr) minmax(150px,auto);
  gap:16px;padding:13px 2px;border-bottom:1px solid var(--line);align-items:start;
}
.reference-row span{color:var(--muted);font-weight:750;}
.reference-row strong{text-align:right;color:var(--text);}
.resource-note{
  margin-top:16px;padding:12px 13px;border-left:4px solid var(--gold);
  background:var(--soft);color:var(--muted);font-size:.9rem;line-height:1.45;
}
.conversion-tool{display:grid;gap:10px;}
.conversion-mode-row{display:grid;grid-template-columns:minmax(0,1fr) 48px;gap:8px;align-items:stretch;}
.conversion-mode-row select{margin:0;}
.conversion-swap{width:48px;min-width:48px;padding:0;font-size:1.25rem;}
.conversion-input-row{display:grid;grid-template-columns:minmax(0,1fr) 64px;gap:8px;align-items:stretch;}
.conversion-input-row input{margin:0;}
.conversion-unit{
  display:flex;align-items:center;justify-content:center;border:1px solid var(--line);
  background:var(--soft);color:var(--text);font-weight:900;border-radius:8px;
}
.conversion-output{
  min-height:64px;display:flex;align-items:center;padding:13px 14px;
  border-left:4px solid var(--green);background:#ecfdf3;color:#14532d;
  font-weight:900;line-height:1.35;border-radius:8px;
}
body.dark .resource-note,body.dark .conversion-unit{background:#10243b;border-color:#38506b;}
body.dark .conversion-output{background:#12351f;color:#bbf7d0;}

.mme-math{
  padding:12px 13px;border:1px solid var(--line);border-radius:8px;
  background:var(--soft);color:var(--text);font-weight:750;line-height:1.45;
}
body.dark .mme-math{background:#10243b;border-color:#38506b;}

body.dark .quick-tool-icons{background:rgba(255,255,255,.035);border-color:rgba(255,255,255,.12);}
body.dark .quick-tool-icons .quick-tool-btn{
  background:transparent !important;
  border:0 !important;
  box-shadow:none !important;
  color:#f8fafc !important;
}
body.dark .quick-tool-icons .quick-tool-btn:hover{
  background:rgba(255,255,255,.10) !important;
}
body.dark button.quick-tool-btn,
body.dark button.quick-tool-btn:hover,
body.dark .quick-tool-icons button.quick-tool-btn,
body.dark .quick-tool-icons button.quick-tool-btn:hover{
  background:transparent !important;
  border:0 !important;
  box-shadow:none !important;
  filter:none !important;
  color:#f8fafc !important;
}

body.dark .quick-tool-icons button.quick-tool-btn:hover{
  background:rgba(255,255,255,.10) !important;
}

body.dark .favorite-toggle{background:#1b3656;color:#f8fafc;border-color:#38506b;}
body.dark .favorite-toggle.is-active{background:var(--gold);color:#1f1300;}
body.dark .tool-list-item{background:#10243b;border-color:#38506b;}
body.dark .tool-type-badge{background:#1e293b;border-color:#475569;color:#cbd5e1;}
body.dark .tool-type-badge.is-reference{background:#33270d;border-color:#765f1b;color:#fde68a;}
body.dark .tool-type-badge.is-utility{background:#12351f;border-color:#287346;color:#bbf7d0;}
@media (max-width:600px){
  .header-actions{justify-content:space-between;align-items:center;}
  .quick-tool-btn{width:36px;height:34px;}
  .tool-modal-backdrop{align-items:flex-end;padding:10px;}
  .tool-modal{max-height:90vh;border-radius:22px 22px 0 0;}
}

@media print{
  .skip-link{display:none !important;}
}
@media (max-width:520px){
  .reference-row{grid-template-columns:1fr;gap:4px;}
  .reference-row strong{text-align:left;}
}



/* iOS Safari keyboard overlap fix for Search/Favorites modals */
@media (max-width:600px){
  .tool-modal-backdrop{
    align-items:flex-start !important;
    padding:calc(env(safe-area-inset-top, 0px) + 10px) 10px 10px !important;
    overflow:auto;
  }

  .tool-modal{
    max-height:90dvh !important;
    border-radius:22px !important;
    margin:0 auto !important;
  }

  .tool-modal-body{
    padding-bottom:calc(env(safe-area-inset-bottom, 0px) + 22px);
  }
}


/* iOS Safari input focus keyboard fix */
input,
select,
textarea{
  scroll-margin-top:calc(env(safe-area-inset-top, 0px) + 24px);
  scroll-margin-bottom:340px;
}

@supports (height: 100dvh){
  input,
  select,
  textarea{
    scroll-margin-bottom:38dvh;
  }
}


@media (max-width:560px){
  /* Tighten the Favorites modal header on mobile Safari */
  #favorites_modal .tool-modal-head{
    padding:16px 18px 14px;
    gap:10px;
  }

  #favorites_modal .tool-modal-head h2{
    font-size:1.65rem;
    line-height:1.08;
  }

  #favorites_modal .tool-modal-head p{
    font-size:.92rem;
    line-height:1.25;
    margin-top:5px;
  }

  #favorites_modal .tool-modal-close{
    min-width:42px;
    min-height:42px;
    border-radius:14px;
    font-size:1.25rem;
  }
}

@media (max-width:380px){
  #favorites_modal .tool-modal-head p{
    display:none;
  }
}

/* Mobile header + Favorites modal polish */
@media (max-width:600px){

  header{
    padding:18px 18px 20px !important;
  }

  .brand-lockup{
    gap:9px !important;
    align-items:center !important;
  }

  .header-logo{
    width:46px !important;
    height:46px !important;
    flex-basis:46px !important;
  }

  h1{
    font-size:clamp(1.75rem, 9vw, 2.35rem) !important;
    line-height:1 !important;
  }

  .sub{
    margin-top:6px !important;
    font-size:.94rem !important;
    line-height:1.24 !important;
  }

  .header-actions{
    margin-top:10px !important;
    gap:10px !important;
    align-items:center !important;
  }

  .quick-tool-icons{
    gap:0 !important;
    padding:3px !important;
    border-radius:15px !important;
  }

  .quick-tool-btn{
    width:34px !important;
    height:32px !important;
    min-width:34px !important;
    padding:0 !important;
    border-radius:10px !important;
    font-size:.94rem !important;
  }

  .theme-switch{
    gap:7px !important;
  }

  .theme-slider{
    width:46px !important;
    height:26px !important;
    flex-basis:46px !important;
  }

  .theme-slider::before{
    width:20px !important;
    height:20px !important;
    top:2px !important;
    left:3px !important;
  }

  .theme-switch input:checked + .theme-slider::before{
    transform:translateX(20px) !important;
  }

  .theme-label{
    font-size:.82rem !important;
  }

  #favorites_modal .tool-modal{
    width:calc(100vw - 20px) !important;
    max-height:90dvh !important;
    border-radius:22px !important;
  }

  #favorites_modal .tool-modal-head{
    padding:16px 16px 13px !important;
    gap:10px !important;
  }

  #favorites_modal .tool-modal-head h2{
    font-size:1.35rem !important;
    line-height:1.05 !important;
    margin:0 !important;
  }

  #favorites_modal .tool-modal-head p{
    margin-top:5px !important;
    font-size:.84rem !important;
    line-height:1.25 !important;
  }

  #favorites_modal .tool-modal-close{
    width:42px !important;
    height:42px !important;
    min-width:42px !important;
    min-height:42px !important;
    border-radius:14px !important;
    font-size:1.25rem !important;
    padding:0 !important;
  }

  #favorites_modal .tool-modal-body{
    padding:14px !important;
    padding-bottom:calc(env(safe-area-inset-bottom, 0px) + 18px) !important;
  }

  #favorites_modal .tool-list{
    gap:9px !important;
  }

  #favorites_modal .tool-list-item{
    min-height:54px !important;
    padding:12px 13px !important;
    border-radius:16px !important;
  }

  #favorites_modal .tool-list-title{
    font-size:.96rem !important;
    line-height:1.15 !important;
  }

  #favorites_modal .tool-list-meta{
    font-size:.78rem !important;
    line-height:1.25 !important;
  }

}

@media (max-width:380px){
  .theme-label{
    display:none !important;
  }

  .quick-tool-btn{
    width:31px !important;
    height:31px !important;
    min-width:31px !important;
  }

  #favorites_modal .tool-modal-head p{
    display:none !important;
  }
}

/* Prevent iOS Safari input zoom jump */
input,
select,
textarea{
  font-size:16px;
}

.favorite-remove-btn{
min-width:42px;
padding:10px 12px;
border-radius:14px;
box-shadow:none;
background:var(--gold);
color:#1f1300;
border:1px solid var(--gold);
font-size:1.1rem;
}



/* Saved settings fields */
.settings-section{
  margin-top:18px;
  padding-top:16px;
  border-top:1px solid var(--line);
}
.settings-section h3{
  margin:0 0 10px;
  color:var(--text);
  font-size:1rem;
}


/* Favorite sorting states */
#favorites_results .favorite-drag-handle{
  cursor:grab;
  touch-action:none;
  -webkit-user-select:none;
  user-select:none;
}

#favorites_results .sortable-chosen{
  filter:brightness(1.03);
}


/* Search/Favorites modal scrolling */
.tool-modal{
  overflow:hidden !important;
}

.tool-modal-body{
  overflow-y:auto;
  max-height:calc(84vh - 112px);
  scrollbar-gutter:stable;
}

/* Custom modal scrollbars: desktop polish with safe native fallbacks on iOS */
.tool-modal-body,
#layout_modal .layout-scroll,
.changelog-panel,
.disclaimer-panel,
.table-scroll{
  scrollbar-width:thin;
  scrollbar-color:transparent transparent;
}

.tool-modal-body::-webkit-scrollbar,
#layout_modal .layout-scroll::-webkit-scrollbar,
.changelog-panel::-webkit-scrollbar,
.disclaimer-panel::-webkit-scrollbar,
.table-scroll::-webkit-scrollbar{
  width:10px;
  height:10px;
}

.tool-modal-body::-webkit-scrollbar-track,
#layout_modal .layout-scroll::-webkit-scrollbar-track,
.changelog-panel::-webkit-scrollbar-track,
.disclaimer-panel::-webkit-scrollbar-track,
.table-scroll::-webkit-scrollbar-track{
  background:transparent;
  border-radius:999px;
}

.tool-modal-body::-webkit-scrollbar-thumb,
#layout_modal .layout-scroll::-webkit-scrollbar-thumb,
.changelog-panel::-webkit-scrollbar-thumb,
.disclaimer-panel::-webkit-scrollbar-thumb,
.table-scroll::-webkit-scrollbar-thumb{
  background:transparent;
  border:2px solid transparent;
  border-radius:999px;
  background-clip:padding-box;
}

.tool-modal-body:hover,
.tool-modal-body:focus-within,
.tool-modal-body.is-scrolling,
#layout_modal .layout-scroll:hover,
#layout_modal .layout-scroll:focus-within,
#layout_modal .layout-scroll.is-scrolling,
.changelog-panel:hover,
.changelog-panel:focus-within,
.changelog-panel.is-scrolling,
.disclaimer-panel:hover,
.disclaimer-panel:focus-within,
.disclaimer-panel.is-scrolling,
.table-scroll:hover,
.table-scroll:focus-within,
.table-scroll.is-scrolling{
  scrollbar-color:rgba(255,255,255,.36) rgba(255,255,255,.08);
}

.tool-modal-body:hover::-webkit-scrollbar-track,
.tool-modal-body:focus-within::-webkit-scrollbar-track,
.tool-modal-body.is-scrolling::-webkit-scrollbar-track,
#layout_modal .layout-scroll:hover::-webkit-scrollbar-track,
#layout_modal .layout-scroll:focus-within::-webkit-scrollbar-track,
#layout_modal .layout-scroll.is-scrolling::-webkit-scrollbar-track,
.changelog-panel:hover::-webkit-scrollbar-track,
.changelog-panel:focus-within::-webkit-scrollbar-track,
.changelog-panel.is-scrolling::-webkit-scrollbar-track,
.disclaimer-panel:hover::-webkit-scrollbar-track,
.disclaimer-panel:focus-within::-webkit-scrollbar-track,
.disclaimer-panel.is-scrolling::-webkit-scrollbar-track,
.table-scroll:hover::-webkit-scrollbar-track,
.table-scroll:focus-within::-webkit-scrollbar-track,
.table-scroll.is-scrolling::-webkit-scrollbar-track{
  background:rgba(255,255,255,.08);
}

.tool-modal-body:hover::-webkit-scrollbar-thumb,
.tool-modal-body:focus-within::-webkit-scrollbar-thumb,
.tool-modal-body.is-scrolling::-webkit-scrollbar-thumb,
#layout_modal .layout-scroll:hover::-webkit-scrollbar-thumb,
#layout_modal .layout-scroll:focus-within::-webkit-scrollbar-thumb,
#layout_modal .layout-scroll.is-scrolling::-webkit-scrollbar-thumb,
.changelog-panel:hover::-webkit-scrollbar-thumb,
.changelog-panel:focus-within::-webkit-scrollbar-thumb,
.changelog-panel.is-scrolling::-webkit-scrollbar-thumb,
.disclaimer-panel:hover::-webkit-scrollbar-thumb,
.disclaimer-panel:focus-within::-webkit-scrollbar-thumb,
.disclaimer-panel.is-scrolling::-webkit-scrollbar-thumb,
.table-scroll:hover::-webkit-scrollbar-thumb,
.table-scroll:focus-within::-webkit-scrollbar-thumb,
.table-scroll.is-scrolling::-webkit-scrollbar-thumb{
  background:rgba(255,255,255,.36);
}

.tool-modal-body::-webkit-scrollbar-thumb:hover,
#layout_modal .layout-scroll::-webkit-scrollbar-thumb:hover,
.changelog-panel::-webkit-scrollbar-thumb:hover,
.disclaimer-panel::-webkit-scrollbar-thumb:hover,
.table-scroll::-webkit-scrollbar-thumb:hover{
  background:rgba(255,255,255,.52);
  border:2px solid transparent;
  background-clip:padding-box;
}

body:not(.dark) .tool-modal-body,
body:not(.dark) #layout_modal .layout-scroll,
body:not(.dark) .changelog-panel,
body:not(.dark) .disclaimer-panel,
body:not(.dark) .table-scroll{
  scrollbar-color:transparent transparent;
}

body:not(.dark) .tool-modal-body::-webkit-scrollbar-track,
body:not(.dark) #layout_modal .layout-scroll::-webkit-scrollbar-track,
body:not(.dark) .changelog-panel::-webkit-scrollbar-track,
body:not(.dark) .disclaimer-panel::-webkit-scrollbar-track,
body:not(.dark) .table-scroll::-webkit-scrollbar-track{
  background:transparent;
}

body:not(.dark) .tool-modal-body::-webkit-scrollbar-thumb,
body:not(.dark) #layout_modal .layout-scroll::-webkit-scrollbar-thumb,
body:not(.dark) .changelog-panel::-webkit-scrollbar-thumb,
body:not(.dark) .disclaimer-panel::-webkit-scrollbar-thumb,
body:not(.dark) .table-scroll::-webkit-scrollbar-thumb{
  background:transparent;
  border:2px solid transparent;
  background-clip:padding-box;
}

body:not(.dark) .tool-modal-body:hover,
body:not(.dark) .tool-modal-body:focus-within,
body:not(.dark) .tool-modal-body.is-scrolling,
body:not(.dark) #layout_modal .layout-scroll:hover,
body:not(.dark) #layout_modal .layout-scroll:focus-within,
body:not(.dark) #layout_modal .layout-scroll.is-scrolling,
body:not(.dark) .changelog-panel:hover,
body:not(.dark) .changelog-panel:focus-within,
body:not(.dark) .changelog-panel.is-scrolling,
body:not(.dark) .disclaimer-panel:hover,
body:not(.dark) .disclaimer-panel:focus-within,
body:not(.dark) .disclaimer-panel.is-scrolling,
body:not(.dark) .table-scroll:hover,
body:not(.dark) .table-scroll:focus-within,
body:not(.dark) .table-scroll.is-scrolling{
  scrollbar-color:rgba(15,33,54,.36) rgba(15,33,54,.08);
}

body:not(.dark) .tool-modal-body:hover::-webkit-scrollbar-track,
body:not(.dark) .tool-modal-body:focus-within::-webkit-scrollbar-track,
body:not(.dark) .tool-modal-body.is-scrolling::-webkit-scrollbar-track,
body:not(.dark) #layout_modal .layout-scroll:hover::-webkit-scrollbar-track,
body:not(.dark) #layout_modal .layout-scroll:focus-within::-webkit-scrollbar-track,
body:not(.dark) #layout_modal .layout-scroll.is-scrolling::-webkit-scrollbar-track,
body:not(.dark) .changelog-panel:hover::-webkit-scrollbar-track,
body:not(.dark) .changelog-panel:focus-within::-webkit-scrollbar-track,
body:not(.dark) .changelog-panel.is-scrolling::-webkit-scrollbar-track,
body:not(.dark) .disclaimer-panel:hover::-webkit-scrollbar-track,
body:not(.dark) .disclaimer-panel:focus-within::-webkit-scrollbar-track,
body:not(.dark) .disclaimer-panel.is-scrolling::-webkit-scrollbar-track,
body:not(.dark) .table-scroll:hover::-webkit-scrollbar-track,
body:not(.dark) .table-scroll:focus-within::-webkit-scrollbar-track,
body:not(.dark) .table-scroll.is-scrolling::-webkit-scrollbar-track{
  background:rgba(15,33,54,.08);
}

body:not(.dark) .tool-modal-body:hover::-webkit-scrollbar-thumb,
body:not(.dark) .tool-modal-body:focus-within::-webkit-scrollbar-thumb,
body:not(.dark) .tool-modal-body.is-scrolling::-webkit-scrollbar-thumb,
body:not(.dark) #layout_modal .layout-scroll:hover::-webkit-scrollbar-thumb,
body:not(.dark) #layout_modal .layout-scroll:focus-within::-webkit-scrollbar-thumb,
body:not(.dark) #layout_modal .layout-scroll.is-scrolling::-webkit-scrollbar-thumb,
body:not(.dark) .changelog-panel:hover::-webkit-scrollbar-thumb,
body:not(.dark) .changelog-panel:focus-within::-webkit-scrollbar-thumb,
body:not(.dark) .changelog-panel.is-scrolling::-webkit-scrollbar-thumb,
body:not(.dark) .disclaimer-panel:hover::-webkit-scrollbar-thumb,
body:not(.dark) .disclaimer-panel:focus-within::-webkit-scrollbar-thumb,
body:not(.dark) .disclaimer-panel.is-scrolling::-webkit-scrollbar-thumb,
body:not(.dark) .table-scroll:hover::-webkit-scrollbar-thumb,
body:not(.dark) .table-scroll:focus-within::-webkit-scrollbar-thumb,
body:not(.dark) .table-scroll.is-scrolling::-webkit-scrollbar-thumb{
  background:rgba(15,33,54,.36);
}

body:not(.dark) .tool-modal-body::-webkit-scrollbar-thumb:hover,
body:not(.dark) #layout_modal .layout-scroll::-webkit-scrollbar-thumb:hover,
body:not(.dark) .changelog-panel::-webkit-scrollbar-thumb:hover,
body:not(.dark) .disclaimer-panel::-webkit-scrollbar-thumb:hover,
body:not(.dark) .table-scroll::-webkit-scrollbar-thumb:hover{
  background:rgba(15,33,54,.52);
  border:2px solid transparent;
  background-clip:padding-box;
}

/* Keep modal scrollbars quiet while idle, even when fields inside the modal are focused. */
.tool-modal-body:hover:not(.is-scrolling),
.tool-modal-body:focus-within:not(.is-scrolling),
#layout_modal .layout-scroll:hover:not(.is-scrolling),
#layout_modal .layout-scroll:focus-within:not(.is-scrolling),
.changelog-panel:hover:not(.is-scrolling),
.changelog-panel:focus-within:not(.is-scrolling),
.disclaimer-panel:hover:not(.is-scrolling),
.disclaimer-panel:focus-within:not(.is-scrolling),
.table-scroll:hover:not(.is-scrolling),
.table-scroll:focus-within:not(.is-scrolling),
body:not(.dark) .tool-modal-body:hover:not(.is-scrolling),
body:not(.dark) .tool-modal-body:focus-within:not(.is-scrolling),
body:not(.dark) #layout_modal .layout-scroll:hover:not(.is-scrolling),
body:not(.dark) #layout_modal .layout-scroll:focus-within:not(.is-scrolling),
body:not(.dark) .changelog-panel:hover:not(.is-scrolling),
body:not(.dark) .changelog-panel:focus-within:not(.is-scrolling),
body:not(.dark) .disclaimer-panel:hover:not(.is-scrolling),
body:not(.dark) .disclaimer-panel:focus-within:not(.is-scrolling),
body:not(.dark) .table-scroll:hover:not(.is-scrolling),
body:not(.dark) .table-scroll:focus-within:not(.is-scrolling){
  scrollbar-color:transparent transparent;
}

.tool-modal-body:hover:not(.is-scrolling)::-webkit-scrollbar-track,
.tool-modal-body:focus-within:not(.is-scrolling)::-webkit-scrollbar-track,
#layout_modal .layout-scroll:hover:not(.is-scrolling)::-webkit-scrollbar-track,
#layout_modal .layout-scroll:focus-within:not(.is-scrolling)::-webkit-scrollbar-track,
.changelog-panel:hover:not(.is-scrolling)::-webkit-scrollbar-track,
.changelog-panel:focus-within:not(.is-scrolling)::-webkit-scrollbar-track,
.disclaimer-panel:hover:not(.is-scrolling)::-webkit-scrollbar-track,
.disclaimer-panel:focus-within:not(.is-scrolling)::-webkit-scrollbar-track,
.table-scroll:hover:not(.is-scrolling)::-webkit-scrollbar-track,
.table-scroll:focus-within:not(.is-scrolling)::-webkit-scrollbar-track,
body:not(.dark) .tool-modal-body:hover:not(.is-scrolling)::-webkit-scrollbar-track,
body:not(.dark) .tool-modal-body:focus-within:not(.is-scrolling)::-webkit-scrollbar-track,
body:not(.dark) #layout_modal .layout-scroll:hover:not(.is-scrolling)::-webkit-scrollbar-track,
body:not(.dark) #layout_modal .layout-scroll:focus-within:not(.is-scrolling)::-webkit-scrollbar-track,
body:not(.dark) .changelog-panel:hover:not(.is-scrolling)::-webkit-scrollbar-track,
body:not(.dark) .changelog-panel:focus-within:not(.is-scrolling)::-webkit-scrollbar-track,
body:not(.dark) .disclaimer-panel:hover:not(.is-scrolling)::-webkit-scrollbar-track,
body:not(.dark) .disclaimer-panel:focus-within:not(.is-scrolling)::-webkit-scrollbar-track,
body:not(.dark) .table-scroll:hover:not(.is-scrolling)::-webkit-scrollbar-track,
body:not(.dark) .table-scroll:focus-within:not(.is-scrolling)::-webkit-scrollbar-track{
  background:transparent;
}

.tool-modal-body:hover:not(.is-scrolling)::-webkit-scrollbar-thumb,
.tool-modal-body:focus-within:not(.is-scrolling)::-webkit-scrollbar-thumb,
#layout_modal .layout-scroll:hover:not(.is-scrolling)::-webkit-scrollbar-thumb,
#layout_modal .layout-scroll:focus-within:not(.is-scrolling)::-webkit-scrollbar-thumb,
.changelog-panel:hover:not(.is-scrolling)::-webkit-scrollbar-thumb,
.changelog-panel:focus-within:not(.is-scrolling)::-webkit-scrollbar-thumb,
.disclaimer-panel:hover:not(.is-scrolling)::-webkit-scrollbar-thumb,
.disclaimer-panel:focus-within:not(.is-scrolling)::-webkit-scrollbar-thumb,
.table-scroll:hover:not(.is-scrolling)::-webkit-scrollbar-thumb,
.table-scroll:focus-within:not(.is-scrolling)::-webkit-scrollbar-thumb,
body:not(.dark) .tool-modal-body:hover:not(.is-scrolling)::-webkit-scrollbar-thumb,
body:not(.dark) .tool-modal-body:focus-within:not(.is-scrolling)::-webkit-scrollbar-thumb,
body:not(.dark) #layout_modal .layout-scroll:hover:not(.is-scrolling)::-webkit-scrollbar-thumb,
body:not(.dark) #layout_modal .layout-scroll:focus-within:not(.is-scrolling)::-webkit-scrollbar-thumb,
body:not(.dark) .changelog-panel:hover:not(.is-scrolling)::-webkit-scrollbar-thumb,
body:not(.dark) .changelog-panel:focus-within:not(.is-scrolling)::-webkit-scrollbar-thumb,
body:not(.dark) .disclaimer-panel:hover:not(.is-scrolling)::-webkit-scrollbar-thumb,
body:not(.dark) .disclaimer-panel:focus-within:not(.is-scrolling)::-webkit-scrollbar-thumb,
body:not(.dark) .table-scroll:hover:not(.is-scrolling)::-webkit-scrollbar-thumb,
body:not(.dark) .table-scroll:focus-within:not(.is-scrolling)::-webkit-scrollbar-thumb{
  background:transparent;
}

/* Match the How-To modal feel: modal areas stay scrollable without a visible scrollbar. */
.tool-modal-body,
#layout_modal .layout-scroll,
.changelog-panel,
.disclaimer-panel,
.table-scroll{
  -ms-overflow-style:none;
  scrollbar-width:none !important;
  scrollbar-color:transparent transparent !important;
}

.tool-modal-body::-webkit-scrollbar,
#layout_modal .layout-scroll::-webkit-scrollbar,
.changelog-panel::-webkit-scrollbar,
.disclaimer-panel::-webkit-scrollbar,
.table-scroll::-webkit-scrollbar{
  width:0 !important;
  height:0 !important;
}

.tool-modal-body::-webkit-scrollbar-track,
#layout_modal .layout-scroll::-webkit-scrollbar-track,
.changelog-panel::-webkit-scrollbar-track,
.disclaimer-panel::-webkit-scrollbar-track,
.table-scroll::-webkit-scrollbar-track,
.tool-modal-body::-webkit-scrollbar-thumb,
#layout_modal .layout-scroll::-webkit-scrollbar-thumb,
.changelog-panel::-webkit-scrollbar-thumb,
.disclaimer-panel::-webkit-scrollbar-thumb,
.table-scroll::-webkit-scrollbar-thumb{
  background:transparent !important;
  border:0 !important;
}

@media (max-width:600px){
  .tool-modal-body{
    max-height:calc(90dvh - 106px);
  }
}

/* Settings modal: fixed header/footer with one scrollable middle region */
#layout_modal.layout-modal{
  background:rgba(2,6,23,.66) !important;
  backdrop-filter:blur(5px) !important;
}

#layout_modal .layout-panel{
  width:min(92vw,760px) !important;
  max-height:84vh !important;
  min-height:0 !important;
  padding:0 !important;
  overflow:hidden !important;
  background:var(--card) !important;
  color:var(--text) !important;
  border:2px solid var(--line) !important;
  border-radius:24px !important;
  box-shadow:0 24px 80px rgba(0,0,0,.35) !important;
  display:flex !important;
  flex-direction:column !important;
}

#layout_modal .layout-head{
  position:relative !important;
  top:auto !important;
  z-index:2 !important;
  display:flex !important;
  align-items:flex-start !important;
  justify-content:space-between !important;
  gap:12px !important;
  flex:0 0 auto !important;
  padding:20px 22px !important;
  background:var(--navy) !important;
  color:#fff !important;
  border-bottom:6px solid var(--gold) !important;
}

#layout_modal .layout-head h2{
  margin:0 !important;
  padding:0 !important;
  border:0 !important;
  color:#fff !important;
}

#layout_modal .layout-head .small{
  margin:6px 0 0 !important;
  color:#f2efe7 !important;
  line-height:1.35 !important;
  font-size:.95rem !important;
}

#layout_modal .layout-close{
  min-width:42px !important;
  min-height:42px !important;
  padding:0 !important;
  border-radius:14px !important;
  border:1px solid rgba(255,255,255,.35) !important;
  background:rgba(255,255,255,.14) !important;
  color:#fff !important;
  box-shadow:none !important;
  font-size:1.25rem !important;
}

#layout_modal .layout-scroll{
  flex:1 1 auto !important;
  min-height:0 !important;
  overflow-x:hidden !important;
  overflow-y:auto !important;
  -webkit-overflow-scrolling:touch !important;
  touch-action:pan-y !important;
  overscroll-behavior:contain !important;
  padding:20px 22px 0 !important;
  scrollbar-gutter:stable !important;
}

#layout_modal .layout-list{
  margin-top:0 !important;
  display:flex !important;
  flex-direction:column !important;
  flex:1 1 auto !important;
  gap:10px !important;
  min-height:0 !important;
  max-height:none !important;
  overflow:visible !important;
  padding-right:0 !important;
}

#layout_modal .layout-row{
  min-height:64px !important;
  padding:13px 14px !important;
  border-radius:16px !important;
  background:var(--soft) !important;
  border:1px solid var(--line) !important;
  color:var(--text) !important;
  touch-action:pan-y !important;
}

#layout_modal .layout-drag-handle{
  touch-action:none !important;
}

#layout_modal .settings-section{
  margin-top:18px !important;
  padding-top:16px !important;
  border-top:1px solid var(--line) !important;
}

#layout_modal .layout-footer{
  flex:0 0 auto !important;
  display:flex !important;
  justify-content:flex-end !important;
  gap:10px !important;
  margin:0 !important;
  padding:16px 22px calc(16px + env(safe-area-inset-bottom, 0px)) !important;
  border-top:1px solid var(--line) !important;
  background:var(--card) !important;
  position:relative !important;
  z-index:3 !important;
}

body.dark #layout_modal .layout-row,
body.dark #layout_modal .layout-footer{
  background:#10243b !important;
  color:#f8fafc !important;
  border-color:#38506b !important;
}

body.dark #layout_modal .layout-panel{
  background:#0f2136 !important;
  color:#f8fafc !important;
  border-color:#38506b !important;
}

body.dark #layout_modal .layout-scroll,
body.dark #layout_modal .settings-section{
  border-color:#38506b !important;
}

body.dark #layout_modal .layout-footer{
  background:#0f2136 !important;
}

@media (max-width:600px){
  #layout_modal.layout-modal{
    align-items:center !important;
    justify-content:center !important;
    padding:calc(env(safe-area-inset-top, 0px) + 10px) 10px calc(env(safe-area-inset-bottom, 0px) + 10px) !important;
    overflow:hidden !important;
  }

  #layout_modal .layout-panel{
    width:calc(100vw - 20px) !important;
    height:auto !important;
    max-height:90dvh !important;
    border-radius:22px !important;
  }

  #layout_modal .layout-head{
    padding:16px 18px 14px !important;
    gap:10px !important;
  }

  #layout_modal .layout-head h2{
    font-size:1.35rem !important;
    line-height:1.08 !important;
  }

  #layout_modal .layout-head .small{
    font-size:.92rem !important;
    line-height:1.25 !important;
    margin-top:5px !important;
  }

  #layout_modal .layout-close{
    width:42px !important;
    height:42px !important;
    min-width:42px !important;
    min-height:42px !important;
    max-width:42px !important;
    max-height:42px !important;
    border-radius:14px !important;
    font-size:1.25rem !important;
  }

  #layout_modal .layout-scroll{
    margin-top:10px !important;
    padding:14px 18px 0 !important;
  }

  #layout_modal .layout-list{
    gap:9px !important;
  }

  #layout_modal .layout-row{
    min-height:58px !important;
    padding:10px 12px !important;
    border-radius:16px !important;
    gap:10px !important;
  }

  #layout_modal .layout-drag-handle{
    width:38px !important;
    height:38px !important;
    flex:0 0 38px !important;
    border-radius:13px !important;
  }

  #layout_modal .layout-name{
    font-size:1rem !important;
    line-height:1.15 !important;
  }

  #layout_modal .settings-section h3{
    margin-bottom:8px !important;
    font-size:1rem !important;
  }

  #layout_modal .settings-section label{
    margin-top:9px !important;
    font-size:.9rem !important;
    line-height:1.15 !important;
  }

  #layout_modal .settings-section select,
  #layout_modal .settings-section input{
    min-height:46px !important;
    padding:9px 12px !important;
    border-radius:15px !important;
    font-size:16px !important;
  }

  #layout_modal .settings-section .row{
    gap:8px !important;
  }

  #layout_modal .settings-section .btns{
    display:grid !important;
    grid-template-columns:1fr 1fr !important;
    gap:8px !important;
    margin-top:10px !important;
  }

  #layout_modal .settings-section .btns button{
    width:100% !important;
    min-height:44px !important;
    padding:9px 10px !important;
    border-radius:15px !important;
    font-size:.82rem !important;
  }

  #layout_modal .settings-section .small{
    margin-top:8px !important;
    font-size:.82rem !important;
    line-height:1.25 !important;
  }

  #layout_modal .layout-footer{
    display:grid !important;
    grid-template-columns:1fr 1fr !important;
    gap:10px !important;
    padding:12px 18px calc(12px + env(safe-area-inset-bottom, 0px)) !important;
  }

  #layout_modal .layout-footer button{
    width:100% !important;
    min-height:48px !important;
    padding:10px 12px !important;
    border-radius:16px !important;
    font-size:.9rem !important;
  }
}

@media (max-width:380px){
  #layout_modal .layout-head .small{
    display:none !important;
  }

  #layout_modal .settings-section .btns{
    grid-template-columns:1fr !important;
  }
}

/* Day Supply polish: keep example presets close to actions */
#tool_standard_day_supply .gen-example-row{
  margin-top:10px;
}




/* ==========================================================================
   Shared reorder rows and dark-mode interaction states
   ========================================================================== */
.favorite-list-row.layout-row{
  display:flex;
  align-items:center;
  gap:8px;
  width:100%;
}

.favorite-layout-name{
  flex:1 1 auto;
  min-width:0;
  text-align:left;
  background:transparent;
  color:var(--text);
  border:0;
  box-shadow:none;
  padding:0;
  font:inherit;
  font-weight:850;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  cursor:pointer;
}

.favorite-layout-name:hover{
  text-decoration:underline;
}

.favorite-layout-remove{
  width:40px;
  min-width:40px;
  height:36px;
  flex:0 0 40px;
  padding:0;
  border-radius:12px;
  box-shadow:none;
  display:flex;
  align-items:center;
  justify-content:center;
}

body.dark .favorite-layout-name{
  color:#f8fafc;
}

/* Keep Search/Favorites modal rows from inheriting global dark action-button blue */
body.dark .tool-list-item,
body.dark button.tool-list-item,
body.dark .tool-search-main,
body.dark .favorite-layout-name{
  background:var(--soft) !important;
  color:var(--text) !important;
  border-color:var(--line) !important;
  box-shadow:none !important;
  filter:none !important;
}

body.dark .tool-list-item:hover,
body.dark button.tool-list-item:hover,
body.dark .tool-search-main:hover,
body.dark .favorite-layout-name:hover{
  background:rgba(255,255,255,.06) !important;
  border-color:rgba(216,168,51,.72) !important;
  filter:none !important;
}

body.dark .tool-search-fav-btn,
body.dark .favorite-layout-remove{
  background:var(--soft) !important;
  color:#facc15 !important;
  border-color:var(--line) !important;
  box-shadow:none !important;
  filter:none !important;
}

body.dark .tool-search-fav-btn:hover,
body.dark .favorite-layout-remove:hover{
  background:rgba(255,255,255,.08) !important;
  border-color:rgba(216,168,51,.72) !important;
  filter:none !important;
}

body.dark .tool-search-fav-btn.is-active{
  background:var(--gold) !important;
  color:#1f1300 !important;
  border-color:var(--gold) !important;
}

/* Card favorite buttons should stay gold after toggling in dark mode */
body.dark button.secondary.favorite-toggle.is-active,
body.dark button.favorite-toggle.is-active,
body.dark .card button.favorite-toggle.is-active{
  background:var(--gold) !important;
  color:#1f1300 !important;
  border-color:#b8870d !important;
  box-shadow:0 4px 0 rgba(0,0,0,.28) !important;
  filter:none !important;
}

body.dark button.secondary.favorite-toggle.is-active:hover,
body.dark button.favorite-toggle.is-active:hover,
body.dark .card button.favorite-toggle.is-active:hover{
  background:var(--gold) !important;
  color:#1f1300 !important;
  border-color:#b8870d !important;
  filter:none !important;
}

/* ==========================================================================
   Global mobile spacing
   ========================================================================== */
@media (max-width:600px){
  main{
    padding:14px 12px 18px !important;
  }

  .grid{
    gap:14px !important;
  }

  .card{
    padding:18px 14px !important;
    border-radius:20px !important;
  }

  .card h2{
    margin-bottom:12px !important;
    padding-bottom:9px !important;
  }

  .row{
    gap:10px !important;
  }

  .btns{
    gap:8px !important;
    margin-top:12px !important;
  }

  .preset-row{
    gap:7px !important;
    margin-top:12px !important;
  }

  .history{
    margin-top:14px !important;
    padding-top:12px !important;
  }

  .small{
    margin-top:8px !important;
  }

  input,
  select,
  textarea,
  .result{
    margin-top:5px !important;
  }
}

/* Workflow-grouped tool browser */
.tool-group{
  display:grid;
  gap:10px;
}
.tool-group + .tool-group{
  margin-top:10px;
}
.tool-group-header{
  margin:8px 0 0;
  padding:0 2px 7px;
  border-bottom:2px solid var(--gold);
  color:var(--navy);
  font-size:.78rem;
  font-weight:950;
  letter-spacing:.08em;
  line-height:1.2;
  text-transform:uppercase;
}
.tool-group-list{
  display:grid;
  gap:10px;
}
body.dark .tool-group-header{
  color:#f8fafc;
  border-bottom-color:var(--gold);
}

/* Search polish: result counts and favorites group */
.tool-search-count{
  margin:0 0 10px;
  padding:8px 10px;
  border:1px solid var(--line);
  border-radius:12px;
  background:var(--soft);
  color:var(--muted);
  font-size:.82rem;
  font-weight:850;
  line-height:1.25;
}
.tool-group-favorites .tool-group-header::before{
  content:'★ ';
  color:var(--gold);
}
body.dark .tool-search-count{
  background:#10243b;
  border-color:#38506b;
  color:#cbd5e1;
}


/* Unified modal close button sizing */
.tool-modal-close,
.layout-close,
.changelog-close,
.disclaimer-close,
.howto-modal-close{
  flex:0 0 42px;
  width:42px;
  height:42px;
  min-width:42px;
  min-height:42px;
  max-width:42px;
  max-height:42px;
  padding:0;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:14px;
  box-shadow:none;
  font-size:1.25rem;
  line-height:1;
}


.noscript-warning {
  margin: 1rem auto;
  max-width: 920px;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(255, 193, 7, 0.45);
  border-radius: 14px;
  background: rgba(255, 193, 7, 0.12);
  color: #fff7d6;
  font-weight: 700;
  text-align: center;
}

.result-note-copy{
  flex:0 0 auto;
  border:1px solid #cfd8e3;
  border-radius:999px;
  padding:7px 10px;
  background:#fff;
  color:var(--navy);
  font-size:.78rem;
  font-weight:900;
  box-shadow:none;
}
.result-note-copy:hover{transform:none;background:#f8fafc}
@media(max-width:520px){
  .result-summary-header{align-items:stretch;flex-direction:column}
  .result-note-copy{width:max-content}
}

.sig-parser-panel {
  margin: 1rem 0;
  padding: 0.9rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 14px;
  background: rgba(148, 163, 184, 0.08);
}
.sig-parser-panel textarea {
  width: 100%;
  min-height: 5rem;
  resize: vertical;
}
.sig-parser-inline-row {
  align-items: end;
}
.sig-parser-inline-row > div {
  min-width: 0;
}
.sig-parser-actions {
  display: flex;
  align-items: end;
  align-self: end;
}
.sig-parser-actions button {
  width: 100%;
  min-height: 48px;
  margin: 0;
}
@media (max-width: 640px) {
  .sig-parser-inline-row {
    grid-template-columns: 1fr 1fr;
  }
}
.sig-parser-success {
  color: var(--success-text, #166534);
  font-weight: 700;
}
.sig-parser-warning {
  color: var(--warning-text, #92400e);
  font-weight: 700;
}


.smart-fill-beta-box {
  display: grid;
  gap: 10px;
}
.smart-fill-beta-box textarea {
  min-height: 96px;
  resize: vertical;
}

.smart-fill-enhanced {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
  overflow: hidden;
}
.smart-fill-enhanced summary {
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 800;
  color: var(--text);
  list-style: none;
}
.smart-fill-enhanced summary::-webkit-details-marker {
  display: none;
}
.smart-fill-enhanced summary::after {
  content: ' +';
  float: right;
}
.smart-fill-enhanced[open] summary::after {
  content: ' −';
}
.smart-fill-enhanced-body {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
}

.smart-fill-beta-result:empty {
  display: none;
}
.smart-fill-match {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}
.smart-fill-field-list {
  display: grid;
  gap: 6px;
}
.smart-fill-field-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
.smart-fill-field-list div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.smart-fill-package-info {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold);
  border-radius: 12px;
  background: rgba(212, 160, 23, 0.08);
  color: var(--text);
}
.smart-fill-package-info strong {
  font-size: .92rem;
}
.smart-fill-package-info div {
  color: var(--text);
  line-height: 1.35;
  font-weight: 750;
}
.smart-fill-package-info em {
  color: var(--muted);
  font-style: normal;
  font-size: .86rem;
}
body.dark .smart-fill-package-info {
  background: rgba(250, 204, 21, 0.08);
  border-color: #38506b;
  border-left-color: #facc15;
}

.smart-fill-medication-recognized {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.smart-fill-medication-recognized strong {
  font-size: .9rem;
  color: var(--text);
}
.smart-fill-medication-recognized span {
  font-weight: 850;
  color: var(--text);
}
.smart-fill-medication-recognized em {
  color: var(--muted);
  font-style: normal;
  font-size: .86rem;
}

.seq-stage-list{
  display:grid;
  gap:16px;
  margin-top:16px;
}

.seq-stage-card{
  border:1px solid var(--border);
  border-radius:18px;
  padding:16px;
  background:rgba(255,255,255,.55);
}

.seq-stage-card h3{
  margin:0 0 12px;
  font-size:1.05rem;
  color:var(--navy);
}

.seq-stage-grid{
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:14px;
}

.seq-custom-frequency{
  margin-top:10px;
}

body.dark .seq-stage-card{
  background:rgba(15,23,42,.45);
  border-color:#334155;
}

body.dark .seq-stage-card h3{
  color:#e2e8f0;
}

@media (max-width: 720px){
  .seq-stage-grid{
    grid-template-columns:1fr;
  }
}

.copyright-footer{margin-top:0.45rem;font-size:0.82rem;opacity:0.78;text-align:center;}


/* SEO/internal reference links */
.quick-tool-icons a.quick-tool-btn{ text-decoration:none; }
.footer-reference-links{ display:flex; flex-wrap:wrap; justify-content:center; gap:8px 12px; margin:0 auto 12px; max-width:900px; }
.footer-reference-links a{ color:inherit; font-weight:800; text-decoration:underline; text-underline-offset:3px; }
.footer-reference-links a:hover{ color:var(--navy); }


/* Top quick-tools: keep Reference/User Guide help icon aligned with buttons */
.quick-tool-icons a.quick-tool-btn.help-link{
  margin-top:0 !important;
  padding:0 !important;
  gap:0 !important;
  border:0 !important;
  border-radius:11px !important;
  width:36px !important;
  height:34px !important;
  min-width:36px !important;
  display:inline-flex !important;
  align-items:center !important;
  justify-content:center !important;
  line-height:1 !important;
  font-family:Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
  font-size:1.35rem !important;
  font-weight:900 !important;
  transform:none !important;
}
.quick-tool-icons a.quick-tool-btn.help-link span{
  display:block;
  line-height:1;
  transform:translateY(-2px);
}
@media (max-width:480px){
  .quick-tool-icons a.quick-tool-btn.help-link{
    width:34px !important;
    height:32px !important;
    min-width:34px !important;
    font-size:1.28rem !important;
  }
}

/* Advanced Utilities polish */
.advanced-utilities input[type=number],
.advanced-utilities input,
.advanced-utilities select{
border-radius:12px!important;
padding:10px 12px!important;
border:1px solid #d8cdb8!important;
background:#fff!important;
font-size:15px!important;
box-shadow:inset 0 1px 2px rgba(0,0,0,.04);
}
.advanced-utilities .utility-card,
.advanced-utilities .input-card{
padding:14px!important;
}
.advanced-utilities label{
font-size:1.05rem!important;
font-weight:700!important;
margin-bottom:8px!important;
display:block;
}

/* MME stack reference enhancements */
.mme-mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0 0 1rem;
}
.mme-mode-tabs .active {
  background: var(--navy);
  color: #fff;
}
.mme-stack-table-wrap {
  margin-top: 0.75rem;
}
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-gutter: stable;
}
.mme-stack-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  margin-top: 0.5rem;
}
.mme-stack-table th,
.mme-stack-table td {
  border: 1px solid rgba(13, 43, 76, 0.16);
  padding: 0.55rem 0.65rem;
  text-align: left;
  vertical-align: middle;
}
.mme-stack-table th {
  background: rgba(13, 43, 76, 0.06);
  font-weight: 800;
}
.mme-stack-table tfoot td {
  background: rgba(218, 165, 32, 0.12);
}

body.dark .mme-stack-table th,
body.dark .mme-stack-table td {
  border-color: rgba(233, 238, 246, 0.18);
}
body.dark .mme-stack-table th {
  background: rgba(233, 238, 246, 0.08);
}
body.dark .mme-stack-table tfoot td {
  background: rgba(212, 160, 23, 0.18);
}

/* CSP-safe initial hidden state for sections previously hidden with inline styles. */
.hidden-by-default{display:none;}


/* How-To modal externalized for CSP */
.howto-modal-backdrop{
      position:fixed;
      inset:0;
      z-index:9999;
      display:none;
      align-items:center;
      justify-content:center;
      padding:18px;
      background:rgba(2,6,23,.66);
      backdrop-filter:blur(5px);
    }
    .howto-modal-backdrop.is-open{display:flex;}
    .howto-modal{
      width:min(92vw,760px);
      max-height:84vh;
      overflow:hidden;
      background:var(--card,#fff);
      color:var(--text,#0d243f);
      border:2px solid var(--line,#d9d6cc);
      border-radius:24px;
      box-shadow:0 24px 80px rgba(0,0,0,.35);
      display:flex;
      flex-direction:column;
    }
    .howto-modal-header{
      position:sticky;
      top:0;
      z-index:1;
      display:flex;
      align-items:flex-start;
      justify-content:space-between;
      gap:12px;
      padding:20px 22px;
      background:var(--navy,#0d243f);
      color:#fff;
      border-bottom:6px solid var(--gold,#d4a017);
    }
    .howto-modal-header h2{
      margin:0;
      padding:0;
      border:0;
      color:#fff;
      font-size:1.35rem;
    }
    .howto-modal-header p{
      margin:6px 0 0;
      color:#f2efe7;
      line-height:1.35;
      font-size:.95rem;
    }
    .howto-modal-close{
      flex:0 0 42px;
      width:42px;
      height:42px;
      min-width:42px;
      min-height:42px;
      max-width:42px;
      max-height:42px;
      padding:0;
      display:inline-flex;
      align-items:center;
      justify-content:center;
      font-size:1.25rem;
      line-height:1;
      border:1px solid rgba(255,255,255,.35);
      background:rgba(255,255,255,.14);
      color:#fff;
      border-radius:14px;
      box-shadow:none;
      cursor:pointer;
    }
    .howto-modal-body{
      padding:20px 22px 22px;
      overflow-y:auto;
      flex:1;
      scrollbar-gutter:stable;
    }

    /* Match other modal scrollbars */
    .howto-modal-body{
      scrollbar-width:thin;
      scrollbar-color:rgba(255,255,255,.36) rgba(255,255,255,.08);
    }
    .howto-modal-body::-webkit-scrollbar{width:10px;}
    .howto-modal-body::-webkit-scrollbar-track{
      background:rgba(255,255,255,.08);
      border-radius:999px;
    }
    .howto-modal-body::-webkit-scrollbar-thumb{
      background:rgba(255,255,255,.36);
      border:2px solid transparent;
      border-radius:999px;
      background-clip:padding-box;
    }
    .howto-modal-body::-webkit-scrollbar-thumb:hover{
      background:rgba(255,255,255,.52);
      border:2px solid transparent;
      background-clip:padding-box;
    }

    .howto-modal-grid{
      display:grid;
      grid-template-columns:repeat(auto-fit,minmax(240px,1fr));
      gap:14px;
    }
    .howto-card{
      border:1px solid var(--line,#d9d6cc);
      border-radius:18px;
      padding:15px;
      background:var(--soft,#f3f0e8);
    }
    .howto-card h3{
      margin:0 0 8px;
      color:var(--text,#0d243f);
      font-size:1rem;
    }
    .howto-card ul,
    .howto-card ol{
      margin:0;
      padding-left:20px;
      line-height:1.45;
    }
    .howto-card li{margin:5px 0;}
    .howto-modal-note{
      margin-top:16px;
      padding:14px;
      border-radius:16px;
      background:var(--soft,#f3f0e8);
      border:1px solid var(--line,#d9d6cc);
      line-height:1.4;
      font-size:.92rem;
    }
    .howto-modal-footer{
      display:flex;
      justify-content:flex-end;
      gap:10px;
      flex-wrap:wrap;
      padding:0 22px 22px;
    }
    .howto-full-link{
      display:inline-flex;
      align-items:center;
      justify-content:center;
      border:1px solid transparent;
      border-radius:14px;
      padding:12px 16px;
      background:var(--navy,#0d243f);
      color:#fff;
      font-weight:850;
      text-decoration:none;
      box-shadow:0 4px 0 rgba(13,36,63,.18);
    }
    body.dark .howto-full-link{
      background:#2563eb;
      border-color:#60a5fa;
      box-shadow:0 4px 0 rgba(0,0,0,.35), 0 0 0 1px rgba(96,165,250,.18);
    }
    body.dark .howto-full-link:hover{
      background:#3b82f6;
    }
    body.dark .howto-modal-footer button.secondary{
      background:#1e3a5f;
      border-color:#7c9bc2;
      box-shadow:0 4px 0 rgba(0,0,0,.3), 0 0 0 1px rgba(124,155,194,.12);
    }
    body.dark .howto-modal-footer button.secondary:hover{
      background:#284b78;
    }
    body.dark .howto-card,
    body.dark .howto-modal-note{
      background:#10243b;
      border-color:#38506b;
    }
    body.dark .howto-card h3{color:#f8fafc;}
    body.howto-modal-locked{overflow:hidden;}
    @media (max-width:600px){
      .howto-modal-backdrop{
        padding:calc(env(safe-area-inset-top, 0px) + 10px) 10px 10px;
        align-items:flex-start;
        overflow:auto;
      }
      .howto-modal{
        max-height:90dvh;
        border-radius:22px;
        margin:0 auto;
        overflow:hidden;
        display:flex;
        flex-direction:column;
      }
      .howto-modal-header{padding:20px 22px;}
      .howto-modal-body{
        padding:20px 22px 22px;
        padding-bottom:calc(env(safe-area-inset-bottom, 0px) + 22px);
      }
      .howto-modal-footer{padding:0 22px calc(env(safe-area-inset-bottom, 0px) + 18px);}
    }


/* v3.2.7 Official release: command palette browse card cleanup */
#command_palette_tabs{
  margin-top:14px;
}
.command-tabs{
  display:grid;
  grid-template-columns:auto 1fr 1fr 1fr;
  align-items:stretch;
  gap:0;
  overflow:hidden;
  padding:0;
  margin:0 0 4px;
  border:1px solid var(--gold);
  border-radius:14px;
  background:var(--soft);
}
.command-tab{
  min-height:38px;
  min-width:0;
  border:0;
  border-right:1px solid var(--line);
  background:transparent;
  color:var(--text);
  border-radius:0;
  padding:8px 10px;
  font-size:.82rem;
  font-weight:850;
  line-height:1;
  white-space:nowrap;
  box-shadow:none;
}
.command-tab:last-child{
  border-right:0;
}
.command-tab:hover{
  filter:none;
  background:rgba(216,168,51,.10);
}
.command-tab.is-active{
  background:var(--navy);
  color:#fff;
}

.command-browse-home{
  display:grid;
  gap:16px;
}
.command-browse-title{
  margin-top:2px;
  color:var(--navy);
  font-size:.88rem;
  font-weight:950;
  letter-spacing:.04em;
}
.command-browse-grid{
  display:grid;
  grid-template-columns:1fr;
  gap:10px;
}
.command-browse-card{
  width:100%;
  display:grid;
  grid-template-columns:auto 1fr auto;
  align-items:center;
  gap:12px;
  min-height:64px;
  padding:13px 14px;
  border:1px solid var(--line);
  border-radius:17px;
  background:var(--soft);
  color:var(--text);
  box-shadow:none;
  text-align:left;
}
.command-browse-card:hover{
  filter:none;
  border-color:var(--gold);
  transform:translateY(-1px);
}
.command-browse-icon{
  width:34px;
  height:34px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:12px;
  background:#fff;
  border:1px solid var(--line);
  font-size:1.05rem;
}
.command-browse-copy{
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:4px;
}
.command-browse-card-title{
  display:block;
  color:var(--text);
  font-size:.95rem;
  font-weight:950;
  line-height:1.1;
}
.command-browse-card-meta{
  display:block;
  color:var(--muted);
  font-size:.82rem;
  font-weight:700;
  line-height:1.3;
}
.command-browse-arrow{
  color:var(--muted);
  font-size:1.15rem;
  font-weight:950;
}

.command-home{display:grid;gap:16px;}
.command-home-group{display:grid;gap:10px;}
.command-result .tool-list-meta{font-size:.82rem;}
.command-empty-note{color:var(--muted);font-size:.9rem;padding:10px;border:1px dashed var(--line);border-radius:14px;background:rgba(255,255,255,.04);}
body.dark .command-tabs{
  background:#10243b;
  border-color:#f7d878;
}
body.dark .command-tab{
  background:transparent;
  border-color:#38506b;
  color:#e5e7eb;
}
body.dark .command-tab:hover{
  background:rgba(247,216,120,.12);
}
body.dark .command-tab.is-active{
  background:#f7d878;
  color:#0d243f;
}
body.dark .command-browse-title{color:#f8fafc;}
body.dark .command-browse-card{background:#10243b;border-color:#38506b;color:#e5e7eb;}
body.dark .command-browse-card:hover{border-color:rgba(216,168,51,.72);}
body.dark .command-browse-icon{background:#0b1d33;border-color:#38506b;}
body.dark .command-browse-card-title{color:#f8fafc;}
body.dark .command-browse-card-meta,
body.dark .command-browse-arrow{color:#cbd5e1;}
@media (max-width:560px){
  .command-tab{min-height:36px;padding:8px 7px;font-size:.74rem;}
}


.smart-fill-match{animation:smartFillIn .18s ease-out;}
.smart-fill-match-header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
  margin-bottom:6px;
}
.smart-fill-match-title{display:flex;flex-direction:column;gap:2px;}
.smart-fill-match-eyebrow{
  font-size:.7rem;
  font-weight:700;
  letter-spacing:.03em;
  text-transform:uppercase;
  color:var(--muted);
}
.smart-fill-confidence{
  display:inline-flex;
  flex-direction:column;
  align-items:flex-end;
  gap:0;
  min-width:88px;
  padding:4px 7px;
  border:1px solid var(--line);
  border-radius:8px;
  background:rgba(255,255,255,.72);
  color:var(--ink);
  font-weight:800;
  line-height:1.1;
  text-align:right;
  white-space:nowrap;
}
.smart-fill-confidence small{
  display:block;
  color:var(--muted);
  font-size:.62rem;
  font-weight:700;
  line-height:1.15;
}
.smart-fill-confidence-auto{border-color:rgba(19,126,57,.35);background:rgba(19,126,57,.08);color:#137e39;}
.smart-fill-confidence-review{border-color:rgba(216,168,51,.45);background:rgba(216,168,51,.12);color:#8a5a00;}
.smart-fill-confidence-manual{border-color:rgba(174,42,35,.35);background:rgba(174,42,35,.09);color:#ae2a23;}
.smart-fill-why{
  margin:10px 0;
  padding:8px 10px;
  border:1px solid var(--line);
  border-radius:8px;
  background:rgba(255,255,255,.5);
}
.smart-fill-why summary{
  cursor:pointer;
  font-weight:800;
  color:var(--ink);
}
.smart-fill-why ul{
  margin:7px 0 0;
  padding-left:18px;
}
.smart-fill-why li{margin:3px 0;color:var(--muted);}
body.dark .smart-fill-confidence,
body.dark .smart-fill-why{
  background:#10243b;
  border-color:#38506b;
}
body.dark .smart-fill-confidence-auto{background:rgba(74,222,128,.12);border-color:rgba(74,222,128,.32);color:#86efac;}
body.dark .smart-fill-confidence-review{background:rgba(247,216,120,.12);border-color:rgba(247,216,120,.35);color:#fde68a;}
body.dark .smart-fill-confidence-manual{background:rgba(248,113,113,.12);border-color:rgba(248,113,113,.32);color:#fca5a5;}
@keyframes smartFillIn{
  from{opacity:0;transform:translateY(3px);}
  to{opacity:1;transform:translateY(0);}
}
@media (max-width:560px){
  .smart-fill-match-header{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:start;}
  .smart-fill-confidence{align-items:flex-end;text-align:right;white-space:nowrap;}
}
body.dark .tool-empty-suggestion{background:#1b3656;color:#f8fafc;border-color:#38506b;}
body.dark .card{background:linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,0) 40%), var(--card);}

/* Smart Fill support surfaced in search without exposing backend intelligence panels */
.smartfill-med-search-card{
  display:grid;
  gap:10px;
  margin:0 0 10px;
  padding:14px;
  border:1px solid rgba(40,124,93,.35);
  border-radius:18px;
  background:linear-gradient(180deg, rgba(236,253,243,.95), rgba(255,255,255,.98));
  box-shadow:0 8px 22px rgba(13,36,63,.08);
}
.smartfill-med-search-top{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;}
.smartfill-med-search-title{font-weight:950;color:var(--navy);font-size:1rem;line-height:1.15;}
.smartfill-med-search-meta{margin-top:3px;color:var(--muted);font-weight:750;font-size:.82rem;line-height:1.3;}
.smartfill-med-search-supported{font-weight:950;color:#166534;font-size:.9rem;}
.smartfill-med-search-badges{display:flex;gap:6px;flex-wrap:wrap;}
.smartfill-med-search-badges span{
  display:inline-flex;align-items:center;padding:4px 8px;border-radius:999px;
  background:#fff;border:1px solid rgba(22,101,52,.22);color:#14532d;
  font-size:.74rem;font-weight:900;line-height:1;
}
.smartfill-med-search-actions{display:grid;gap:8px;}
.smartfill-med-try{justify-self:start;padding:9px 12px;border-radius:12px;font-size:.86rem;}
.smartfill-med-related{display:flex;align-items:center;gap:6px;flex-wrap:wrap;color:var(--muted);font-size:.78rem;font-weight:850;}
.smartfill-med-related button{
  appearance:none;border:1px solid var(--line);background:var(--soft);color:var(--navy);
  border-radius:999px;padding:5px 8px;font-size:.74rem;font-weight:900;box-shadow:none;
}
.smartfill-med-related button:hover{border-color:var(--gold);filter:none;}
body.dark .smartfill-med-search-card{background:linear-gradient(180deg, rgba(20,83,45,.35), rgba(16,36,59,.95));border-color:rgba(134,213,163,.45);box-shadow:none;}
body.dark .smartfill-med-search-title{color:#f8fafc;}
body.dark .smartfill-med-search-supported{color:#86efac;}
body.dark .smartfill-med-search-badges span{background:#10243b;border-color:#2f6f4e;color:#bbf7d0;}
body.dark .smartfill-med-related button{background:#10243b;color:#e2e8f0;border-color:#38506b;}


/* Smart Fill explanation contract */
.smart-fill-explanation{display:grid;gap:.5rem;margin-top:.7rem}
.smart-fill-explanation-section{padding:.58rem .65rem;border:1px solid var(--border-color, #d9d9d9);border-radius:8px;background:var(--surface-soft, rgba(127,127,127,.06))}
.smart-fill-explanation-section>strong{display:block;margin-bottom:.2rem}
.smart-fill-explanation-section ul{margin:.15rem 0 0 1rem;padding:0}
.smart-fill-explanation-section li+li{margin-top:.12rem}

/* ==========================================================================
   Numeric input spinners
   --------------------------------------------------------------------------
   The native up/down arrows on type="number" are removed. Nobody steps a
   quantity or a day supply one click at a time, and at step="0.25" — which is
   most fields here — each click moves a quarter unit, so the control does not
   even do the thing it looks like it does.

   Hiding the arrows is cosmetic on its own. The behaviour that matters is
   wheel stepping, handled in app.js: see the wheel listener beside this
   comment's counterpart.
   ========================================================================== */
input[type="number"]{
  -moz-appearance:textfield;
  appearance:textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button{
  -webkit-appearance:none;
  appearance:none;
  margin:0;
}

/* ==========================================================================
   Unparseable numeric input
   --------------------------------------------------------------------------
   Marks a type="number" field whose contents the browser cannot parse. Such a
   field still displays what was typed or pasted while .value returns an empty
   string, so without this the user sees a filled box and a message asking for
   a valid value. Paired with flagUnparseableNumericInput() in app.js.
   ========================================================================== */
input[type="number"].field-bad-input,
input[type="number"].field-bad-input:focus{
  border-color:var(--red);
  box-shadow:0 0 0 3px rgba(180,35,24,.18);
}
body.dark input[type="number"].field-bad-input,
body.dark input[type="number"].field-bad-input:focus{
  border-color:#f87171;
  box-shadow:0 0 0 3px rgba(248,113,113,.22);
}
