:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #697586;
  --line: #dfe5ed;
  --page: #f3f6fa;
  --card: #ffffff;
  --blue: #1469e8;
  --blue-dark: #0e56c2;
  --navy: #0c1728;
  --green: #0b9b6d;
  --red: #c93434;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--page);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(228, 234, 242, 0.42) 1px, transparent 1px),
    linear-gradient(90deg, rgba(228, 234, 242, 0.42) 1px, transparent 1px),
    var(--page);
  background-size: 36px 36px;
}

button,
input,
textarea {
  font: inherit;
}

button,
a,
summary {
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  padding: 12px max(22px, env(safe-area-inset-right)) 12px
    max(22px, env(safe-area-inset-left));
  border-bottom: 1px solid rgba(214, 222, 232, 0.8);
  background: rgba(243, 246, 250, 0.88);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  display: flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 11px;
  background: var(--navy);
  box-shadow: 0 8px 18px rgba(12, 23, 40, 0.16);
}

.brand-mark i {
  display: block;
  width: 3px;
  height: 9px;
  border-radius: 4px;
  background: #60a5fa;
}

.brand-mark i:nth-child(2) {
  height: 16px;
  background: #dbeafe;
}

.brand-mark i:nth-child(3) {
  height: 12px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 14px;
  letter-spacing: 0.02em;
}

.brand small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.text-button {
  padding: 8px 4px;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.page {
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 36px 22px max(56px, env(safe-area-inset-bottom));
}

.login-layout {
  display: grid;
  min-height: calc(100vh - 160px);
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.75fr);
  align-items: center;
  gap: clamp(44px, 8vw, 110px);
}

.eyebrow {
  margin: 0 0 15px;
  color: #3078d6;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.login-intro h1 {
  max-width: 680px;
  margin: 0;
  font-size: clamp(38px, 6vw, 70px);
  font-weight: 650;
  letter-spacing: -0.06em;
  line-height: 1.06;
}

.intro-copy {
  max-width: 510px;
  margin: 25px 0 34px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.85;
}

.feature-list {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.feature-list li {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 13px 9px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #4b5565;
  background: rgba(255, 255, 255, 0.7);
  font-size: 12px;
}

.feature-list span {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  color: var(--blue);
  background: #e8f0fd;
  font-size: 9px;
  font-weight: 800;
}

.login-card,
.settings-card,
.status-card,
.password-card {
  border: 1px solid rgba(213, 221, 231, 0.92);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow:
    0 28px 70px rgba(30, 52, 78, 0.08),
    0 2px 8px rgba(30, 52, 78, 0.04);
}

.login-card {
  padding: 30px;
}

.login-card h2,
.settings-card h2 {
  margin: 0;
  font-size: 23px;
  letter-spacing: -0.035em;
}

.muted {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

label {
  display: block;
  margin-top: 20px;
}

label > span {
  display: block;
  margin-bottom: 8px;
  color: #374151;
  font-size: 12px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid #d1d9e3;
  border-radius: 12px;
  outline: none;
  color: var(--ink);
  background: #fff;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease;
}

input {
  min-height: 48px;
  padding: 0 14px;
}

textarea {
  min-height: 290px;
  padding: 15px;
  resize: vertical;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.7;
  tab-size: 2;
}

input:focus,
textarea:focus {
  border-color: #69a2ef;
  box-shadow: 0 0 0 4px rgba(20, 105, 232, 0.1);
}

input::placeholder,
textarea::placeholder {
  color: #9aa5b4;
}

.primary-button,
.secondary-button,
.preview-button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 12px;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform 150ms ease,
    background 150ms ease;
}

.primary-button {
  width: 100%;
  margin-top: 24px;
  padding: 0 20px;
  color: #fff;
  background: var(--blue);
}

.primary-button:hover,
.preview-button:hover {
  background: var(--blue-dark);
}

.primary-button:active,
.secondary-button:active,
.preview-button:active {
  transform: translateY(1px);
}

.primary-button:disabled,
.secondary-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.secondary-button {
  width: 100%;
  margin-top: 18px;
  padding: 0 18px;
  color: var(--blue);
  background: #eaf1fc;
}

.form-message {
  min-height: 18px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.form-message.error {
  color: var(--red);
}

.form-message.success {
  color: var(--green);
}

.dashboard {
  padding-top: 12px;
}

.dashboard-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 25px;
}

.dashboard-head h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 52px);
  letter-spacing: -0.055em;
}

