:root {
  color-scheme: dark;
  --bg: #07111f;
  --surface: #0d1928;
  --surface-raised: #132235;
  --line: #26384b;
  --line-strong: #3b5269;
  --text: #f6f8fb;
  --muted: #99aabe;
  --cyan: #25d4e8;
  --cyan-strong: #75e8f3;
  --pink: #f0449d;
  --green: #38d996;
  --danger: #ff7a8a;
  --focus: rgba(37, 212, 232, .24);
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(37, 212, 232, .035) 1px, transparent 1px) 0 0 / 42px 42px,
    linear-gradient(rgba(37, 212, 232, .035) 1px, transparent 1px) 0 0 / 42px 42px,
    var(--bg);
}

button, input, select { font: inherit; }
select { width:100%; min-height:44px; padding:10px; color:var(--text); background:var(--surface); border:1px solid var(--line); border-radius:6px; }
.passkey-item > span { min-width:0; overflow-wrap:anywhere; font-size:12px; }
.passkey-item > button { flex-shrink:0; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .58; }

.topbar {
  height: 76px;
  padding: 0 clamp(20px, 5vw, 76px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 17, 31, .92);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand img { width: 44px; height: 44px; border-radius: 8px; }
.brand span { display: grid; }
.brand strong { font-size: 18px; }
.brand small, .service-state { color: var(--muted); font-size: 12px; }

.service-state { display: inline-flex; align-items: center; gap: 8px; }
.service-state i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(56, 217, 150, .12); }

