:root {
  --bg: #fff;
  --fg: #1d1d1f;
  --muted: #6e6e73;
  --line: #d2d2d7;
  --surface: #f5f5f7;
  --danger: #d70015;
  --warn: #a35200;
  --radius: 18px;
  --gutter: 16px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --fg: #f5f5f7;
    --muted: #98989d;
    --line: #2c2c2e;
    --surface: #1c1c1e;
    --danger: #ff453a;
    --warn: #ff9f0a;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.bar, main, footer {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.brand {
  color: var(--fg);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand span { color: var(--muted); font-weight: 500; margin-left: 6px; }

main { flex: 1; padding-top: 24px; padding-bottom: 48px; }

footer {
  padding-top: 16px;
  padding-bottom: 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
footer p { margin: 2px 0; }

h1 {
  margin: 0;
  font-size: clamp(34px, 6.5vw, 56px);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 700;
  text-align: center;
}

.lead {
  margin: 12px auto 32px;
  max-width: 520px;
  text-align: center;
  color: var(--muted);
  font-size: clamp(17px, 2.4vw, 20px);
}

h2 { margin: 0; font-size: 20px; letter-spacing: -0.01em; font-weight: 650; }

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gutter);
  align-items: stretch;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.card > .btn:last-child { margin-top: auto; }
.card p { margin: 0; color: var(--muted); }

.field-label { font-size: 13px; color: var(--muted); }

.btn, .ghost {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  height: 44px;
  padding: 0 22px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  text-decoration: none;
}
.btn { background: var(--fg); color: var(--bg); }
.btn:hover { opacity: 0.86; }
.btn:disabled { opacity: 0.35; cursor: default; }
.ghost { background: transparent; color: var(--fg); border-color: var(--line); }
.ghost:hover { background: var(--bg); }
.small { height: 32px; padding: 0 14px; font-size: 14px; }
.danger { color: var(--danger); }

button:focus-visible, input:focus-visible, .drop:focus-within {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.seg {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--bg);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  height: 36px;
  border-radius: 999px;
  cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }

.codebox {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  border-radius: 999px;
  padding: 0 20px;
  font: 600 17px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
}
.codebox::placeholder { color: var(--muted); font-weight: 500; }

.notice {
  margin: 0 auto 16px;
  max-width: 560px;
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--surface);
  color: var(--danger);
  text-align: center;
  font-size: 15px;
}

/* room */
.head {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  margin-bottom: var(--gutter);
}
.head .label { font-size: 13px; color: var(--muted); }
.code {
  font: 650 clamp(24px, 6vw, 38px)/1.1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.08em;
  user-select: all;
}
.head .row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.meta { display: flex; gap: 8px 16px; flex-wrap: wrap; justify-content: center; color: var(--muted); font-size: 14px; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--line); margin-right: 6px; vertical-align: 1px; }
.dot.on { background: var(--fg); }

.col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.col > h2 { padding: 0 4px; }

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  min-height: 96px;
  padding: 16px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--muted);
  font-size: 15px;
}
.drop b { color: var(--fg); font-weight: 600; }
.drop.over { border-color: var(--fg); background: var(--surface); }
.drop small { font-size: 13px; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.list { display: flex; flex-direction: column; gap: 8px; }

.empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  border-radius: var(--radius);
  background: var(--surface);
}

.file {
  background: var(--surface);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.file .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.file .name { font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.file .sub { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.file .sub + .sub { margin-top: -4px; }
.file .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  background: var(--bg);
  color: var(--muted);
  white-space: nowrap;
}
.pill.ok { background: var(--fg); color: var(--bg); }
.pill.bad { color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.pill.warn { color: var(--warn); box-shadow: inset 0 0 0 1px var(--warn); }

.spin {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--fg);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.bar-track { height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--fg); transition: width 0.15s linear; }

.foot-actions { display: flex; justify-content: center; margin-top: 24px; }

@media (max-width: 720px) {
  .grid2 { grid-template-columns: 1fr; }
  .card { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .spin { animation-duration: 2.4s; }
  .bar-fill { transition: none; }
}
