:root {
  --card: var(--surface); --text: var(--ink); --border: var(--line); --success: var(--ok);
  --accent-weak: var(--accent-hover); --radius: 14px;
  --scroll-track: var(--bg); --scroll-thumb: var(--line); --scroll-thumb-hover: var(--muted);
}
.title { font-family: var(--f-display); font-weight: 400; font-size: clamp(26px, 5vw, 40px); line-height: 1.2; }
.wrap {
      max-width: min(960px, 92vw);
      margin: clamp(16px, 3.5vw, 40px) auto;
      padding: clamp(16px, 2.5vw, 28px);
    }
.hdr {
      display: grid;
      gap: 8px;
      justify-items: start;
    }
.title {
      font-size: clamp(1.6rem, 2.6vw + .6rem, 2.4rem);
      font-weight: 800;
      letter-spacing: .02em;
    }
.lead {
      color: var(--muted);
      font-size: clamp(.95rem, .25vw + .9rem, 1.05rem);
      background: color-mix(in oklab, var(--card) 85%, transparent);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 14px 16px;
      box-shadow: var(--shadow);
    }
.grid {
      display: grid;
      grid-template-columns: 1fr;
      gap: 18px;
    }
@media (min-width: 760px) {
.grid {
        grid-template-columns: 1.2fr .8fr;
      }
}
.card {
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      padding: clamp(16px, 2vw, 22px);
    }
label {
      font-weight: 600;
      display: inline-block;
      margin-bottom: 6px;
    }
.row {
      display: grid;
      grid-template-columns: 1fr;
      gap: 10px;
    }
@media (min-width: 560px) {
.row {
        grid-template-columns: 1fr 1fr;
      }
}
input[type="number"], input[type="text"] {
      width: 100%;
      padding: 12px 14px;
      border: 1px solid var(--border);
      border-radius: 10px;
      background: var(--card);
      color: var(--text);
      font-size: 1rem;
    }
fieldset {
      border: 1px dashed var(--border);
      border-radius: 10px;
      padding: 10px 12px;
    }
legend {
      padding: 0 6px;
      color: var(--muted);
      font-size: .95rem;
    }
.radio {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      margin-right: 12px;
    }
.btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: .5em;
      padding: 12px 16px;
      border: none;
      border-radius: 12px;
      cursor: pointer;
      font-weight: 700;
      letter-spacing: .02em;
      font-size: 1rem;
      background: var(--accent);
      color: var(--accent-ink);
      transition: transform .06s ease, filter .2s ease;
    }
.btn:hover {
      filter: brightness(1.05);
    }
.btn:active {
      transform: translateY(1px) scale(.99);
    }
.btn.secondary {
      background: transparent;
      color: var(--accent);
      border: 1px solid var(--accent-weak);
    }
.outputs {
      display: grid;
      gap: 12px;
      margin-top: 8px;
    }
.out-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      padding: 10px 12px;
      border: 1px solid var(--border);
      border-radius: 12px;
      background: color-mix(in oklab, var(--card) 88%, transparent);
    }
.out-row strong {
      font-weight: 700;
    }
.value {
      font-family: var(--f-mono);
      font-size: 1.05rem;
      letter-spacing: .02em;
      padding: 4px 8px;
      border-radius: 8px;
      background: color-mix(in oklab, var(--card) 70%, transparent);
      border: 1px dashed var(--border);
      min-width: 8ch;
      text-align: right;
    }
.tools ul {
      margin: 0;
      padding-left: 1.1em;
    }
.tools li {
      margin: 6px 0;
      color: var(--muted);
    }
.tools a {
      color: var(--accent);
      text-decoration: none;
    }
.tools a:hover {
      text-decoration: underline;
    }
.footer {
      text-align: center;
      color: var(--muted);
      font-size: .95rem;
      margin-top: 22px;
    }
.footer a {
      color: var(--accent);
      text-decoration: none;
    }
.header-links {
      margin-top: 8px;
      font-size: .9rem;
      color: var(--muted);
    }
.link-btn {
      background: none;
      border: none;
      padding: 0;
      margin: 0;
      font: inherit;
      color: var(--accent);
      cursor: pointer;
      text-decoration: underline;
    }
.header-links .link-btn {
      background: none;
      border: solid 3px;
      padding: 1.2em;
      margin-bottom: 1em;
      font: inherit;
      color: var(--accent);
      cursor: pointer;
      font-weight: 700;
      border-radius: 20px;
      text-decoration: none;
    }
.link-btn:hover {
      opacity: .85;
    }
.hint {
      color: var(--muted);
      font-size: .9rem;
      margin-top: 8px;
    }
.error {
      color: var(--svg);
      font-size: .9rem;
      display: none;
      margin-top: 6px;
    }
.toast {
      position: fixed;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%) scale(0.9);
      background: color-mix(in oklab, var(--card) 95%, rgba(0, 0, 0, 0.3));
      color: var(--text);
      border: 1px solid var(--border);
      padding: 16px 28px;
      border-radius: 12px;
      box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
      opacity: 0;
      pointer-events: none;
      transition: opacity .2s ease, transform .2s ease;
      z-index: 9999;
      font-weight: 600;
      font-size: 1.1rem;
    }
.toast.show {
      opacity: 1;
      transform: translate(-50%, -50%) scale(1);
    }
.hist-actions {
      margin-left: auto;
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
    }
.hist-memo {
      font-size: .9rem;
      font-weight: 500;
    }
.history-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      margin-bottom: 8px;
    }
.history-clear {
      font-size: .8rem;
      padding: 4px 10px;
    }
.modal-head-main {
      display: flex;
      align-items: center;
      gap: 8px;
    }
