/* Written by Richard Christopher, Copyright 2026 Mindfull */
/*
 * THE FRAME'S OWN SURFACES: the user icon's dropdown and the sign-in gate. global.css owns the document and
 * the palette; engine.css owns the seam with CloudCanvas; the unified sheets own the shell and its views.
 * The settings dialog that once showed the account pane, the modal sheet that held its frame and the page
 * after them are gone: the dropdown is the one way in.
 * The legacy nav bar, toolbar, window body, panel frame and renderer sheets went with the legacy
 * panels (M1b).
 *
 * THE DESIGN LANGUAGE, in one place so every rule in every sheet is an
 * application of it rather than a fresh decision:
 *
 *   panels     opaque `--bg-raised` boxes: hairline border, `--radius-lg`,
 *              `--elevation-3` for a dialog.
 *   rhythm     the `--space-*` scale only.
 *   colour     tokens only. Signals use the `--*-wash` tints; nothing in any
 *              sheet states a hex value that global.css does not already own.
 */

/* ------------------ THE USER ICON'S DROPDOWN (shell/account-dropdown.js) ------------------ */
/*
 * A column of rows and sections on the kit's popover, which places it, holds it to the screen and scrolls it. Its width is its own and never
 * wider than a phone: the popover's padding and margin are taken off the viewport. A row is the height of a target and keeps the check's column
 * whether or not it holds the check, so the words line up. A section opens under its row. Tokens only, so both themes are the palette's.
 */
.unified-account-menu {
  --cc-control-min: 36px;
  box-sizing: border-box; width: min(24rem, calc(100vw - 42px)); min-width: 0; font-family: var(--font-sans); font-size: var(--text-base);
  color: var(--text);
}
.unified-account-column { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; min-width: 0; }
.unified-account-column [hidden] { display: none; }
.unified-account-block { min-width: 0; padding: var(--space-1) var(--space-2) var(--space-2); overflow-wrap: anywhere; }
.unified-account-row {
  box-sizing: border-box; display: flex; align-items: center; gap: var(--space-2); width: 100%; min-width: 0; min-height: var(--cc-control-min);
  padding: var(--space-1) var(--space-2); color: var(--text); background: transparent; border: 0; border-radius: var(--radius); font: inherit;
  text-align: start; cursor: pointer;
}
.unified-account-row:is(:hover, :focus):not(:disabled), .unified-account-row[aria-expanded="true"] { background: var(--accent-wash); }
.unified-account-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.unified-account-row:disabled { opacity: .5; cursor: not-allowed; }
.unified-account-row[data-account-separated] { position: relative; margin-block-start: var(--space-2); }
.unified-account-row[data-account-separated]::before { content: ""; position: absolute; inset-inline: 0; inset-block-start: calc(-1 * var(--space-1) - 1px); border-block-start: 1px solid var(--border); }
.unified-account-row-check { display: grid; place-items: center; flex: none; width: 1rem; visibility: hidden; }
.unified-account-row-check[data-account-checked] { visibility: visible; }
.unified-account-row-check [data-icon], .unified-account-row-more [data-icon] { width: 1rem; height: 1rem; }
.unified-account-row-label { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.unified-account-row-more { display: grid; place-items: center; flex: none; color: var(--text-dim); }
.unified-account-row[aria-expanded="true"] .unified-account-row-more { transform: rotate(180deg); }
.unified-account-section { min-width: 0; padding: var(--space-2) var(--space-2) var(--space-3); }
/* The row over a section already names it. */
.unified-account-section > .momentum-settings-pane > .mindfull-settings-heading { display: none; }
.unified-account-section > .momentum-settings-pane > :is(.mindfull-settings-status, .mindfull-settings-body) { margin-block-start: 0; }
.unified-account-pane { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); min-width: 0; --cc-control-min: 36px; }
@media (pointer: coarse), (max-width: 760px) {
  .unified-account-menu, .unified-account-pane { --cc-control-min: 44px; }
}
/* The rows of a group stand one under the other at this width, whatever the screen, with its control beside both. */
.unified-account-menu .mindfull-settings-list { grid-template-columns: minmax(0, 1fr) max-content; column-gap: var(--space-3); }
.unified-account-menu .mindfull-settings-row { min-height: 44px; align-content: center; }
.unified-account-menu .mindfull-settings-name { grid-column: 1; grid-row: 1; }
.unified-account-menu .mindfull-settings-meta { grid-column: 1; grid-row: 2; }
.unified-account-menu .mindfull-settings-act { grid-column: 2; grid-row: 1 / span 2; }
.unified-account-menu .mindfull-settings-field { flex-basis: 100%; max-width: none; }
.unified-account-menu .mindfull-settings-aside { min-height: 0; }

