/* ============================================================
   v0.28.1.0: the account menu (Components/AccountMenu.razor) and the
   hotkeys window (Components/HotkeysDialog.razor).

   Token-driven, so both read in the light and the dark theme; the few
   dark-only touches sit at the end. Loaded after 31-topnav.css and
   37-user-chip.css (it leans on their avatar rules) and before 95-rtl and
   24-theme-dark. Every inline direction is logical, so Hebrew mirrors it.
   ============================================================ */

/* ---- the trigger: the old avatar chip, now a <details> summary --------------
   The section (.topnav-seg.user-chip.account-seg) keeps the box the old chip had,
   so the strip does not move. The summary inside it is only as big as the avatar;
   its ::after covers the whole section (the nearest positioned box, since the
   details and the summary stay static), so a tap anywhere in the 40px phone cell
   opens the menu, as a tap anywhere on the old chip opened the profile. */
.account-menu { position: static; }

.account-menu > summary.account-trigger {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: center;
    position: static;
    cursor: pointer;
    user-select: none;
}
.account-menu > summary.account-trigger::-webkit-details-marker { display: none; }
.account-menu > summary.account-trigger::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 2;
    border-radius: 6px;
}
.account-menu > summary.account-trigger:focus-visible { outline: none; }
.account-menu > summary.account-trigger:focus-visible::after {
    outline: 2px solid var(--chronos-violet);
    outline-offset: -2px;
}
/* Above the section's skewed plate (z 0), like every .topnav-seg-body. */
.account-trigger .avatar { position: relative; z-index: 1; }
.account-menu[open] > summary.account-trigger .avatar { box-shadow: 0 0 0 2px var(--chronos-violet); }

/* ---- the menu --------------------------------------------------------------- */
.account-panel {
    position: absolute;
    top: calc(100% + 8px);
    inset-inline-end: 0;
    z-index: 60;
    width: 268px;
    max-width: calc(100vw - 24px);
    padding: 6px;
    border-radius: 14px;
    background: var(--chronos-card-bg);
    border: 1px solid var(--chronos-outline);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
    /* The strip paints its subtree near-white for its violet plate (see 26-settings-menu.css,
       "white on white"); the menu states its own type once so nothing inside inherits that. */
    color: var(--chronos-fg-primary);
    font-family: var(--chronos-font-sans);
    font-size: 14px;
    line-height: 1.3;
    letter-spacing: normal;
    text-transform: none;
    white-space: normal;
    text-align: start;
    cursor: default;
    display: flex;
    flex-direction: column;
    gap: 1px;
    /* Never taller than the screen under the trigger: the language list unfolds inside. */
    max-height: calc(100vh - var(--popover-anchor-bottom, 56px) - 20px);
    max-height: calc(100dvh - var(--popover-anchor-bottom, 56px) - 20px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    animation: account-pop 0.14s ease-out;
}

@keyframes account-pop {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}

.account-panel .account-item,
.account-panel .account-head {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: auto;
    min-height: 38px;
    margin: 0;
    padding: 7px 10px;
    border: 0;
    border-radius: 9px;
    background: none;
    box-shadow: none;
    color: inherit;
    font: inherit;
    text-align: start;
    text-decoration: none;
    cursor: pointer;
}
.account-panel .account-item:hover,
.account-panel .account-head:hover,
.account-panel .account-item:focus-visible,
.account-panel .account-head:focus-visible {
    background: var(--chronos-hover-bg);
    outline: none;
}

.account-panel .account-icon {
    flex: 0 0 auto;
    width: 20px;
    font-size: 19px;
    color: var(--chronos-fg-secondary);
    text-align: center;
}
.account-label {
    flex: 1 1 auto;
    min-width: 0;
}
.account-value {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 50%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    color: var(--chronos-fg-muted);
}
.account-sep {
    flex: 0 0 auto;
    height: 1px;
    margin: 4px 6px;
    background: var(--chronos-outline);
}

/* The profile row: who you are, and the door to the profile. */
.account-panel .account-head { min-height: 52px; }
.account-head .account-head-avatar {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    margin: 0;
    font-size: 15px;
}
.account-head-text {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
}
.account-head-name {
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.account-head-sub {
    font-size: 12px;
    color: var(--chronos-fg-muted);
}

/* Sign-out keeps the strip's warning tint on hover. */
.account-panel .account-logout:hover,
.account-panel .account-logout:hover .account-icon { color: var(--chronos-red); }

/* Theme: 01-topbar.css shows exactly one of the two glyphs for the current theme. */
.account-panel .theme-toggle .material-icons { font-size: 19px; color: var(--chronos-fg-secondary); }

/* Language: unfolds in place. */
.account-lang > summary { list-style: none; }
.account-lang > summary::-webkit-details-marker { display: none; }
.account-chevron {
    flex: 0 0 auto;
    font-size: 18px;
    color: var(--chronos-fg-muted);
    transition: transform 0.15s ease;
}
.account-lang[open] .account-chevron { transform: rotate(180deg); }
.account-lang-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    padding: 2px 4px 6px;
    padding-inline-start: 34px;
}
.account-lang-item {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    padding: 6px 8px;
    border-radius: 8px;
    color: inherit;
    font-size: 13px;
    text-decoration: none;
}
.account-lang-item:hover { background: var(--chronos-hover-bg); }
.account-lang-item.is-active { color: var(--chronos-violet); font-weight: 700; }
.account-lang-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- keycaps: the menu's hints and the window's combinations ----------------- */
.account-kbd,
.hotkeys-modal kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border: 1px solid var(--chronos-outline);
    border-bottom-width: 2px;
    border-radius: 6px;
    background: var(--chronos-chip-bg);
    color: var(--chronos-fg-primary);
    font: 600 12px/1 var(--chronos-font-mono);
    white-space: nowrap;
}
.account-kbd { flex: 0 0 auto; color: var(--chronos-fg-secondary); }
/* An author display beats the user agent's [hidden]; the script hides a hint with no key. */
.account-kbd[hidden] { display: none; }

