@charset "UTF-8";

:root {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: #2b2824;
  background: #f8f6f0;
  color-scheme: light;
  font-size: 16px;
  line-height: 1.55;
  --canvas: #f8f6f0;
  --paper: #fffdf8;
  --ink: #2b2824;
  --muted: #665e53;
  --line: #e5ded3;
  --border-control: #aca092;
  --accent: #a53e29;
  --accent-dark: #822e1d;
  --accent-soft: #f8e4d9;
  --danger: #a22c2c;
  --green: #365640;
  --radius: 18px;
  --space-top: max(env(safe-area-inset-top, 0px), calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)));
  --space-bottom: max(env(safe-area-inset-bottom, 0px), calc(var(--tg-safe-area-inset-bottom, 0px) + var(--tg-content-safe-area-inset-bottom, 0px)));
  --space-left: max(env(safe-area-inset-left, 0px), calc(var(--tg-safe-area-inset-left, 0px) + var(--tg-content-safe-area-inset-left, 0px)));
  --space-right: max(env(safe-area-inset-right, 0px), calc(var(--tg-safe-area-inset-right, 0px) + var(--tg-content-safe-area-inset-right, 0px)));
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 0; min-height: 100vh; padding: var(--space-top) var(--space-right) var(--space-bottom) var(--space-left); }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .62; }
button:active:not(:disabled) { filter: brightness(.91); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
[data-heading]:focus, main:focus, .empty h2:focus { outline: none; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3, p, dd, strong { overflow-wrap: anywhere; }
ul { margin: 0; padding: 0; list-style: none; }
h1 { font-size: clamp(1.65rem, 3.3vw, 2.4rem); line-height: 1.2; letter-spacing: -.035em; }
h2 { line-height: 1.25; }
svg { display: block; width: 20px; height: 20px; flex: 0 0 auto; }
fieldset { padding: 0; border: 0; margin: 0; min-width: 0; }

.sr, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip:focus { position: absolute; top: 8px; left: 8px; z-index: 2; padding: 8px 12px; background: var(--paper); }
.muted { color: var(--muted); }
#header { border-bottom: 1px solid var(--line); background: var(--paper); }
.header-inner { max-width: 1224px; margin: 0 auto; min-height: 73px; padding: 8px 36px; }
.header-inner, .header-start, .header-end, .brand { display: flex; align-items: center; gap: 12px; }
.header-inner { justify-content: space-between; }
.brand { font-size: .98rem; font-weight: 750; white-space: nowrap; }
.brand-mark, .provider-icon, .empty-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: var(--accent); background: var(--accent-soft); }
.mode-label { color: var(--muted); font-size: .82rem; white-space: nowrap; }
main { max-width: 1224px; margin: 0 auto; padding: 40px 36px 64px; }
.button { display: inline-flex; min-width: 44px; min-height: 44px; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 10px; padding: 8px 14px; font-weight: 650; line-height: 1.35; text-align: center; text-decoration: none; transition: background-color 140ms, color 140ms, border-color 140ms; }
.primary { background: var(--accent); color: white; }
.primary:hover:not(:disabled) { background: var(--accent-dark); }
.secondary { background: var(--paper); border-color: var(--border-control); color: var(--ink); }
.secondary:hover:not(:disabled), .quiet:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent-dark); }
.quiet { background: transparent; color: var(--muted); }
.danger-text { background: transparent; color: var(--danger); }
.danger-text:hover:not(:disabled) { background: #fae9e5; }
.danger { background: var(--danger); color: white; }
.danger:hover:not(:disabled) { background: #852222; }
.full { width: 100%; }

.welcome { display: grid; grid-template-columns: 1.05fr .95fr; max-width: 1000px; margin: 4px auto 0; overflow: hidden; border: 1px solid var(--line); border-radius: 26px; background: var(--paper); box-shadow: 0 14px 50px #37291d0b; }
.welcome-art { position: relative; isolation: isolate; display: flex; flex-direction: column; justify-content: space-between; box-sizing: border-box; min-height: 615px; overflow: hidden; padding: clamp(32px, 5vw, 64px); background: #98402c; color: #fff5ea; }
.art-ring { position: absolute; z-index: -1; width: 405px; height: 405px; border: 1px solid #f8c6aa64; border-radius: 50%; rotate: -25deg; right: -175px; top: -170px; box-shadow: 0 0 0 38px #d4785226, 0 0 0 76px #d4785221, 0 0 0 114px #d4785218; }
.art-mark { display: grid; place-items: center; width: 92px; height: 92px; border: 1px solid #f8c6aa85; border-radius: 50%; }
.art-mark svg { width: 54px; height: 54px; stroke-width: 1; }
.wordmark { display: block; margin-bottom: 20px; font-size: .88rem; letter-spacing: .15em; }
.welcome-copy h2 { font-family: "Songti SC", "Noto Serif CJK SC", Georgia, serif; font-size: clamp(2rem, 4.5vw, 3.25rem); letter-spacing: .025em; font-weight: 700; margin-bottom: 20px; }
.welcome-copy p { max-width: 235px; color: #ffe4d3; }
.auth-card { align-self: center; padding: 36px clamp(24px, 5vw, 54px); }
.auth-card h1 { font-size: clamp(1.55rem, 3.2vw, 2rem); margin-bottom: 18px; }
.auth-copy { margin: -4px 0 20px; }
.auth-methods { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 16px; background: var(--canvas); border-radius: 12px; }
.auth-methods .button { background: transparent; border-color: transparent; padding-inline: 6px; }
.auth-methods .button[aria-pressed=true] { background: var(--paper); color: var(--accent-dark); border-color: var(--border-control); }
.auth-controls > .button, .auth-controls > form + .button { margin-top: 8px; }
.auth-controls form .primary, .binding form .primary { margin-top: 8px; }
.auth-controls fieldset, .binding fieldset { display: grid; gap: 12px; }
.auth-controls[inert] { opacity: .73; }
.stack { display: grid; gap: 10px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .875rem; margin: 14px 0; }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.demo-action { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 8px; }

.collection-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 24px; }
.collection-head p { margin-top: 5px; color: var(--muted); }
.collection-grid { display: grid; gap: 20px; min-width: 0; }
.collection-grid.split { grid-template-columns: minmax(220px, .85fr) minmax(0, 2fr); }
.collection-list { min-width: 0; }
.collection-grid.split .collection-list { max-height: min(72vh, 720px); overflow: auto; padding: 4px; margin: -4px; }
.profiles { display: grid; gap: 9px; }
.profile-link { width: 100%; min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; text-align: left; padding: 11px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; color: var(--ink); }
.profile-link[aria-current=true] { border-color: var(--accent); background: #fff3ea; }
@media (hover: hover) { .profile-link:hover { border-color: var(--accent); } }
.profile-link strong, .profile-link small { display: block; overflow-wrap: anywhere; }
.profile-link small { margin-top: 2px; color: var(--muted); }
.profile-link > svg { width: 16px; height: 16px; color: var(--muted); }
.portrait { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; color: #702d26; background: #f4d4cb; font-family: "Songti SC", "Noto Serif CJK SC", Georgia, serif; font-weight: 700; font-size: 1.35rem; }
.tone-1 { color: #385343; background: #dce9db; }
.tone-2 { color: #62466d; background: #e9ddee; }
.tone-3 { color: #654820; background: #f5e5be; }
.portrait-large { width: 70px; height: 70px; border-radius: 22px; font-size: 2rem; flex: 0 0 auto; }
.detail-card, .inner, .empty { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(18px, 3vw, 32px); background: var(--paper); }
.detail-top, .person, .actions { display: flex; align-items: center; gap: 12px; }
.detail-top, .actions { flex-wrap: wrap; }
.detail-top { justify-content: space-between; }
.person { min-width: 0; }
.person h2 { font-size: clamp(1.35rem, 3.4vw, 2rem); }
.person p { margin-top: 3px; color: var(--muted); }
.detail-top .actions { gap: 6px; }
.details-section { border-top: 1px solid var(--line); margin-top: 24px; padding-top: 21px; }
.details-section h3 { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; font-size: 1rem; }
.details-section h3 svg { color: var(--accent); }
.birth-grid, .detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.birthday { display: grid; gap: 10px; }
.birth-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.birthday-note { font-size: .9rem; }
.birth-grid > div { border-radius: 10px; background: var(--canvas); padding: 10px 12px; }
dt { color: var(--muted); font-size: .86rem; margin-bottom: 3px; }
dd { font-weight: 560; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags li { border-radius: 8px; max-width: 100%; padding: 3px 8px; background: #f4ede1; color: #594831; font-size: .91rem; overflow-wrap: anywhere; }
.empty { text-align: center; min-height: 280px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.empty-icon { width: 48px; height: 48px; }
.empty h2 { font-size: 1.25rem; }
.empty p { color: var(--muted); }
.loading { border-radius: var(--radius); border: 1px solid var(--line); background: var(--paper); padding: 18px; display: grid; gap: 12px; }
.loading > span:not(.sr) { display: block; min-height: 40px; background: linear-gradient(100deg, #efe8de 30%, #f9f3ec 50%, #efe8de 70%); background-size: 220% 100%; animation: shimmer 1.45s infinite linear; border-radius: 10px; }
.loading > span:nth-child(3) { width: 86%; }
.loading > span:last-child { width: 72%; }
@keyframes shimmer { to { background-position: -220% 0; } }

.inner { max-width: 720px; margin: 0 auto; }
.inner h1 { margin-bottom: 22px; }
.form-section + .form-section { margin-top: 21px; border-top: 1px solid var(--line); padding-top: 18px; }
.form-section h2, .settings h2 { font-size: 1.05rem; margin-bottom: 12px; }
.form-hint { margin: -3px 0 10px; font-size: .88rem; }
.field-group { min-width: 0; display: grid; gap: 12px; }
.field-group.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-group.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-group + .field-group { margin-top: 12px; }
.field { display: grid; align-content: start; gap: 5px; min-width: 0; }
.field label { font-weight: 650; font-size: .91rem; }
.field input { width: 100%; background: var(--paper); color: var(--ink); border: 1px solid var(--border-control); min-height: 46px; border-radius: 9px; padding: 9px 10px; scroll-margin: 16px; }
.field input[aria-invalid=true] { border: 2px solid var(--danger); }
.field small { color: var(--muted); line-height: 1.4; }
.field small.field-error { color: var(--danger); }
.form-actions { justify-content: flex-end; margin-top: 24px; }
.feedback { border-radius: 10px; padding: 10px 12px; margin: 10px 0; overflow-wrap: anywhere; }
.feedback.error { background: #fae9e5; color: #852222; }
.feedback.success { background: #e8efe5; color: var(--green); }
.connections { border: 1px solid var(--line); border-radius: 13px; }
.connections li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px; min-height: 63px; }
.connections li + li { border-top: 1px solid var(--line); }
.connections small { display: block; color: var(--muted); margin-top: 3px; }
.binding { border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-top: 16px; max-width: 420px; }
.binding > button { margin-top: 6px; }
.settings-footer { margin-top: 16px; }

dialog { color: var(--ink); background: var(--paper); border: 1px solid var(--line); padding: 0; border-radius: 18px; width: min(460px, calc(100% - 32px)); box-shadow: 0 18px 70px #291c1a36; }
dialog::backdrop { background: #2b211bbb; }
.dialog-inner { padding: 22px; }
.dialog-inner h2 { font-size: 1.25rem; margin-bottom: 9px; }
.dialog-inner > p { color: var(--muted); margin-bottom: 16px; }
.dialog-inner .actions { justify-content: flex-end; }

.mini #header .header-inner { max-width: 550px; min-height: 57px; padding: 6px 14px; }
.mini main { max-width: 550px; padding: 19px 14px 30px; }
.mini .welcome { display: block; margin-top: 0; }
.mini .welcome-art { display: none; }
.mini .auth-card { padding: 24px; }
.mini .collection-grid.split { grid-template-columns: minmax(0, 1fr); }
.mini .collection-grid.split .collection-list { padding: 0; margin: 0; max-height: none; overflow: visible; }
.mini .field-group.two { grid-template-columns: minmax(0, 1fr); }
.mini .form-actions { display: grid; grid-template-columns: 1fr 1.4fr; }
.mini dialog[data-type=delete] { position: fixed; width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 18px 18px 0 0; padding: 0 var(--space-right) var(--space-bottom) var(--space-left); }
.mini dialog[data-type=delete] .dialog-inner { max-width: 550px; margin: 0 auto; }

@media (min-width: 760px) {
  body:not(.mini) .birth-grid > div {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 3px 10px;
    background: none;
    padding: 0;
  }
  body:not(.mini) .birth-grid dt { margin: 0; }
}

@media (max-width: 759px) {
  .header-inner { min-height: 57px; padding: 6px 14px; }
  .header-start, .header-end, .brand { gap: 6px; }
  .header-start > .button, .header-end > .button { padding-inline: 7px; }
  .header-start > .button svg { display: none; }
  .brand-mark { width: 27px; height: 27px; border-radius: 8px; }
  .brand-mark svg { width: 16px; height: 16px; }
  .brand { font-size: .85rem; }
  .mode-label { font-size: .75rem; }
  main { padding: 20px 14px 36px; }
  .welcome { grid-template-columns: minmax(0, 1fr); max-width: 520px; margin-top: 0; }
  .welcome-art { display: block; min-height: 0; padding: 18px 24px; }
  .art-mark, .wordmark, .welcome-copy p { display: none; }
  .welcome-copy h2 { font-size: 1.38rem; margin: 0; }
  .welcome-copy h2 br { display: none; }
  .auth-card { padding: 24px; }
  .collection-head { margin-bottom: 16px; }
  .collection-grid.split { grid-template-columns: minmax(0, 1fr); }
  .collection-grid.split .collection-list { max-height: none; overflow: visible; padding: 0; margin: 0; }
  .form-actions { display: grid; grid-template-columns: 1fr 1.4fr; }
}

@media (max-width: 410px) {
  .header-end .button svg, .header-start:has(> .button) .brand-mark { display: none; }
  .field-group.two { grid-template-columns: minmax(0, 1fr); }
  .detail-card, .inner { padding: 16px; }
  .detail-top .actions { width: 100%; }
  .detail-top .actions .button { flex: 1; }
  .birth-grid { gap: 8px; }
  .birth-grid > div { padding: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
