
/* Site-adapted ISO 286 app — structure identical to original */
/* Watermark stacking follows site .wm-rotator in style.css */
#tolerances-app {
  position: relative;
  z-index: 1;
}
#tolerances-app button { font-family: inherit; }
#tolerances-app .hidden { display: none !important; }
#tolerances-app.theme-dark .tip[data-tip]::after {
  color: #0d1117;
  background: #e8edf2;
}


    :root {
      --bg: transparent;
      --bg-grid: transparent;
      --surface: rgba(255,255,255,0.78);
      --surface-2: rgba(248,249,250,0.95);
      --surface-3: #e8e9eb;
      --border: #bcc0c4;
      --border-strong: #9aa3ab;
      --text: #1a1a1a;
      --muted: #555;
      --accent: #ff6600;
      --accent-soft: rgba(255, 102, 0, 0.12);
      --ok: #0b6b45;
      --warn: #9a4d08;
      --danger: #a11c14;
      --shadow: 0 12px 40px rgba(0,0,0,0.08);
    }
    #tolerances-app.theme-dark,
    .theme-dark {
      --bg: #0d1117;
      --bg-grid: rgba(232, 236, 240, 0.035);
      --surface: #151b23;
      --surface-2: #1c2430;
      --surface-3: #242e3b;
      --border: #2c3848;
      --border-strong: #4a5a6d;
      --text: #e8edf2;
      --muted: #9aabbc;
      --accent: #ff8533;
      --accent-soft: rgba(255, 102, 0, 0.15);
      --ok: #3dba86;
      --warn: #e0a03a;
      --danger: #e0716a;
      --shadow: 0 1px 0 rgba(0,0,0,0.25), 0 16px 40px rgba(0,0,0,0.35);
    }
    #tolerances-app.theme-dark .topbar {
      background: color-mix(in srgb, #0d1117 82%, transparent);
    }
    #tolerances-app, #tolerances-app * { box-sizing: border-box; }
    #tolerances-app {
      font-family: 'Rajdhani', system-ui, sans-serif;
      color: var(--text);
      text-align: left;
      position: relative;
      z-index: 1;
    }
    #tolerances-app .seg button.active {
      background: var(--accent);
      color: #fff;
    }
    #tolerances-app .panel-head {
      border-bottom: 2px solid var(--accent);
    }
    #tolerances-app .app-shell { max-width: 1180px; padding-top: 1.25rem; }
    .app-shell { max-width: 1180px; margin: 0 auto; padding: 0 1rem 2.5rem; }
    @media (min-width: 640px) { .app-shell { padding: 0 1.5rem 3rem; } }

    .topbar {
      position: sticky; top: 0; z-index: 40;
      margin: 0 -1rem 1.25rem; padding: 0.85rem 1rem;
      backdrop-filter: blur(12px) saturate(1.1);
      background: color-mix(in srgb, var(--bg) 82%, transparent);
      border-bottom: 1px solid var(--border);
    }
    @media (min-width: 640px) { .topbar { margin: 0 -1.5rem 1.5rem; padding: 0.95rem 1.5rem; } }

    .brand-mark {
      width: 2.35rem; height: 2.35rem; border-radius: 8px;
      display: grid; place-items: center;
      background: var(--accent); color: #fff;
      font-family: 'Orbitron', ui-monospace, monospace;
      font-size: 0.68rem; font-weight: 600;
      box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
      flex-shrink: 0;
    }
    .theme-dark .brand-mark { color: #0d1117; }

    .panel {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 14px;
      box-shadow: var(--shadow);
      overflow: hidden;
    }
    .panel-head {
      display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
      padding: 0.85rem 1.15rem;
      background: linear-gradient(180deg, var(--surface-2), var(--surface));
      border-bottom: 1px solid var(--border);
    }
    .panel-body { padding: 1.15rem; }
    @media (min-width: 640px) { .panel-body { padding: 1.3rem 1.4rem 1.45rem; } }

    .label {
      color: var(--muted);
      font-size: 0.7rem; font-weight: 700;
      letter-spacing: 0.06em; text-transform: uppercase;
    }
    .field {
      width: 100%;
      background: var(--surface);
      border: 1px solid var(--border);
      color: var(--text);
      border-radius: 8px;
      padding: 0.7rem 0.85rem;
      font-size: 0.95rem;
      outline: none;
      transition: border-color .15s, box-shadow .15s;
      appearance: none;
    }
    select.field {
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235c6978' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 0.85rem center;
      padding-right: 2.2rem;
    }
    .field:hover { border-color: var(--border-strong); }
    .field:focus {
      border-color: var(--accent);
      box-shadow: 0 0 0 3px var(--accent-soft);
    }
    .unit-chip {
      min-width: 3.1rem;
      display: inline-flex; align-items: center; justify-content: center;
      padding: 0 0.75rem; border-radius: 8px;
      border: 1px solid var(--border); background: var(--surface-2);
      color: var(--muted); font-size: 0.8rem; font-weight: 700;
    }

    .seg {
      display: flex; background: var(--surface-2);
      border: 1px solid var(--border); border-radius: 10px;
      padding: 3px; gap: 2px;
    }
    .seg button {
      flex: 1; padding: 0.55rem 0.4rem; border-radius: 8px;
      font-size: 0.82rem; font-weight: 600; color: var(--muted);
      transition: background .15s, color .15s, box-shadow .15s;
    }
    .seg button:hover:not(.active) { color: var(--text); background: color-mix(in srgb, var(--surface) 70%, transparent); }
    .seg button.active {
      background: var(--accent); color: #fff;
      box-shadow: 0 1px 2px rgba(0,0,0,0.12);
    }
    .theme-dark .seg button.active { color: #0d1117; }

    .icon-btn {
      display: inline-flex; align-items: center; gap: 0.45rem;
      padding: 0.55rem 0.8rem; border-radius: 9px;
      border: 1px solid var(--border); background: var(--surface);
      color: var(--text); font-size: 0.82rem; font-weight: 600; cursor: pointer;
    }
    .icon-btn:hover { border-color: var(--border-strong); background: var(--surface-2); }

    .spec-callout {
      display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
      padding: 0.85rem 1rem; border-radius: 10px;
      border: 1px dashed var(--border-strong);
      background: linear-gradient(135deg, var(--accent-soft), transparent 55%), var(--surface-2);
    }
    .spec-callout .code {
      font-family: 'Orbitron', ui-monospace, monospace;
      font-size: 1.35rem; font-weight: 600; letter-spacing: 0.02em; line-height: 1;
    }

    .divider { height: 1px; background: var(--border); margin: 1.1rem 0; }
    .mono { font-family: 'Orbitron', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
    .pos { color: var(--ok); }
    .neg { color: var(--danger); }
    .zero { color: var(--muted); }

    .hero-result {
      background: linear-gradient(180deg, color-mix(in srgb, var(--surface-2) 80%, var(--surface)), var(--surface));
    }
    .tol-readout {
      font-size: clamp(1.85rem, 4vw, 2.65rem);
      font-weight: 600; letter-spacing: -0.02em; line-height: 1.1;
    }
    .tol-bar {
      height: 12px; border-radius: 999px;
      background:
        repeating-linear-gradient(90deg, transparent, transparent 7px, color-mix(in srgb, var(--border) 70%, transparent) 7px, color-mix(in srgb, var(--border) 70%, transparent) 8px),
        var(--surface-2);
      border: 1px solid var(--border);
      position: relative; overflow: hidden;
    }
    .tol-scale {
      display: grid; grid-template-columns: 1fr auto 1fr; gap: 0.5rem;
      margin-top: 0.55rem; font-size: 0.72rem; color: var(--muted);
    }
    .tol-scale span:first-child { text-align: left; }
    .tol-scale span:nth-child(2) { text-align: center; }
    .tol-scale span:last-child { text-align: right; }

    .fit-badge {
      display: inline-flex; align-items: center; gap: 0.4rem;
      padding: 0.4rem 0.75rem; border-radius: 999px;
      font-size: 0.75rem; font-weight: 700;
    }
    .fit-badge::before {
      content: ""; width: 0.45rem; height: 0.45rem;
      border-radius: 50%; background: currentColor;
    }
    .fit-clearance {
      background: color-mix(in srgb, var(--ok) 14%, transparent);
      color: var(--ok);
      border: 1px solid color-mix(in srgb, var(--ok) 32%, transparent);
    }
    .fit-transition {
      background: color-mix(in srgb, var(--warn) 14%, transparent);
      color: var(--warn);
      border: 1px solid color-mix(in srgb, var(--warn) 32%, transparent);
    }
    .fit-interference {
      background: color-mix(in srgb, var(--danger) 14%, transparent);
      color: var(--danger);
      border: 1px solid color-mix(in srgb, var(--danger) 32%, transparent);
    }

    .metric {
      position: relative;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 0.9rem 0.95rem 0.95rem 1rem;
    }
    .metric::before {
      content: ""; position: absolute; left: 0; top: 0.7rem; bottom: 0.7rem;
      width: 3px; border-radius: 0 2px 2px 0; background: var(--border-strong);
    }
    .grid-results {
      display: grid; gap: 0.7rem;
      grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
    }

    .error-box {
      margin-top: 1rem; padding: 0.75rem 0.9rem; border-radius: 9px;
      background: color-mix(in srgb, var(--danger) 10%, var(--surface));
      color: var(--danger);
      border: 1px solid color-mix(in srgb, var(--danger) 28%, transparent);
      font-size: 0.875rem;
    }
    .footnote {
      margin-top: 0.25rem; padding: 0.85rem 1rem; border-radius: 10px;
      border: 1px solid var(--border);
      background: color-mix(in srgb, var(--surface) 70%, transparent);
      color: var(--muted); font-size: 0.75rem; line-height: 1.55;
    }
    .section-title {
      display: flex; align-items: baseline; justify-content: space-between;
      gap: 0.75rem; margin-bottom: 0.9rem;
    }

    /* Guided UI */
    .ui-mode-seg { max-width: 420px; }
    .industry-grid {
      display: grid; gap: 0.55rem;
      grid-template-columns: 1fr;
    }
    @media (min-width: 480px) {
      .industry-grid { grid-template-columns: 1fr 1fr; }
    }
    .industry-card {
      text-align: left;
      padding: 0.75rem 0.85rem;
      border-radius: 10px;
      border: 1px solid var(--border);
      background: var(--surface);
      cursor: pointer;
      transition: border-color .15s, background .15s, box-shadow .15s;
    }
    .industry-card:hover {
      border-color: var(--border-strong);
      background: var(--surface-2);
    }
    .industry-card.active {
      border-color: var(--accent);
      background: var(--accent-soft);
      box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
    }
    .industry-card .name { font-size: 0.82rem; font-weight: 700; line-height: 1.25; }
    .industry-card .meta {
      margin-top: 0.3rem;
      font-size: 0.68rem;
      color: var(--muted);
      font-family: 'Orbitron', ui-monospace, monospace;
    }

    .app-list { display: flex; flex-direction: column; gap: 0.45rem; }
    .app-item {
      text-align: left;
      padding: 0.7rem 0.85rem;
      border-radius: 10px;
      border: 1px solid var(--border);
      background: var(--surface);
      cursor: pointer;
      transition: border-color .15s, background .15s;
    }
    .app-item:hover { border-color: var(--border-strong); background: var(--surface-2); }
    .app-item.active {
      border-color: var(--accent);
      background: var(--accent-soft);
    }
    .app-item .row {
      display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
    }
    .app-item .fit-code {
      font-family: 'Orbitron', ui-monospace, monospace;
      font-weight: 600; font-size: 0.9rem;
      white-space: nowrap;
    }
    .app-item .desc {
      margin-top: 0.25rem;
      font-size: 0.72rem;
      color: var(--muted);
      line-height: 1.4;
    }

    .tip {
      position: relative;
      display: inline-flex; align-items: center; justify-content: center;
      width: 1.05rem; height: 1.05rem;
      border-radius: 999px;
      border: 1px solid var(--border-strong);
      color: var(--muted);
      font-size: 0.65rem; font-weight: 700;
      cursor: help;
      vertical-align: middle;
    }
    .tip:hover, .tip:focus { color: var(--accent); border-color: var(--accent); outline: none; }
    .tip[data-tip]::after {
      content: attr(data-tip);
      position: absolute;
      z-index: 50;
      left: 50%; bottom: calc(100% + 8px);
      transform: translateX(-50%) scale(0.98);
      width: min(260px, 70vw);
      padding: 0.55rem 0.7rem;
      border-radius: 8px;
      background: var(--text);
      color: #e8e9eb;
      font-size: 0.7rem; font-weight: 500; line-height: 1.4;
      letter-spacing: 0;
      text-transform: none;
      opacity: 0; pointer-events: none;
      transition: opacity .12s, transform .12s;
      box-shadow: var(--shadow);
    }
    .tip:hover::after, .tip:focus::after {
      opacity: 1; transform: translateX(-50%) scale(1);
    }

    .advice-box {
      padding: 0.9rem 1rem;
      border-radius: 10px;
      border: 1px solid var(--border);
      background: var(--surface-2);
    }
    .advice-box h3 {
      margin: 0 0 0.35rem;
      font-size: 0.85rem; font-weight: 700;
    }
    .advice-box p {
      margin: 0;
      font-size: 0.78rem;
      color: var(--muted);
      line-height: 1.5;
    }
    .chip-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.7rem; }
    .chip {
      font-family: 'Orbitron', ui-monospace, monospace;
      font-size: 0.72rem; font-weight: 600;
      padding: 0.28rem 0.55rem;
      border-radius: 999px;
      border: 1px solid var(--border);
      background: var(--surface);
      color: var(--text);
      cursor: pointer;
    }
    .chip:hover, .chip.active {
      border-color: var(--accent);
      background: var(--accent-soft);
      color: var(--accent);
    }
    .step-pill {
      display: inline-flex; align-items: center; gap: 0.35rem;
      font-size: 0.68rem; font-weight: 700;
      color: var(--muted);
      letter-spacing: 0.04em;
      text-transform: uppercase;
    }
    .step-pill b {
      display: inline-grid; place-items: center;
      width: 1.15rem; height: 1.15rem; border-radius: 999px;
      background: var(--accent); color: #fff;
      font-size: 0.65rem;
    }
    .theme-dark .step-pill b { color: #0d1117; }
    .locked-note {
      font-size: 0.72rem; color: var(--muted);
      padding: 0.55rem 0.7rem;
      border-radius: 8px;
      background: var(--surface-2);
      border: 1px solid var(--border);
    }
  