:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #142033;
  --muted: #6a7689;
  --line: #e1e7ef;
  --primary: #1f6feb;
  --primary-dark: #1557bd;
  --green: #16815c;
  --red: #c73838;
  --shadow: 0 12px 32px rgba(24, 48, 80, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.shell { width: min(100% - 28px, 760px); margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 0 40px; }
.card { background: var(--card); border: 1px solid rgba(225, 231, 239, .9); border-radius: 20px; box-shadow: var(--shadow); padding: 20px; margin: 14px 0; }
.auth-card { max-width: 430px; margin: 12vh auto 0; padding: 30px; }
.brand-mark { display: grid; place-items: center; width: 48px; height: 48px; background: var(--primary); color: white; border-radius: 15px; font-weight: 800; letter-spacing: -.04em; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(1.55rem, 5vw, 2.2rem); margin-bottom: 4px; letter-spacing: -.04em; }
h2 { font-size: 1.08rem; margin-bottom: 0; }
.eyebrow { color: var(--primary); font-size: .74rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; margin: 0 0 5px; }
.muted { color: var(--muted); }
.stack { display: grid; gap: 14px; }
.compact { gap: 10px; margin-top: 13px; }
label { display: grid; gap: 7px; font-weight: 650; font-size: .92rem; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfe; color: var(--text); padding: 12px 13px; outline: none; }
textarea { resize: vertical; min-height: 108px; line-height: 1.55; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31, 111, 235, .14); }
button { border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 750; }
.primary { background: var(--primary); color: #fff; }
.primary:hover { background: var(--primary-dark); }
.secondary { background: #eaf2ff; color: var(--primary-dark); }
.wide { width: 100%; }
.send-button { min-height: 52px; font-size: 1.05rem; margin-top: 2px; }
.topbar, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar { padding: 8px 2px 2px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-button, .text-button { padding: 7px 9px; background: transparent; color: var(--muted); }
.text-button { color: var(--primary); }
.status-pill { padding: 6px 9px; border-radius: 99px; font-size: .78rem; font-weight: 750; white-space: nowrap; }
.status-pill.online { color: var(--green); background: #e4f7ef; }
.status-pill.offline { color: #8a5b12; background: #fff2d7; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { color: var(--muted); font-size: .8rem; font-weight: 700; margin-bottom: 7px; }
.choice-grid { display: grid; gap: 15px; margin: 14px 0; }
.segmented { display: flex; gap: 7px; flex-wrap: wrap; }
.segmented label { display: block; }
.segmented input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.segmented span { display: inline-block; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); font-weight: 650; cursor: pointer; }
.segmented input:checked + span { border-color: var(--primary); background: #eaf2ff; color: var(--primary-dark); }
.duration-segmented { gap: 6px; }
.duration-segmented span { padding: 8px 10px; font-size: .88rem; }
.feedback, .error { min-height: 1.2em; margin: 0; font-size: .86rem; }
.error { color: var(--red); }
.feedback { color: var(--green); }
.help { font-size: .86rem; margin: 12px 0 0; }
.device-list, .history-list { display: grid; gap: 9px; margin-top: 14px; }
.device-row, .history-row { border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.device-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.device-name, .history-title { font-weight: 750; }
.device-meta, .history-meta { color: var(--muted); font-size: .82rem; margin-top: 4px; }
.device-state { white-space: nowrap; font-size: .82rem; font-weight: 750; }
.device-state.online { color: var(--green); }
.device-state.offline { color: var(--muted); }
.history-row { display: grid; gap: 9px; }
.history-top { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.history-content { white-space: pre-wrap; line-height: 1.5; }
.history-status { font-size: .76rem; font-weight: 800; border-radius: 99px; padding: 5px 8px; background: #edf1f6; color: #5c6878; white-space: nowrap; }
.history-status.displayed { color: var(--green); background: #e4f7ef; }
.history-status.revoked { color: var(--red); background: #fde9e9; }
.history-actions { display: flex; justify-content: flex-end; }
.revoke-button { color: var(--red); background: #fff1f1; padding: 8px 10px; font-size: .82rem; }
.empty { color: var(--muted); text-align: center; padding: 16px 0; }
.empty.small { text-align: left; padding: 10px 0; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { min-width: 0; }
details { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 14px; }
summary { cursor: pointer; font-weight: 750; }
.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translate(-50%, 120px); background: #142033; color: #fff; border-radius: 99px; padding: 10px 16px; opacity: 0; transition: .2s ease; z-index: 10; pointer-events: none; font-size: .88rem; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
[hidden] { display: none !important; }
@media (min-width: 640px) {
  .choice-grid { grid-template-columns: 1fr 1fr; }
  .card { padding: 24px; }
}