/* A group, and a part of one. The status line says nothing at rest, and then it takes no room. */
.momentum-settings-pane { min-width: 0; }
.unified-account-pane > .momentum-settings-pane:last-child { padding-block-start: var(--space-3); border-block-start: 1px solid var(--border); }
.momentum-settings-group { min-width: 0; }
.mindfull-settings-heading { margin: 0; font-size: var(--text-lg); font-weight: var(--weight-bold); line-height: var(--leading-tight); }
.mindfull-settings-subheading { margin: 0; font-size: var(--text-lg); font-weight: var(--weight-bold); line-height: var(--leading-tight); }
.mindfull-settings-subheading:focus-visible, .mindfull-settings-step:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: var(--radius); }
.mindfull-settings-status:not(:has(.is-quiet)) { margin-block-start: var(--space-3); }
.mindfull-settings-body { display: grid; gap: var(--space-3); min-width: 0; margin-block-start: var(--space-3); }
.mindfull-settings-body:empty { display: none; }
/* The parts of a group stand further apart than the lines of a part, and so does a part from the step in hand above it. */
.momentum-settings-group + .momentum-settings-group, .mindfull-settings-step:not([hidden]) + .momentum-settings-group { margin-block-start: var(--space-3); }

/* Named facts: the name quiet, the value the row. */
.mindfull-settings-facts { display: grid; grid-template-columns: minmax(6rem, max-content) minmax(0, 1fr); column-gap: var(--space-4); margin: 0; min-width: 0; }
.mindfull-settings-fact { display: grid; grid-template-columns: subgrid; grid-column: 1 / -1; align-items: center; min-height: var(--space-6); }
.mindfull-settings-key { color: var(--text-dim); font-size: var(--text-base); }
.mindfull-settings-value { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* Rows: what a thing is, what is said of it, and its one control, on the list's own tracks. Each is tall
   enough for a 44px control with air above and below, so no two touch. */
.mindfull-settings-list { display: grid; grid-template-columns: minmax(8rem, 16rem) minmax(0, 1fr) max-content; column-gap: var(--space-4); min-width: 0; }
.mindfull-settings-row { display: grid; grid-template-columns: subgrid; grid-column: 1 / -1; align-items: center; min-height: calc(44px + var(--space-2)); min-width: 0; }
.mindfull-settings-name { font-weight: var(--weight-medium); overflow-wrap: anywhere; }
.mindfull-settings-meta { color: var(--text-dim); font-size: var(--text-base); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.mindfull-settings-act { display: flex; justify-content: flex-end; }

/* Fields and the action they feed share one line, the action level with the fields' own boxes. */
.mindfull-settings-line { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-2) var(--space-3); min-width: 0; }
.mindfull-settings-field { display: grid; gap: var(--space-1); flex: 1 1 12rem; min-width: 0; max-width: 24rem; color: var(--text-dim); font-size: var(--text-base); }
.mindfull-settings-input { box-sizing: border-box; width: 100%; min-width: 0; min-height: 44px; color: var(--text); }
.mindfull-settings-note { margin: 0; color: var(--text-dim); font-size: var(--text-base); overflow-wrap: anywhere; }
.mindfull-settings-aside { display: flex; align-items: center; min-height: 44px; }
/* A typed code the service refused, said under its field: the failure colour, and no line while there is nothing to say. */
.mindfull-settings-refusal { color: var(--fail); }
.mindfull-settings-refusal:empty { display: none; }

/* The one overflow a part carries, and the form a primary action opens under itself. */
.mindfull-settings-more { min-width: 0; color: var(--text-dim); font-size: var(--text-base); }
.mindfull-settings-more-summary { box-sizing: border-box; min-height: 44px; padding-block: var(--space-3); cursor: pointer; border-radius: var(--radius); }
.mindfull-settings-more-summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mindfull-settings-more-body, .mindfull-settings-reveal { display: grid; gap: var(--space-3); min-width: 0; }
.mindfull-settings-more-body { padding-block-end: var(--space-2); }

/* The step in hand: a challenge to answer, or codes to save. A rule at its start says it is one thing. */
.mindfull-settings-step { display: grid; gap: var(--space-3); min-width: 0; padding-inline-start: var(--space-3); border-inline-start: 2px solid var(--accent); }
.mindfull-settings-secret { font-family: var(--font-mono); font-size: var(--text-base); white-space: pre-wrap; user-select: all; }
.mindfull-settings-qr { width: 192px; max-width: 100%; height: auto; background: var(--qr-paper); padding: var(--space-2); border-radius: var(--radius-lg); }

/* The group's Details: Feed's disclosure, set flush with the group and given this page's target size. */
.momentum-settings-pane > .feed-details { padding: 0; margin-block-start: var(--space-2); }
/* The times among a group's Details stand under its facts, on the same rhythm. */
.mindfull-settings-moments { display: grid; gap: var(--space-2); }
.mindfull-settings-moments:not(:empty) { margin-block-start: var(--space-2); }

@media (max-width: 760px) {
  /* Narrow: a row keeps one height on two lines, the name over what is said of it, with its control beside both. */
  .mindfull-settings-list { grid-template-columns: minmax(0, 1fr) max-content; column-gap: var(--space-3); }
  .mindfull-settings-row { min-height: 56px; align-content: center; }
  .mindfull-settings-name { grid-column: 1; grid-row: 1; }
  .mindfull-settings-meta { grid-column: 1; grid-row: 2; }
  .mindfull-settings-act { grid-column: 2; grid-row: 1 / span 2; }
  .mindfull-settings-field { flex-basis: 100%; max-width: none; }
  /* A sentence beside a control is under it here, so it is as tall as its words. */
  .mindfull-settings-aside { min-height: 0; }
}

/* ------------------ SIGN-IN ------------------ */

.mindfull-signin {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 60;
  display: flex; flex-direction: column; gap: var(--space-3); min-width: 300px;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--bg-raised); padding: var(--space-5);
  box-shadow: var(--elevation-3);
}
.mindfull-signin-title { margin: 0; font-size: var(--text-xl); font-weight: var(--weight-bold); }
.mindfull-signin-note { margin: 0 0 var(--space-2); font-size: var(--text-sm); color: var(--text-dim); }
.mindfull-signin-field { padding: var(--space-2) var(--space-3); }
.mindfull-signin-submit { margin-top: var(--space-2); padding: var(--space-2) var(--space-3); }
.mindfull-signin-error { margin: 0; font-size: var(--text-sm); color: var(--fail); min-height: 1em; }
/* The three steps of one exchange: credentials, phone verification, code.
   The gate is a column, so each step is one too - and the attribute rule
   restates the hide because `display: flex` here would otherwise outrank the UA's `[hidden]`. */
