/* Breckly kit: controls, feedback and patterns added for the component gallery and sign-in. */

[hidden] { display: none !important; }

/* ---------- Fields ---------- */

.fgroup { display: grid; gap: 6px; min-width: 0; }
.fgroup > label, .flabel { font-size: 12.5px; font-weight: 600; }
.fhint { font-size: 11.5px; color: var(--ink-3); }
.ferr, .fok { display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; color: var(--crit); }
.fok { color: var(--ok); }
.ferr .icon, .fok .icon { flex: none; }
.field.invalid { border-color: var(--crit-mark); box-shadow: 0 0 0 3px color-mix(in oklab, var(--crit-mark) 14%, transparent); }
.field[disabled] { background: var(--sunken); color: var(--ink-3); cursor: not-allowed; }
textarea.field { height: auto; min-height: 76px; padding: 8px 10px; resize: vertical; line-height: 1.5; }
.fcount { justify-self: end; font-size: 11.5px; color: var(--ink-3); }
.with-icon { position: relative; display: block; }
.with-icon > .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.with-icon .field { width: 100%; padding-left: 32px; }
.with-action .field { padding-right: 38px; }
.field-btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; color: var(--ink-3);
}
.field-btn:hover { background: var(--sunken); color: var(--ink); }
.fgroup .select-wrap, .fgroup .select-wrap select { width: 100%; }
.linkish { color: var(--accent); font-weight: 600; font-size: 12.5px; display: inline-flex; align-items: center; gap: 4px; }
.linkish:hover, .link-text:hover { text-decoration: underline; text-underline-offset: 3px; }
.link-text { color: var(--accent); font-weight: 600; text-decoration: underline; text-decoration-color: var(--accent-line); text-underline-offset: 3px; }
.panel-link { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--accent); }

/* ---------- Choice controls ---------- */

.check { display: inline-flex; align-items: center; gap: 9px; font-size: 13px; cursor: pointer; }
.check input {
  appearance: none; -webkit-appearance: none; flex: none; margin: 0; display: grid; place-items: center;
  width: 16px; height: 16px; border-radius: 4.5px; border: 1.5px solid var(--line-strong); background: var(--surface);
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.check input:hover { border-color: var(--ink-3); }
.check input:checked, .check input:indeterminate { background: var(--btn); border-color: var(--btn); }
.check input:checked::after { content: ""; width: 8px; height: 4.5px; border: 2px solid #FFFFFF; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.check input:indeterminate::after { content: ""; width: 8px; height: 2px; border-radius: 1px; background: #FFFFFF; transform: none; border: 0; }
.check input[type="radio"] { border-radius: 50%; }
.check input[type="radio"]:checked { background: var(--surface); border: 5px solid var(--btn); }
.check input[type="radio"]:checked::after { content: none; }
.check:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }
.check input:disabled { cursor: not-allowed; }
.radio-set { border: 0; margin: 0; padding: 0; display: grid; gap: 9px; min-width: 0; }
.radio-set legend { padding: 0; margin-bottom: 9px; font-size: 12.5px; font-weight: 600; }

.switch { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; cursor: pointer; }
.switch input {
  appearance: none; -webkit-appearance: none; position: relative; flex: none; margin: 0;
  width: 30px; height: 18px; border-radius: 9px; background: var(--line-strong); cursor: pointer; transition: background 0.2s;
}
.switch input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: #FFFFFF; box-shadow: 0 1px 2px rgba(6, 22, 65, 0.3); transition: transform 0.25s var(--ease-out);
}
.switch input:checked { background: var(--btn); }
.switch input:checked::after { transform: translateX(12px); }
.switch:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 27px; padding: 0 11px; border-radius: 99px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); font-size: 12.5px; font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip:hover { color: var(--ink); border-color: var(--ink-3); }
.chip .icon { display: none; }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); font-weight: 600; }
.chip[aria-pressed="true"] .icon { display: block; }

.range-row { display: flex; align-items: center; gap: 12px; }
.range { flex: 1; min-width: 0; accent-color: var(--btn); height: 18px; }
.range-row output { min-width: 38px; text-align: right; font-weight: 700; font-size: 13px; }

/* ---------- Buttons ---------- */