/* ---- phones: a sheet under the strip ----------------------------------------
   The strip spans the screen here and the avatar is its seventh cell, so a menu
   hung off its end would leave the screen on the left. The sheet takes the
   width instead, starting under the trigger (popover-dismiss.js measures it). */
@media (max-width: 720px) {
    .account-panel {
        position: fixed;
        top: calc(var(--popover-anchor-bottom, 120px) + 10px);
        inset-inline: 10px;
        width: auto;
        max-width: none;
        max-height: calc(100vh - var(--popover-anchor-bottom, 120px) - 24px);
        max-height: calc(100dvh - var(--popover-anchor-bottom, 120px) - 24px);
    }
    .account-panel .account-item,
    .account-panel .account-head { min-height: 44px; }
}
/* A touch screen has no keys: no hints, and no hotkeys item at all (owner, 2026-11-08: "на
   мобильном виде" hotkeys are noise, gestures would be the phone's answer). Keyed on the input,
   not on the width: a narrow desktop window still has a keyboard and keeps the item. Without the
   item and without a keyboard there is no way to reach the window, and the dispatcher never hears a
   key, so nothing of the feature is left on a phone. */
@media (hover: none) and (pointer: coarse) {
    .account-kbd { display: none; }
    .account-panel [data-account-item="hotkeys"] { display: none; }
}

/* ---- the hotkeys window ------------------------------------------------------
   Fixed height, the list scrolls inside, and the status line under it has a fixed
   height of its own: nothing a click or a message does can move the window. */
.modal-card.hotkeys-modal {
    width: min(560px, calc(100vw - 24px));
    max-width: 560px;
    min-width: 0;
    height: min(calc(100vh - 24px), 680px);
    height: min(calc(100dvh - 24px), 680px);
    padding: 20px;
    gap: 10px;
    overflow: hidden;
    /* The window is mounted inside the nav strip (AccountMenu), whose type is set for the strip:
       state ours once, as the menu does. */
    color: var(--chronos-fg-primary);
    font-family: var(--chronos-font-sans);
    font-size: 14px;
    line-height: 1.35;
    letter-spacing: normal;
    text-transform: none;
    white-space: normal;
    text-align: start;
    cursor: default;
}
.hotkeys-modal > .modal-head,
.hotkeys-modal > .hk-intro,
.hotkeys-modal > .hk-status,
.hotkeys-modal > .hk-actions { flex: 0 0 auto; }

