:root {
  color-scheme: light;
  --primary: #007aff;
  --success: #34c759;
  --warning: #ff9500;
  --danger: #ff3b30;
  --paper: #fef7ed;
  --surface: #fffdfa;
  --surface-muted: #fff5e6;
  --border: rgba(73, 52, 38, 0.12);
  --ink: #1c1917;
  --muted: #78716c;
  --radius: 20px;
  --shadow: 0 12px 40px rgba(80, 55, 35, 0.10), 0 1px 3px rgba(80, 55, 35, 0.08);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 149, 0, 0.10), transparent 28rem),
    var(--paper);
  font-size: 16px;
  line-height: 1.5;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.48; }

.shell { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 48px 0 28px; }
.header { display: grid; grid-template-columns: 68px 1fr auto; gap: 18px; align-items: center; margin-bottom: 28px; }
.brand-mark { width: 64px; height: 64px; border-radius: 18px; background: var(--ink); position: relative; box-shadow: var(--shadow); }
.brand-mark::before { content: ""; position: absolute; width: 29px; height: 29px; left: 17px; top: 20px; background: var(--surface); transform: rotate(45deg); border-radius: 5px; }
.brand-mark span { position: absolute; width: 15px; height: 23px; left: 25px; top: 27px; background: var(--ink); border-radius: 3px 3px 0 0; z-index: 1; }
.eyebrow, .step { margin: 0; color: var(--primary); font-size: 12px; font-weight: 700; letter-spacing: 0.12em; }
h1, h2 { margin: 0; letter-spacing: -0.025em; }
h1 { font-size: clamp(30px, 4vw, 42px); line-height: 1.15; }
h2 { font-size: 24px; line-height: 1.25; }
.subtitle, .description { color: var(--muted); }
.subtitle { margin: 4px 0 0; }
.description { margin: 14px 0 20px; }
.status-pill, .minor-state { border-radius: 999px; font-size: 13px; font-weight: 650; }
.status-pill { min-height: 44px; display: inline-flex; align-items: center; padding: 0 16px; background: var(--surface-muted); border: 1px solid var(--border); }
.status-pill.online { color: #14752f; background: #eaf8ee; border-color: rgba(52, 199, 89, 0.3); }
.status-pill.offline { color: #9f241c; background: #fff0ef; border-color: rgba(255, 59, 48, 0.3); }
.minor-state { color: var(--muted); background: var(--surface-muted); padding: 6px 10px; }

.grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.card { background: rgba(255, 253, 250, 0.94); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.card-heading { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; }
.field { display: grid; gap: 7px; margin-bottom: 16px; color: var(--muted); font-size: 14px; font-weight: 650; }
.field input { min-height: 48px; border: 1px solid var(--border); border-radius: 12px; padding: 0 14px; color: var(--ink); background: #fff; outline: none; }
.field input:focus-visible { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.18); }

.login-view { min-height: min(610px, calc(100vh - 220px)); display: grid; place-items: center; padding: 20px 0 40px; }
.login-card { width: min(460px, 100%); padding: 32px; }
.login-icon { width: 52px; height: 52px; margin-bottom: 18px; display: grid; place-items: center; border-radius: 16px; color: var(--primary); background: rgba(0, 122, 255, 0.10); }
.login-icon svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.login-description { margin-bottom: 24px; }
.account-hint { display: grid; gap: 3px; margin: -8px 0 22px; padding: 13px 14px; border: 1px solid rgba(0, 122, 255, 0.18); border-radius: 12px; background: rgba(0, 122, 255, 0.06); }
.account-hint span, .account-hint small { color: var(--muted); font-size: 12px; }
.account-hint strong { overflow-wrap: anywhere; color: var(--ink); font-size: 15px; }
.login-form { display: grid; gap: 14px; }
.login-form .field { margin: 0; }
.login-submit { width: 100%; margin-top: 4px; }
.form-message { margin: 0; padding: 10px 12px; border-radius: 10px; color: #9f241c; background: #fff0ef; border: 1px solid rgba(255, 59, 48, 0.22); font-size: 14px; }
.login-help { margin: 18px 0 0; color: var(--muted); font-size: 13px; text-align: center; }

.operator-bar { min-height: 64px; margin-bottom: 16px; padding: 10px 12px 10px 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 1px solid var(--border); border-radius: 16px; background: rgba(255, 253, 250, 0.86); }
.operator-bar > div { min-width: 0; display: grid; gap: 2px; }
.operator-label { color: var(--muted); font-size: 12px; }
.operator-bar strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-button { flex: 0 0 auto; min-height: 44px; padding: 0 18px; }

.qr-surface { min-height: 310px; border-radius: 16px; background: var(--surface-muted); border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 18px; text-align: center; }
.qr-surface img { width: min(260px, 78vw); height: min(260px, 78vw); background: #fff; border-radius: 12px; }
.qr-surface p { color: var(--muted); margin: 12px 0 0; }
.qr-placeholder { width: 94px; height: 94px; border: 8px solid var(--border); border-radius: 12px; position: relative; }
.qr-placeholder::after { content: ""; position: absolute; inset: 22px; border: 7px solid var(--border); border-radius: 5px; }
.qr-surface:not(.empty) .qr-placeholder { display: none; }

.actions { display: flex; gap: 10px; margin-top: 16px; }
.button, .icon-button { min-height: 48px; border-radius: 999px; border: 1px solid transparent; transition: transform 180ms ease, background 180ms ease, border-color 180ms ease; }
.button { flex: 1; padding: 0 18px; font-weight: 700; }
.button.primary { color: #fff; background: var(--primary); }
.button.primary:hover:not(:disabled) { background: #006ee6; }
.button.secondary { color: var(--ink); background: var(--surface); border-color: var(--border); }
.button.secondary:hover:not(:disabled) { background: var(--surface-muted); }
.button:active:not(:disabled), .icon-button:active:not(:disabled) { transform: scale(0.98); }
.button:focus-visible, .icon-button:focus-visible { outline: 3px solid rgba(0, 122, 255, 0.25); outline-offset: 2px; }
.icon-button { width: 48px; padding: 0; display: grid; place-items: center; color: var(--muted); background: var(--surface-muted); border-color: var(--border); }
.icon-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.pairing-list { display: grid; gap: 12px; }
.pairing-item { border: 1px solid var(--border); border-radius: 14px; padding: 16px; background: #fff; }
.pairing-item h3 { margin: 0; font-size: 17px; }
.pairing-meta { color: var(--muted); font-size: 13px; margin: 4px 0 14px; overflow-wrap: anywhere; }
.pairing-actions { display: flex; gap: 8px; }
.pairing-actions .button { min-height: 44px; }
.pairing-actions .deny { color: var(--danger); }
.empty-state { min-height: 180px; display: grid; place-items: center; text-align: center; padding: 24px; color: var(--muted); background: var(--surface-muted); border: 1px dashed var(--border); border-radius: 14px; }
footer { margin-top: 20px; color: var(--muted); font-size: 13px; text-align: center; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); max-width: min(560px, calc(100% - 32px)); padding: 12px 16px; border-radius: 12px; color: #fff; background: var(--ink); box-shadow: var(--shadow); z-index: 10; }

@media (max-width: 780px) {
  .shell { padding-top: 24px; }
  .header { grid-template-columns: 56px 1fr; }
  .brand-mark { width: 52px; height: 52px; border-radius: 15px; transform: scale(0.82); transform-origin: left center; }
  .status-pill { grid-column: 1 / -1; justify-self: stretch; justify-content: center; }
  .grid { grid-template-columns: 1fr; }
  .login-view { min-height: auto; padding-top: 0; }
  .login-card { padding: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
