:root {
  color-scheme: light;
  --paper: oklch(97.2% 0.008 94);
  --paper-alt: oklch(94.8% 0.011 94);
  --surface: oklch(99.2% 0.004 94);
  --surface-muted: oklch(96% 0.008 94);
  --ink: oklch(18.5% 0.018 85);
  --ink-soft: oklch(36% 0.019 85);
  --muted: oklch(53% 0.016 85);
  --line: oklch(80% 0.012 88);
  --line-soft: oklch(88% 0.009 90);
  --green: oklch(43% 0.09 146);
  --green-dark: oklch(31% 0.075 146);
  --green-soft: oklch(91.5% 0.034 146);
  --red: oklch(52% 0.13 30);
  --red-soft: oklch(92% 0.04 34);
  --amber: oklch(66% 0.13 76);
  --amber-soft: oklch(93% 0.05 78);
  --max: 1180px;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Noto Sans SC", "Microsoft YaHei UI", sans-serif;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid oklch(67% 0.11 146 / 0.5); outline-offset: 3px; }

.account-nav { border-bottom: 1px solid var(--line-soft); background: var(--surface); }
.nav-inner {
  width: min(var(--max), calc(100% - 48px));
  min-height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand { display: inline-flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 800; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: block;
  object-fit: contain;
}
.nav-actions, .dashboard-actions { display: flex; align-items: center; gap: 10px; }
.back-link, .language-button, .quiet-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}
.back-link:hover, .language-button:hover, .quiet-button:hover { border-color: var(--ink-soft); color: var(--ink); }

main { width: min(var(--max), calc(100% - 48px)); min-height: calc(100vh - 145px); margin: 0 auto; }
.loading-view { min-height: 560px; display: grid; place-content: center; justify-items: center; gap: 16px; color: var(--muted); }
.loading-mark { width: 28px; height: 28px; border: 2px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.auth-view {
  min-height: calc(100vh - 145px);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(390px, .78fr);
  gap: clamp(54px, 8vw, 112px);
  align-items: center;
  padding: clamp(56px, 8vw, 96px) 0;
}
.eyebrow, .panel-index {
  margin: 0 0 16px;
  color: var(--green-dark);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}
h1, h2, h3, p { text-wrap: pretty; }
h1 { max-width: 720px; margin: 0; font-size: clamp(38px, 5vw, 66px); line-height: 1.08; letter-spacing: -.045em; }
.auth-lead { max-width: 650px; margin: 24px 0 0; color: var(--ink-soft); font-size: clamp(17px, 2vw, 20px); }
.trust-list { max-width: 650px; margin: 44px 0 0; border-top: 1px solid var(--line); }
.trust-list > div { display: grid; grid-template-columns: 185px 1fr; gap: 22px; padding: 18px 0; border-bottom: 1px solid var(--line-soft); }
.trust-list dt { display: flex; align-items: center; gap: 9px; font-weight: 750; }
.trust-list dt i { color: var(--green); font-size: 18px; }
.trust-list dd { margin: 0; color: var(--muted); font-size: 14px; }

.auth-panel { border: 1px solid var(--line); background: var(--surface); box-shadow: 10px 10px 0 var(--paper-alt); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); }
.auth-tab { min-height: 52px; border: 0; background: var(--surface-muted); color: var(--muted); cursor: pointer; font-weight: 750; }
.auth-tab + .auth-tab { border-left: 1px solid var(--line); }
.auth-tab.is-active { background: var(--surface); color: var(--ink); box-shadow: inset 0 -2px var(--green); }
.social-auth { padding: 22px 28px 0; }
.google-button { width: 100%; min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); cursor: pointer; font-weight: 750; }
.google-button:hover { border-color: var(--ink-soft); background: var(--surface-muted); }
.google-button:disabled { cursor: wait; opacity: .62; }
.google-button svg { width: 19px; height: 19px; flex: 0 0 auto; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin-top: 18px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.auth-divider::before, .auth-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.form-heading { padding: 30px 34px 12px; }
.form-heading .panel-index { margin-bottom: 11px; }
.form-heading h2 { margin: 0; font-size: 28px; letter-spacing: -.03em; }
.form-heading p:last-child { margin: 7px 0 0; color: var(--muted); font-size: 14px; }
form { padding: 15px 34px 34px; }
label { display: block; margin: 17px 0 7px; color: var(--ink-soft); font-size: 13px; font-weight: 750; }
input {
  width: 100%;
  min-height: 48px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  outline: none;
}
input:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
input[aria-invalid="true"] { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.password-field { position: relative; }
.password-field input { padding-right: 48px; }
.password-toggle { position: absolute; inset: 4px 4px 4px auto; width: 40px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; }
.form-message, .dashboard-message { min-height: 22px; margin: 16px 0 0; color: var(--red); font-size: 13px; }
.form-message.is-success, .dashboard-message.is-success { color: var(--green-dark); }
.submit-button {
  width: 100%;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding: 0 17px;
  border: 0;
  border-radius: 7px;
  background: var(--ink);
  color: var(--surface);
  cursor: pointer;
  font-weight: 750;
}
.submit-button:hover { background: var(--green-dark); }
.submit-button:disabled { cursor: wait; opacity: .62; }
.form-note { margin: 15px 0 0; color: var(--muted); font-size: 12px; text-align: center; }

.dashboard-view { padding: clamp(52px, 7vw, 86px) 0 70px; }
.dashboard-header { display: flex; justify-content: space-between; gap: 32px; align-items: flex-end; }
.dashboard-header h1 { font-size: clamp(38px, 5vw, 58px); }
.account-email { margin: 10px 0 0; color: var(--ink-soft); font-family: "IBM Plex Mono", monospace; font-size: 14px; }
.account-strip {
  display: grid;
  grid-template-columns: 1.25fr repeat(3, 1fr);
  margin-top: 42px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.account-strip > div { min-height: 92px; display: flex; flex-direction: column; justify-content: center; padding: 16px 24px; }
.account-strip > div + div { border-left: 1px solid var(--line); }
.account-strip .access-summary { flex-direction: row; align-items: center; justify-content: flex-start; gap: 13px; }
.status-dot { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px var(--green-soft); }
.status-dot.is-expired { background: var(--amber); box-shadow: 0 0 0 5px var(--amber-soft); }
.summary-label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; font-weight: 650; }
.account-strip strong { font-size: 17px; }

.device-section { margin-top: 64px; }
.section-heading { display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.section-heading .panel-index { margin-bottom: 10px; }
.section-heading h2 { margin: 0; font-size: 30px; letter-spacing: -.025em; }
.section-heading p:last-child { margin: 7px 0 0; color: var(--muted); font-size: 14px; }
.device-count { min-width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; font-family: "IBM Plex Mono", monospace; font-weight: 600; }
.device-list { border-bottom: 1px solid var(--line); }
.device-row {
  min-height: 104px;
  display: grid;
  grid-template-columns: minmax(230px, 1.3fr) minmax(180px, .9fr) minmax(160px, .8fr) auto;
  gap: 24px;
  align-items: center;
  padding: 18px 4px;
  border-top: 1px solid var(--line-soft);
}
.device-row:first-child { border-top: 0; }
.device-row.is-removed { opacity: .58; }
.device-primary { display: flex; align-items: center; gap: 14px; min-width: 0; }
.device-icon { width: 40px; height: 40px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface); font-size: 20px; }
.device-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-id { display: block; margin-top: 3px; color: var(--muted); font-family: "IBM Plex Mono", monospace; font-size: 11px; }
.device-meta span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.device-meta strong { display: block; margin-top: 3px; font-size: 13px; font-weight: 650; }
.device-status { display: inline-flex; align-items: center; gap: 7px; color: var(--green-dark); font-size: 13px; font-weight: 750; }
.device-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.is-removed .device-status { color: var(--muted); }
.is-removed .device-status::before { background: var(--muted); }
.disconnect-button { min-width: 94px; min-height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--ink-soft); cursor: pointer; font-size: 13px; font-weight: 700; }
.disconnect-button:hover { border-color: var(--red); color: var(--red); }
.disconnect-button.is-confirm { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.disconnect-button:disabled { cursor: wait; opacity: .55; }
.empty-state { min-height: 260px; display: grid; place-content: center; justify-items: center; text-align: center; color: var(--muted); border-bottom: 1px solid var(--line); }
.empty-state i { font-size: 34px; }
.empty-state h3 { margin: 14px 0 0; color: var(--ink); font-size: 18px; }
.empty-state p { margin: 6px 0 0; font-size: 14px; }
.security-note { display: flex; align-items: flex-start; gap: 9px; margin: 22px 0 0; color: var(--muted); font-size: 12px; }
.security-note i { margin-top: 2px; color: var(--green); font-size: 16px; }

footer { width: min(var(--max), calc(100% - 48px)); min-height: 72px; display: flex; justify-content: space-between; align-items: center; gap: 24px; margin: 0 auto; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 12px; }
footer span:first-child { color: var(--ink-soft); font-weight: 750; }

@media (max-width: 900px) {
  .auth-view { grid-template-columns: 1fr; gap: 48px; align-items: start; }
  .auth-panel { max-width: 620px; width: 100%; }
  .account-strip { grid-template-columns: 1fr 1fr; }
  .account-strip > div:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .account-strip > div:nth-child(4) { border-top: 1px solid var(--line); }
  .device-row { grid-template-columns: minmax(220px, 1fr) 1fr auto; }
  .device-meta.first-seen { display: none; }
}

@media (max-width: 640px) {
  .nav-inner, main, footer { width: min(100% - 28px, var(--max)); }
  .nav-inner { min-height: 64px; }
  .brand { font-size: 17px; }
  .brand-mark { width: 36px; height: 36px; font-size: 12px; }
  .back-link span { display: none; }
  .back-link { width: 40px; padding: 0; }
  .auth-view { padding: 42px 0 58px; }
  h1 { font-size: 38px; }
  .trust-list > div { grid-template-columns: 1fr; gap: 5px; }
  .auth-panel { box-shadow: 6px 6px 0 var(--paper-alt); }
  .form-heading { padding: 25px 22px 10px; }
  form { padding: 12px 22px 25px; }
  .dashboard-view { padding-top: 42px; }
  .dashboard-header { align-items: flex-start; flex-direction: column; }
  .dashboard-actions { width: 100%; }
  .dashboard-actions .quiet-button { flex: 1; }
  .account-strip { grid-template-columns: 1fr; }
  .account-strip > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .device-section { margin-top: 48px; }
  .section-heading { align-items: flex-start; }
  .device-row { grid-template-columns: 1fr auto; gap: 12px; padding: 18px 0; }
  .device-meta { grid-column: 1; padding-left: 54px; }
  .device-meta.first-seen { display: none; }
  .device-row .disconnect-button, .device-row .device-status { grid-column: 2; grid-row: 1; }
  footer { align-items: flex-start; flex-direction: column; justify-content: center; padding: 18px 0; }
}

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