:root {
  color-scheme: light;
  --paper: #f4f3ee;
  --paper-deep: #eceae2;
  --ink: #1d312b;
  --ink-hover: #2c4a40;
  --muted: #6c766e;
  --subtle: #929b92;
  --line: #dfe3d8;
  --line-strong: #cdd5c6;
  --accent: #2f6653;
  --accent-soft: #e6efe8;
  --accent-ring: rgba(47, 102, 83, 0.16);
  --panel: #fffefa;
  --danger: #a84232;
  --danger-bg: #fdf3f1;
  --danger-line: #e4b5aa;
  --success-bg: #f1f7f3;
  --success-line: #b6d1be;
  --shadow-panel:
    0 1px 2px rgba(29, 49, 43, 0.04),
    0 18px 44px -12px rgba(29, 49, 43, 0.09),
    0 4px 16px -4px rgba(29, 49, 43, 0.04);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
  background-color: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input {
  font: inherit;
}

[hidden] {
  display: none !important;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Subtle organic ambient background */
.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(ellipse 60% 52% at 12% 14%, rgba(164, 196, 174, 0.24), transparent 68%),
    radial-gradient(ellipse 52% 48% at 88% 82%, rgba(214, 206, 184, 0.32), transparent 66%),
    radial-gradient(rgba(29, 49, 43, 0.055) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 26px 26px;
}

/* Header & Footer */
.masthead,
footer {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 48px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  border-radius: 10px;
  transition: opacity 0.16s ease;
}

.brand:hover {
  opacity: 0.88;
}

.mark {
  display: grid;
  place-items: center;
  position: relative;
  width: 36px;
  height: 36px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 10px;
  font-family: Georgia, "Songti SC", serif;
  font-size: 25px;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(29, 49, 43, 0.16);
}

.mark span {
  position: absolute;
  right: 4px;
  bottom: 1px;
  font-size: 22px;
  color: #b4d2aa;
}

.brand-text {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.brand-text strong {
  font-size: 20px;
  letter-spacing: -0.4px;
  font-weight: 650;
}

.brand-text small {
  font-size: 11px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--subtle);
  font-weight: 500;
}

.edition {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 254, 250, 0.72);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.6px;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4e8a6b;
  box-shadow: 0 0 0 3px rgba(78, 138, 107, 0.18);
}

/* Main Grid */
main {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 28px 48px 56px;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 424px);
  align-items: center;
  gap: 72px;
}

.eyebrow {
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 2.6px;
  color: var(--accent);
  opacity: 0.82;
  margin: 0 0 18px;
}

h1 {
  font-family: Georgia, "Songti SC", "Noto Serif CJK SC", "STSong", serif;
  font-weight: 500;
  font-size: clamp(38px, 4.4vw, 54px);
  line-height: 1.3;
  letter-spacing: 0.8px;
  margin: 0 0 20px;
  color: var(--ink);
}

.lead {
  font-size: 15px;
  line-height: 1.95;
  color: var(--muted);
  margin: 0;
  max-width: 440px;
}

/* Continuity divider */
.continuity {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 176px;
  margin: 34px 0 26px;
}

.continuity .node {
  width: 7px;
  height: 7px;
  border: 1.5px solid #8aa693;
  border-radius: 50%;
  flex-shrink: 0;
}

.continuity .node.mid {
  width: 5px;
  height: 5px;
  border-color: #aebfb2;
}

.continuity .node.active {
  width: 9px;
  height: 9px;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 102, 83, 0.14);
}

.continuity i {
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, #cfd8cc, #9eb4a4);
}

/* Highlights list */
.highlights {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 16px;
  max-width: 430px;
}

.highlights li {
  display: flex;
  align-items: flex-start;
  gap: 13px;
}

.hi-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: rgba(255, 254, 250, 0.82);
  border: 1px solid var(--line);
  color: var(--accent);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.hi-icon svg {
  width: 16px;
  height: 16px;
}

.highlights strong {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 3px;
}

.highlights p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--muted);
}

/* Auth Panel */
.panel {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 38px 34px 32px;
  box-shadow: var(--shadow-panel);
  min-height: 410px;
}

.panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--ink), var(--accent) 55%, #8ab096);
  opacity: 0.9;
}

.panel .eyebrow {
  font-size: 9.5px;
  letter-spacing: 2.2px;
  margin-bottom: 10px;
}

h2 {
  font-size: 24px;
  letter-spacing: -0.5px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--ink);
}

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

/* Forms & Fields */
form {
  display: flex;
  flex-direction: column;
}

