/* The account page is a document, not the single-screen app. advisor.css sets
   `html, body { height: 100% }` and `body { overflow: hidden }`, which is right
   for the adviser and wrong here — it left the profile form unscrollable below
   the fold. These rules undo that for this page only. */

html.account-html {
    height: auto;
    min-height: 100%;
    overflow-y: auto;
}

body.account-body {
    height: auto;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    background: var(--paper, #f3eee2);
    color: var(--ink, #211f18);
    font-family: Inter, "Noto Sans TC", system-ui, sans-serif;
    margin: 0;
}

.account-main {
    width: min(760px, calc(100% - 48px));
    margin: 0 auto;
    padding: 40px 0 96px;
}

/* The account page reuses advisor.css for type and colour; this file only
   covers the shapes that page introduces. */

.account-card {
    max-width: 46rem;
    margin: 0 auto;
    padding: 1.5rem 0 3rem;
}

.account-auth-card {
    max-width: 30rem;
}

.account-back-link {
    display: inline-block;
    margin-bottom: 1.25rem;
}

.account-clerk-mount {
    min-height: 26rem;
}

.account-clerk-mount > div {
    margin-inline: auto;
}

.account-auth-unavailable {
    padding: 2rem;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: rgba(255, 255, 255, 0.55);
}

.account-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.account-email {
    margin: 0.1rem 0 0;
    opacity: 0.7;
    font-size: 0.95rem;
}

.account-intro {
    opacity: 0.85;
    line-height: 1.6;
    max-width: 44rem;
}

.account-form {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin: 1rem 0;
}

.account-form label {
    font-weight: 600;
    margin-top: 0.75rem;
}

.account-form input,
.account-form select,
.account-form textarea {
    font: inherit;
    padding: 0.6rem 0.7rem;
    border: 1px solid rgba(0, 0, 0, 0.25);
    border-radius: 8px;
    background: #fff;
    color: inherit;
    width: 100%;
    box-sizing: border-box;
}

.account-form textarea {
    resize: vertical;
    min-height: 2.9rem;
}

.account-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.account-hint {
    margin: 0.3rem 0 0;
    font-size: 0.9rem;
    opacity: 0.7;
}

.account-source {
    font-size: 0.78rem;
    font-weight: 500;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.07);
    opacity: 0.8;
}

/* Carried over from the conversation and not saved yet. It has to look
   different from a stored value, or a family cannot tell what pressing save
   would actually keep. */
.account-source-suggested {
    background: rgba(31, 79, 63, 0.12);
    color: #1f4f3f;
    opacity: 1;
}

.account-suggested-note {
    margin: 0.25rem 0 0.75rem;
    padding: 0.6rem 0.8rem;
    border-radius: 0.6rem;
    background: rgba(31, 79, 63, 0.08);
    font-size: 0.9rem;
    line-height: 1.5;
}

.account-primary {
    font: inherit;
    font-weight: 600;
    padding: 0.65rem 1.2rem;
    border: 0;
    border-radius: 8px;
    background: #1f4f3f;
    color: #fff;
    cursor: pointer;
    align-self: flex-start;
    margin-top: 1rem;
}

.account-primary-link {
    display: inline-flex;
    width: fit-content;
    text-decoration: none;
}

.account-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.account-link {
    font: inherit;
    background: none;
    border: 0;
    padding: 0;
    color: #1f4f3f;
    text-decoration: underline;
    cursor: pointer;
}

.account-switch {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.account-notice {
    max-width: 46rem;
    margin: 1rem auto 0;
    padding: 0.7rem 0.9rem;
    border-radius: 8px;
    border-left: 4px solid currentColor;
}

.account-notice-success { color: #1f4f3f; background: rgba(31, 79, 63, 0.08); }
.account-notice-error { color: #8a2a2a; background: rgba(138, 42, 42, 0.08); }
.account-notice-info { color: #33475b; background: rgba(51, 71, 91, 0.08); }

.account-danger {
    margin-top: 2.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.15);
}

.account-profile-section {
    margin-top: 2.25rem;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.45);
}

.account-profile-section > summary {
    padding: 1rem 1.15rem;
    color: #1f4f3f;
    cursor: pointer;
    font-weight: 700;
}

.account-profile-content {
    padding: 0 1.15rem 1.25rem;
}

.account-history { margin-top: 2.5rem; }
.account-folder-drops { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.account-folder-drop { border: 1px dashed #1f4f3f; border-radius: 999px; padding: .35rem .7rem; background: transparent; color: #1f4f3f; cursor: pointer; }
.account-divider { display: flex; align-items: center; gap: 1rem; margin: 1.5rem 0; color: #1f4f3f; font-weight: 700; }
.account-divider::before, .account-divider::after { content: ''; height: 1px; flex: 1; background: rgba(0, 0, 0, 0.18); }
.account-conversation { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid rgba(0, 0, 0, 0.12); }
.account-conversation p { margin: .25rem 0 0; font-size: .88rem; opacity: .7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-conversation select { width: auto; min-width: 7rem; }

.account-memory { margin-top: 2.5rem; }
.account-memory-card { padding: 1rem 1.15rem; margin: 1rem 0; border: 1px solid rgba(0, 0, 0, 0.15); border-radius: 12px; background: rgba(255, 255, 255, 0.45); }
.account-memory-card h3 { margin: 0; font-size: 1.05rem; color: #1f4f3f; }
.account-memory-row { display: grid; grid-template-columns: minmax(0, 1.2fr) auto minmax(0, 2fr); gap: .5rem; align-items: center; }
.account-memory-row label { margin-top: 0; font-weight: 600; font-size: .92rem; }
.account-memory-row select { width: auto; }
@media (max-width: 640px) { .account-memory-row { grid-template-columns: 1fr; } }

.account-danger summary {
    cursor: pointer;
    font-weight: 600;
}

.account-danger-btn {
    font: inherit;
    font-weight: 600;
    padding: 0.6rem 1.1rem;
    border: 1px solid #8a2a2a;
    border-radius: 8px;
    background: transparent;
    color: #8a2a2a;
    cursor: pointer;
    align-self: flex-start;
    margin-top: 1rem;
}

@media (max-width: 640px) {
    .account-card { padding: 1rem 0 2rem; }
    .account-conversation { grid-template-columns: 1fr auto; }
    .account-conversation select { grid-column: 1; }
}

/* One block per child. The remove control sits in the corner of the block it
   belongs to, so it is never ambiguous which child it removes. */
.account-child {
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    padding: 0.75rem 1rem 1rem;
    margin: 1.25rem 0;
}

.account-child legend {
    font-weight: 700;
    padding: 0 0.4rem;
}

.account-remove-child {
    position: absolute;
    top: 0.6rem;
    right: 0.8rem;
    font: inherit;
    font-size: 0.85rem;
    background: none;
    border: 0;
    color: #8a2a2a;
    text-decoration: underline;
    cursor: pointer;
}

.account-child-head {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

/* The name labels the child, so it sits on its own row above the details. */
.account-child-head .account-field-name {
    grid-column: 1 / -1;
}

.account-child-details {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(0, 0, 0, 0.12);
}

.account-child-details > summary {
    color: #1f4f3f;
    cursor: pointer;
    font-weight: 600;
}

.account-child-details-fields {
    display: grid;
    gap: 0.35rem;
    margin-top: 0.65rem;
}

@media (max-width: 640px) {
    .account-child-head { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------------------
   Signed-in page, redesigned 2026-10-01: a top bar, a greeting, then three
   sections (children as cards, conversations by child, what is remembered).
   The sign-in card keeps the narrow column above.
   --------------------------------------------------------------------------- */
.account-main:has(.acct) {
    width: min(1120px, calc(100% - 48px));
    padding-top: 0;
}

.account-main:has(.acct) .account-notice {
    position: sticky;
    top: 12px;
    z-index: 5;
    max-width: none;
    margin: 12px 0 0;
}

.acct { padding-bottom: 32px; }

.acct-top {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 18px 0;
    border-bottom: 1px solid var(--line, #ddd5bf);
}

.acct-brand {
    color: var(--ink, #211f18);
    font-family: var(--serif, Georgia, serif);
    font-size: 22px;
    font-weight: 600;
    text-decoration: none;
}

.acct-nav {
    display: flex;
    gap: 18px;
    margin-right: auto;
}

.acct-nav a {
    color: var(--ink-2, #46422f);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.acct-nav a:hover { color: var(--green, #1d4a38); }

.acct-user {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    font-size: 13.5px;
}

.acct-user-email {
    overflow: hidden;
    color: var(--mut, #716a58);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.acct-text-btn {
    padding: 6px 10px;
    border: 1px solid var(--line-2, #c9bfa3);
    border-radius: 8px;
    background: transparent;
    color: var(--ink, #211f18);
    font: inherit;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.acct-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    padding: 36px 0 28px;
}

.acct-kicker {
    margin: 0 0 6px;
    color: var(--brass, #87641f);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.acct-hero h1 {
    margin: 0 0 8px;
    font-family: var(--serif, Georgia, serif);
    font-size: clamp(28px, 3.2vw, 40px);
    line-height: 1.12;
}

.acct-lead {
    max-width: 560px;
    margin: 0;
    color: var(--ink-2, #46422f);
    font-size: 16px;
}

.acct-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.acct-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 10px;
    font: inherit;
    font-size: 14.5px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.acct-btn-small { min-height: 34px; padding: 0 12px; font-size: 13.5px; }
.acct-btn-primary { background: var(--green, #1d4a38); color: #fff; }
.acct-btn-primary:hover { filter: brightness(1.12); }
.acct-btn-ghost { border-color: var(--line-2, #c9bfa3); background: var(--card, #fffdf6); color: var(--ink, #211f18); }
.acct-btn-ghost:hover { border-color: var(--ink, #211f18); }
.acct-btn-danger { border-color: rgba(138, 42, 42, 0.35); background: transparent; color: #8a2a2a; }

.acct-section {
    padding: 28px 0;
    border-top: 1px solid var(--line, #ddd5bf);
    scroll-margin-top: 16px;
}

.acct-section-head { margin-bottom: 18px; }

.acct-section-head h2 {
    margin: 0 0 6px;
    font-family: var(--serif, Georgia, serif);
    font-size: 26px;
}

.acct-section-head p {
    max-width: 720px;
    margin: 0;
    color: var(--mut, #716a58);
    font-size: 14.5px;
    line-height: 1.6;
}

/* Children */
.acct-children {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.acct-child-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
    border: 1px solid var(--line, #ddd5bf);
    border-radius: 16px;
    background: var(--card, #fffdf6);
}

.acct-child-card.is-editing { grid-column: 1 / -1; }

.acct-child-top {
    display: flex;
    align-items: center;
    gap: 12px;
}

.acct-avatar {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    color: #fff;
    font-family: var(--serif, Georgia, serif);
    font-size: 20px;
    font-weight: 700;
}

.acct-avatar-0 { background: #1d4a38; }
.acct-avatar-1 { background: #87641f; }
.acct-avatar-2 { background: #2b5b86; }
.acct-avatar-3 { background: #8a4b6a; }
.acct-avatar-4 { background: #5a6b2f; }

.acct-child-id { flex: 1; min-width: 0; }

.acct-child-id h3 {
    margin: 0;
    overflow: hidden;
    font-size: 18px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.acct-child-id p { margin: 2px 0 0; color: var(--mut, #716a58); font-size: 13.5px; }

.acct-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line, #ddd5bf);
    border-radius: 50%;
    background: transparent;
    color: var(--ink-2, #46422f);
    cursor: pointer;
}

.acct-icon-btn:hover { border-color: var(--ink, #211f18); }

.acct-child-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.acct-child-stats li {
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(33, 31, 24, 0.06);
    color: var(--ink-2, #46422f);
    font-size: 12.5px;
    font-weight: 600;
}

.acct-child-stats .acct-remembered { background: rgba(29, 74, 56, 0.1); color: var(--green, #1d4a38); }

.acct-child-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }

.acct-add-child {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 150px;
    border: 2px dashed var(--line-2, #c9bfa3);
    border-radius: 16px;
    background: transparent;
    color: var(--ink-2, #46422f);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.acct-add-child span { font-size: 28px; line-height: 1; color: var(--green, #1d4a38); }
.acct-add-child:hover { border-color: var(--green, #1d4a38); color: var(--green, #1d4a38); }

.acct-child-form .account-child { margin: 0; }
.acct-form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* Conversations */
.acct-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }

.acct-chip {
    padding: 6px 12px;
    border: 1px solid var(--line-2, #c9bfa3);
    border-radius: 999px;
    background: transparent;
    color: var(--ink-2, #46422f);
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
}

.acct-chip span { margin-left: 4px; color: var(--mut, #716a58); font-weight: 500; }
.acct-chip.is-active { border-color: var(--ink, #211f18); background: var(--ink, #211f18); color: var(--paper, #f3eee2); }
.acct-chip.is-active span { color: inherit; opacity: 0.75; }

.acct-conversations {
    overflow: hidden;
    border: 1px solid var(--line, #ddd5bf);
    border-radius: 16px;
    background: var(--card, #fffdf6);
}

.acct-conversations > .acct-empty { margin: 0; padding: 18px; }

.acct-conv {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
}

.acct-conv + .acct-conv { border-top: 1px solid var(--line, #ddd5bf); }
.acct-conv-main { flex: 1; min-width: 0; }

.acct-conv-main h3 {
    margin: 0;
    overflow: hidden;
    font-size: 15px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.acct-conv-side { display: flex; flex: 0 0 auto; align-items: center; gap: 10px; }

.acct-conv-child {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--mut, #716a58);
    font-size: 12.5px;
    font-weight: 600;
}

.acct-conv-child select {
    min-height: 34px;
    padding: 0 8px;
    border: 1px solid var(--line-2, #c9bfa3);
    border-radius: 8px;
    background: #fff;
    color: var(--ink, #211f18);
    font: inherit;
    font-size: 13.5px;
}

.acct-muted { margin: 2px 0 0; color: var(--mut, #716a58); font-size: 13px; }
.acct-empty { color: var(--mut, #716a58); }

/* Memory */
.acct-memories { display: grid; gap: 14px; }

.acct-memory-card {
    padding: 18px;
    border: 1px solid var(--line, #ddd5bf);
    border-radius: 16px;
    background: var(--card, #fffdf6);
}

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

.acct-memory-head h3 { margin: 0; font-size: 17px; }
.acct-memory-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.acct-facts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px 20px;
    margin: 0 0 10px;
}

.acct-fact dt { color: var(--mut, #716a58); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; }
.acct-fact dd { margin: 2px 0 0; color: var(--ink, #211f18); font-size: 14.5px; }
.acct-fact dd.is-muted { color: var(--mut, #716a58); font-style: italic; }

.acct-memory-extra { margin-top: 10px; }
.acct-memory-extra span { color: var(--mut, #716a58); font-size: 12px; font-weight: 700; }
.acct-memory-extra p { margin: 2px 0 0; font-size: 14.5px; }

.acct-memory-form {
    margin-top: 14px;
    padding: 14px 0 0;
    border: 0;
    border-top: 1px solid var(--line, #ddd5bf);
    border-radius: 0;
    background: transparent;
}

@media (max-width: 760px) {
    .account-main:has(.acct) { width: calc(100% - 32px); }
    .acct-top { flex-wrap: wrap; gap: 10px 16px; }
    .acct-nav { order: 3; width: 100%; overflow-x: auto; }
    .acct-user { margin-left: auto; }
    .acct-user-email { display: none; }
    .acct-hero { flex-direction: column; align-items: flex-start; padding: 24px 0 20px; }
    .acct-conv { flex-direction: column; align-items: stretch; gap: 10px; }
    .acct-conv-side { justify-content: space-between; }
    .acct-memory-head { flex-direction: column; }
}

/* .account-form sets display, which would otherwise override [hidden]. */
.acct-memory-form[hidden] { display: none; }
