/* Personal Agent · 独立邮箱账号与对话界面 */
:root {
  color-scheme: light;
  --page: #f5f3f0;
  --surface: #fffefd;
  --surface-muted: #f8f6f3;
  --ink: #29232d;
  --ink-soft: #615a65;
  --ink-faint: #746d77;
  --line: #e3dde3;
  --line-strong: #c9c0cb;
  --accent: #703f78;
  --accent-hover: #59305f;
  --accent-soft: #f1e9f2;
  --accent-warm: #d9906a;
  --focus: #703f78;
  --pending: #735111;
  --pending-bg: #fff4d8;
  --success: #285e43;
  --success-bg: #e8f3ec;
  --danger: #923d3d;
  --danger-bg: #fbeceb;
  --revoked: #5e5962;
  --revoked-bg: #eeebf0;
  --radius-sm: 10px;
  --radius: 18px;
  --radius-lg: 26px;
  --shadow: 0 2px 4px rgb(41 35 45 / 3%), 0 18px 50px rgb(61 42 65 / 7%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  font-synthesis: none;
}

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

html {
  min-width: 280px;
  background: var(--page);
  color: var(--ink);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 8% 4%, rgb(217 144 106 / 10%), transparent 25rem),
    radial-gradient(circle at 95% 25%, rgb(112 63 120 / 8%), transparent 28rem),
    var(--page);
}

button,
input,
textarea {
  font: inherit;
}

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

button {
  touch-action: manipulation;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  color: var(--ink);
  line-height: 1.3;
  text-wrap: balance;
}

