:root, [data-theme="dark"] {
    --bg: #050505;
    --card: rgba(255,255,255,.035);
    --card-border: rgba(255,255,255,.1);
    --text: #f2f2f2;
    --muted: #8a8a8a;
    --line: rgba(255,255,255,.14);
    --solid: #ffffff;
    --on-solid: #050505;
    --glow: rgba(255,255,255,.25);
    --code-bg: rgba(255,255,255,.04);
    --ease: cubic-bezier(.34,1.2,.64,1);
  }
  [data-theme="light"] {
    --bg: #f7f7f7;
    --card: rgba(0,0,0,.025);
    --card-border: rgba(0,0,0,.12);
    --text: #111111;
    --muted: #6b6b6b;
    --line: rgba(0,0,0,.16);
    --solid: #0a0a0a;
    --on-solid: #ffffff;
    --glow: rgba(0,0,0,.18);
    --code-bg: rgba(0,0,0,.045);
  }
  * { margin:0; padding:0; box-sizing:border-box; }
  ::selection { background: var(--solid); color: var(--on-solid); }
  html { scroll-behavior: smooth; }
  body {
    font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
    background: var(--bg); color: var(--text);
    min-height: 100vh; overflow-x: hidden; position: relative;
    -webkit-font-smoothing: antialiased;
    transition: background .45s ease, color .45s ease;
  }
  .amb {
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    background:
      radial-gradient(900px circle at 15% 0%, var(--glow), transparent 55%),
      radial-gradient(700px circle at 100% 100%, var(--glow), transparent 50%);
    opacity: .08;
    transition: opacity .45s ease;
  }
  [data-theme="light"] .amb { opacity: .07; }

  .wrap { position: relative; z-index: 1; max-width: 820px; margin: 0 auto; padding: 34px 22px 90px; }

  .topbar {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 36px; animation: rise .6s var(--ease) both; flex-wrap: wrap;
  }
  .brandmark {
    width: 42px; height: 42px; border-radius: 12px; flex: none;
    display: flex; align-items: center; justify-content: center;
    background: var(--solid); color: var(--on-solid);
    box-shadow: 0 2px 10px var(--glow);
    transition: transform .3s var(--ease);
  }
  .brandmark:hover { transform: rotate(-6deg) scale(1.05); }
  .brandmark svg { width: 21px; height: 21px; }
  .brand { display: flex; flex-direction: column; min-width: 0; }
  .brand .name { font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
  .brand .sub { color: var(--muted); font-size: .78rem; }
  .topbar .spacer { flex: 1; }
  .iconbtn {
    width: 40px; height: 40px; border-radius: 12px; flex: none;
    display: flex; align-items: center; justify-content: center;
    background: var(--card); border: 1px solid var(--card-border);
    color: var(--text); cursor: pointer;
    transition: background .25s ease, transform .25s var(--ease), border-color .25s ease, color .25s ease;
  }
  .iconbtn:hover { background: var(--solid); color: var(--on-solid); transform: translateY(-2px); border-color: transparent; }
  .iconbtn:active { transform: scale(.92); }
  .iconbtn svg { width: 18px; height: 18px; }
  [data-theme="dark"] .ico-sun { display: block; }
  [data-theme="dark"] .ico-moon { display: none; }
  [data-theme="light"] .ico-sun { display: none; }
  [data-theme="light"] .ico-moon { display: block; }

  .card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 18px;
    padding: clamp(18px, 3.5vw, 26px); margin-bottom: 20px;
    animation: rise .7s var(--ease) both;
    transition: border-color .3s ease, box-shadow .3s ease, transform .3s var(--ease);
  }
  .card:hover { border-color: var(--line); }
  .card:nth-of-type(2){ animation-delay:.06s; } .card:nth-of-type(3){ animation-delay:.12s; } .card:nth-of-type(4){ animation-delay:.18s; }
  @keyframes rise { from { opacity:0; transform: translateY(20px) scale(.985);} to { opacity:1; transform:none;} }

  .step-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
  .step-num {
    width: 32px; height: 32px; border-radius: 10px; flex: none;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: .9rem; color: var(--on-solid);
    background: var(--solid);
  }
  .step-head h2 { font-size: 1.05rem; font-weight: 650; letter-spacing: -.01em; }
  .step-head .hint { margin-left: auto; color: var(--muted); font-size: .76rem; white-space: nowrap; }

  .drop {
    border: 2px dashed var(--line); border-radius: 14px;
    padding: clamp(26px, 5vw, 40px) 20px; text-align: center; cursor: pointer;
    transition: border-color .25s ease, background .25s ease, transform .25s var(--ease);
    position: relative; overflow: hidden;
  }
  .drop::before {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(500px circle at var(--mx, 50%) var(--my, 50%), var(--glow), transparent 45%);
    opacity: 0; transition: opacity .3s ease; pointer-events: none;
  }
  .drop:hover::before, .drop.over::before { opacity: .18; }
  .drop:hover, .drop.over { border-color: var(--solid); background: var(--code-bg); transform: scale(1.006); }
  .drop .icon {
    width: 54px; height: 54px; margin: 0 auto 13px; border-radius: 15px;
    display: flex; align-items: center; justify-content: center; color: var(--text);
    background: var(--code-bg); border: 1px solid var(--card-border);
    transition: transform .3s var(--ease), background .3s ease, color .3s ease;
  }
  .drop .icon svg { width: 24px; height: 24px; }
  .drop:hover .icon { transform: translateY(-4px) scale(1.06); background: var(--solid); color: var(--on-solid); }
  .drop .main { font-weight: 650; margin-bottom: 5px; }
  .drop .sub { color: var(--muted); font-size: .84rem; }

  .chip {
    display: inline-flex; align-items: center; gap: 9px; margin-top: 13px;
    background: var(--code-bg); border: 1px solid var(--card-border);
    border-radius: 10px; padding: 8px 13px; font-size: .85rem; color: var(--text);
    animation: pop .3s var(--ease) both;
  }
  .chip svg { width: 14px; height: 14px; color: var(--muted); flex: none; }
  .chip button {
    background:none; border:none; color: var(--muted); cursor:pointer;
    padding: 3px; display: flex; align-items: center; border-radius: 6px;
    transition: color .2s ease, background .2s ease;
  }
  .chip button svg { width: 12px; height: 12px; }
  .chip button:hover { color: var(--text); background: var(--code-bg); }

  .editor { position: relative; margin-top: 15px; }
  textarea {
    width: 100%; min-height: clamp(150px, 30vw, 210px);
    background: var(--code-bg); color: var(--text);
    border: 1px solid var(--card-border); border-radius: 13px;
    padding: 15px 15px 34px; font-family: 'Cascadia Code', Consolas, monospace; font-size: .88rem;
    line-height: 1.6; resize: vertical; outline: none;
    transition: border-color .25s ease, box-shadow .25s ease, min-height .35s var(--ease);
  }
  textarea:focus { border-color: var(--solid); box-shadow: 0 0 0 3px var(--glow); }
  .editor.focus textarea { min-height: 68vh; }
  .editor .meta {
    position: absolute; bottom: 10px; right: 14px;
    color: var(--muted); font-size: .72rem; font-family: Consolas, monospace; pointer-events: none;
  }
  .editor .expand {
    position: absolute; top: 8px; right: 8px; z-index: 2;
    width: 30px; height: 30px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: 1px solid transparent;
    color: var(--muted); cursor: pointer;
    transition: background .2s ease, color .2s ease, border-color .2s ease, transform .2s var(--ease);
  }
  .editor .expand:hover { background: var(--code-bg); color: var(--text); border-color: var(--card-border); }
  .editor .expand:active { transform: scale(.9); }
  .editor .expand svg { width: 14px; height: 14px; }

  .opts { display: flex; flex-wrap: wrap; gap: 10px; }
  .opt {
    display: flex; align-items: center; gap: 10px; padding: 11px 15px;
    background: var(--code-bg); border: 1px solid var(--card-border);
    border-radius: 12px; cursor: pointer; user-select: none; font-size: .88rem;
    transition: border-color .2s ease, background .2s ease, transform .2s var(--ease);
  }
  .opt:hover { transform: translateY(-2px); border-color: var(--line); }
  .opt:active { transform: scale(.98); }
  .opt input { display: none; }
  .opt .sw {
    width: 38px; height: 21px; border-radius: 12px; background: var(--line);
    position: relative; transition: background .25s ease; flex: none;
  }
  .opt .sw::after {
    content: ''; position: absolute; top: 2.5px; left: 3px; width: 16px; height: 16px;
    border-radius: 50%; background: var(--text); transition: transform .25s var(--ease), background .25s ease;
  }
  .opt input:checked + .sw { background: var(--solid); }
  .opt input:checked + .sw::after { transform: translateX(16px); background: var(--on-solid); }

  .or {
    display: flex; align-items: center; gap: 14px;
    color: var(--muted); font-size: .74rem; letter-spacing: .3em; margin: 18px 0 14px; text-transform: uppercase;
  }
  .or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--card-border); }

  .manual input {
    width: 100%; padding: 13px 15px; background: var(--code-bg); color: var(--text);
    border: 1px solid var(--card-border); border-radius: 12px; font-size: .9rem;
    font-family: Consolas, monospace; outline: none;
    transition: border-color .25s ease, box-shadow .25s ease;
  }
  .manual input:focus { border-color: var(--solid); box-shadow: 0 0 0 3px var(--glow); }

  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 9px;
    padding: 13px 25px; border: none; border-radius: 12px; cursor: pointer;
    font-size: .93rem; font-weight: 700; letter-spacing: .01em;
    background: var(--solid); color: var(--on-solid);
    transition: transform .2s var(--ease), box-shadow .2s ease, opacity .2s ease, background .25s ease, color .25s ease;
    box-shadow: 0 2px 10px var(--glow);
    position: relative; overflow: hidden;
  }
  .btn::after {
    content: ''; position: absolute; top: 0; left: -80%; width: 45%; height: 100%;
    background: linear-gradient(100deg, transparent, rgba(127,127,127,.25), transparent);
    transform: skewX(-20deg); transition: left .55s ease; pointer-events: none;
  }
  .btn:hover::after { left: 130%; }
  .btn svg { width: 16px; height: 16px; flex: none; }
  .btn:hover { transform: translateY(-2px); box-shadow: 0 4px 16px var(--glow); }
  .btn:active { transform: translateY(0) scale(.96); }
  .btn:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }
  .btn:disabled::after { display: none; }
  .btn.ghost {
    background: transparent; color: var(--text); box-shadow: none;
    border: 1px solid var(--line);
  }
  .btn.ghost:hover { background: var(--code-bg); border-color: var(--solid); box-shadow: none; }
  .btnrow { display: flex; gap: 11px; flex-wrap: wrap; align-items: center; }

  .spinner {
    width: 16px; height: 16px; border-radius: 50%; flex: none;
    border: 2px solid color-mix(in srgb, var(--on-solid) 25%, transparent); border-top-color: var(--on-solid);
    animation: spin .7s linear infinite; display: none;
  }
  .busy .spinner { display: inline-block; }
  .busy .btxt, .busy svg { display: none; }
  @keyframes spin { to { transform: rotate(360deg); } }

  .outwrap { position: relative; }
  .out {
    background: var(--code-bg); border: 1px solid var(--card-border);
    border-radius: 13px; padding: 17px;
    font-family: 'Cascadia Code', Consolas, monospace; font-size: .86rem;
    line-height: 1.6; word-break: break-all; white-space: pre-wrap; color: var(--text);
    min-height: 80px; transition: border-color .25s ease, box-shadow .25s ease;
    cursor: text;
  }
  .out.done { border-color: var(--solid); box-shadow: 0 0 0 3px var(--glow); }
  .out .placeholder { color: var(--muted); font-size: .84rem; }
  .out .hl { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
  .out .kw { font-weight: 700; opacity: .65; }
  .badge {
    position: absolute; top: -10px; right: 15px;
    background: var(--solid); color: var(--on-solid);
    font-size: .66rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
    padding: 4px 12px; border-radius: 999px;
    animation: pop .35s var(--ease) both;
  }

  .rawbox {
    margin-top: 13px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    background: var(--code-bg); border: 1px solid var(--card-border);
    border-radius: 11px; padding: 10px 13px;
  }
  .rawbox .lbl { color: var(--muted); font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; flex: none; }
  .rawbox a {
    color: var(--text); font-family: Consolas, monospace; font-size: .82rem;
    text-decoration: none; word-break: break-all; flex: 1; min-width: 180px;
    transition: opacity .2s ease;
  }
  .rawbox a:hover { opacity: .7; text-decoration: underline; }

  /* every small pill button, one consistent size everywhere */
  .mini {
    flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    background: transparent; border: 1px solid var(--line);
    color: var(--text); border-radius: 8px; padding: 5px 11px; font-size: .76rem; cursor: pointer;
    transition: background .2s ease, border-color .2s ease, color .2s ease, transform .2s var(--ease);
    text-decoration: none; line-height: 1; overflow: hidden;
  }
  .mini svg { width: 12px; height: 12px; flex: none; display: block; }
  .mini:hover { background: var(--solid); color: var(--on-solid); border-color: transparent; }
  .mini:active { transform: scale(.9); }

  .hist { margin-top: 16px; }
  .hist-head {
    display: flex; align-items: center; gap: 8px; margin-bottom: 9px;
    color: var(--muted); font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  }
  .hist-head svg { width: 13px; height: 13px; }
  .hist-head .clear {
    margin-left: auto; background: none; border: none; color: var(--muted);
    font-size: .72rem; cursor: pointer; letter-spacing: .04em;
    border-bottom: 1px solid transparent; transition: color .2s ease, border-color .2s ease;
  }
  .hist-head .clear:hover { color: var(--text); border-color: var(--muted); }
  .hist-item {
    display: flex; align-items: center; gap: 10px; padding: 9px 12px;
    border: 1px solid var(--card-border); border-radius: 10px; margin-bottom: 7px;
    cursor: pointer; background: transparent;
    transition: background .2s ease, border-color .2s ease, transform .2s var(--ease);
    animation: pop .3s var(--ease) both;
  }
  .hist-item:hover { background: var(--code-bg); border-color: var(--line); transform: translateX(3px); }
  .hist-item:active { transform: translateX(0) scale(.99); }
  .hist-item .t { color: var(--muted); font-size: .72rem; font-family: Consolas, monospace; flex: none; }
  .hist-item .u {
    flex: 1; min-width: 0; color: var(--text); text-decoration: none;
    font-family: Consolas, monospace; font-size: .8rem;
    word-break: break-all;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    transition: opacity .2s ease;
  }
  .hist-item .u:hover { opacity: .65; text-decoration: underline; }
  .hist-item .acts { display: flex; gap: 6px; flex: none; }
  .empty { color: var(--muted); font-size: .78rem; }

  .toast {
    position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(90px) scale(.95);
    background: var(--solid); color: var(--on-solid);
    padding: 12px 22px; border-radius: 12px; font-size: .88rem; font-weight: 600;
    opacity: 0; transition: all .45s var(--ease); z-index: 99;
    box-shadow: 0 8px 24px var(--glow);
    max-width: 90vw; text-align: center;
  }
  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }

  footer { text-align: center; color: var(--muted); font-size: .78rem; margin-top: 34px; line-height: 1.8; }
  kbd {
    background: var(--code-bg); border: 1px solid var(--card-border);
    border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px;
    font-family: Consolas, monospace; font-size: .7rem;
  }

  @media (min-width: 860px) {
    .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
    .row2 .card { margin-bottom: 20px; }
  }
  @media (max-width: 600px) {
    .wrap { padding: 24px 13px 70px; }
    .topbar { gap: 9px; }
    .brand .name { font-size: 1.1rem; }
    .step-head .hint { display: none; }
    .btnrow .btn { flex: 1 1 100%; }
    .rawbox { align-items: flex-start; }
    .rawbox a { min-width: 100%; }
    .hist-item { flex-wrap: wrap; row-gap: 6px; }
    .hist-item .u { flex-basis: 100%; order: 3; -webkit-line-clamp: 3; }
  }

  .btn.danger { border-style: dashed; }
  .btn.danger:hover { background: var(--code-bg); border-color: var(--solid); }
  @media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
    html { scroll-behavior: auto; }
  }

  /* delete progress strip (below the Delete link button) */
  .delstrip {
    display: flex; align-items: center; gap: 12px;
    margin-top: 14px; padding: 14px 16px;
    border: 1px solid var(--line); border-radius: var(--r);
    background: var(--code-bg);
    opacity: 0; transform: translateY(6px) scale(.98);
    transition: opacity .22s var(--ease), transform .22s var(--ease);
    will-change: opacity, transform;
  }
  .delstrip.show { opacity: 1; transform: translateY(0) scale(1); }
  .delstrip.err { border-style: dashed; }
  .delstrip .dt { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
  .delstrip .dt b { font-size: .95rem; }
  .delstrip .dt span { font-size: .8rem; color: var(--muted); }
  .dspin {
    width: 22px; height: 22px; flex: none;
    border: 2px solid var(--line); border-top-color: var(--solid);
    border-radius: 50%; animation: spin .8s linear infinite;
  }
  .dstamp {
    width: 30px; height: 30px; flex: none; display: grid; place-items: center;
    border: 1.5px solid var(--solid); border-radius: 50%;
  }
  .dstamp svg { width: 16px; height: 16px; }
  .delstrip.err .dstamp { border-style: dashed; }
