:root {
  color-scheme: light dark;
  --bg: #f5f5f7;
  --panel: #ffffff;
  --glass: rgba(255, 255, 255, 0.72);
  --text: #1d1d1f;
  --text-2: #515154;
  --accent: #0066cc;
  --on-accent: #ffffff;
  --danger: #c4001a;
  --line: #d2d2d7;
  --track: #e8e8ed;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
  --r-card: 24px;
  --r-ctl: 14px;
  --s-1: 8px;
  --s-2: 16px;
  --s-3: 24px;
  --s-4: 40px;
  --tap: 44px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --panel: #1c1c1e;
    --glass: rgba(28, 28, 30, 0.72);
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --accent: #2997ff;
    --on-accent: #000000;
    --danger: #ff6b6b;
    --line: #38383a;
    --track: #2c2c2e;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  }
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 clamp(16px, 1.1vw + 12px, 18px)/1.5 var(--font);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
h1 { font-size: clamp(1.6rem, 2vw + 1rem, 2.2rem); line-height: 1.15; margin: 0 0 var(--s-1); letter-spacing: -0.02em; }
h2 { font-size: 1.3rem; margin: 0 0 var(--s-2); }
p { margin: 0 0 var(--s-2); }
.muted { color: var(--text-2); }
.label { margin: var(--s-2) 0 var(--s-1); }
.noscript { margin: var(--s-2); padding: var(--s-2); border-radius: var(--r-ctl); background: var(--panel); color: var(--danger); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.shell { max-width: 1100px; margin: 0 auto; padding: var(--s-3) var(--s-2) calc(var(--s-4) + 72px); }
.card {
  background: var(--panel);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: var(--s-3);
  container-type: inline-size;
}
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .card { background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px); }
}
.card-inner { background: var(--bg); border-radius: var(--r-ctl); padding: var(--s-2); margin-top: var(--s-2); }
.center { max-width: 460px; margin: 12vh auto 0; text-align: center; }
.icon { font-size: 3rem; margin-bottom: var(--s-1); }
.layout { display: grid; gap: var(--s-3); grid-template-columns: 1fr; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); min-width: var(--tap); padding: 0 var(--s-3);
  border: 0; border-radius: var(--r-ctl);
  font: 600 1rem/1 var(--font); cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.primary { background: var(--accent); color: var(--on-accent); width: 100%; min-height: 50px; }
.secondary { background: var(--track); color: var(--text); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.seg { display: flex; background: var(--track); border-radius: var(--r-ctl); padding: 3px; gap: 3px; }
.seg label { flex: 1; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: var(--tap); border-radius: 11px; font-weight: 600; color: var(--text-2); }
.seg input:checked + span { background: var(--panel); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15); }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 1px; }

.drop {
  margin: var(--s-2) 0; padding: var(--s-4) var(--s-2);
  border: 2px dashed var(--line); border-radius: var(--r-card); text-align: center;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}
.drop:hover, .drop.over { border-color: var(--accent); }
.drop-title { font-size: 1.2rem; font-weight: 600; margin-bottom: 4px; }
.switch { display: flex; align-items: center; gap: var(--s-1); min-height: var(--tap); margin-top: var(--s-1); }
.switch input { width: 24px; height: 24px; accent-color: var(--accent); }
.input, .textout {
  width: 100%; min-height: var(--tap); padding: 10px var(--s-2);
  border: 1px solid var(--line); border-radius: var(--r-ctl);
  background: var(--panel); color: var(--text); font: inherit;
}
.textout { resize: vertical; margin-bottom: var(--s-2); }
.actionbar { margin-top: var(--s-3); }
.progress { margin-top: var(--s-2); }
.track { height: 10px; background: var(--track); border-radius: 999px; overflow: hidden; }
.bar { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width 0.2s linear; }
.link { display: block; word-break: break-all; font: 0.95rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; margin: var(--s-1) 0 var(--s-2); user-select: all; }
.row { display: flex; gap: var(--s-1); flex-wrap: wrap; }
.row .btn { flex: 1; }
.status { min-height: 1.5em; margin: var(--s-2) 0 0; text-align: center; color: var(--text-2); }
.status.error { color: var(--danger); }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-1); }
.list li { display: flex; align-items: center; justify-content: space-between; gap: var(--s-1); padding: var(--s-2); border-radius: var(--r-ctl); background: var(--bg); min-height: var(--tap); flex-wrap: wrap; }
.list .state { color: var(--text-2); font-size: 0.9rem; }

@container (max-width: 380px) {
  .drop { padding: var(--s-3) var(--s-1); }
  .row .btn { flex-basis: 100%; }
}

/* phone: bottom action bar */
@media (max-width: 599px) {
  .actionbar {
    position: fixed; left: 0; right: 0; bottom: 0; margin: 0;
    padding: var(--s-2) calc(var(--s-2) + env(safe-area-inset-right)) calc(var(--s-2) + env(safe-area-inset-bottom)) calc(var(--s-2) + env(safe-area-inset-left));
    background: var(--panel);
  }
  @supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
    .actionbar { background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px); }
  }
  .center { margin-top: 6vh; }
}
/* tablet and desktop: two panes */
@media (min-width: 600px) {
  .layout { grid-template-columns: 3fr 2fr; align-items: start; }
  .primary { width: auto; min-width: 220px; }
}
@media (min-width: 1025px) {
  .shell { padding-top: var(--s-4); }
  .layout { grid-template-columns: 1.4fr 1fr; gap: var(--s-4); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