h1 {
  margin-bottom: 18px;
  font-size: clamp(2.15rem, 10vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.16;
}

h1 span {
  color: var(--accent);
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(1.35rem, 5vw, 1.65rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

h3 {
  margin-bottom: 0;
  font-size: 1rem;
  font-weight: 650;
}

.skip-link {
  position: fixed;
  z-index: 20;
  top: 8px;
  left: 8px;
  padding: 9px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  text-decoration: none;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  border-bottom: 1px solid rgb(201 192 203 / 65%);
  background: rgb(255 254 253 / 82%);
  backdrop-filter: blur(14px);
}

.header-inner {
  display: flex;
  width: min(100% - 32px, 1080px);
  min-height: 68px;
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  font-size: 0.94rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-mark,
.empty-mark {
  display: inline-grid;
  flex: 0 0 auto;
  border-radius: 10px 10px 10px 3px;
  background: var(--accent);
  color: #fff;
  font-family: Georgia, serif;
  font-style: italic;
  place-items: center;
}

.brand-mark {
  width: 34px;
  height: 34px;
  font-size: 1.08rem;
  box-shadow: 0 5px 14px rgb(112 63 120 / 20%);
}

.session-tools {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.account-email {
  max-width: 130px;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-shell {
  width: min(100% - 32px, 1080px);
  margin: 0 auto;
  padding: 28px 0 20px;
}

.auth-layout {
  display: grid;
  gap: 26px;
}

.welcome-copy {
  padding: 4px 2px 0;
}

.eyebrow,
.section-kicker {
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 0.69rem;
  font-weight: 750;
  letter-spacing: 0.13em;
}

.section-kicker {
  margin-bottom: 6px;
  letter-spacing: 0.08em;
}

.intro-copy {
  max-width: 33rem;
  margin-bottom: 24px;
  color: var(--ink-soft);
  font-size: 0.96rem;
  line-height: 1.8;
}

.journey {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
  gap: 14px;
}

.journey li {
  display: flex;
  align-items: center;
  gap: 12px;
}

.journey-number {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: rgb(255 254 253 / 65%);
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
  place-items: center;
}

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

.journey strong {
  font-size: 0.86rem;
  font-weight: 650;
}

.journey small {
  margin-top: 1px;
  color: var(--ink-faint);
  font-size: 0.74rem;
}

.auth-card,
.panel {
  border: 1px solid rgb(227 221 227 / 90%);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card {
  padding: 24px 20px;
  border-radius: var(--radius-lg);
}

.card-heading {
  margin-bottom: 20px;
}

.card-heading > p:last-child,
.verify-heading > p:last-child {
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-muted);
  gap: 4px;
}

.mode-button {
  min-width: 0;
  min-height: 46px;
  padding: 9px 8px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 650;
  line-height: 1.3;
  cursor: pointer;
  transition: background-color 150ms ease, box-shadow 150ms ease, color 150ms ease;
}

.mode-button:hover {
  color: var(--accent);
}

.mode-button.is-active,
.mode-button[aria-pressed="true"] {
  border-color: var(--line);
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 2px 8px rgb(41 35 45 / 7%);
}

.mode-help {
  margin: 10px 2px 22px;
  color: var(--ink-faint);
  font-size: 0.75rem;
  line-height: 1.6;
}

.stacked-form {
  display: grid;
  gap: 17px;
}

.verify-form {
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.verify-heading {
  margin-bottom: 1px;
}

.verify-heading h3 {
  margin-bottom: 7px;
  font-size: 1.12rem;
}

.field-group {
  display: grid;
  gap: 7px;
}

.field-group label {
  width: fit-content;
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 650;
}

input,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input {
  min-height: 48px;
  padding: 11px 13px;
}

#code {
  letter-spacing: 0.12em;
}

textarea {
  min-height: 108px;
  padding: 11px 13px;
  line-height: 1.6;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #7c737e;
  opacity: 1;
}

input:hover,
textarea:hover {
  border-color: #aa9cae;
}

input:focus-visible,
textarea:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgb(112 63 120 / 15%);
}

input:disabled,
textarea:disabled {
  border-color: var(--line);
  background: var(--surface-muted);
  color: var(--ink-faint);
  cursor: not-allowed;
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

.field-help {
  margin-bottom: 0;
  color: var(--ink-faint);
  font-size: 0.74rem;
}

.button {
  display: inline-flex;
  min-height: 44px;
  padding: 10px 17px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.35;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
}

.button:active:not(:disabled) {
  transform: translateY(1px);
}

.button:focus-visible,
.mode-button:focus-visible,
summary:focus-visible {
  outline: 3px solid rgb(112 63 120 / 30%);
  outline-offset: 3px;
}

.button:disabled,
.button[aria-disabled="true"],
.mode-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button-primary:hover:not(:disabled) {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.button-secondary {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.button-secondary:hover:not(:disabled),
.button-quiet:hover:not(:disabled) {
  border-color: #aa9cae;
  background: var(--surface-muted);
}

.button-danger {
  border-color: #d9adad;
  background: var(--surface);
  color: var(--danger);
}

.button-danger:hover:not(:disabled) {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.button-quiet {
  border-color: transparent;
  background: transparent;
  color: var(--ink-soft);
}

.button-small {
  min-height: 40px;
  padding: 7px 12px;
  font-size: 0.8rem;
}

.button-full {
  width: 100%;
}

.help-details {
  margin-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.help-details summary {
  width: fit-content;
  min-height: 44px;
  padding: 13px 0 6px;
  color: var(--ink-soft);
  font-weight: 600;
  cursor: pointer;
}

.help-details p {
  margin: 3px 0 0;
}

.notice {
  margin-bottom: 16px;
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.notice:not(:empty) {
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.notice.is-error,
.notice[data-type="error"] {
  border-color: #e2baba;
  background: var(--danger-bg);
  color: var(--danger);
}

.notice.is-success,
.notice[data-type="success"] {
  border-color: #bad5c4;
  background: var(--success-bg);
  color: var(--success);
}

.panel {
  padding: 22px 18px;
  border-radius: var(--radius);
}

.panel-narrow {
  max-width: 720px;
  margin: 20px auto 0;
}

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

.section-heading h2 {
  margin-bottom: 0;
}

.section-description {
  margin: -4px 0 20px;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.access-tag {
  display: inline-flex;
  min-height: 28px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  align-items: center;
  flex: 0 0 auto;
  color: var(--ink-soft);
  font-size: 0.7rem;
  white-space: nowrap;
}

.status-summary {
  margin-bottom: 20px;
  padding: 17px;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface-muted);
}

.status-summary h3 {
  margin-bottom: 6px;
  font-size: 1rem;
}

.status-summary p {
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.status-chip {
  display: inline-flex;
  min-height: 27px;
  padding: 3px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  font-size: 0.71rem;
  font-weight: 650;
  line-height: 1.25;
  white-space: nowrap;
}

.status-pending,
.status-chip[data-status="pending"] {
  border-color: #e5d19f;
  background: var(--pending-bg);
  color: var(--pending);
}

.status-approved,
.status-chip[data-status="approved"] {
  border-color: #bad5c4;
  background: var(--success-bg);
  color: var(--success);
}

.status-rejected,
.status-chip[data-status="rejected"] {
  border-color: #e2baba;
  background: var(--danger-bg);
  color: var(--danger);
}

.status-revoked,
.status-chip[data-status="revoked"] {
  border-color: #d4cdd7;
  background: var(--revoked-bg);
  color: var(--revoked);
}

.status-guide {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.status-guide > h3 {
  margin-bottom: 13px;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.status-guide ul {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
  gap: 12px;
}

.status-guide li {
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  color: var(--ink-soft);
  font-size: 0.76rem;
}

.panel-chat,
.panel-admin {
  max-width: 880px;
  margin: 0 auto;
}

.transcript {
  display: flex;
  min-height: 280px;
  max-height: 55vh;
  padding: 14px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-muted);
  flex-direction: column;
  gap: 12px;
  overscroll-behavior: contain;
}

.transcript:focus-visible {
  outline: 3px solid rgb(112 63 120 / 24%);
  outline-offset: 2px;
}

.chat-empty {
  margin: auto;
  padding: 28px 12px;
  color: var(--ink-faint);
  font-size: 0.8rem;
  text-align: center;
}

.empty-mark {
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  font-size: 1.1rem;
}

.chat-empty strong {
  display: block;
  margin-bottom: 5px;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 650;
}

.chat-empty p {
  margin-bottom: 0;
}

.turn {
  width: fit-content;
  max-width: 94%;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  font-size: 0.88rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.turn-user {
  align-self: flex-end;
  border-color: var(--accent);
  border-bottom-right-radius: 4px;
  background: var(--accent);
  color: #fff;
}

.turn-assistant {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  background: var(--surface);
}

.chat-form {
  margin-top: 18px;
}

.chat-form-footer {
  display: flex;
  margin-top: 12px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-form-footer > span {
  color: var(--ink-faint);
  font-size: 0.72rem;
}

.admin-toolbar {
  display: flex;
  min-height: 44px;
  margin-bottom: 13px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-toolbar h3 {
  margin-bottom: 0;
  font-size: 0.86rem;
}

.admin-list {
  display: grid;
  gap: 11px;
}

.list-placeholder,
.admin-footnote {
  margin-bottom: 0;
  color: var(--ink-faint);
  font-size: 0.77rem;
}

.list-placeholder {
  padding: 28px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  text-align: center;
}

.admin-footnote {
  margin-top: 16px;
}

.review-row {
  display: grid;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  gap: 12px;
}

.review-row p {
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}

.review-row small,
.review-meta {
  display: block;
  color: var(--ink-faint);
  font-size: 0.73rem;
  overflow-wrap: anywhere;
}

.review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.review-actions .button,
.review-actions button {
  min-height: 40px;
}

.page-footer {
  padding: 26px 0 4px;
  color: var(--ink-faint);
  font-size: 0.7rem;
  text-align: center;
}

.page-footer p {
  margin-bottom: 0;
}

.check-field {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  column-gap: 9px;
}

.check-field input[type="checkbox"] {
  width: 20px;
  height: 20px;
  min-height: 20px;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
}

.check-field label {
  width: fit-content;
  font-size: 0.85rem;
  font-weight: 650;
  cursor: pointer;
}

.check-field .field-help {
  grid-column: 2;
}

.auth-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
}

.text-button {
  display: inline-flex;
  min-height: 44px;
  padding: 7px 0;
  border: 0;
  border-radius: 4px;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 650;
  line-height: 1.4;
  text-align: center;
  text-decoration: underline;
  text-decoration-color: rgb(112 63 120 / 35%);
  text-underline-offset: 3px;
  cursor: pointer;
}

.text-button:hover:not(:disabled) {
  color: var(--accent-hover);
  text-decoration-color: currentColor;
}

.text-button:focus-visible {
  outline: 3px solid rgb(112 63 120 / 30%);
  outline-offset: 2px;
}

.text-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.admin-entry {
  min-height: 40px;
  margin: -5px auto -7px;
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 600;
}

.password-fields {
  display: grid;
  gap: 17px;
}

.password-dialog {
  width: min(calc(100% - 32px), 480px);
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 24px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 80px rgb(41 35 45 / 25%);
}

.password-dialog::backdrop {
  background: rgb(41 35 45 / 48%);
  backdrop-filter: blur(3px);
}

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

.dialog-heading h2 {
  margin-bottom: 0;
}

.dialog-heading .button {
  flex: 0 0 auto;
}

.dialog-description {
  margin-bottom: 12px;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.dialog-notice {
  margin-bottom: 16px;
}

.dialog-notice:empty {
  display: none;
}

.password-dialog .verify-form {
  margin-top: 20px;
}

@media (max-width: 599px) {
  .session-tools .account-email {
    display: none;
  }

  .session-tools .button-small {
    padding-inline: 8px;
    font-size: 0.74rem;
  }
}

@media (max-width: 359px) {
  .brand-name {
    display: none;
  }

  .password-dialog {
    width: calc(100% - 20px);
    max-height: calc(100dvh - 20px);
    padding: 20px 16px;
  }
}

@media (min-width: 600px) {
  .header-inner,
  .page-shell {
    width: min(100% - 48px, 1080px);
  }

  .page-shell {
    padding-top: 40px;
  }

  .auth-card {
    padding: 30px;
  }

  .panel {
    padding: 28px;
  }

  .account-email {
    max-width: 240px;
    font-size: 0.82rem;
  }

  .turn {
    max-width: 80%;
  }

  .review-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .review-actions {
    justify-content: flex-end;
  }
}

@media (min-width: 900px) {
  .page-shell {
    padding-top: 58px;
  }

  .auth-layout {
    grid-template-columns: minmax(0, 1fr) minmax(360px, 430px);
    align-items: center;
    gap: clamp(48px, 8vw, 96px);
  }

  .welcome-copy {
    padding: 0 0 20px;
  }

  .journey {
    margin-top: 34px;
    gap: 18px;
  }

  .auth-card {
    padding: 32px;
  }

  .panel-narrow {
    margin-top: 0;
  }
}

@media (max-width: 420px) {
  .brand-name {
    font-size: 0.85rem;
  }

  .account-email {
    max-width: 100px;
  }

  .chat-form-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .chat-form-footer .button {
    width: 100%;
  }

  .section-heading {
    gap: 8px;
  }
}

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

@media (forced-colors: active) {
  .status-chip,
  .turn,
  .auth-card,
  .panel,
  .mode-button[aria-pressed="true"] {
    border-color: CanvasText;
  }

  .button:focus-visible,
  .mode-button:focus-visible,
  input:focus-visible,
  textarea:focus-visible,
  summary:focus-visible {
    outline: 2px solid Highlight;
  }
}