.mindfull-signin-step { display: flex; flex-direction: column; gap: var(--space-3); }
.mindfull-signin-step[hidden] { display: none; }
.mindfull-signin-credentials { margin: 0; }
.mindfull-signin-phone { margin: 0; }
.mindfull-signin-code { margin: 0; }
.mindfull-signin-actions { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-2); }
.mindfull-signin-actions .mindfull-signin-submit { margin-top: 0; flex: 1; }
.mindfull-signin-back {
  padding: var(--space-2) var(--space-3); background: none; border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-dim); cursor: pointer;
}
.mindfull-signin-back:hover { color: var(--text); border-color: var(--border-strong); }
.mindfull-signin-continue { margin-top: var(--space-2); }
.mindfull-signin-device { margin-top: var(--space-2); }
/* Forgot password (sign-in) and Change password (Account): a quiet line, its link the one thing in it to press. */
.password-help { margin: 0; color: var(--text-dim); font-size: var(--text-sm); }
.password-help a { color: var(--accent); }
.mindfull-signin-help { margin-top: var(--space-1); }
.mindfull-signin-phone-submit { margin-top: 0; }
.mindfull-signin-verify { margin-top: 0; }
.mindfull-signin-resend {
  padding: var(--space-1) var(--space-2); background: none; border: none;
  color: var(--text-dim); font-size: var(--text-sm); text-decoration: underline; cursor: pointer;
}

/* Account enrollment stays readable on a phone and exposes no workspace chrome. */
.mindfull-signin-setup { display: grid; gap: 12px; justify-items: center; }
.mindfull-signin-secret { display: block; max-width: 100%; overflow-wrap: anywhere; font-size: 0.85rem; user-select: all; }
.mindfull-signin-qr { width: 192px; max-width: 100%; height: auto; background: var(--qr-paper); padding: 8px; border-radius: 8px; }
.mindfull-signin-alternatives { display: flex; flex-wrap: wrap; gap: 8px; }
.mindfull-signin-method { padding: 8px 12px; border: 1px solid currentColor; border-radius: 6px; background: transparent; color: inherit; cursor: pointer; }
