:root {
  --ink: #24324b;
  --muted: #6e7b91;
  --blue: #4f83e8;
  --blue-dark: #315fae;
  --blue-light: #8db5ff;
  --blue-soft: #edf4ff;
  --yellow: #ffd66b;
  --orange: #ff8b55;
  --orange-soft: #fff2e9;
  --green: #35a56f;
  --red: #dc5b5b;
  --paper: #ffffff;
  --bg: #f5f8ff;
  --line: #dfe7f3;
  --shadow: 0 20px 60px rgba(53, 76, 118, 0.14);
  --shadow-soft: 0 14px 40px rgba(57, 83, 132, .1);
}

* { box-sizing: border-box; }
html { margin: 0; min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100%; position: relative; isolation: isolate; overflow-x: hidden; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 2%, rgba(255, 214, 107, .42), transparent 24rem),
    radial-gradient(circle at 96% 8%, rgba(79, 131, 232, .28), transparent 28rem),
    radial-gradient(circle at 76% 92%, rgba(255, 139, 85, .16), transparent 23rem),
    var(--bg);
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  opacity: .55;
  background-image:
    linear-gradient(rgba(79,131,232,.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79,131,232,.055) 1px, transparent 1px),
    radial-gradient(circle, rgba(49,95,174,.13) 1.2px, transparent 1.4px);
  background-size: 34px 34px, 34px 34px, 22px 22px;
  background-position: center, center, 11px 11px;
  mask-image: linear-gradient(to bottom, black, rgba(0,0,0,.25) 75%, transparent);
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.shell { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0 64px; position: relative; }
.shell::before, .shell::after, .setup-page::before, .setup-page::after, .classroom-shell::before, .classroom-shell::after {
  position: absolute; pointer-events: none; z-index: -1; font-weight: 900; letter-spacing: .12em; user-select: none;
}
.shell::before { content: 'ABC'; top: 125px; left: -88px; color: rgba(79,131,232,.13); font-size: 70px; transform: rotate(-12deg); }
.shell::after { content: '1  2  3'; right: -100px; bottom: 70px; color: rgba(255,139,85,.12); font-size: 56px; transform: rotate(9deg); }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 24px;
  padding: 15px 18px; border-radius: 22px; background: rgba(255,255,255,.78);
  border: 1px solid rgba(255,255,255,.9); box-shadow: var(--shadow-soft); backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 52px; height: 52px; border-radius: 17px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--blue), var(--blue-light)); color: white; font-size: 25px;
  box-shadow: 0 12px 30px rgba(79, 131, 232, .34); border: 3px solid rgba(255,255,255,.7);
}
.brand h1 { font-size: 22px; margin: 0; letter-spacing: .02em; }
.brand p { font-size: 13px; margin: 4px 0 0; color: var(--muted); }
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 9px 13px; border-radius: 999px; background: rgba(255,255,255,.9); border: 1px solid var(--line); font-size: 13px; box-shadow: 0 7px 18px rgba(58,79,116,.07); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #aab4c4; }
.status-pill.online .status-dot { background: var(--green); box-shadow: 0 0 0 5px rgba(53,165,111,.12); }
.status-pill.offline .status-dot { background: var(--red); }

