:root {
  color-scheme: light;
  --auth-ink: #14213d;
  --auth-muted: #5c677d;
  --auth-line: #d9e2ec;
  --auth-panel: #f8fafc;
  --auth-accent: #1d4f8f;
  --auth-accent-soft: #e8f1ff;
  --auth-danger: #9f1239;
  --auth-ok: #166534;
  --auth-warn: #92400e;
  --auth-bg: #ffffff;
}

* {
  box-sizing: border-box;
}

.auth-page [hidden] {
  display: none !important;
}

body.auth-page {
  margin: 0;
  min-height: 100vh;
  background: var(--auth-bg);
  color: var(--auth-ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

.auth-shell {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 48px;
}

.auth-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 24px;
}

.auth-top a,
.auth-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--auth-accent);
  border-radius: 7px;
  padding: 7px 12px;
  background: var(--auth-accent-soft);
  color: var(--auth-accent);
  font-weight: 700;
  text-decoration: none;
}

.auth-title h1 {
  margin: 0 0 5px;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: 0;
}

.auth-title p,
.auth-note {
  margin: 0;
  color: var(--auth-muted);
}

.auth-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(300px, 0.95fr);
  gap: 18px;
  align-items: start;
}

.auth-card {
  border: 1px solid var(--auth-line);
  border-radius: 9px;
  background: var(--auth-panel);
  padding: 18px;
}

.auth-card h2 {
  margin: 0 0 12px;
  font-size: 20px;
  line-height: 1.25;
}

.auth-card h3 {
  margin: 16px 0 8px;
  font-size: 16px;
}

.auth-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.auth-saved-data {
  margin-bottom: 18px;
}

.auth-save-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.auth-save-stat {
  border: 1px solid var(--auth-line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.auth-save-stat strong {
  display: block;
  font-size: 22px;
  line-height: 1.1;
}

.auth-save-stat span {
  color: var(--auth-muted);
  font-size: 13px;
  font-weight: 650;
}

.auth-save-list {
  display: grid;
  gap: 10px;
}

.auth-save-empty {
  margin: 0;
  border: 1px dashed var(--auth-line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  color: var(--auth-muted);
}

.auth-save-group {
  border: 1px solid var(--auth-line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.auth-save-group h3 {
  margin: 0;
  border-bottom: 1px solid var(--auth-line);
  background: #eef4fc;
  padding: 10px 12px;
}

.auth-save-items {
  display: grid;
  gap: 0;
}

.auth-save-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--auth-line);
  padding: 10px 12px;
}

.auth-save-item:last-child {
  border-bottom: 0;
}

.auth-save-badge {
  border-radius: 999px;
  padding: 3px 8px;
  background: #fff1f2;
  color: var(--auth-danger);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.auth-save-badge.is-mastered {
  background: #ecfdf5;
  color: var(--auth-ok);
}

.auth-save-title {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.auth-save-item a {
  color: var(--auth-accent);
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.auth-form {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.auth-form label {
  display: grid;
  gap: 4px;
  font-weight: 700;
  color: #26364f;
}

.auth-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--auth-line);
  border-radius: 7px;
  padding: 9px 11px;
  background: #fff;
  color: var(--auth-ink);
  font: inherit;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.auth-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--auth-accent);
  border-radius: 7px;
  padding: 8px 13px;
  background: var(--auth-accent);
  color: #fff;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.auth-button.secondary {
  background: #fff;
  color: var(--auth-accent);
}

.auth-button.danger {
  border-color: var(--auth-danger);
  background: #fff1f2;
  color: var(--auth-danger);
}

.auth-button:disabled,
.auth-form input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.auth-status {
  min-height: 24px;
  margin: 0 0 12px;
  color: var(--auth-muted);
  font-weight: 650;
}

.auth-status.ok {
  color: var(--auth-ok);
}

.auth-status.warn {
  color: var(--auth-warn);
}

.auth-status.error {
  color: var(--auth-danger);
}

.auth-user {
  display: grid;
  gap: 6px;
  border: 1px solid var(--auth-line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  overflow-wrap: anywhere;
}

.auth-muted {
  color: var(--auth-muted);
}

.auth-list {
  margin: 10px 0 0 20px;
  padding: 0;
}

.auth-list li {
  margin-bottom: 6px;
}

.auth-code {
  display: block;
  margin-top: 8px;
  border: 1px solid var(--auth-line);
  border-radius: 7px;
  background: #fff;
  padding: 10px;
  overflow-x: auto;
  font: 13px/1.45 Consolas, "SFMono-Regular", monospace;
}

@media (max-width: 760px) {
  .auth-shell {
    width: min(100% - 20px, 980px);
    padding-top: 20px;
  }

  .auth-top,
  .auth-grid,
  .auth-section-head {
    display: block;
  }

  .auth-top a,
  .auth-section-head .auth-link-button {
    margin-top: 10px;
  }

  .auth-card {
    margin-bottom: 14px;
    padding: 15px;
  }

  .auth-save-summary {
    grid-template-columns: 1fr;
  }

  .auth-save-item {
    grid-template-columns: 1fr;
  }
}
