/* Account, admin and legal pages. Loaded after engine.css and reuses its
   tokens, nav, chips and cards, so these pages match the helper. All sizes in rem. */

:root {
  --ok: #86efac;
  --ok-bg: rgba(34, 197, 94, 0.14);
  --warn-bg: rgba(255, 155, 142, 0.12);
  --field-bg: rgba(255, 255, 255, 0.06);
  --page-w: min(calc(100% - 2rem), 120rem);
}
:root[data-theme="light"] {
  --ok: #166534;
  --ok-bg: #dcfce7;
  --warn-bg: #fff1ef;
  --field-bg: #ffffff;
}

/* Cards and forms set their own display, so "hidden" has to win explicitly. */
[hidden] { display: none !important; }

.acct-main { width: var(--page-w); margin: 0 auto; padding-bottom: 1.5rem; }
.acct-hero { width: 100%; padding-top: 1.25rem; }
.acct-hero h1 { font-size: clamp(1.75rem, 1.1rem + 2.2vw, 2.75rem); }

.acct-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}
@media (min-width: 768px) { .acct-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .acct-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .acct-grid.two { grid-template-columns: 1.1fr 0.9fr; } }
/* Signed-in page: three set columns (profile + balance + payments + saved chats,
   then checkout, then vault + sign-in) so their heights even out and nothing
   leaves a gap. Tablets flow the same cards into 2 columns; phones stack them. */
#view-in.acct-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.75rem; align-items: start; }
.acct-col { display: flex; flex-direction: column; gap: 0.75rem; min-width: 0; }
@media (min-width: 768px) and (max-width: 1279.98px) {
  #view-in.acct-grid { display: block; columns: 2; column-gap: 0.75rem; }
  #view-in .acct-col { display: contents; }
  #view-in .acct-card { break-inside: avoid; margin: 0 0 0.75rem; }
}
@media (min-width: 1280px) { #view-in.acct-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Change password tucks away until needed. */
details.quiet-zone { border: 1px solid var(--panel-line); border-radius: 0.85rem; padding: 0.6rem 0.8rem; background: var(--inset); }
details.quiet-zone summary { cursor: pointer; font-weight: 700; min-height: 2rem; display: flex; align-items: center; }
details.quiet-zone[open] summary { margin-bottom: 0.6rem; }

/* Once signed in, the big welcome headline shrinks so the cards start near the top. */
.acct-main.is-in .acct-hero { padding: 0.75rem 0 0.6rem; gap: 0.25rem; }
.acct-main.is-in .acct-hero .chip, .acct-main.is-in .acct-hero .subline { display: none; }
.acct-main.is-in .acct-hero h1 { font-size: clamp(1.35rem, 1rem + 1vw, 1.9rem); }

.span-2 { grid-column: 1 / -1; }
@media (min-width: 1280px) { .span-2 { grid-column: span 2; } }

.acct-card { display: flex; flex-direction: column; gap: 0.75rem; scroll-margin-top: 6rem; container-type: inline-size; }
.acct-card > * { flex: none; }
.acct-card::before { background: linear-gradient(90deg, var(--indigo), var(--purple)); }
.acct-card.c2::before { background: linear-gradient(90deg, var(--purple), var(--pink)); }
.acct-card.c3::before { background: linear-gradient(90deg, var(--indigo-soft), var(--purple-soft)); }
.acct-card.c4::before { background: linear-gradient(90deg, var(--pink), var(--indigo)); }
.acct-card h2 { font-size: 1.2rem; }
.acct-card h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }

/* status / flash lines */
.flash { padding: 0.7rem 0.9rem; border-radius: 0.8rem; font-weight: 600; margin: 0 0 0.75rem; }
.flash[hidden] { display: none; }
.flash.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid currentColor; }
.flash.warn { background: var(--warn-bg); color: var(--coral); border: 1px solid currentColor; }
.flash.info { background: var(--inset); color: var(--text); border: 1px solid var(--panel-line); }
.form-error { color: var(--coral); font-weight: 600; font-size: 0.9rem; }
.form-error:empty { display: none; }
.form-ok { color: var(--ok); font-weight: 600; font-size: 0.9rem; }
.form-ok:empty { display: none; }