.grid { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(280px, .72fr); gap: 24px; align-items: start; }
.card { background: rgba(255,255,255,.9); border: 1px solid rgba(255,255,255,.95); border-radius: 28px; padding: 28px; box-shadow: var(--shadow); backdrop-filter: blur(16px); position: relative; overflow: hidden; }
.card::before { content: ''; position: absolute; inset: 0 0 auto; height: 7px; background: linear-gradient(90deg, var(--blue), var(--yellow), var(--orange)); }
.card::after { content: ''; position: absolute; width: 150px; height: 150px; border-radius: 50%; right: -85px; top: -90px; background: rgba(79,131,232,.07); }
.card h2 { margin: 0 0 6px; font-size: 23px; }
.eyebrow { color: var(--orange); font-weight: 800; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; }
.subtle { color: var(--muted); line-height: 1.65; font-size: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { margin-top: 18px; }
.field label { display: block; font-size: 14px; font-weight: 650; margin-bottom: 8px; }
.field input, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px;
  outline: none; color: var(--ink); background: rgba(248,251,255,.9); transition: .2s;
}
.field select {
  width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 13px 42px 13px 14px;
  outline: none; color: var(--ink); background: rgba(248,251,255,.9); transition: .2s;
}
.field textarea { min-height: 90px; resize: vertical; }
.field-help { margin: 7px 2px 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(79,131,232,.12); background: white; }
.templates { display: grid; gap: 10px; margin-top: 10px; }
.template {
  display: flex; align-items: center; gap: 11px; padding: 13px 14px; border: 1px solid var(--line);
  border-radius: 15px; background: rgba(255,255,255,.88); transition: .2s; box-shadow: 0 5px 14px rgba(48,75,124,.04);
}
.template:hover { border-color: #a9c4f6; transform: translateY(-2px); box-shadow: 0 9px 20px rgba(48,75,124,.09); }
.template input { accent-color: var(--blue); }
.template:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.primary {
  width: 100%; border: 0; border-radius: 16px; padding: 15px 20px; margin-top: 22px;
  color: white; font-weight: 750; background: linear-gradient(135deg, #5a91f0, var(--blue-dark));
  box-shadow: 0 12px 28px rgba(49,95,174,.26); transition: .2s;
}
.primary:hover { transform: translateY(-1px); box-shadow: 0 15px 32px rgba(49,95,174,.32); }
.primary:disabled { opacity: .55; transform: none; cursor: wait; }
.secondary { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; background: rgba(255,255,255,.9); color: var(--ink); font-weight: 650; box-shadow: 0 6px 15px rgba(47,73,118,.06); transition: .2s; }
.secondary:hover { border-color: #b6ccf5; transform: translateY(-1px); box-shadow: 0 9px 19px rgba(47,73,118,.1); }
.sound-button { border: 1px solid #a9c4f6; border-radius: 12px; padding: 10px 14px; background: var(--blue-soft); color: var(--blue-dark); font-weight: 750; }
.sound-button.needs-sound { color: white; border-color: var(--orange); background: linear-gradient(135deg, var(--orange), #f06c37); box-shadow: 0 0 0 6px rgba(255,139,85,.13); animation: sound-pulse 1.8s ease-in-out infinite; }
.text-button { width: 100%; border: 0; margin-top: 12px; padding: 8px; background: transparent; color: var(--muted); }
@keyframes sound-pulse { 50% { box-shadow: 0 0 0 10px rgba(255,139,85,.04); } }
.notice { border-radius: 16px; padding: 14px 16px; margin-top: 16px; font-size: 14px; line-height: 1.55; background: linear-gradient(135deg, #fff9e5, #fff2e9); border: 1px solid #f8df93; }
.result { display: none; margin-top: 18px; padding: 15px; border-radius: 16px; background: var(--blue-soft); border: 1px solid #cfdef8; }
.result.show { display: block; }
.result.error-result { color: #a13c3c; background: #fff0f0; border-color: #f2b9b9; }
.result strong { display: block; margin-bottom: 5px; }
.mini-list { display: grid; gap: 13px; margin-top: 20px; }
.mini-item { display: flex; gap: 12px; align-items: flex-start; }
.mini-icon { flex: 0 0 36px; height: 36px; border-radius: 12px; background: var(--blue-soft); display: grid; place-items: center; color: var(--blue-dark); font-weight: 800; box-shadow: inset 0 0 0 1px rgba(79,131,232,.08); }
.mini-item:nth-child(2) .mini-icon { background: #fff7d8; color: #9a6b00; }
.mini-item:nth-child(3) .mini-icon { background: var(--orange-soft); color: #c65b2d; }
.mini-item strong { font-size: 14px; }
.mini-item p { margin: 3px 0 0; font-size: 13px; color: var(--muted); line-height: 1.55; }
.link { color: var(--blue-dark); text-decoration: none; font-weight: 700; }
.setup-link { text-align: center; margin: 17px 0 0; }
.setup-page { min-height: 100vh; display: grid; place-items: center; padding: 38px 24px; position: relative; }
.setup-page::before { content: 'ABC'; left: 7%; top: 12%; font-size: clamp(52px, 8vw, 110px); color: rgba(79,131,232,.13); transform: rotate(-11deg); }
.setup-page::after { content: '1 · 2 · 3'; right: 5%; bottom: 10%; font-size: clamp(42px, 6vw, 82px); color: rgba(255,139,85,.13); transform: rotate(8deg); }
.setup-page .setup-box { width: min(620px, 100%); }
.success-panel { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.success-code { font-size: 28px; font-weight: 850; color: var(--blue-dark); margin: 4px 0 14px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions a { text-align: center; }

/* admin */
.admin-shell { padding-bottom: 70px; }
.admin-login-card { width: min(520px, 100%); margin: 70px auto 0; }
.admin-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 34px 2px 20px; }
.admin-toolbar h2 { margin: 4px 0; font-size: 30px; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.activation-output-card { min-height: 300px; }
.empty-state { display: grid; place-items: center; min-height: 120px; color: var(--muted); text-align: center; }
.activation-code { margin: 26px 0 16px; padding: 19px 15px; border-radius: 18px; background: var(--blue-soft); border: 1px dashed #8db5ff; color: var(--blue-dark); text-align: center; font-size: clamp(17px, 2.4vw, 24px); font-weight: 900; letter-spacing: .08em; line-height: 1.7; white-space: pre-wrap; user-select: all; max-height: 260px; overflow: auto; }
.copy-code-button { width: 100%; min-height: 48px; }
.activation-list-card { margin-top: 24px; }
.activation-list-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.activation-list-heading h2 { margin: 4px 0; }
.activation-stats { margin: 18px 0 12px; padding: 11px 14px; border-radius: 13px; background: rgba(237,244,255,.8); color: var(--blue-dark); font-size: 13px; font-weight: 700; }
.activation-list { display: grid; gap: 10px; }
.activation-row { display: flex; align-items: center; gap: 14px; padding: 14px 15px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.84); }
.activation-row-text { flex: 1; min-width: 0; }
.activation-masked { display: block; font-size: 16px; letter-spacing: .04em; }
.activation-detail { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.activation-badge { flex: 0 0 auto; padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.activation-badge.unused { color: #216b4c; background: #e5f7ee; }
.activation-badge.used { color: #315fae; background: #e7f0ff; }
.activation-badge.revoked { color: #8b5960; background: #f5e9eb; }
.revoke-button { width: auto; margin: 0; color: #a34d4d; padding: 7px; }

/* classroom */
.classroom-body { min-height: 100vh; overflow: hidden; background: linear-gradient(145deg, #f8fbff 0%, #edf4ff 52%, #fff8e7 100%); }
.classroom-shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; padding: 24px 30px 22px; position: relative; }
.classroom-shell::before { content: 'ABC'; left: 5%; top: 20%; font-size: clamp(58px, 9vw, 120px); color: rgba(79,131,232,.1); transform: rotate(-14deg); }
.classroom-shell::after { content: '1  2  3'; right: 4%; bottom: 16%; font-size: clamp(48px, 7vw, 92px); color: rgba(255,139,85,.1); transform: rotate(11deg); }
.classroom-header {
  display: flex; justify-content: space-between; align-items: center; gap: 20px; z-index: 1;
  padding: 15px 18px; border-radius: 22px; background: rgba(255,255,255,.76);
  border: 1px solid rgba(255,255,255,.92); box-shadow: var(--shadow-soft); backdrop-filter: blur(14px);
}
.classroom-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.room-title { font-size: clamp(24px, 3vw, 42px); font-weight: 850; }
.idle { display: grid; place-items: center; text-align: center; padding: 24px 0; z-index: 0; }
.idle > div { width: min(720px, 88vw); padding: clamp(22px, 4vw, 42px); border-radius: 40px; background: rgba(255,255,255,.66); border: 1px solid rgba(255,255,255,.92); box-shadow: var(--shadow); backdrop-filter: blur(12px); position: relative; }
.idle > div::before, .idle > div::after { position: absolute; font-size: 30px; color: rgba(79,131,232,.24); }
.idle > div::before { content: '✦'; left: 10%; top: 13%; }
.idle > div::after { content: '●'; right: 11%; bottom: 16%; color: rgba(255,139,85,.24); }
.idle-illustration { width: min(290px, 52vw); aspect-ratio: 1; position: relative; margin: 0 auto 8px; }
.idle-circle { position: absolute; inset: 10%; border-radius: 50%; background: linear-gradient(145deg, #fff1aa, #e2edff 68%, #ffe5d6); box-shadow: inset 0 0 0 5px rgba(255,255,255,.6), var(--shadow); }
.idle-bell { position: absolute; inset: 0; display: grid; place-items: center; font-size: clamp(90px, 15vw, 150px); filter: drop-shadow(0 18px 22px rgba(61,83,125,.15)); }
.idle h2 { font-size: clamp(24px, 4vw, 42px); margin: 0; }
.idle p { color: var(--muted); font-size: clamp(14px, 2vw, 20px); }
.classroom-footer { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; z-index: 1; padding: 10px 14px 0; }
.setup-overlay, .call-overlay {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 24px;
  background: rgba(34,47,72,.62); backdrop-filter: blur(10px); z-index: 10;
}
.setup-box { width: min(520px, 100%); background: rgba(255,255,255,.96); border: 1px solid rgba(255,255,255,.96); border-radius: 28px; padding: 30px; box-shadow: 0 30px 100px rgba(20,35,60,.24); position: relative; overflow: hidden; }
.setup-box::before { content: ''; position: absolute; inset: 0 0 auto; height: 8px; background: linear-gradient(90deg, var(--blue), var(--yellow), var(--orange)); }
.setup-box h2 { margin: 5px 0 8px; font-size: 27px; }
.sound-settings-box { width: min(600px, 100%); }
.settings-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 12px; margin-top: 20px; }
.settings-actions .primary { margin-top: 0; }
.settings-actions .secondary { min-height: 52px; }
.call-overlay { opacity: 0; pointer-events: none; transition: opacity .25s ease; background: rgba(27,42,69,.76); }
.call-overlay.show { opacity: 1; pointer-events: auto; }
.call-card { width: min(900px, 94vw); min-height: min(600px, 80vh); background: linear-gradient(145deg, #fff, #f7faff 70%, #fff7e4); border: 3px solid rgba(255,255,255,.8); border-radius: 38px; padding: 42px; display: grid; place-items: center; text-align: center; position: relative; overflow: hidden; box-shadow: 0 40px 120px rgba(0,0,0,.3); }
.call-card::before { content: ''; position: absolute; inset: 0 0 auto; height: 14px; background: linear-gradient(90deg, var(--blue), var(--yellow), var(--orange)); }
.call-card::after { content: '✦'; position: absolute; right: 7%; bottom: 7%; color: rgba(79,131,232,.16); font-size: 90px; }
.call-label { color: var(--orange); font-weight: 800; letter-spacing: .18em; }
.call-name { font-size: clamp(46px, 9vw, 104px); font-weight: 900; margin: 22px 0 12px; line-height: 1.08; }
.call-text { font-size: clamp(25px, 4vw, 48px); color: #43516b; font-weight: 650; line-height: 1.35; }
.call-time { margin-top: 30px; color: var(--muted); }
.hidden { display: none !important; }

@media (max-width: 760px) {
  .shell { width: min(100% - 22px, 620px); padding-top: 16px; }
  .shell::before, .shell::after, .setup-page::before, .setup-page::after { opacity: .55; }
  .topbar { align-items: flex-start; padding: 13px 14px; border-radius: 19px; }
  .brand p { display: none; }
  .grid { grid-template-columns: 1fr; }
  .card { border-radius: 22px; padding: 22px 20px; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .info-card { order: 2; }
  .classroom-shell { padding: 14px; }
  .classroom-header { align-items: flex-start; }
  .classroom-actions { max-width: 55%; }
  .classroom-actions .status-pill { order: -1; }
  .classroom-actions button { padding: 9px 11px; }
  .classroom-footer { flex-direction: column; gap: 5px; }
  .actions { grid-template-columns: 1fr; }
  .settings-actions { grid-template-columns: 1fr; }
  .idle > div { border-radius: 28px; padding: 22px 16px; }
  .idle-illustration { width: min(240px, 52vw); }
  .admin-login-card { margin-top: 35px; }
  .admin-toolbar { align-items: flex-start; }
  .admin-grid { grid-template-columns: 1fr; }
  .activation-row { align-items: flex-start; flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