.dashboard-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 9px;
}

.ios-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border: 1px solid #d1d9e3;
  border-radius: 12px;
  color: #344052;
  background: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.preview-button {
  flex-shrink: 0;
  min-height: 44px;
  gap: 14px;
  padding: 0 17px;
  color: #fff;
  background: var(--navy);
  font-size: 13px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(270px, 0.7fr);
  align-items: start;
  gap: 18px;
}

.settings-card {
  padding: 28px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.card-head > div {
  display: flex;
  align-items: center;
  gap: 11px;
}

.card-head h2 {
  font-size: 17px;
}

.card-index {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 9px;
  color: var(--blue);
  background: #e9f0fb;
  font-size: 10px;
  font-weight: 800;
}

.save-state,
.code-count {
  color: #8792a2;
  font-size: 11px;
}

.save-state.success {
  color: var(--green);
}

.field-hint {
  margin: 9px 1px 0;
  color: #7b8798;
  font-size: 11px;
  line-height: 1.65;
}

code {
  padding: 1px 4px;
  border-radius: 4px;
  color: #42536a;
  background: #eef2f7;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
  font-size: 0.94em;
}

.divider {
  height: 1px;
  margin: 27px 0 24px;
  background: #edf0f4;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-top: 8px;
}

.form-actions .primary-button {
  width: auto;
  min-width: 116px;
  margin: 0;
}

.form-actions .form-message {
  margin: 0;
}

.side-column {
  display: grid;
  gap: 18px;
}

.status-card {
  padding: 24px;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 3px;
  font-size: 19px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #b8c1cd;
  box-shadow: 0 0 0 4px rgba(184, 193, 205, 0.15);
}

.status-dot.active {
  background: #20b983;
  box-shadow: 0 0 0 4px rgba(32, 185, 131, 0.12);
}

.status-card dl {
  margin: 24px 0 0;
}

.status-card dl > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid #edf0f4;
  font-size: 11px;
}

.status-card dt {
  color: #808b9b;
}

.status-card dd {
  margin: 0;
  color: #344052;
  text-align: right;
}

.status-card a {
  color: var(--blue);
  text-decoration: none;
}

.password-card {
  padding: 0 22px;
  box-shadow: none;
}

.password-card summary {
  padding: 18px 0;
  color: #4a5667;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.password-card form {
  padding-bottom: 20px;
}

.password-card label:first-of-type {
  margin-top: 2px;
}

[hidden] {
  display: none !important;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 20px;
  bottom: max(20px, env(safe-area-inset-bottom));
  padding: 12px 16px;
  border-radius: 12px;
  color: #fff;
  background: var(--navy);
  box-shadow: 0 14px 38px rgba(12, 23, 40, 0.22);
  font-size: 12px;
  animation: toast-in 180ms ease-out;
}

@keyframes toast-in {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
}

@media (max-width: 800px) {
  .topbar {
    min-height: 62px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .page {
    padding: 22px 14px max(36px, env(safe-area-inset-bottom));
  }

  .login-layout {
    display: block;
    min-height: auto;
  }

  .login-intro {
    padding: 30px 7px 27px;
  }

  .login-intro h1 {
    font-size: clamp(38px, 12vw, 54px);
  }

  .intro-copy {
    margin: 18px 0 22px;
    font-size: 14px;
  }

  .feature-list li {
    font-size: 11px;
  }

  .login-card {
    padding: 23px;
  }

  .dashboard {
    padding-top: 4px;
  }

  .dashboard-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 17px;
    padding: 10px 5px 3px;
  }

  .dashboard-head h1 {
    font-size: 40px;
  }

  .preview-button {
    width: 100%;
    justify-content: space-between;
  }

  .dashboard-actions {
    display: grid;
    width: 100%;
    grid-template-columns: 0.8fr 1.2fr;
  }

  .ios-button {
    width: 100%;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .settings-card {
    padding: 22px 18px;
    border-radius: 18px;
  }

  .side-column {
    gap: 14px;
  }

  .status-card {
    padding: 21px;
    border-radius: 18px;
  }

  .password-card {
    border-radius: 18px;
  }

  .form-actions {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

  .form-actions .primary-button {
    width: 100%;
  }

  textarea {
    min-height: 250px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