.field {
  margin-bottom: 18px;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.field > label {
  display: block;
  margin-bottom: 8px;
}

label {
  font-size: 12.5px;
  font-weight: 500;
  color: #4b5950;
}

.caps-hint {
  font-size: 11px;
  color: #9e6526;
  background: #fbf3e4;
  border: 1px solid #ecd7b2;
  padding: 2px 7px;
  border-radius: 5px;
}

.pw-count {
  font-size: 11px;
  color: var(--subtle);
  font-variant-numeric: tabular-nums;
}

.pw-count.ok {
  color: var(--accent);
  font-weight: 600;
}

.input-wrap {
  position: relative;
}

input {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fdfcf7;
  padding: 0 14px;
  outline: none;
  font-size: 14px;
  color: var(--ink);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.input-wrap.has-toggle input {
  padding-right: 44px;
}

input::placeholder {
  color: #a6aea4;
  font-size: 13px;
}

input:hover {
  border-color: var(--line-strong);
}

input:focus {
  background: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px var(--accent-ring);
}

input.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(168, 66, 50, 0.12);
}

/* Password visibility toggle */
.toggle-pw {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--subtle);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.toggle-pw:hover {
  color: var(--ink);
  background: rgba(29, 49, 43, 0.05);
}

.toggle-pw svg {
  width: 17px;
  height: 17px;
}

.toggle-pw .icon-eye-off {
  display: none;
}

.toggle-pw[aria-pressed="true"] .icon-eye {
  display: none;
}

.toggle-pw[aria-pressed="true"] .icon-eye-off {
  display: block;
}

/* Buttons */
button {
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.12s ease, opacity 0.16s ease;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
.workspace-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.primary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 48px;
  background: var(--ink);
  color: #ffffff;
  border: 0;
  border-radius: 10px;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 550;
  letter-spacing: 0.6px;
  margin-top: 6px;
  box-shadow: 0 6px 18px -6px rgba(29, 49, 43, 0.45);
}

.primary:hover:not(:disabled) {
  background: var(--ink-hover);
  transform: translateY(-1px);
}

.primary:active:not(:disabled) {
  transform: translateY(0);
}

.primary .btn-arrow {
  font-size: 18px;
  font-weight: 300;
  transition: transform 0.18s ease;
}

.primary:hover:not(:disabled) .btn-arrow {
  transform: translate(2px, -2px);
}

.btn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

button.is-busy .btn-arrow {
  display: none;
}

button.is-busy .btn-spinner {
  display: inline-block;
}

.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 42px;
  background: #edf1e8;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 550;
  color: var(--ink);
}

.secondary:hover:not(:disabled) {
  background: #e3eadc;
  border-color: var(--line-strong);
}

.secondary .btn-spinner {
  border-color: rgba(29, 49, 43, 0.22);
  border-top-color: var(--ink);
}

.panel-foot {
  font-size: 11px;
  line-height: 1.7;
  color: var(--subtle);
  margin: 16px 0 0;
  text-align: center;
}

/* Account View */
.workspace-card {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 16px 14px;
  background: #f9faf5;
  border: 1px solid var(--line);
  border-radius: 13px;
  margin-bottom: 18px;
  cursor: pointer;
  transition: border-color 0.16s ease, background-color 0.16s ease, transform 0.14s ease;
}

.workspace-card:hover {
  border-color: #b7c8ba;
  background: #f4f8f2;
  transform: translateY(-1px);
}

.workspace-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 10px;
  width: 40px;
  height: 40px;
}

.workspace-icon svg {
  width: 18px;
  height: 18px;
}

.workspace-meta {
  min-width: 0;
}

.workspace-card strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.workspace-card p {
  font-size: 12px;
  color: var(--muted);
  margin: 3px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.private-tag {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 9px;
  border-radius: 999px;
  font-weight: 500;
}

.private-tag i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #4e8a6b;
}

details {
  margin-top: 22px;
  border-top: 1px solid #eceee7;
  padding-top: 16px;
}

summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 0;
  transition: color 0.15s ease;
}

summary::-webkit-details-marker {
  display: none;
}

summary:hover {
  color: var(--ink);
}

summary .chev {
  width: 15px;
  height: 15px;
  transition: transform 0.18s ease;
}

details[open] summary .chev {
  transform: rotate(180deg);
}

details form {
  padding-top: 16px;
}

.account-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-start;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--subtle);
  font-size: 12px;
  padding: 6px 2px;
}

.text-button:hover:not(:disabled) {
  color: var(--danger);
}

/* Status & Messages */
#message {
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid var(--danger-line);
  border-radius: 10px;
  padding: 10px 13px;
  margin: 18px 0 0;
}

#message.success {
  color: var(--accent);
  background: var(--success-bg);
  border-color: var(--success-line);
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 320px;
  font-size: 13px;
  color: var(--muted);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

footer {
  font-size: 11px;
  color: var(--subtle);
  border-top: 1px solid rgba(223, 227, 216, 0.85);
  padding-top: 20px;
  padding-bottom: 24px;
  letter-spacing: 0.4px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes arrive {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.shake {
  animation: shake 0.26s ease-in-out;
}

@media (prefers-reduced-motion: no-preference) {
  main {
    animation: arrive 0.48s cubic-bezier(0.22, 1, 0.36, 1);
  }
}

@media (max-width: 960px) {
  .masthead,
  footer {
    padding-left: 32px;
    padding-right: 32px;
  }

  main {
    gap: 44px;
    grid-template-columns: minmax(0, 1fr) 380px;
    padding: 20px 32px 44px;
  }

  .panel {
    padding: 32px 28px 28px;
  }
}

@media (max-width: 720px) {
  .masthead {
    padding: 20px 22px;
  }

  main {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 24px;
    padding: 8px 22px 36px;
    max-width: 480px;
  }

  .intro .eyebrow {
    margin-bottom: 10px;
  }

  h1 {
    font-size: 32px;
    line-height: 1.32;
    margin-bottom: 12px;
  }

  .lead br {
    display: none;
  }

  .lead {
    font-size: 13.5px;
    line-height: 1.8;
  }

  .continuity,
  .highlights {
    display: none;
  }

  .panel {
    padding: 28px 22px 24px;
    min-height: 360px;
    border-radius: 18px;
  }

  footer {
    padding: 18px 22px;
    font-size: 10.5px;
  }
}