@media (prefers-reduced-motion: reduce) {
.btn {
        transition: none;
      }
.toast {
        transition: none;
      }
}
* {
      scrollbar-width: thin;
      scrollbar-color: var(--scroll-thumb) var(--scroll-track);
    }
::-webkit-scrollbar {
      width: 10px;
      height: 10px;
    }
::-webkit-scrollbar-track {
      background: var(--scroll-track);
      border-radius: 999px;
    }
::-webkit-scrollbar-thumb {
      background: linear-gradient(180deg, color-mix(in oklab, var(--accent) 25%, var(--scroll-thumb)), var(--scroll-thumb));
      border-radius: 999px;
      border: 2px solid var(--scroll-track);
      min-height: 36px;
    }
::-webkit-scrollbar-thumb:hover {
      background: color-mix(in oklab, var(--accent) 45%, var(--scroll-thumb));
    }
::-webkit-scrollbar-corner {
      background: transparent;
    }
.wrap {
      max-width: min(1100px, 94vw);
    }
.hdr-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
    }
.theme-toggle {
      position: relative;
      width: 64px;
      height: 32px;
      display: inline-flex;
      align-items: center;
      cursor: pointer;
    }
.theme-toggle input {
      appearance: none;
      position: absolute;
      inset: 0;
      margin: 0;
    }
.theme-toggle .track {
      position: absolute;
      inset: 0;
      background: color-mix(in oklab, var(--card) 80%, transparent);
      border: 1px solid var(--border);
      border-radius: 999px;
      box-shadow: var(--shadow);
    }
.theme-toggle .icon {
      position: absolute;
      font-size: 16px;
      top: 50%;
      transform: translateY(-50%);
    }
.theme-toggle .moon {
      left: 8px;
      opacity: .8;
    }
.theme-toggle .sun {
      right: 8px;
      opacity: .6;
    }
.theme-toggle input+.track::before {
      content: "";
      position: absolute;
      top: 4px;
      left: 4px;
      width: 24px;
      height: 24px;
      border-radius: 999px;
      background: var(--accent);
      transition: transform .22s ease;
    }
.theme-toggle input:checked+.track::before {
      transform: translateX(32px);
    }
.uploader {
      margin-top: 10px;
      margin-bottom: 14px;
      padding: 10px 12px;
      border-radius: 12px;
      border: 1px dashed var(--border);
      background: color-mix(in oklab, var(--card) 90%, transparent);
      font-size: .9rem;
      color: var(--muted);
    }
.drop-zone {
      margin-top: 6px;
      padding: 14px 12px;
      border-radius: 10px;
      border: 1px dashed var(--accent-weak);
      background: color-mix(in oklab, var(--card) 86%, transparent);
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 4px;
      cursor: pointer;
      text-align: center;
    }
.drop-zone strong {
      color: var(--accent);
    }
.drop-zone.dragover {
      border-style: solid;
      background: color-mix(in oklab, var(--card) 80%, var(--accent) 6%);
    }
.drop-help {
      margin-top: 6px;
      font-size: .85rem;
      color: var(--muted);
    }
.grid {
      grid-template-columns: 1fr;
    }
.history {
      display: none;
    }
@media (min-width: 760px) {
.grid {
        grid-template-columns: 1.2fr .8fr;
      }
}
@media (min-width: 1024px) {
.grid {
        grid-template-columns: .9fr 1.2fr .8fr;
      }
.history {
        display: block;
      }
}
.history-list {
      display: grid;
      gap: 10px;
      max-height: 60vh;
      overflow: auto;
      padding-right: 6px;
    }
.hist-item {
      display: flex;
      align-items: center;
      gap: 10px;
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 10px;
      background: color-mix(in oklab, var(--card) 88%, transparent);
    }
.hist-main {
      display: flex;
      flex-direction: column;
      gap: 2px;
      min-width: 0;
    }
.hist-meta {
      font-size: .85rem;
      color: var(--muted);
    }
.hist-actions {
      margin-left: auto;
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
    }
.chip {
      font: inherit;
      padding: 6px 10px;
      border-radius: 999px;
      border: 1px solid var(--border);
      background: transparent;
      color: var(--text);
      cursor: pointer;
    }
.fab {
      position: fixed;
      right: 18px;
      bottom: 18px;
      width: 56px;
      height: 56px;
      border-radius: 50%;
      border: none;
      background: var(--accent);
      color: var(--accent-ink);
      font-size: 28px;
      line-height: 0;
      box-shadow: var(--shadow);
      cursor: pointer;
    }
@media (min-width: 1024px) {
.fab {
        display: none;
      }
}
.modal {
      position: fixed;
      inset: 0;
      display: none;
      justify-content: center;
      align-items: center;
      background: rgba(0, 0, 0, .35);
      z-index: 10000;
      padding: 16px;
    }
.modal.show {
      display: flex;
    }
.modal-card {
      background: var(--card);
      color: var(--text);
      border: 1px solid var(--border);
      border-radius: calc(var(--radius) + 4px);
      max-width: 720px;
      width: 100%;
      max-height: 82vh;
      display: flex;
      flex-direction: column;
      box-shadow: var(--shadow);
      overflow: hidden;
      
    }
.modal-card a {
      color: var(--accent);
      text-decoration: none;
    }
.modal-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 12px 14px;
      border-bottom: 1px solid var(--border);
      position: sticky;
      top: 0;
      background: var(--card);
      z-index: 1;
    }
.modal-body {
      padding: 12px 14px;
      overflow: auto;
    }
.modal-close {
      border: none;
      background: transparent;
      font-size: 22px;
      color: var(--muted);
      cursor: pointer;
    }
h1.title { margin: 0; }