/* forms */
.form { display: grid; gap: 0.7rem; }
.field-row { display: grid; gap: 0.3rem; }
.field-row label, .legend { font-weight: 600; font-size: 0.9rem; }
.hint { font-size: 0.82rem; color: var(--muted); }
.form input[type="text"], .form input[type="email"], .form input[type="password"], .form textarea {
  width: 100%; min-width: 0; font: inherit; color: var(--text);
  background: var(--field-bg); border: 1px solid var(--panel-line); border-radius: 0.75rem;
  padding: 0.65rem 0.8rem; min-height: 2.75rem;
}
.form textarea { resize: vertical; min-height: 5rem; line-height: 1.45; }
.form input::placeholder, .form textarea::placeholder { color: var(--muted); opacity: 1; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 2.75rem; padding: 0.5rem 1.15rem; border-radius: 999px;
  font: inherit; font-weight: 700; font-size: 0.95rem; text-decoration: none; cursor: pointer;
  border: 1px solid var(--panel-line); background: var(--btn-bg); color: var(--text);
}
.btn:hover:not(:disabled) { background: var(--btn-bg-hover); }
.btn.primary { border-color: transparent; color: #fff; background: linear-gradient(135deg, #4f46e5, #7e22ce); }
.btn.primary:hover:not(:disabled) { background: linear-gradient(135deg, #4338ca, #6b21a8); }
.btn.danger { color: var(--coral); border-color: var(--coral); background: transparent; }
.btn.small-btn { min-height: 2.25rem; padding: 0.3rem 0.85rem; font-size: 0.875rem; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--link); text-decoration: underline; cursor: pointer; }

/* tabs */
.tabs { display: flex; gap: 0.3rem; padding: 0.25rem; border-radius: 999px; background: var(--btn-bg); align-self: flex-start; flex-wrap: wrap; }
.tab { border: 0; background: transparent; border-radius: 999px; padding: 0.45rem 1rem; font: inherit; font-weight: 700; cursor: pointer; color: var(--text); min-height: 2.5rem; }
.tab[aria-selected="true"] { background: linear-gradient(135deg, #4f46e5, #7e22ce); color: #fff; }

/* plan list (signed out) */
.how { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.how li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.15rem 0.75rem; padding: 0.7rem 0.8rem; border-radius: 0.8rem; background: var(--inset); border: 1px solid var(--inset-line); }
.how .price { font-family: var(--font-head); font-weight: 700; font-size: 1.15rem; grid-row: span 2; min-width: 4.25rem; color: var(--accent-text); }
.how .what { font-weight: 700; }
.how .detail { font-size: 0.88rem; color: var(--muted); }

/* profile picture container */
.profile-top { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.avatar-frame {
  position: relative; flex: none; width: 7rem; height: 7rem; border-radius: 50%; padding: 0.22rem;
  background: linear-gradient(135deg, var(--indigo), var(--purple) 55%, var(--pink));
  box-shadow: 0 0.6rem 1.6rem rgba(99, 102, 241, 0.35);
}
.avatar-inner { width: 100%; height: 100%; border-radius: 50%; overflow: hidden; background: var(--panel); display: grid; place-items: center; }
.avatar-inner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-initial { font-family: var(--font-head); font-weight: 700; font-size: 2.6rem; color: var(--accent-text); }
.avatar-busy { position: absolute; inset: 0.22rem; border-radius: 50%; display: grid; place-items: center; background: rgba(10, 12, 34, 0.6); color: #fff; font-weight: 700; font-size: 0.85rem; }
.avatar-busy[hidden] { display: none; }
.who { min-width: 0; display: grid; gap: 0.15rem; }
.who .name { font-family: var(--font-head); font-weight: 700; font-size: 1.35rem; line-height: 1.2; }
.who .handle { color: var(--muted); font-weight: 600; }
.bio { white-space: pre-wrap; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.file-btn:focus-within { outline: 0.18rem solid var(--focus); outline-offset: 0.15rem; }

/* balance */
.balance { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.balance-num { font-family: var(--font-head); font-weight: 700; font-size: 3rem; line-height: 1; }
.pill { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.2rem 0.7rem; border-radius: 999px; font-size: 0.82rem; font-weight: 700; }
.pill.member { color: #fff; background: linear-gradient(90deg, #6d28d9, #be185d); }
.pill.free { background: var(--btn-bg-hover); color: var(--text); }
.note { padding: 0.6rem 0.75rem; border-radius: 0.75rem; background: var(--inset); border: 1px solid var(--panel-line); font-size: 0.92rem; }

/* checkout */
.choice-grid { display: grid; gap: 0.5rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 480px) { .choice-grid.cols { grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); } }
.choice { position: relative; display: grid; gap: 0.15rem; padding: 0.75rem 0.85rem; border-radius: 0.85rem; border: 1px solid var(--inset-line); background: var(--inset); cursor: pointer; min-width: 0; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice:has(input:checked) { border-color: var(--purple-soft); box-shadow: inset 0 0 0 1px var(--purple-soft); background: var(--btn-bg-hover); }
.choice:has(input:focus-visible) { outline: 0.18rem solid var(--focus); outline-offset: 0.15rem; }
.choice:has(input:disabled) { opacity: 0.55; cursor: not-allowed; }
.choice .c-title { font-weight: 700; }
.choice .c-price { font-family: var(--font-head); font-weight: 700; font-size: 1.1rem; color: var(--accent-text); }
.choice .c-detail { font-size: 0.85rem; color: var(--muted); }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 0.5rem; }
legend { padding: 0; margin-bottom: 0.4rem; }

.pay-box { display: grid; gap: 0.6rem; padding: 0.85rem; border-radius: 0.9rem; border: 1px solid var(--purple-soft); background: var(--inset); }
.pay-box[hidden] { display: none; }
.pay-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.15rem 0.5rem; align-items: center; }
.pay-line .k { grid-column: 1 / -1; font-size: 0.8rem; font-weight: 700; color: var(--muted); }
.pay-line .v { font-family: var(--font-head); font-weight: 700; font-size: 1.15rem; overflow-wrap: anywhere; min-width: 0; }
.steps { margin: 0; padding-left: 1.2rem; display: grid; gap: 0.3rem; text-align: left; }

/* tables that become stacked cards on phones */
.rows { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.rows th { text-align: left; font-size: 0.78rem; color: var(--muted); font-weight: 700; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--inset-line); }
.rows td { padding: 0.55rem 0.5rem; border-bottom: 1px solid var(--inset-line); vertical-align: middle; overflow-wrap: anywhere; }
.status { display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.78rem; font-weight: 700; background: var(--btn-bg-hover); white-space: nowrap; }
.status.paid { background: var(--ok-bg); color: var(--ok); }
.status.claimed, .status.pending { background: var(--btn-bg-hover); color: var(--text); }
.status.rejected, .status.failed, .status.partial { background: var(--warn-bg); color: var(--coral); }
/* Stacked label/value cards whenever the card itself is narrow (phones, or a slim grid column). */
@container (max-width: 40rem) {
  .rows thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .rows, .rows tbody, .rows tr, .rows td { display: block; width: 100%; }
  .rows tr { padding: 0.6rem 0.75rem; margin-bottom: 0.5rem; border-radius: 0.8rem; background: var(--inset); border: 1px solid var(--inset-line); text-align: left; }
  .rows td { border: 0; padding: 0.2rem 0; display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: 0.5rem; }
  .rows td::before { content: attr(data-label); font-weight: 700; font-size: 0.8rem; color: var(--muted); }
  .rows td.td-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; padding-top: 0.4rem; }
  .rows td.td-actions::before { content: none; }
}

/* vault */
.drop {
  display: grid; gap: 0.35rem; place-items: center; text-align: center;
  padding: 1.1rem 0.9rem; border-radius: 0.9rem; border: 2px dashed var(--panel-line); background: var(--inset);
}
.drop.is-over { border-color: var(--purple-soft); background: var(--btn-bg-hover); }
.meter { height: 0.55rem; border-radius: 999px; background: var(--inset-line); overflow: hidden; }
.meter > span { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--indigo), var(--purple), var(--pink)); }
.item-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; text-align: left; }
.item-list:empty { display: none; }
.item-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.2rem 0.6rem; align-items: center; padding: 0.55rem 0.7rem; border-radius: 0.75rem; background: var(--inset); border: 1px solid var(--inset-line); }
.item-list .i-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.item-list .i-meta { font-size: 0.8rem; color: var(--muted); grid-column: 1; }
.item-list .i-actions { grid-row: 1 / span 2; grid-column: 2; display: flex; gap: 0.35rem; flex-wrap: wrap; justify-content: flex-end; }
.item-list progress { grid-column: 1 / -1; width: 100%; height: 0.45rem; accent-color: var(--purple); }
.empty-line { color: var(--muted); font-size: 0.9rem; }

details.danger-zone { border: 1px solid var(--coral); border-radius: 0.85rem; padding: 0.6rem 0.8rem; }
details.danger-zone summary { cursor: pointer; font-weight: 700; color: var(--coral); min-height: 2rem; display: flex; align-items: center; }
details.danger-zone[open] summary { margin-bottom: 0.6rem; }

.loading { padding: 2rem 0; text-align: center; color: var(--muted); }

/* legal page */
.prose { display: grid; gap: 0.7rem; line-height: 1.65; }
.prose h2 { font-size: 1.3rem; margin-top: 0.4rem; }
.prose h3 { font-size: 1.05rem; margin-top: 0.3rem; }
.prose ul { margin: 0; padding-left: 1.2rem; text-align: left; display: grid; gap: 0.3rem; }
.toc { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }

/* admin */
.order-ref { font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; letter-spacing: 0.02em; }
.reject-row { display: flex; flex-wrap: wrap; gap: 0.4rem; width: 100%; }
.reject-row input { flex: 1 1 10rem; min-width: 0; font: inherit; color: var(--text); background: var(--field-bg); border: 1px solid var(--panel-line); border-radius: 0.6rem; padding: 0.4rem 0.6rem; min-height: 2.25rem; }

/* phones: centered text, lists and forms stay left */
@media (max-width: 699.98px) {
  .acct-card h2, .acct-card > p, .card-head, .balance, .profile-top, .who, .actions, .flash, .drop, .loading { text-align: center; justify-content: center; }
  .profile-top { flex-direction: column; }
  .tabs { align-self: center; }
  .form, .how, .item-list, .steps, .choice, .pay-box, .rows, .prose ul { text-align: left; }
  .form .actions { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) { .meter > span { transition: none; } }
