/* Личный кабинет (tshop_3) — вход, регистрация, восстановление доступа, профиль, история заказов.
 * Поля, флажки и кнопка с загрузкой — form/default/list.css; меню кабинета и аватар — core.css (.t3-accmenu, .t3-avatar).
 * Ручки дизайнера стилей на корне блока (.t3-account):
 *   --acc-card-bg, --acc-card-radius, --acc-card-pad — карточки (вход, разделы профиля, заказы);
 *   --acc-auth-width — ширина карточки входа;  --acc-aside-width — ширина колонки меню кабинета;
 *   --field-h, --field-radius — поля ввода (как у форм).
 */
@layer modules {
  .t3-account {
    --acc-card-bg: var(--surface);
    --acc-card-radius: var(--radius-l);
    --acc-card-pad: clamp(20px, 3vw, 32px);
    --acc-auth-width: 460px;
    --acc-aside-width: 280px;
    --field-h: 52px;
    --field-radius: min(var(--radius-m), 14px);
    --field-bg: var(--surface);
    --field-border: var(--line-strong);
    --field-text: var(--text);
    --form-gap: 16px;
  }

  /* ───────── вход, регистрация, восстановление: карточка по центру ───────── */

  .t3-auth--wide { --acc-auth-width: 760px; }
  .t3-auth__wrap { display: grid; justify-items: center; }
  .t3-auth__card {
    width: min(100%, var(--acc-auth-width)); padding: var(--acc-card-pad);
    background: var(--acc-card-bg); border-radius: var(--acc-card-radius); box-shadow: var(--shadow-1);
  }
  [data-style="quiet"] .t3-auth__card { border: 1px solid var(--line); box-shadow: none; }
  [data-style="editorial"] .t3-auth__card { border: var(--line-w) solid var(--line); box-shadow: none; }

  /* в модальном окне карточкой служит само окно. Определяем по месту в DOM, а не флагом сервера:
     с открытой панелью конструктора сервер не отличает окно от перерисовки блока */
  .t3-modal .t3-auth { --block-pt: 0px; --block-pb: 0px; background: none; }
  .t3-modal .t3-auth > .t3-block__bg { display: none; }
  .t3-modal .t3-auth__wrap { width: 100%; max-width: none; padding: 0; margin: 0; }
  .t3-modal .t3-auth__card { width: 100%; padding: 0; background: none; box-shadow: none; border: 0; border-radius: 0; }
  .t3-modal .t3-auth__head { padding-right: var(--s-7); }

  /* заголовок страницы дублирует заголовок карточки — оставляем его только для экранных дикторов */
  .t3-main:has(.t3-auth) .page-head {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }

  .t3-auth__head { display: grid; gap: var(--s-2); margin-bottom: var(--s-5); }
  .t3-auth__icon {
    display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: var(--s-2);
    border-radius: var(--radius-m); background: var(--brand-soft); color: var(--brand-text);
  }
  [data-style="editorial"] .t3-auth__icon { background: none; border: var(--line-w) solid currentColor; color: var(--text); }
  .t3-auth__title { font-size: var(--fs-xl); text-wrap: balance; }
  .t3-auth__sub { margin: 0; color: var(--text-2); font-size: var(--fs-s); }
  .t3-auth__foot { margin: var(--s-5) 0 0; padding-top: var(--s-4); border-top: 1px solid var(--line); text-align: center; font-size: var(--fs-s); color: var(--text-2); }
  .t3-auth__link { color: var(--brand-text); font-weight: 600; background: none; font-size: inherit; }
  .t3-auth__link:hover { text-decoration: underline; text-underline-offset: .2em; }

  .t3-account .t3-form--stack .t3-form__submit { width: 100%; }
  .t3-account .t3-form__submit { gap: var(--s-2); }

  /* уже авторизован */
  .t3-auth__me { display: grid; justify-items: center; gap: var(--s-3); text-align: center; }
  .t3-avatar--l { width: 64px; height: 64px; font-size: var(--fs-l); margin-bottom: var(--s-1); }
  .t3-auth__me-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-2); margin-top: var(--s-2); }
  .t3-auth__logout { margin-top: var(--s-2); font-weight: 500; color: var(--text-2); }

  /* ───────── элементы форм кабинета ───────── */

  .t3-field__row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); }
  .t3-field__row .t3-auth__link { font-size: var(--fs-s); }
  .t3-field__hint { margin: 0; font-size: var(--fs-xs); color: var(--text-3); }
  .t3-field__control:disabled { opacity: .6; cursor: not-allowed; }
  .t3-field__control[readonly] { background: var(--surface-2); }

  /* пароль: кнопка «показать» внутри поля */
  .t3-pass { position: relative; }
  .t3-pass .t3-field__control { padding-right: 52px; }
  .t3-pass__toggle {
    position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
    display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--radius-pill); color: var(--text-3);
  }
  .t3-pass__toggle:hover { color: var(--text); background: var(--surface-2); }
  .t3-pass__toggle[aria-pressed="true"] { color: var(--brand-text); }

  /* две колонки полей на широкой карточке */
  .t3-form__fields--2 { grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); align-items: start; }

  /* частное лицо / организация */
  .t3-typeseg {
    display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin: 0 0 var(--s-1); padding: 3px; border: 0;
    border-radius: var(--radius-pill); background: var(--surface-2);
  }
  .t3-typeseg__opt { position: relative; cursor: pointer; }
  .t3-typeseg__opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
  .t3-typeseg__opt span {
    display: grid; place-items: center; min-height: 42px; padding: 0 var(--s-3); border-radius: var(--radius-pill);
    font-size: var(--fs-s); font-weight: 600; color: var(--text-2); transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
  }
  .t3-typeseg__opt:hover span { color: var(--text); }
  .t3-typeseg__opt input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / .1); }
  .t3-typeseg__opt input:focus-visible + span { box-shadow: var(--focus-ring); }
  [data-style="editorial"] :is(.t3-typeseg, .t3-typeseg__opt span) { border-radius: 0; }

  .t3-fieldset { display: grid; gap: var(--s-3); margin: 0; padding: 0; border: 0; min-width: 0; }
  .t3-fieldset__legend { padding: 0; margin-bottom: var(--s-3); font-size: var(--fs-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
  .t3-account__org { display: grid; gap: var(--s-5); }
  .t3-account__org[hidden] { display: none; }

  /* раскрывающийся раздел «Банковские реквизиты» */
  .t3-more { border: 1px solid var(--line); border-radius: var(--radius-m); }
  .t3-more > summary {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-height: 56px; padding: var(--s-2) var(--s-4);
    list-style: none; cursor: pointer; font-weight: 600;
  }
  .t3-more > summary::-webkit-details-marker { display: none; }
  .t3-more > summary span { display: grid; }
  .t3-more > summary small { font-weight: 400; font-size: var(--fs-xs); color: var(--text-3); }
  .t3-more > summary .i { transition: transform var(--dur) var(--ease); color: var(--text-3); }
  .t3-more[open] > summary .i { transform: rotate(180deg); }
  .t3-more > .t3-form__fields { padding: 0 var(--s-4) var(--s-4); }

  /* ───────── кабинет: меню слева, содержимое справа ───────── */

  .t3-lk__wrap { container: lk / inline-size; }
  .t3-lk__layout { display: grid; gap: var(--s-5); align-items: start; }
  .t3-lk__main { display: grid; gap: var(--s-4); min-width: 0; }
  .t3-lk__form { gap: var(--s-4); }

  .t3-accmenu--aside { padding: var(--s-4) var(--s-3); background: var(--acc-card-bg); border-radius: var(--acc-card-radius); box-shadow: var(--shadow-1); }
  [data-style="quiet"] .t3-accmenu--aside { border: 1px solid var(--line); box-shadow: none; }
  [data-style="editorial"] .t3-accmenu--aside { border: var(--line-w) solid var(--line); box-shadow: none; }
  .t3-accmenu--aside .t3-accmenu__user { padding: 0 var(--s-2) var(--s-3); border-bottom: 1px solid var(--line); margin-bottom: var(--s-1); }

  /* телефон и узкая колонка: меню — горизонтальная лента пунктов под пользователем */
  @container lk (max-width: 819px) {
    .t3-accmenu--aside { grid-template-columns: minmax(0, 1fr); padding: var(--s-3); }
    .t3-accmenu--aside .t3-accmenu__list { display: flex; gap: var(--s-1); overflow-x: auto; scrollbar-width: none; margin-inline: calc(var(--s-3) * -1); padding-inline: var(--s-3); }
    .t3-accmenu--aside .t3-accmenu__list::-webkit-scrollbar { display: none; }
    .t3-accmenu--aside .t3-accmenu__link { white-space: nowrap; width: auto; border: 1px solid var(--line); border-radius: var(--radius-pill); }
    .t3-accmenu--aside .t3-accmenu__link[aria-current] { border-color: transparent; }
    .t3-accmenu--aside .t3-accmenu__foot { display: flex; flex-wrap: wrap; gap: var(--s-1); }
    .t3-accmenu--aside .t3-accmenu__foot .t3-accmenu__link { flex: 1; width: auto; border: 0; }
  }
  @container lk (min-width: 820px) {
    .t3-lk__layout { grid-template-columns: var(--acc-aside-width) minmax(0, 1fr); gap: clamp(24px, 3vw, 40px); }
    .t3-lk__aside { position: sticky; top: calc(var(--header-h) + var(--s-4)); }
  }

  .t3-lk__card {
    display: grid; gap: var(--s-4); padding: var(--acc-card-pad);
    background: var(--acc-card-bg); border-radius: var(--acc-card-radius); box-shadow: var(--shadow-1);
  }
  [data-style="quiet"] .t3-lk__card { border: 1px solid var(--line); box-shadow: none; }
  [data-style="editorial"] .t3-lk__card { border: var(--line-w) solid var(--line); box-shadow: none; }
  .t3-lk__head { display: grid; gap: 4px; }
  .t3-lk__title { font-size: var(--fs-l); font-weight: 700; }
  .t3-lk__sub, .t3-lk__lead { margin: 0; font-size: var(--fs-s); color: var(--text-2); }
  .t3-lk__card .t3-typeseg { max-width: 360px; }

  .t3-lk__actions { gap: var(--s-4); }
  .t3-lk__saved { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: var(--fs-s); font-weight: 600; color: var(--success); }
  .t3-lk__saved[hidden] { display: none; }

  /* строка «Пароль — Сменить пароль» */
  .t3-lk__row { grid-template-columns: auto minmax(0, 1fr); align-items: center; }
  .t3-lk__row > .btn { grid-column: 1 / -1; justify-self: start; }
  @container lk (min-width: 600px) {
    .t3-lk__row { grid-template-columns: auto minmax(0, 1fr) auto; }
    .t3-lk__row > .btn { grid-column: auto; }
  }
  .t3-lk__row-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--radius-m); background: var(--surface-2); color: var(--text-2); }
  .t3-lk__row-text { display: grid; gap: 2px; }

  /* раздел «Пароль» профиля: заголовок-строка раскрывает форму смены пароля */
  .t3-lk__pass { gap: 0; scroll-margin-top: calc(var(--header-h) + var(--s-4)); }
  .t3-lk__pass > summary { display: grid; gap: var(--s-4); list-style: none; cursor: pointer; }
  .t3-lk__pass > summary::-webkit-details-marker { display: none; }
  .t3-lk__pass > summary:focus-visible { outline: 2px solid var(--brand); outline-offset: 4px; border-radius: var(--radius-s); }
  .t3-lk__pass .t3-lk__sub.is-done { color: var(--success); font-weight: 600; }
  .t3-lk__pass-toggle { pointer-events: none; }
  .t3-lk__pass > summary:hover .t3-lk__pass-toggle { --_bg: var(--surface-2); }
  .t3-lk__pass-close, .t3-lk__pass[open] .t3-lk__pass-open { display: none; }
  .t3-lk__pass[open] .t3-lk__pass-close { display: inline; }
  .t3-lk__pass-form { margin-top: var(--s-5); padding-top: var(--s-5); border-top: 1px solid var(--line); }
  .t3-lk__pass-old { display: grid; }
  @container lk (min-width: 600px) { .t3-lk__pass-old { max-width: calc(50% - var(--form-gap) / 2); } }

  /* панель несохранённых изменений — прилипает к низу экрана, над нижней панелью телефона */
  .t3-savebar {
    position: sticky; bottom: calc(var(--s-3) + env(safe-area-inset-bottom)); z-index: 5;
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); padding: var(--s-3) var(--s-3) var(--s-3) var(--s-5);
    background: var(--text); color: var(--bg); border-radius: var(--radius-l); box-shadow: var(--shadow-pop);
    animation: t3-savebar-in .25s var(--ease-out);
  }
  .t3-savebar[hidden] { display: none; }
  [data-tabbar="1"] .t3-savebar { bottom: calc(76px + env(safe-area-inset-bottom)); }
  @media (min-width: 1024px) { [data-tabbar="1"] .t3-savebar { bottom: var(--s-4); } }
  .t3-savebar__text { flex: 1; min-width: 160px; font-size: var(--fs-s); font-weight: 600; }
  .t3-savebar .btn--ghost { --_fg: var(--bg); --_bd: color-mix(in srgb, var(--bg) 40%, transparent); }
  .t3-savebar .btn--ghost:hover { --_bg: color-mix(in srgb, var(--bg) 14%, transparent); }
  @keyframes t3-savebar-in { from { opacity: 0; transform: translateY(12px); } }

  .t3-lk__empty-title { margin: 0; font-size: var(--fs-l); font-weight: 700; color: var(--text); }
  .t3-lk__pager { margin-top: var(--s-2); }

  /* ───────── история заказов ───────── */

  .t3-orders { display: grid; gap: var(--s-3); margin: 0; padding: 0; list-style: none; }
  .t3-order { background: var(--acc-card-bg); border-radius: var(--acc-card-radius); box-shadow: var(--shadow-1); overflow: hidden; }
  [data-style="quiet"] .t3-order { border: 1px solid var(--line); box-shadow: none; }
  [data-style="editorial"] .t3-order { border: var(--line-w) solid var(--line); box-shadow: none; }

  .t3-order__sum {
    display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: var(--s-3) var(--s-4);
    padding: var(--s-4) var(--acc-card-pad); list-style: none; cursor: pointer;
  }
  .t3-order__sum::-webkit-details-marker { display: none; }
  .t3-order__sum:hover .t3-order__title { color: var(--brand-text); }
  .t3-order__main { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--s-3); min-width: 0; }
  .t3-order__title { font-weight: 700; font-size: var(--fs-l); transition: color var(--dur) var(--ease); }
  .t3-order__meta { flex-basis: 100%; font-size: var(--fs-s); color: var(--text-2); }
  .t3-order__thumbs { display: none; }
  .t3-order__thumbs img { width: 44px; height: 44px; object-fit: contain; border-radius: var(--radius-s); background: var(--surface-2); border: 2px solid var(--acc-card-bg); }
  .t3-order__thumbs img + img { margin-left: -14px; }
  @container lk (min-width: 720px) { .t3-order__thumbs { display: flex; } .t3-order__sum { grid-template-columns: minmax(0, 1fr) auto auto auto; } }
  .t3-order__total { font-weight: 700; font-size: var(--fs-l); font-variant-numeric: tabular-nums; white-space: nowrap; }
  .t3-order__chev { color: var(--text-3); transition: transform var(--dur) var(--ease); }
  .t3-order[open] .t3-order__chev { transform: rotate(180deg); }

  .t3-order__body { display: grid; gap: var(--s-4); padding: 0 var(--acc-card-pad) var(--acc-card-pad); border-top: 1px solid var(--line); padding-top: var(--s-4); }
  .t3-order__facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); gap: var(--s-3); margin: 0; }
  .t3-order__facts div { display: grid; gap: 2px; padding: var(--s-3) var(--s-4); border-radius: var(--radius-m); background: var(--surface-2); }
  .t3-order__facts dt { font-size: var(--fs-xs); color: var(--text-3); }
  .t3-order__facts dd { margin: 0; font-weight: 600; font-size: var(--fs-s); }

  /* статус заказа */
  .t3-status {
    display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 10px; border-radius: var(--radius-pill);
    font-size: var(--fs-xs); font-weight: 700; --_c: var(--brand-text); color: var(--_c); background: color-mix(in srgb, var(--_c) 12%, var(--surface));
  }
  .t3-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
  .t3-status--success { --_c: var(--success); }
  .t3-status--warn { --_c: var(--warning); }
  .t3-status--danger { --_c: var(--danger); }
  [data-style="editorial"] .t3-status { border-radius: 0; }

  /* доставка Ozon */
  .t3-order__ship { display: grid; gap: var(--s-3); padding: var(--s-4); border: 1px solid var(--line); border-radius: var(--radius-m); }
  .t3-order__ship-head { display: flex; align-items: center; gap: var(--s-2); margin: 0; font-weight: 600; }
  .t3-order__tc { padding: 2px 8px; border-radius: var(--radius-s); background: #005bff; color: #fff; font-size: var(--fs-xs); font-weight: 800; letter-spacing: .02em; }
  .t3-order__ship-rows { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px var(--s-4); margin: 0; font-size: var(--fs-s); }
  .t3-order__ship-rows dt { color: var(--text-3); }
  .t3-order__ship-rows dd { margin: 0; }
  .t3-order__state { margin: 0; padding: var(--s-2) var(--s-3); border-radius: var(--radius-s); background: var(--surface-2); font-size: var(--fs-s); }
  .t3-order__state--success { background: color-mix(in srgb, var(--success) 12%, var(--surface)); }
  .t3-order__state--warn { background: color-mix(in srgb, var(--warning) 14%, var(--surface)); }
  .t3-order__state--danger { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); }
  .t3-ocancel { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
  .t3-ocancel .t3-select { flex: 1 1 240px; }
  .t3-ocancel .t3-select select { width: 100%; }
  .t3-ocancel__start:hover { --_fg: var(--danger); --_bd: var(--danger); }
  .t3-ocancel__confirm { --_bg: var(--danger); --_bd: var(--danger); --_fg: #fff; }
  .t3-ocancel__confirm:hover { --_bg: color-mix(in srgb, var(--danger) 86%, #000); --_bd: transparent; }
  .t3-ocancel__msg { flex-basis: 100%; margin: 0; font-size: var(--fs-s); color: var(--text-2); }
  .t3-ocancel__msg.is-error { color: var(--danger); }

  /* состав */
  .t3-order__items { display: grid; gap: var(--s-2); }
  .t3-order__items-title { margin: 0; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
  .t3-order__lines { display: grid; margin: 0; padding: 0; list-style: none; }
  .t3-order__line { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; gap: var(--s-3); padding: var(--s-2) 0; border-bottom: 1px solid var(--line); }
  .t3-order__img { display: grid; place-items: center; width: 56px; aspect-ratio: 1; border-radius: var(--radius-s); background: var(--surface-2); overflow: hidden; color: var(--text-3); }
  .t3-order__img img { width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; }
  [data-scheme="dark"] .t3-order__img img { mix-blend-mode: normal; }
  .t3-order__line-info { display: grid; gap: 2px; min-width: 0; }
  .t3-order__line-name { font-weight: 600; font-size: var(--fs-s); line-height: 1.35; }
  .t3-order__line-meta { font-size: var(--fs-xs); color: var(--text-3); }
  .t3-order__line-sum { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .t3-order__totals { display: grid; gap: var(--s-1); margin: var(--s-2) 0 0; }
  .t3-order__totals div { display: flex; justify-content: space-between; gap: var(--s-3); font-size: var(--fs-s); color: var(--text-2); }
  .t3-order__totals dd { margin: 0; font-variant-numeric: tabular-nums; }
  .t3-order__totals .t3-order__grand { font-size: var(--fs-l); font-weight: 700; color: var(--text); }
  .t3-order__actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
}
