:root{
      --bg:#f4f7fb;
      --bg-2:#eaf0f9;
      --panel:rgba(255,255,255,.82);
      --panel-solid:#ffffff;
      --text:#0f172a;
      --muted:#64748b;
      --border:#d8e0eb;
      --accent:#6d28d9;
      --accent-2:#0ea5e9;
      --accent-3:#16a34a;
      --warn:#b45309;
      --danger:#dc2626;
      --shadow:0 16px 40px rgba(15,23,42,.08);
      --radius:24px;
    }
    html[data-theme="dark"]{
      --bg:#07111f;
      --bg-2:#0b1528;
      --panel:rgba(15,23,42,.84);
      --panel-solid:#0f172a;
      --text:#e5e7eb;
      --muted:#94a3b8;
      --border:#223044;
      --accent:#8b5cf6;
      --accent-2:#38bdf8;
      --accent-3:#22c55e;
      --warn:#f59e0b;
      --danger:#ef4444;
      --shadow:0 20px 60px rgba(0,0,0,.30);
    }
    *{box-sizing:border-box}
    html{scroll-behavior:smooth}
    body{
      margin:0;
      min-height:100vh;
      font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
      color:var(--text);
      background:
        radial-gradient(circle at top left, rgba(139,92,246,.18), transparent 28%),
        radial-gradient(circle at top right, rgba(56,189,248,.12), transparent 26%),
        linear-gradient(180deg,var(--bg) 0%, var(--bg-2) 100%);
      padding:22px;
    }
    .wrap{
      width:min(1240px,100%);
      margin:0 auto;
      display:grid;
      gap:18px;
    }
    .hero,.card{
      background:var(--panel);
      border:1px solid var(--border);
      box-shadow:var(--shadow);
      border-radius:var(--radius);
      backdrop-filter:blur(14px);
    }
    .hero{
      padding:28px;
      display:grid;
      gap:14px;
    }
    .eyebrow{
      display:inline-flex;
      align-items:center;
      gap:8px;
      width:max-content;
      padding:8px 12px;
      border-radius:999px;
      background:rgba(139,92,246,.12);
      color:var(--accent);
      border:1px solid rgba(139,92,246,.25);
      font-size:.82rem;
      letter-spacing:.04em;
      text-transform:uppercase;
      font-weight:700;
    }
    h1{
      margin:0;
      font-size:clamp(2rem,4vw,3.6rem);
      line-height:1.02;
      letter-spacing:-.05em;
    }
    .subtitle{
      margin:0;
      max-width:80ch;
      color:var(--muted);
      line-height:1.65;
      font-size:1.02rem;
    }
    .topbar{
      display:flex;
      flex-wrap:wrap;
      gap:12px;
      justify-content:space-between;
      align-items:center;
    }
    .group{
      display:flex;
      flex-wrap:wrap;
      gap:10px;
      align-items:center;
    }
    .chip, .badge{
      display:inline-flex;
      align-items:center;
      gap:8px;
      padding:8px 12px;
      border-radius:999px;
      border:1px solid var(--border);
      background:rgba(255,255,255,.04);
      color:var(--text);
      font-size:.86rem;
      line-height:1;
      white-space:nowrap;
    }
    .chip strong, .badge strong{font-weight:700}

    .github-link{
      display:inline-flex;
      align-items:center;
      justify-content:center;
      gap:8px;
      padding:11px 15px;
      min-height:44px;
      border-radius:14px;
      border:1px solid var(--border);
      background:rgba(15,23,42,.9);
      color:#e5e7eb;
      text-decoration:none;
      box-shadow:none;
      line-height:1;
      white-space:nowrap;
      font-weight:500;
      transition:transform .15s ease, opacity .15s ease, box-shadow .15s ease, background .15s ease;
    }
    html[data-theme="light"] .github-link{
      background:#eaf0f7;
      color:#0f172a;
    }
    .github-link:hover{
      transform:translateY(-1px);
    }
    .badge.purple{background:rgba(139,92,246,.12);border-color:rgba(139,92,246,.24)}
    .badge.blue{background:rgba(56,189,248,.12);border-color:rgba(56,189,248,.24)}
    .badge.green{background:rgba(34,197,94,.12);border-color:rgba(34,197,94,.24)}
    .badge.orange{background:rgba(245,158,11,.12);border-color:rgba(245,158,11,.25)}
    .badge.red{background:rgba(239,68,68,.10);border-color:rgba(239,68,68,.24)}
    .tabs{
      display:flex;
      flex-wrap:wrap;
      gap:8px;
    }
    .tabs button{
      border:1px solid var(--border);
      background:rgba(255,255,255,.03);
      color:var(--text);
      box-shadow:none;
      border-radius:14px;
      padding:11px 14px;
      min-width:120px;
    }
    .tabs button.active{
      background:linear-gradient(135deg,var(--accent),#5b21b6);
      color:#fff;
      border-color:transparent;
    }
    .grid{
      display:grid;
      grid-template-columns:1.05fr .95fr;
      gap:18px;
    }
    .card{
      padding:20px;
      display:grid;
      gap:14px;
      align-content:start;
    }
    .header-row{
      display:flex;
      flex-wrap:wrap;
      gap:12px;
      justify-content:space-between;
      align-items:end;
    }
    .stack{
      display:grid;
      gap:8px;
      min-width:min(100%,320px);
    }
    .label{
      font-size:.9rem;
      font-weight:700;
      letter-spacing:.02em;
      color:var(--text);
    }
    .hint{
      font-size:.85rem;
      color:var(--muted);
      line-height:1.45;
    }
    select,textarea,button,input{
      font:inherit;
    }
    select,textarea,input,.output,.panel{
      width:100%;
      border:1px solid var(--border);
      background:var(--panel-solid);
      color:var(--text);
      border-radius:18px;
      outline:none;
      transition:border-color .15s ease, box-shadow .15s ease, transform .15s ease, background .15s ease;
    }
    html[data-theme="dark"] select,
    html[data-theme="dark"] textarea,
    html[data-theme="dark"] input,
    html[data-theme="dark"] .output,
    html[data-theme="dark"] .panel{
      background:#0b1220;
    }
    select{
      padding:12px 14px;
      max-width:340px;
    }
    input{
      padding:11px 13px;
    }
    select:focus,textarea:focus,input:focus{
      border-color:rgba(139,92,246,.9);
      box-shadow:0 0 0 4px rgba(139,92,246,.16);
    }
    textarea{
      min-height:240px;
      padding:16px;
      resize:vertical;
      line-height:1.6;
      font-size:1rem;
    }
    .output{
      height:240px;
      padding:16px;
      overflow-y:auto;
      white-space:pre-wrap;
      word-break:break-word;
      line-height:1.65;
      font-size:1rem;
    }
    .actions,.examples,.toolbar,.row-actions,.shortcut-row{
      display:flex;
      flex-wrap:wrap;
      gap:10px;
    }
    .toolbar{
      align-items:center;
      justify-content:space-between;
    }
    button{
      border:0;
      border-radius:14px;
      padding:11px 15px;
      cursor:pointer;
      transition:transform .15s ease, opacity .15s ease, box-shadow .15s ease, background .15s ease;
      color:#fff;
      background:linear-gradient(135deg,var(--accent),#5b21b6);
      box-shadow:0 10px 24px rgba(139,92,246,.18);
    }
    button:hover{transform:translateY(-1px)}
    button:active{transform:translateY(0)}
    button.secondary{
      background:rgba(15,23,42,.9);
      color:#e5e7eb;
      border:1px solid var(--border);
      box-shadow:none;
    }
    html[data-theme="light"] button.secondary{
      background:#eaf0f7;
      color:#0f172a;
    }
    button.green{background:linear-gradient(135deg,#16a34a,var(--accent-3));box-shadow:0 10px 24px rgba(34,197,94,.15)}
    button.blue{background:linear-gradient(135deg,#0ea5e9,var(--accent-2));box-shadow:0 10px 24px rgba(56,189,248,.16)}
    button.orange{background:linear-gradient(135deg,#f59e0b,#d97706);box-shadow:0 10px 24px rgba(245,158,11,.16)}
    button.danger{background:linear-gradient(135deg,#ef4444,#dc2626);box-shadow:0 10px 24px rgba(239,68,68,.14)}
    .examples button{
      padding:9px 13px;
      font-size:.92rem;
    }
    .section-title{
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:12px;
      flex-wrap:wrap;
      margin:0 0 2px;
    }
    .section-title h2{
      margin:0;
      font-size:1rem;
      letter-spacing:.02em;
    }
    .small-note{
      color:var(--muted);
      font-size:.88rem;
      line-height:1.5;
      margin:0;
    }
    .breakdown{
      padding:0;
      overflow:hidden;
    }
    .breakdown-empty{
      padding:16px;
      color:var(--muted);
      line-height:1.6;
    }
    .entry{
      padding:14px 16px;
      border-top:1px solid rgba(148,163,184,.22);
      display:grid;
      gap:10px;
    }
    .entry:first-child{border-top:0}
    .entry-head{
      display:flex;
      flex-wrap:wrap;
      justify-content:space-between;
      gap:10px;
      align-items:flex-start;
    }
    .entry-title{
      font-size:.74rem;
      text-transform:uppercase;
      letter-spacing:.09em;
      color:var(--muted);
    }
    .entry-head .chip{
      white-space:normal;
      overflow-wrap:anywhere;
      line-height:1.35;
    }
    .entry-body{
      display:grid;
      gap:8px;
    }
    .pair{
      display:grid;
      grid-template-columns:minmax(0,1fr);
      gap:8px;
      align-items:start;
    }
    .pair > div{
      min-width:0;
    }
    .source,.result,.rules{
      font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
      font-size:.94rem;
      line-height:1.5;
      overflow-wrap:anywhere;
      word-break:break-word;
      white-space:normal;
    }
    .source-title,.result-title,.rules-title{
      display:block;
      font-size:.73rem;
      text-transform:uppercase;
      letter-spacing:.08em;
      color:var(--muted);
      margin-bottom:5px;
    }
    .rules{
      color:var(--muted);
      background:rgba(148,163,184,.08);
      border:1px solid rgba(148,163,184,.16);
      border-radius:14px;
      padding:10px 12px;
    }
    .arrow{
      color:var(--muted);
      padding-top:0;
      user-select:none;
      justify-self:center;
    }
    .subgrid{
      display:grid;
      grid-template-columns:1fr 1fr;
      gap:14px;
    }
    .mini{
      display:grid;
      gap:10px;
      align-content:start;
    }
    .mini h3{
      margin:0;
      font-size:.92rem;
    }
    .mini p{
      margin:0;
      color:var(--muted);
      line-height:1.5;
      font-size:.88rem;
    }
    .checklist{
      display:grid;
      gap:8px;
      margin:0;
      padding:0;
      list-style:none;
    }
    .checklist li{
      display:flex;
      gap:10px;
      align-items:flex-start;
      color:var(--text);
      font-size:.9rem;
      line-height:1.5;
    }
    .dot{
      width:8px;
      height:8px;
      border-radius:999px;
      margin-top:.55em;
      flex:0 0 auto;
      background:var(--accent);
    }
    .footer{
      text-align:center;
      color:var(--muted);
      font-size:.9rem;
      padding:6px 0 2px;
    }
    .view-toggle{
      display:inline-flex;
      padding:4px;
      border-radius:16px;
      border:1px solid var(--border);
      background:rgba(255,255,255,.04);
      gap:4px;
    }
    .view-toggle button{
      box-shadow:none;
      background:transparent;
      color:var(--text);
      border:0;
      padding:9px 12px;
      border-radius:12px;
      min-width:104px;
    }
    .view-toggle button.active{
      background:linear-gradient(135deg,var(--accent),#5b21b6);
      color:#fff;
    }
    .segment-line{
      display:flex;
      gap:8px;
      flex-wrap:wrap;
    }
    .seg{
      padding:2px 8px;
      border-radius:999px;
      background:rgba(148,163,184,.12);
      border:1px solid rgba(148,163,184,.16);
      font-size:.83rem;
      color:var(--text);
    }
    .warning{
      color:var(--warn);
    }
    .hidden{display:none !important}
    .tab-panel{
      display:none;
    }
    .tab-panel.active{
      display:block;
    }
    .table-wrap{
      overflow:hidden;
      border:1px solid var(--border);
      border-radius:18px;
      background:rgba(255,255,255,.03);
    }
    table{
      width:100%;
      border-collapse:collapse;
      table-layout:fixed;
    }
    th,td{
      padding:10px 12px;
      border-bottom:1px solid rgba(148,163,184,.16);
      vertical-align:top;
      text-align:left;
      font-size:.9rem;
      overflow-wrap:anywhere;
      word-break:break-word;
      white-space:normal;
    }
    th{
      position:sticky;
      top:0;
      background:rgba(15,23,42,.92);
      z-index:1;
    }
    html[data-theme="light"] th{
      background:rgba(255,255,255,.95);
    }
    .muted{
      color:var(--muted);
    }
    .grid-2{
      display:grid;
      grid-template-columns:1fr 1fr;
      gap:18px;
    }
    .rule-editor{
      display:grid;
      gap:12px;
    }
    .rule-row{
      display:grid;
      grid-template-columns:90px 1fr 1fr 110px 44px 44px 44px;
      gap:8px;
      align-items:center;
    }
    .rule-row input[type="checkbox"]{
      width:20px;
      height:20px;
      justify-self:center;
    }
    .rule-row button{
      padding:10px 0;
      min-width:44px;
      border-radius:12px;
    }
    .pill{
      display:inline-flex;
      align-items:center;
      gap:8px;
      padding:7px 11px;
      border-radius:999px;
      border:1px solid var(--border);
      background:rgba(148,163,184,.08);
      font-size:.84rem;
      white-space:nowrap;
    }
    .test-pass{color:var(--accent-3);font-weight:700}
    .test-fail{color:var(--danger);font-weight:700}
    .print-sheet{
      display:grid;
      gap:18px;
    }
    .reference-grid{
      display:grid;
      grid-template-columns:1fr 1fr;
      gap:18px;
    }
    .reference-grid .card{padding:16px}
    .shortcut-list{
      display:grid;
      gap:10px;
      grid-template-columns:repeat(2,minmax(0,1fr));
    }
    .shortcut-item{
      display:flex;
      justify-content:space-between;
      gap:12px;
      padding:10px 12px;
      border:1px solid var(--border);
      border-radius:14px;
      background:rgba(148,163,184,.06);
      font-size:.9rem;
    }
    .kbd{
      font-family:ui-monospace,monospace;
      padding:2px 7px;
      border-radius:8px;
      border:1px solid var(--border);
      background:rgba(255,255,255,.06);
      white-space:nowrap;
    }
    .profile-bar{
      display:flex;
      gap:10px;
      flex-wrap:wrap;
      align-items:center;
    }
    .profile-bar select{max-width:220px}
    .batch-note{
      color:var(--muted);
      font-size:.88rem;
      line-height:1.45;
    }
    .forward-input-head, .reverse-input-head{
      display:flex;
      flex-wrap:wrap;
      align-items:flex-end;
      justify-content:space-between;
      gap:12px;
      width:100%;
    }
    .forward-input-copy, .reverse-input-copy{
      gap:4px;
      min-width:min(100%,240px);
      flex:1 1 240px;
    }
    .compact-mode-select{
      width:auto;
      max-width:190px;
      min-width:160px;
      flex:0 0 180px;
      padding:10px 12px;
    }
    .output-card .section-title{
      min-height:43px;
    }
    .mode-strip{
      padding:18px 20px;
      display:grid;
      gap:12px;
    }
    .section-spacer{height:4px}
    @media (max-width: 1040px){
      .grid,.grid-2,.reference-grid,.subgrid,.shortcut-list{grid-template-columns:1fr}
      .rule-row{grid-template-columns:1fr 1fr}
      .rule-row .dir,.rule-row .toggle,.rule-row .up,.rule-row .down,.rule-row .del{grid-column:auto}
    }
    @media (max-width: 680px){
      body{padding:14px}
      .hero,.card{padding:16px}
      textarea{min-height:190px}
      .output{height:190px}
      .output-card .section-title{min-height:auto}
      .pair{grid-template-columns:1fr}
      .arrow{display:none}
      .toolbar{align-items:flex-start}
      .view-toggle{width:100%}
      .view-toggle button{flex:1}
      .tabs button{min-width:0;flex:1}
      table{min-width:620px}
      .rule-row{grid-template-columns:1fr}
      .rule-row button{width:100%}
    }
    @media print{
      body{background:#fff !important; padding:0 !important}
      .hero,.tabs,.topbar .group:first-child,.grid,.card:not(#reference-panel), .footer{display:none !important}
      #reference-panel{display:block !important; box-shadow:none !important; border:0 !important; background:#fff !important; color:#000 !important}
      .reference-grid .card{break-inside:avoid}
      .table-wrap{border:1px solid #888}
      th{background:#f2f2f2 !important; color:#000 !important}
    }

#priorityView{padding:14px; display:grid; gap:10px;}

.hidden {
  display: none;
}
