/* Kyana v2 additions on top of the brand bundle and the mock-up classes (kyana.css). */

.ky-inline-form { display: inline-flex; margin: 0; }
.ky-inline-form button:not(.te-btn) { font: inherit; }

/* Settings sits at the foot of the sidebar, above the person signed in. */
.te-sidebar__rule.ky-nav-end { margin-top: auto; }
/* From 900px the sidebar holds to the window, so Settings and the person signed in stay in view; its list
   scrolls on its own if the window is short. */
@media (min-width: 900px) {
  .ky-side { position: sticky; top: 0; align-self: flex-start; height: 100vh; }
}

/* The collapsed sidebar, from 900px: a rail of icons under the brand mark, as in Global App. The page names
   stay for screen readers and show on hover. Below 900px the sidebar is the slide-out menu, with its words. */
.ky-mark { display: none; }
.ky-mark svg { width: 13px; height: 19px; }
@media (min-width: 900px) {
  .ky-shell.is-collapsed .ky-side { flex: 0 0 var(--sidebar-width-collapsed); }
  .te-sidebar--collapsed .te-sidebar__logo,
  .te-sidebar--collapsed .te-sidebar__product,
  .te-sidebar--collapsed .te-sidebar__who,
  .te-sidebar--collapsed .te-sidebar__user form { display: none; }
  .te-sidebar--collapsed .te-sidebar__brand { padding: var(--space-4) 0 var(--space-3); }
  .te-sidebar--collapsed .ky-mark { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: var(--radius-lg); background: var(--brand); color: #fff; }
  .te-sidebar--collapsed .te-nav-item { width: 40px; height: 40px; margin: 0 auto; padding: 0; justify-content: center; }
  .te-sidebar--collapsed .te-nav-item[aria-current="page"] { background: var(--sidebar-accent); color: var(--sidebar-primary); }
  .te-sidebar--collapsed .ky-nav-label { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
  .te-sidebar--collapsed .te-sidebar__rule { margin-left: var(--space-1); margin-right: var(--space-1); }
  .te-sidebar--collapsed .te-sidebar__user { justify-content: center; padding-left: 0; }
}

.ky-bell { position: relative; }
.ky-bell__dot { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: var(--radius-full); background: var(--warning-strong); box-shadow: 0 0 0 2px var(--background); }

/* Forms */
.ky-form { display: flex; flex-direction: column; gap: var(--space-4); }
.ky-form .te-field { display: flex; flex-direction: column; gap: 6px; }
.ky-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.ky-row--end { justify-content: flex-end; }
.ky-textarea { min-height: 120px; resize: vertical; font-family: var(--font-sans); }
.ky-textarea--code { min-height: 220px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 18px; }
.ky-num-input { max-width: 120px; }

/* A pasted email is shown sealed: no script runs and no outside content loads. */
.ky-sealed { width: 100%; min-height: 220px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: #fff; }

/* Empty states and small notes */
.ky-empty { padding: var(--space-6); border: 1px dashed var(--border); border-radius: var(--radius-lg); color: var(--muted-foreground); text-align: center; }
.ky-pre { margin: 0; padding: var(--space-3); overflow: auto; border-radius: var(--radius-md); background: var(--muted); font: 12px/18px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.ky-note-box { display: flex; flex-direction: column; gap: 6px; padding: var(--space-3) var(--space-4); border: 1px solid var(--warning-border); border-radius: var(--radius-lg); background: var(--warning-bg); }
.ky-note-box .ky-label { color: var(--warning-text); }
.ky-dashed { padding: 1px 2px; border-bottom: 2px dashed var(--warning-strong); }

/* A form button that reads as a link */
.ky-linkbtn { padding: 0; border: 0; background: none; color: var(--primary); font: inherit; font-weight: 500; cursor: pointer; text-underline-offset: 4px; }
.ky-linkbtn:hover { text-decoration: underline; }

/* Choices that are submit buttons */
button.ky-choice[aria-pressed="true"] { border-color: var(--primary); }
.ky-choices { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* Segmented choices pressed by app.js (data-choice-group) */
.te-tab[aria-pressed="true"] { background: var(--background); color: var(--foreground); box-shadow: var(--shadow-xs); }

/* Replies: a filter under each heading, long text cut to two lines, and rows that open the reply. */
.ky-replies-search { flex: 1 1 380px; flex-wrap: nowrap; }
.ky-replies-search .te-search { flex: 1 1 auto; max-width: 520px; }
.ky-replies .te-th { gap: 2px; }
/* A column's filter: a popover under its button (app.js and replies.js place it); centred without the script. */
.ky-fpop { position: fixed; inset: 0; height: fit-content; margin: auto; overflow: visible; font-weight: 400; white-space: normal; }
.ky-fpop:not(:popover-open) { display: none; }
.ky-fpop.is-placed { inset: auto; margin: 0; }
.ky-fpop .te-input { height: var(--control-height-sm); font-size: 13px; }
.ky-frange { display: flex; flex-direction: column; gap: var(--space-2); }
.ky-fbound { display: flex; flex-direction: column; gap: 4px; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--muted-foreground); }
.ky-clip { min-width: 220px; max-width: 420px; }
.ky-clip__text { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ky-click { cursor: pointer; }
.ky-why { min-width: 220px; color: var(--warning-text); font-size: 13px; line-height: 18px; }
p.ky-why .ky-label { display: block; color: var(--muted-foreground); }
.te-record.ky-click:hover { border-color: var(--ring); }

/* Choose columns: a menu under its button, closed by default. */
.ky-pop > summary { list-style: none; }
.ky-pop > summary::-webkit-details-marker { display: none; }
.ky-pop > summary .te-icon { width: 14px; height: 14px; margin-right: 6px; }
.ky-colpick { width: min(340px, calc(100vw - 32px)); padding: var(--space-3); gap: var(--space-3); }
.ky-colpick__list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--space-3); max-height: min(420px, 60vh); overflow-y: auto; }
.ky-colpick__item { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; line-height: 18px; cursor: pointer; }
.ky-colpick__item input { flex: none; width: 15px; height: 15px; margin: 0; accent-color: var(--primary); }

/* A button that has started slow work: it says so, spins, and cannot be pressed again. */
.te-btn.is-busy { opacity: .8; cursor: progress; }
.te-btn.is-busy::before { content: ""; flex: none; width: 14px; height: 14px; margin-right: 8px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: ky-spin .8s linear infinite; }
@keyframes ky-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .te-btn.is-busy::before { animation: none; border-right-color: currentColor; opacity: .6; } }

/* A switch that is a real checkbox, so it posts with its form. */
.ky-switch-row { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.ky-switch-row.is-off { cursor: default; }
.ky-switch-row.is-off .te-switch { opacity: .5; cursor: default; }
.ky-switch-row input:checked + .te-switch { background: var(--primary); }
.ky-switch-row input:checked + .te-switch::after { transform: translateX(16px); }
.ky-switch-row input:focus-visible + .te-switch { box-shadow: var(--focus-ring); }
.ky-switch-row .te-switch { pointer-events: none; }

/* Replay on a run page: a menu of switches under its button (app.js closes it on a click outside). */
.ky-replay > summary { list-style: none; }
.ky-replay > summary::-webkit-details-marker { display: none; }
.ky-replay > summary .te-icon { width: 14px; height: 14px; margin-left: 6px; }
.ky-replay[open] > summary .te-icon { transform: rotate(180deg); }
.ky-replay__menu { width: min(400px, calc(100vw - 32px)); padding: var(--space-4); gap: var(--space-4); font-weight: 400; white-space: normal; text-align: left; }
.ky-replay__head, .ky-replay__opt { display: flex; flex-direction: column; gap: 4px; }
.ky-replay__opt .te-helper { padding-left: 44px; }
.ky-replay__label { font-size: 14px; font-weight: 500; }
.ky-replay [hidden] { display: none !important; }
.ky-replay__changes { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 0 44px; padding: 0; border: 0; min-width: 0; }
.ky-replay:has([data-replay-proposed]:not(:checked)) .ky-replay__changes { display: none; }
/* The search and the two buttons stay in view; only the list scrolls. */
.ky-replay__tools { display: flex; flex-direction: column; gap: 8px; }
.ky-replay__search { flex: none; max-width: none; }
.ky-replay__search .te-input { height: var(--control-height-sm); font-size: 13px; }
.ky-replay__bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ky-replay__bulk .te-btn { min-height: 28px; padding: 0 10px; font-size: 12px; }
.ky-replay__list { display: flex; flex-direction: column; gap: 8px; max-height: 200px; overflow-y: auto; }
.ky-replay__change { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 18px; cursor: pointer; }
.ky-replay__change input { flex: none; width: 15px; height: 15px; margin: 2px 0 0; accent-color: var(--primary); }
.ky-replay__change > span { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
/* Below 900px the menu is a sheet along the bottom of the screen, so it never runs off either side. */
@media (max-width: 899px) {
  .ky-replay__menu { position: fixed; top: auto; right: 0; bottom: 0; left: 0; z-index: 50; width: auto; max-height: min(85vh, 720px); overflow-y: auto;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0; padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px)); box-shadow: var(--shadow-lg); }
  .ky-replay__list { max-height: 40vh; }
}
.ky-replay__setup { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; }
.ky-replay__setup > li { display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 0 12px; align-items: baseline; }
/* Ticking replies on Replies to run a test on them. */
.ky-selbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 6px 8px 6px 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--muted); }
.ky-selbar__lead { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; font-size: 14px; }
.ky-selbar__lead strong { font-weight: 600; }
.ky-selbar summary[aria-disabled="true"] { opacity: .5; cursor: default; }
.ky-selcell { width: 40px; padding-left: 16px !important; padding-right: 0 !important; }
.ky-selhit { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; margin: -6px; cursor: pointer; }
.ky-selhit input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); cursor: pointer; }
.te-record__head .ky-selhit { margin: 0 -6px 0 0; }
tr.is-picked > td { background: var(--accent); }
.te-record.is-picked { border-color: var(--accent-foreground); background: var(--accent); }
.ky-actmenu { min-width: 300px; max-width: 340px; }
.ky-actmenu .te-menu__item { align-items: flex-start; }
.ky-actmenu .te-menu__item .te-icon { flex: none; margin-top: 2px; }
.ky-item-text { display: flex; flex-direction: column; gap: 2px; }
.ky-item-text small { font-size: 12px; line-height: 16px; color: var(--muted-foreground); }

/* The Replies list's article filter: a longer menu of ticks, each with how many replies read it. */
.ky-artpick { width: min(360px, calc(100vw - 16px)); }
.ky-artpick__list { display: flex; flex-direction: column; max-height: 320px; overflow-y: auto; }
.ky-artpick__item { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; line-height: 18px; cursor: pointer; }
.ky-artpick__item[hidden] { display: none; }
.ky-artpick__item input { flex: none; width: 15px; height: 15px; margin: 0; accent-color: var(--primary); }
.ky-artpick__item .ky-meta { font-variant-numeric: tabular-nums; }
.te-btn.is-active { border-color: var(--primary); color: var(--primary); }