.hk-intro {
    margin: 0;
    font-size: 13px;
    line-height: 1.45;
    color: var(--chronos-fg-secondary);
}

.hk-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-gutter: stable;
    margin-inline: -6px;
    padding-inline: 6px;
}

.hk-group + .hk-group { margin-top: 14px; }
.hk-group-title {
    margin: 0 0 2px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--chronos-fg-muted);
}

.hk-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 58px;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 3px 0;
    border-bottom: 1px solid color-mix(in srgb, var(--chronos-outline) 60%, transparent);
}
.hk-group .hk-row:last-child { border-bottom: 0; }

.hk-label {
    min-width: 0;
    font-size: 14px;
    overflow-wrap: anywhere;
}

.hk-combo {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    min-width: 136px;
    height: 32px;
    margin: 0;
    padding: 0 8px;
    border: 1px dashed transparent;
    border-radius: 8px;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
}
.hk-combo:hover {
    border-color: var(--chronos-outline);
    background: var(--chronos-hover-bg);
}
.hk-combo:focus-visible {
    outline: 2px solid var(--chronos-violet);
    outline-offset: 1px;
}
.hk-row.is-recording .hk-combo {
    border-color: var(--chronos-violet);
    background: color-mix(in srgb, var(--chronos-violet) 10%, transparent);
}
.hk-press {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    color: var(--chronos-violet);
    animation: hk-blink 1.1s ease-in-out infinite;
}
@keyframes hk-blink { 50% { opacity: 0.45; } }
.hk-none {
    font-size: 12px;
    color: var(--chronos-fg-muted);
}
.hk-combo.is-empty kbd { display: none; }

.hk-row.is-fixed .hk-combo,
.hk-row.is-fixed .hk-combo:hover {
    cursor: default;
    border-color: transparent;
    background: none;
}

.hk-tools {
    display: flex;
    justify-content: flex-end;
    gap: 2px;
}
.hk-tool {
    width: 26px;
    height: 26px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 7px;
    background: none;
    color: var(--chronos-fg-muted);
    font: 600 16px/1 var(--chronos-font-sans);
    cursor: pointer;
}
.hk-tool:hover {
    background: var(--chronos-hover-bg);
    color: var(--chronos-fg-primary);
}
.hk-lock {
    font-size: 16px;
    color: var(--chronos-fg-muted);
    padding-inline-end: 5px;
}

/* Two lines, always reserved: a long "already taken by ..." wraps instead of pushing. */
.hk-status {
    margin: 0;
    height: 36px;
    font-size: 12.5px;
    line-height: 18px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}
.hk-status.is-error { color: var(--chronos-red); }
.hk-status.is-ok { color: var(--chronos-fg-muted); }

.hk-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0;
}
.hk-foot {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
    color: var(--chronos-fg-muted);
}
.hk-reset-all {
    flex: 0 0 auto;
    padding: 8px 14px;
    border: 1px solid var(--chronos-outline);
    border-radius: var(--radius-pill, 999px);
    background: none;
    color: var(--chronos-fg-primary);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.hk-reset-all:hover:not(:disabled) { border-color: var(--chronos-violet); color: var(--chronos-violet); }
.hk-reset-all:disabled { opacity: 0.45; cursor: default; }

@media (max-width: 480px) {
    .modal-card.hotkeys-modal { width: calc(100vw - 16px); padding: 16px 14px; }
    .hk-row { grid-template-columns: minmax(0, 1fr) auto 54px; gap: 6px; }
    .hk-combo { min-width: 104px; padding: 0 6px; }
    .hk-label { font-size: 13.5px; }
}

@media (prefers-reduced-motion: reduce) {
    .account-panel { animation: none; }
    .hk-press { animation: none; }
    .account-chevron { transition: none; }
}

/* ---- dark ---------------------------------------------------------------------- */
[data-theme="dark"] .account-panel { box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5); }