.icon-btn.outline { border: 1px solid var(--line-strong); background: var(--surface); }
.btn.danger.solid { background: var(--brique); border-color: transparent; color: #FFFFFF; }
.btn.danger.solid:hover { background: color-mix(in oklab, var(--brique) 88%, #000000); }
.split { display: inline-flex; }
.split .btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split .btn:last-child { border-top-left-radius: 0; border-bottom-left-radius: 0; padding: 0 9px; margin-left: 1px; }
.spin { flex: none; width: 13px; height: 13px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Feedback ---------- */

.banner.compact { margin-bottom: 0; padding: 9px 12px; }
.banner.compact p { min-width: 180px; }
.banner.info { background: color-mix(in oklab, var(--accent) 7%, var(--surface)); border-color: color-mix(in oklab, var(--accent) 28%, var(--surface)); }
.banner.info > .icon { color: var(--accent); }
.banner.ok { background: color-mix(in oklab, var(--ok-mark) 8%, var(--surface)); border-color: color-mix(in oklab, var(--ok-mark) 30%, var(--surface)); }
.banner.ok > .icon { color: var(--ok); }
.banner.warn { background: color-mix(in oklab, var(--wait-mark) 10%, var(--surface)); border-color: color-mix(in oklab, var(--wait-mark) 38%, var(--surface)); }
.banner.warn > .icon { color: var(--wait); }

.toast-demo { display: inline-block; padding: 9px 14px; border-radius: 11px; background: var(--ink); color: var(--bg); font-size: 12.5px; font-weight: 500; box-shadow: var(--shadow-pop); }

.progress { position: relative; height: 6px; border-radius: 3px; background: var(--sunken); overflow: hidden; }
[data-theme="dark"] .progress { background: var(--line); }
.progress span { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--series); }
.progress.indeterminate span { width: 34%; animation: indet 1.4s cubic-bezier(0.6, 0, 0.3, 1) infinite; }
@keyframes indet { from { transform: translateX(-110%); } to { transform: translateX(310%); } }
.progress-label { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); }

.skel-row { display: flex; align-items: center; gap: 10px; }
.skel-lines { flex: 1; display: grid; gap: 6px; }
.skel {
  display: block; height: 10px; border-radius: 5px;
  background: linear-gradient(90deg, var(--sunken) 0%, var(--surface-2) 50%, var(--sunken) 100%);
  background-size: 200% 100%; animation: shimmer 1.6s linear infinite;
}
[data-theme="dark"] .skel { background-image: linear-gradient(90deg, var(--line) 0%, var(--line-strong) 50%, var(--line) 100%); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.empty { display: grid; justify-items: center; gap: 4px; padding: 14px 8px; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--r-md); }
.empty .persona { margin-bottom: 4px; }
.empty strong { font-size: 13.5px; }
.empty span { font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }

/* ---------- Status & identity ---------- */

.badge-n {
  display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 5px;
  font-size: 11px; font-weight: 700; background: var(--sunken); color: var(--ink-2); border: 1px solid var(--line);
}
.badge-n.accent { background: var(--btn); color: #FFFFFF; border-color: transparent; }
.badge-n.crit { background: var(--brique); color: #FFFFFF; border-color: transparent; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.tag {
  display: inline-flex; align-items: center; gap: 4px; height: 23px; padding: 0 4px 0 8px; border-radius: 6px;
  font-size: 11.5px; font-weight: 600; background: var(--sunken); color: var(--ink-2); border: 1px solid var(--line);
}
.tag .x { display: grid; place-items: center; width: 16px; height: 16px; border-radius: 4px; color: var(--ink-3); }
.tag .x:hover { background: var(--line-strong); color: var(--ink); }
.av { display: grid; place-items: center; flex: none; border-radius: 50%; color: #FFFFFF; font-weight: 800; letter-spacing: 0.02em; }
.av.s { width: 22px; height: 22px; font-size: 9px; }
.av.m { width: 29px; height: 29px; font-size: 10.5px; }
.av.l { width: 40px; height: 40px; font-size: 13.5px; }
.av-group { display: flex; }
.av-group .av { box-shadow: 0 0 0 2px var(--surface); }
.av-group .av + .av { margin-left: -7px; }
.av.more { background: var(--sunken); color: var(--ink-2); }
.mark-chip { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 10px 0 7px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); font-size: 12.5px; font-weight: 700; }

/* ---------- Navigation ---------- */

a.tab { display: inline-block; }
.tab[aria-current="page"] { color: var(--ink); }
.tab[aria-current="page"]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.demo-tabs { margin: 0; }
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 12.5px; color: var(--ink-3); }
.crumbs a { color: var(--ink-2); font-weight: 500; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.crumbs [aria-current] { color: var(--ink); font-weight: 600; }
.pager { display: flex; align-items: center; flex-wrap: wrap; gap: 3px; }
.pager button { display: grid; place-items: center; min-width: 29px; height: 29px; padding: 0 8px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.pager button:hover { background: var(--sunken); color: var(--ink); }
.pager button[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.pager button:disabled { opacity: 0.4; cursor: not-allowed; }
.pager .muted { padding: 0 4px; }
.stepper { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
.stepper li { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.stepper li + li::before { content: ""; width: 26px; height: 1.5px; border-radius: 1px; background: var(--line-strong); }
.stepper .n { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: 11px; border: 1.5px solid var(--line-strong); background: var(--surface); }
.stepper .done { color: var(--ink-2); }
.stepper .done .n { background: var(--ok-mark); border-color: var(--ok-mark); color: #FFFFFF; }
.stepper .cur { color: var(--ink); }
.stepper .cur .n { border-color: var(--btn); color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.spec-ink { display: grid; gap: 2px; padding: 8px; border-radius: var(--r-md); background: var(--encre); --rail-ink: #B4BFDB; }
.spec-ink .rail-link { color: var(--rail-ink); }
.spec-ink .rail-link[aria-current="page"] { background: rgba(255, 255, 255, 0.1); color: #FFFFFF; }
.spec-ink .rail-link[aria-current="page"] .icon { color: color-mix(in oklab, var(--p-glow) 75%, #FFFFFF); }

.menu-card, .popover-static { width: min(236px, 100%); padding: 6px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-pop); }
.menu-line { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border-radius: 7px; font-size: 13px; color: var(--ink); text-align: left; }
.menu-line:hover, .menu-line:focus-visible { background: var(--sunken); outline: none; }
.menu-line .icon { color: var(--ink-3); flex: none; }
.menu-line kbd { margin-left: auto; font: 500 10.5px var(--font-ui); color: var(--ink-3); }
.menu-line.danger, .menu-line.danger .icon { color: var(--crit); }
.menu-sep { height: 1px; margin: 5px 2px; background: var(--line); }
.user-head { display: grid; gap: 1px; padding: 6px 8px 9px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.user-head strong { font-size: 13px; }
.user-head span { font-size: 11.5px; color: var(--ink-3); }
button.avatar { border: 0; cursor: pointer; }
button.avatar:hover { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--accent-line); }

/* ---------- Data display ---------- */

.kpi.solo { padding: 0; }
.data-table.compact { min-width: 0; }
.data-table.compact th, .data-table.compact td { padding: 7px 10px; }
.sort { display: inline-flex; align-items: center; gap: 4px; font: inherit; color: inherit; }
.sort:hover { color: var(--ink); }
.tip-demo { position: relative; display: inline-flex; }
.tip {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); z-index: 5;
  padding: 6px 9px; border-radius: 7px; background: var(--ink); color: var(--bg); font-size: 11.5px; font-weight: 500;
  white-space: nowrap; box-shadow: var(--shadow-pop); pointer-events: none;
}
.tip::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -5px; border: 5px solid transparent; border-top-color: var(--ink); }
.tip-demo .tip { opacity: 0; transition: opacity 0.15s; }
.tip-demo:hover .tip, .tip-demo:focus-within .tip { opacity: 1; }
.tip.static { position: relative; bottom: auto; left: auto; transform: none; display: inline-block; margin-bottom: 6px; }
.rows.bare { padding: 0; margin: 0 -16px; }
.machine-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 4px 10px;
  padding: 12px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface-2);
}
.machine-card strong { display: block; font-size: 13.5px; }
.machine-card div > span { font-size: 11.5px; color: var(--ink-3); }
.mc-meters { grid-column: 1 / -1; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 6px 10px; margin-top: 8px; font-size: 11.5px; color: var(--ink-3); }

/* ---------- Overlays ---------- */

#dialogHost { position: fixed; inset: 0; z-index: 90; }
.dialog-backdrop { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(4, 10, 27, 0.5); animation: fade 0.2s; }
.dialog { width: min(420px, 100%); padding: 20px; border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-pop); animation: pop 0.22s var(--ease-out); }
.dialog h2 { display: flex; align-items: center; gap: 9px; font-size: 16px; font-weight: 700; }
.dialog h2 .icon { color: var(--crit); }
.dialog p { margin-top: 8px; color: var(--ink-2); font-size: 13px; line-height: 1.55; }
.dialog .buttons { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
@keyframes fade { from { opacity: 0; } }
.pop-demo { display: flex; }

/* ---------- Gallery ---------- */

.jump { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); gap: 12px; margin-top: 14px; }
.specimen { display: grid; align-content: start; gap: 12px; min-width: 0; padding: 14px 16px 16px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.specimen.wide { grid-column: 1 / -1; }
.specimen > h3 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.specimen > h3 code { font: 500 10.5px var(--font-data); color: var(--ink-3); }
.spec-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.spec-stack { display: grid; gap: 10px; }
.id-section[id^="c-"] { scroll-margin-top: calc(var(--top-h) + 12px); padding-top: 28px; }

/* ---------- Sign-in ---------- */

.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 0; outline: none; }
.auth-brand {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 24px;
  padding: 26px 32px; overflow: hidden; isolation: isolate; color: #FFFFFF; --wm-color: #FFFFFF;
  background: radial-gradient(110% 70% at 50% 105%, #0B2C7A 0%, var(--encre) 60%);
}
.auth-brand::before {
  content: ""; position: absolute; z-index: -1; left: -15%; right: -15%; top: 46%; height: 60%;
  border-radius: 50% 50% 0 0 / 100% 100% 0 0; border-top: 1.5px solid rgba(91, 151, 255, 0.35);
  background: linear-gradient(180deg, rgba(10, 92, 255, 0.16), transparent 60%);
}
.auth-logo { align-self: flex-start; }
.auth-stage { display: grid; justify-items: center; gap: 16px; }
.auth-caption { min-height: 22px; text-align: center; font-size: 15px; font-weight: 600; color: #DCE3F5; }
.auth-foot { font-size: 12.5px; color: #9AA7C7; }
.auth-panel { display: grid; place-items: center; padding: 32px 24px; background: var(--bg); }
.auth-card { width: min(360px, 100%); display: grid; gap: 15px; }
.auth-card h1 { font-size: 23px; font-weight: 700; letter-spacing: -0.02em; }
.auth-card .sub { margin-top: 5px; color: var(--ink-2); font-size: 13.5px; line-height: 1.5; }
.auth-card .btn { width: 100%; height: 36px; }
.auth-card .field { height: 36px; }
.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.auth-row label { font-size: 12.5px; font-weight: 600; }
.auth-card .back { justify-self: start; }
.divider { display: flex; align-items: center; gap: 10px; font-size: 11.5px; color: var(--ink-3); }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-note { text-align: center; font-size: 11.5px; color: var(--ink-3); }
.code-inputs { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.auth-card .code-inputs .field { height: 46px; padding: 0; text-align: center; font: 500 18px var(--font-data); }

@media (max-width: 960px) {
  .gallery { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-brand { padding: 18px 20px; gap: 14px; }
  .auth-brand .persona { width: auto; height: 132px; }
  .auth-foot { display: none; }
  .auth-panel { place-items: start center; padding: 24px 18px 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .progress.indeterminate span { animation: none; width: 100%; opacity: 0.35; }
  .skel { animation: none; }
}

/* ---------- Collapsible rail ---------- */

/* Only the column width animates. Nothing inside the rail changes position or display:
   icons stay put, labels fade and are clipped by the rail, tooltips live outside it. */
.shell { transition: grid-template-columns 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.rail { display: block; padding: 0; }
.rail-inner { display: flex; flex-direction: column; gap: 5px; height: 100%; padding: 10px 10px 12px; overflow: hidden; }
.rail-link { position: relative; padding-left: 12.5px; overflow: hidden; }
.app-switch { padding-left: 6.5px; overflow: hidden; }
.rail-link .lbl, .app-title { white-space: nowrap; }
.rail-link > .icon, .rail-link .lbl, .rail-link .count, .app-switch > .symbol, .app-switch .app-title, .app-switch .updown { flex-shrink: 0; }
.demo-note { min-width: 180px; }
.rail-link .lbl, .rail-link .count, .app-switch .app-title, .app-switch .updown, .demo-note { transition: opacity 0.24s ease 0.1s; }
.rail-link::after {
  content: ""; position: absolute; top: 5px; left: 26px; width: 7px; height: 7px; border-radius: 50%;
  background: color-mix(in oklab, var(--p-accent-dk) 70%, #FFFFFF); box-shadow: 0 0 0 2px var(--rail-bg);
  opacity: 0; transition: opacity 0.2s; pointer-events: none;
}
.rail-anim .topbar { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg); }

.rail-edge {
  position: absolute; z-index: 3; top: 21px; right: -12px; display: grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--line-strong);
  box-shadow: 0 2px 6px -2px rgba(6, 22, 65, 0.3);
  transition: color 0.15s, border-color 0.15s, transform 0.2s var(--ease-out);
}
.rail-edge:hover { color: var(--accent); border-color: var(--accent-line); transform: scale(1.1); }
.rail-edge:focus-visible { outline-offset: 3px; border-radius: 50%; }
.rail-edge .icon { transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); }

#railTip {
  position: fixed; z-index: 70; padding: 5px 9px; border-radius: 7px; pointer-events: none; white-space: nowrap;
  background: var(--surface); color: var(--ink); font-size: 12.5px; font-weight: 600; box-shadow: var(--shadow-pop);
  opacity: 0; transform: translate(-4px, -50%); transition: opacity 0.15s, transform 0.2s var(--ease-out);
}
#railTip.show { opacity: 1; transform: translate(0, -50%); }

@media (min-width: 861px) {
  .shell.rail-collapsed { --rail-w: 62px; }
  .rail-collapsed .rail-link .lbl, .rail-collapsed .rail-link .count, .rail-collapsed .app-switch .app-title,
  .rail-collapsed .app-switch .updown, .rail-collapsed .demo-note { opacity: 0; transition: opacity 0.12s ease; }
  .rail-collapsed .rail-link:has(.count)::after { opacity: 1; }
  .rail-collapsed .rail-edge .icon { transform: rotate(180deg); }
}
@media (max-width: 860px) {
  .rail-edge, #railTip { display: none; }
}

@media (max-width: 860px) {
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: none; white-space: nowrap; }
}

/* ---------- Full-height pages ---------- */

main { display: flex; flex-direction: column; }
.page { flex: 1 0 auto; display: flex; flex-direction: column; min-width: 0; }
.page > .fill { flex: 1 1 auto; }
.home-cols.fill, .detail-grid.fill { align-items: stretch; }
.detail-grid.fill > .stack { display: flex; flex-direction: column; }
.detail-grid.fill > .stack > :last-child { flex: 1 1 auto; }
.table-panel.fill { display: flex; flex-direction: column; }
.table-panel.fill > .table-wrap { flex: 1 1 auto; }
.no-results.fill.center { display: grid; place-content: center; }
main.fit { padding-bottom: 16px; }
.fit .convo-layout { flex: 0 0 auto; height: calc(100dvh - var(--top-h) - 40px); min-height: 420px; align-items: stretch; }
.fit .convo-list { position: static; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.fit .convo-list .rows { flex: 1 1 auto; overflow: auto; }
.fit .thread { display: flex; flex-direction: column; min-height: 0; }
.fit .messages { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-right: 8px; align-content: start; }
.fit .composer-wrap { position: static; padding-top: 6px; }

/* ---------- Account, status and menus ---------- */

.me-avatar {
  position: relative; display: grid; place-items: center; flex: none; border-radius: 50%;
  color: #FFFFFF; font-weight: 800; letter-spacing: 0.02em; background: linear-gradient(135deg, var(--p-deep), var(--p-mid));
}
.me-avatar.md { width: 38px; height: 38px; font-size: 13px; }
.me-avatar.lg { width: 56px; height: 56px; font-size: 18px; }
.me-avatar.xl { width: 68px; height: 68px; font-size: 22px; box-shadow: 0 0 0 3px var(--bg), 0 0 0 4px var(--line-strong); }
.status-dot { position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; background: var(--ok-mark); box-shadow: 0 0 0 2px var(--bg); }
.status-dot.busy { background: var(--wait-mark); }
.status-dot.away { background: var(--ardoise-400); }
.me-avatar.xl .status-dot { width: 16px; height: 16px; right: 1px; bottom: 1px; box-shadow: 0 0 0 3px var(--bg); }
.user-card .status-dot { box-shadow: 0 0 0 2px var(--surface); }
.avatar { position: relative; }
.avatar .status-dot { width: 9px; height: 9px; right: -2px; bottom: -2px; }
.menu-line .status-dot, .status-btn .status-dot { position: static; flex: none; box-shadow: none; width: 9px; height: 9px; }

.popover.menu-pop { padding: 6px; min-width: 200px; max-width: calc(100vw - 16px); }
.user-menu { width: 288px; }
.user-card { display: flex; align-items: center; gap: 11px; padding: 6px 8px 11px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.user-card > div > strong { display: block; font-size: 13.5px; }
.user-card > div > span { display: block; font-size: 11.5px; color: var(--ink-3); }
.menu-aside { margin-left: auto; display: inline-flex; align-items: center; gap: 2px; font-size: 11.5px; color: var(--ink-3); }
.menu-theme { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px 6px; font-size: 13px; }
.menu-theme .segmented button { height: 24px; padding: 0 8px; font-size: 11.5px; }
a.menu-line { text-decoration: none; }
.lb-search { margin-bottom: 6px; }
.lb-search .field { width: 100%; height: 30px; padding-left: 30px; }
.lb-list { display: grid; gap: 1px; max-height: 280px; overflow: auto; }
.lb-opt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border-radius: 7px; font-size: 13px; text-align: left; }
.lb-opt:hover, .lb-opt:focus-visible { background: var(--sunken); outline: none; }
.lb-opt[aria-selected="true"] { font-weight: 600; }
.lb-opt .muted { margin-left: auto; font-size: 11.5px; font-weight: 500; }
.lb-opt > .icon { color: var(--accent); flex: none; }
.lb-opt > span:first-child + .icon { margin-left: auto; }
.lb-empty { padding: 8px; font-size: 12.5px; }
.kebab { width: 30px; height: 30px; }

.account-head { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; margin-bottom: 18px; }
.account-id { flex: 1; min-width: 220px; }
.account-id h1 { font-size: 23.5px; font-weight: 700; letter-spacing: -0.015em; }
.account-id p { margin-top: 3px; color: var(--ink-2); font-size: 13px; }
.status-btn { gap: 8px; }
.account-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.account-nav {
  position: sticky; top: calc(var(--top-h) + 16px); display: grid; gap: 2px; padding: 6px;
  border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1);
}
.account-nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); font-size: 13px; font-weight: 500; color: var(--ink-2); }
.account-nav a:hover { background: var(--sunken); color: var(--ink); }
.account-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.account-nav a.danger { margin-top: 4px; color: var(--crit); }
.account-body { display: grid; gap: 16px; align-content: start; min-width: 0; }
.settings { position: relative; }
.settings .settings-body { padding: 0 17px 6px; }
.srow { display: grid; grid-template-columns: minmax(180px, 300px) minmax(0, 1fr); gap: 8px 28px; align-items: start; padding: 14px 0; border-top: 1px solid var(--line); }
.settings-body > .srow:first-child { border-top: 0; }
.srow-label label, .srow-label .flabel { font-size: 13px; font-weight: 600; }
.srow-label p { margin-top: 3px; max-width: 42ch; font-size: 12px; line-height: 1.45; color: var(--ink-3); }
.srow-control { display: grid; gap: 6px; min-width: 0; max-width: 560px; }
.srow-control > .field, .srow-control > .select-wrap, .srow-control > .select-wrap select, .srow-control .fgroup .field { width: 100%; }
.srow-control > .btn, .srow-control > .segmented, .srow-control > .switch { justify-self: start; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field.dd { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; text-align: left; cursor: pointer; }
.field.dd .icon { flex: none; color: var(--ink-3); }
.field.dd[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.save-bar {
  position: sticky; bottom: 12px; z-index: 5; display: flex; align-items: center; gap: 8px; margin: 6px 12px 12px; padding: 7px 7px 7px 14px;
  border-radius: var(--r-md); background: var(--ink); color: var(--bg); box-shadow: var(--shadow-pop); font-size: 13px;
}
.save-bar > span { display: flex; align-items: center; gap: 8px; margin-right: auto; }
.save-bar .btn.ghost { color: var(--bg); }
.save-bar .btn.ghost:hover { background: color-mix(in oklab, var(--bg) 14%, transparent); }
.session-list { list-style: none; margin: 0; padding: 0 17px 6px; }
.session-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); font-size: 13px; }
.session-list li:first-child { border-top: 0; }
.session-list .muted { font-size: 12px; }
.theme-cards { display: flex; flex-wrap: wrap; gap: 10px; }
.theme-card { display: grid; gap: 7px; width: 150px; padding: 6px 6px 8px; border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--surface); font-size: 12.5px; font-weight: 600; text-align: left; }
.theme-card > span:last-child { display: flex; align-items: center; gap: 6px; padding: 0 4px; }
.theme-card:hover { border-color: var(--ink-3); }
.theme-card[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.theme-art { display: grid; grid-template-columns: 24px 1fr; grid-template-rows: 1fr 1fr; gap: 5px; height: 62px; padding: 6px; border-radius: 7px; background: #F3F6FB; overflow: hidden; }
.theme-art i { grid-row: span 2; border-radius: 4px; background: #061641; }
.theme-art b { border-radius: 4px; background: #FFFFFF; box-shadow: inset 0 0 0 1px #E2E7F0; }
.theme-card.dark .theme-art { background: #070D1F; }
.theme-card.dark .theme-art b, .theme-card.system .theme-art b:last-child { background: #0D152D; box-shadow: inset 0 0 0 1px #1C2643; }
.theme-card.system .theme-art { background: linear-gradient(180deg, #F3F6FB 50%, #070D1F 50%); }
.notify-table td { vertical-align: middle; }
.notify-table th:not(:first-child), .notify-table td:not(:first-child) { width: 96px; text-align: center; }
.notify-table td .switch { justify-content: center; }
.strength { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 6px; }
.strength i { height: 4px; border-radius: 2px; background: var(--sunken); transition: background 0.2s; }
[data-theme="dark"] .strength i { background: var(--line); }
.strength i[data-on="1"], .strength i[data-on="2"] { background: var(--wait-mark); }
.strength i[data-on="3"], .strength i[data-on="4"] { background: var(--ok-mark); }
.dlg-form { display: grid; gap: 12px; margin-top: 12px; }
.dialog p + .dlg-form, .dialog .dlg-form .field { width: 100%; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 18px; margin: 12px 0 0; padding: 12px 14px 12px 34px; border-radius: var(--r-md); background: var(--sunken); font-size: 13px; }
.token-box { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 10px 10px 10px 12px; border-radius: var(--r-md); background: var(--sunken); border: 1px solid var(--line); }
.token-box code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 12px; }
.shortcuts { display: grid; margin: 10px 0 0; }
.shortcuts div { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: center; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; }
.shortcuts div:first-child { border-top: 0; }
.shortcuts dt { margin: 0; }
.shortcuts dd { margin: 0; color: var(--ink-2); }
.shortcuts kbd { display: inline-block; min-width: 22px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; background: var(--surface); font: 600 11.5px var(--font-ui); text-align: center; color: var(--ink); }

html[data-density="compact"] .row { padding-top: 6px; padding-bottom: 6px; }
html[data-density="compact"] .data-table td, html[data-density="compact"] .dt-table td { padding-top: 6px; padding-bottom: 6px; }
html[data-density="compact"] .srow { padding: 10px 0; }
html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }

@media (max-width: 960px) {
  .account-layout { grid-template-columns: minmax(0, 1fr); }
  .account-nav { position: static; display: flex; overflow-x: auto; scrollbar-width: none; }
  .account-nav a { flex: none; white-space: nowrap; }
  .account-nav a.danger { margin-top: 0; }
}
@media (max-width: 720px) {
  .srow { grid-template-columns: minmax(0, 1fr); }
  .session-list li { grid-template-columns: auto minmax(0, 1fr) auto; }
  .session-list li > .muted.num { grid-column: 2; grid-row: 2; }
  .two { grid-template-columns: minmax(0, 1fr); }
  .fit .convo-layout { height: calc(100dvh - var(--top-h) - 36px); }
}
.kebab .icon { stroke-width: 3.2; }