.page-shell {
  width: min(1120px, calc(100% - 40px));
  min-height: calc(100vh - 76px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(320px, .9fr) minmax(420px, 1.1fr);
  align-items: stretch;
}

.identity-pane {
  padding: clamp(54px, 8vh, 96px) clamp(32px, 6vw, 78px) 54px 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid var(--line);
}

.identity-logo {
  width: 112px;
  height: 112px;
  margin-bottom: 32px;
  border-radius: 8px;
  box-shadow: 0 22px 55px rgba(0, 0, 0, .34);
}

.eyebrow { margin: 0 0 10px; color: var(--cyan-strong); font-size: 12px; font-weight: 800; }
.identity-pane h1 { max-width: 480px; margin: 0; font-size: clamp(32px, 4vw, 52px); line-height: 1.16; }

.trust-list { margin-top: 46px; display: grid; gap: 0; border-top: 1px solid var(--line); }
.trust-list p { margin: 0; padding: 14px 0; display: flex; align-items: center; gap: 14px; color: var(--muted); border-bottom: 1px solid var(--line); }
.trust-list span { color: var(--pink); font: 700 11px ui-monospace, monospace; }

.account-pane {
  min-height: 640px;
  padding: clamp(48px, 7vh, 80px) 0 56px clamp(32px, 6vw, 78px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.account-pane > div { width: 100%; max-width: 640px; margin: 0 auto; }
.pane-heading h2, .account-header h2 { margin: 0; font-size: 30px; }
.pane-heading > p:last-child, .account-header p, .step-heading p, .section-heading p { margin: 8px 0 0; color: var(--muted); }

.segmented {
  margin: 30px 0 26px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line);
}

.segmented button {
  padding: 13px 16px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  font-weight: 750;
}

.segmented button.active { color: var(--text); border-bottom-color: var(--cyan); }
.auth-form, .dialog-form { display: grid; gap: 18px; }

label { display: grid; gap: 8px; color: #dbe5ef; font-size: 14px; font-weight: 700; }
label small { color: var(--muted); font-size: 12px; font-weight: 500; }

input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  color: var(--text);
  background: #091522;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: none;
}

input:hover { border-color: #58718a; }
input:focus { border-color: var(--cyan); box-shadow: 0 0 0 4px var(--focus); }

.checkbox { display: flex; align-items: center; gap: 9px; color: var(--muted); font-weight: 600; }
.checkbox input { width: 17px; min-height: 17px; accent-color: var(--cyan); }
.form-options, .section-heading, .account-header, .dialog-heading, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

.primary, .secondary, .text-button, .back-button, .icon-button, .danger-button {
  min-height: 44px;
  padding: 0 17px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-weight: 800;
}

.primary { color: #03141a; background: var(--cyan); }
.primary:hover { background: var(--cyan-strong); }
.secondary { color: var(--text); background: var(--surface-raised); border-color: var(--line-strong); }
.secondary:hover { border-color: var(--cyan); }
.wide { width: 100%; }
.text-button, .back-button { min-height: auto; padding: 0; color: var(--cyan-strong); background: transparent; border: 0; }
.centered { justify-self: center; }
.back-button { justify-self: start; color: var(--muted); }
.back-button:hover, .text-button:hover { color: var(--text); }

.divider { display: flex; align-items: center; gap: 13px; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }

.step-heading { display: flex; align-items: center; gap: 14px; }
.step-heading h3 { margin: 0; font-size: 22px; }
.step-heading p { font-size: 14px; }
.step-icon { width: 48px; height: 48px; flex: 0 0 48px; display: grid; place-items: center; color: var(--bg); background: var(--pink); border-radius: 8px; font-size: 22px; font-weight: 900; }
.otp-input { font: 800 25px ui-monospace, SFMono-Regular, Consolas, monospace; }

.loading-view { display: grid; justify-items: center; gap: 14px; color: var(--muted); }
.spinner { width: 32px; height: 32px; border: 3px solid var(--line); border-top-color: var(--cyan); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.account-header { align-items: flex-start; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.account-header > div:nth-child(2) { min-width: 0; flex: 1; }
.account-header p { overflow-wrap: anywhere; }
.account-initial { width: 54px; height: 54px; flex: 0 0 54px; display: grid; place-items: center; color: var(--bg); background: var(--cyan); border-radius: 8px; font-size: 22px; font-weight: 900; }
.account-kicker { display: flex; align-items: center; gap: 9px; }
.account-kicker .eyebrow { margin: 0; }
.role-badge, .admin-state { padding: 4px 7px; color: #04150f; background: var(--green); border-radius: 4px; font-size: 11px; font-weight: 900; }

.verified-line { margin: 22px 0; padding: 14px; display: flex; gap: 12px; align-items: center; border: 1px solid rgba(56, 217, 150, .32); border-radius: 6px; background: rgba(56, 217, 150, .07); }
.verified-line > span { color: var(--green); font-weight: 900; }
.verified-line div { display: grid; gap: 3px; }
.verified-line small { color: var(--muted); }

.account-section { padding: 24px 0; border-top: 1px solid var(--line); }
.section-heading { align-items: flex-start; }
.section-heading h3 { margin: 0; font-size: 19px; }
.section-heading p { max-width: 300px; font-size: 13px; }
.passkey-list { margin-top: 16px; display: grid; gap: 8px; }
.passkey-item { min-height: 58px; padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.passkey-item div { min-width: 0; display: grid; gap: 3px; }
.passkey-item strong { overflow-wrap: anywhere; }
.passkey-item small, .empty-state { color: var(--muted); }
.danger-button { min-height: 36px; padding: 0 11px; color: var(--danger); background: transparent; border-color: rgba(255, 122, 138, .32); }

.admin-section { padding-bottom: 0; }
.admin-steps { margin: 18px 0 0; padding: 0; display: grid; list-style: none; }
.admin-steps li { padding: 12px 0; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; border-bottom: 1px solid var(--line); }
.admin-steps li > span { width: 28px; height: 28px; display: grid; place-items: center; color: var(--cyan-strong); border: 1px solid var(--line-strong); border-radius: 5px; font: 800 12px ui-monospace, monospace; }
.admin-steps li div { display: grid; gap: 4px; }
.admin-steps small, .admin-note { color: var(--muted); line-height: 1.55; }
.admin-note { margin: 16px 0 0; font-size: 12px; }
.admin-state.offline { color:var(--muted); background:var(--surface-raised); }
.control-summary { margin:16px 0; padding:12px 14px; color:var(--muted); background:var(--surface); border:1px solid var(--line); border-radius:6px; }
.now-playing { margin:18px 0; padding:18px; background:#091522; border:1px solid var(--line-strong); border-radius:8px; }
.now-playing h4 { margin:5px 0 6px; font-size:22px; overflow-wrap:anywhere; }
.now-playing > p:last-of-type { margin:0 0 16px; color:var(--muted); overflow-wrap:anywhere; }
.progress-control { display:grid; grid-template-columns:48px minmax(0,1fr) 48px; align-items:center; gap:10px; }
.progress-control span { color:var(--muted); font:700 12px ui-monospace,Consolas,monospace; text-align:center; }
.progress-control input, #cloudVolume { min-height:22px; padding:0; accent-color:var(--cyan); }
.player-actions { display:flex; justify-content:flex-end; gap:10px; margin-top:14px; }
.control-form { display:grid; gap:14px; margin:18px 0; }
.control-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.cloud-queue { display:grid; gap:8px; }
.cloud-queue-item { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:10px; align-items:center; padding:11px 12px; border:1px solid var(--line); border-radius:6px; background:var(--surface); }
.cloud-queue-item span { min-width:0; overflow-wrap:anywhere; }
.cloud-queue-item small { display:block; margin-top:3px; color:var(--muted); }
.cloud-queue-actions { display:flex; gap:7px; }
.cloud-queue-actions button { min-height:36px; padding:0 11px; }
.presence-control { margin-top:22px; padding:14px 0; border-top:1px solid var(--line); border-bottom:1px solid var(--line); }
.presence-control summary { cursor:pointer; font-weight:800; }

dialog { width: min(480px, calc(100% - 32px)); padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: 0 28px 80px rgba(0, 0, 0, .56); }
dialog::backdrop { background: rgba(1, 7, 14, .78); backdrop-filter: blur(5px); }
.dialog-form { padding: 24px; }
.dialog-heading { align-items: flex-start; }
.dialog-heading h2 { margin: 0; }
.dialog-heading p { margin: 7px 0 0; color: var(--muted); }
.icon-button { min-width: 38px; min-height: 38px; padding: 0; color: var(--muted); background: transparent; border-color: var(--line); font-size: 24px; }
.dialog-actions { justify-content: flex-end; }

.notice { position: fixed; right: 22px; bottom: 22px; width: min(390px, calc(100% - 44px)); padding: 14px 16px; color: var(--text); background: #102638; border: 1px solid var(--cyan); border-radius: 6px; box-shadow: 0 20px 55px rgba(0, 0, 0, .38); z-index: 20; }
.notice.error { background: #301722; border-color: var(--danger); }

@media (max-width: 820px) {
  .topbar { height: 66px; padding: 0 18px; }
  .brand img { width: 38px; height: 38px; }
  .page-shell { width: min(560px, calc(100% - 32px)); min-height: calc(100vh - 66px); grid-template-columns: 1fr; }
  .identity-pane { padding: 34px 0 28px; border-right: 0; border-bottom: 1px solid var(--line); }
  .identity-logo { width: 72px; height: 72px; margin-bottom: 20px; }
  .identity-pane h1 { font-size: 30px; }
  .trust-list { display: none; }
  .account-pane { min-height: 0; padding: 36px 0 56px; }
}

@media (max-width: 500px) {
  .service-state { font-size: 0; }
  .account-header { display: grid; grid-template-columns: 54px minmax(0, 1fr); }
  .account-header #signOutButton { grid-column: 1 / -1; width: 100%; }
  .section-heading { display: grid; }
  .section-heading button { width: 100%; }
  .control-grid { grid-template-columns:1fr; }
  .cloud-queue-item { grid-template-columns:1fr; }
  .cloud-queue-actions { justify-content:flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
}
