/* ==========================================================================
   Layout — the app shell: frame, top bar, sidebar and rail variants, the
   workspace and its context pane, the bars above the main column.
   ========================================================================== */
/* ========== Frame ========== */
.kw-global-indicator { position: fixed; top: 0; left: 0; right: 0; z-index: 9999; height: 3px; background: var(--orange); }
.kw-frame {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: var(--text-body-md);
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  --kw-density-row: 44px;
  --kw-density-pad: var(--space-md);
  --kw-density-gap: var(--space-sm);
}
.kw-frame.compact {
  --kw-density-row: 36px;
  --kw-density-pad: var(--space-sm);
  --kw-density-gap: var(--space-xs);
}

/* ========== Top bar ========== */
.kw-topbar {
  height: 56px;
  flex: 0 0 56px;
  display: flex;
  align-items: center;
  padding: 0 var(--space-lg);
  background: var(--bg);
  border-bottom: 1px solid var(--divider);
  gap: var(--space-lg);
}
.kw-topbar .kw-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 600;
  font-size: var(--text-title-md);
  letter-spacing: -0.005em;
  margin-right: var(--space-xs);
  text-decoration: none;
  color: var(--fg);
}
.kw-topbar .kw-brand svg { display: block; }

/* Top tabs row */
.kw-tabs {
  display: flex;
  align-items: stretch;
  gap: 0;
  height: 100%;
}
.kw-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0 var(--space-md);
  background: transparent;
  border: none;
  cursor: pointer;
  font: inherit;
  font-size: var(--text-label-lg);
  font-weight: 500;
  color: var(--fg-muted);
  position: relative;
  font-family: inherit;
  text-decoration: none;
}
.kw-tab .material-symbols-rounded { font-size: 20px; }
.kw-tab.active { color: var(--fg); }
.kw-tab.active::after {
  content: '';
  position: absolute;
  left: 12px; right: 12px; bottom: -1px;
  height: 2px;
  background: var(--orange);
  border-radius: 1px;
}
.kw-tab:hover:not(.active) { color: var(--fg); }

/* Right-side cluster */
.kw-topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}
.kw-search {
  position: relative;
  width: 280px;
}
/* The top bar is ~1300px of content at full size. With nowrap buttons nothing
   can absorb the shortfall by wrapping any more (#980), so the search yields
   first and collapses to an icon below 1280px, where the tabs also tighten.
   The one breakpoint that is not a design-system window class: it tracks the
   top bar's own content width, which no size class describes. */
.kw-topbar .kw-search { width: auto; flex: 0 1 280px; min-width: 180px; }
@media (max-width: 1279px) {
  .kw-topbar .kw-search { flex-basis: 36px; min-width: 36px; }
  .kw-topbar .kw-search-text { padding: 0; font-size: 0; }
  .kw-topbar .kw-search .kw-kbd { display: none; }
  .kw-topbar .kw-tab { padding: 0 var(--space-sm); }
  .kw-topbar { gap: var(--space-sm); }
}
/* The same trigger renders in the sidebar, whose column is --nav-drawer-width
   less its padding: a fixed 280px overflowed it, and at the width that does fit
   the ⌘K badge sits on top of the placeholder. There the text field is dropped
   and the trigger becomes one more labelled row, matching the .kw-side-item
   links above it (issue #777). */
.kw-search-label { display: none; }
.kw-sidebar .kw-search {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: auto;
  height: 36px;
  padding: 0 var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: var(--text-label-lg);
  font-weight: 500;
  color: var(--fg-muted);
}
.kw-sidebar .kw-search:hover { background: var(--bg-subtle); color: var(--fg); }
/* The inner box carries the focus ring in the top bar, but it is hidden here, so
   the row itself has to show one — the trigger is keyboard-reachable in both. */
.kw-sidebar .kw-search:focus-visible {
  outline: 2px solid var(--border-strong);
  outline-offset: -2px;
}
.kw-sidebar .kw-search-text { display: none; }
.kw-sidebar .kw-search-label { display: inline; }
.kw-sidebar .kw-search .material-symbols-rounded {
  position: static;
  transform: none;
  font-size: 20px;
}
.kw-sidebar .kw-search .kw-kbd { position: static; transform: none; margin-left: auto; }
/* Styled to match the text input it replaced — the wrapper is the button, so a
   real input inside it was a nested interactive control. display:flex because a
   span has no line box to centre the text in the way the input did. */
.kw-search-text {
  display: flex;
  align-items: center;
  width: 100%;
  height: 36px;
  padding: 0 var(--space-2xl) 0 var(--space-xl);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  font-size: var(--text-body-md);
  color: var(--fg-subtle);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.kw-search:focus-visible { outline: none; }
.kw-search:focus-visible .kw-search-text {
  border-color: var(--border-strong);
  background: var(--bg);
}
.kw-search .material-symbols-rounded {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: var(--fg-subtle);
  pointer-events: none;
}
.kw-search .kw-kbd {
  position: absolute;
  right: 8px; top: 50%;
  transform: translateY(-50%);
  font-size: var(--text-eyebrow);
  font-family: var(--font-mono);
  color: var(--fg-subtle);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 1px var(--space-xxs);
  letter-spacing: 0.04em;
}
.kw-iconbtn {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: inherit;
}
.kw-iconbtn:hover { background: var(--bg-subtle); }
.kw-iconbtn .material-symbols-rounded { font-size: 20px; }
.kw-sidebar {
  border-right: 1px solid var(--divider);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding: var(--space-md) var(--space-sm);
  gap: var(--space-xs);
}
.kw-sidebar .kw-brand {
  padding: var(--space-xxs) var(--space-xs) var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 600;
  font-size: var(--text-title-md);
}
.kw-side-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--fg-muted);
  font: inherit;
  font-size: var(--text-label-lg);
  font-weight: 500;
  font-family: inherit;
  text-align: left;
  position: relative;
  text-decoration: none;
}
.kw-side-item:hover { background: var(--bg-subtle); color: var(--fg); }
.kw-side-item.active { background: var(--lavender-surface); color: var(--fg); }
.kw-side-item.active::before {
  content: '';
  position: absolute;
  left: -12px; top: 8px; bottom: 8px;
  width: 3px;
  background: var(--orange);
  border-radius: var(--radius-xs);
}
.kw-side-item .material-symbols-rounded { font-size: 20px; flex: 0 0 auto; }
.kw-side-foot { display: flex; flex-direction: column; gap: var(--space-xs); margin-top: auto; padding: 0 var(--space-xxs); }
.kw-rail-foot { display: flex; flex-direction: column; align-items: center; gap: var(--space-xxs); margin-top: auto; }
.kw-side-mini-timer-mode { font-size: var(--text-label-sm); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-muted); }
.kw-side-mini-timer-time { font-size: 1.4rem; font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; line-height: 1; }
.kw-side-mini-timer {
  margin-top: auto;
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  background: var(--lavender-surface);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}
.kw-rail {
  border-right: 1px solid var(--divider);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-md) 0;
  gap: var(--space-xxs);
}
.kw-rail-brand {
  width: 36px; height: 36px;
  margin-bottom: var(--space-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.kw-rail-item {
  position: relative;
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  text-decoration: none;
}
.kw-rail-item:hover { background: var(--bg-subtle); color: var(--fg); }
.kw-rail-item.active { background: var(--lavender-surface); color: var(--fg); }
.kw-rail-item.active .material-symbols-rounded { font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24; color: var(--orange); }
.kw-rail-item .material-symbols-rounded { font-size: 22px; }

/* ========== Workspace ========== */
.kw-workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr var(--context-pane-width);
  min-height: 0;
  overflow: hidden;
}
.kw-workspace.kw-workspace-full { grid-template-columns: 1fr; }
.kw-workspace.kw-workspace-full {
  display: flex;
  flex-direction: column;
}
.kw-main {
  overflow: auto;
  padding: var(--space-lg) var(--space-xl);
  background: var(--bg);
  flex: 1;
  min-height: 0;
}
.kw-frame.compact .kw-main { padding: var(--space-md) var(--space-lg); }
/* ========== Global timer bar (above main content) ========== */
.kw-global-timer-bar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-xl);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-body-md);
  flex-shrink: 0;
}

/* ========== Demo Account banner (above the timer bar) ========== */
.kw-demo-banner {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-xl);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-body-md);
  flex-shrink: 0;
}
.kw-demo-banner form { margin-left: auto; }

/* ========== Timer panel (right ctx column) ========== */
.kw-timer-panel {
  align-items: center;
  text-align: center;
  padding: var(--space-xl) var(--space-lg);
  gap: var(--space-lg);
}
.kw-timer-panel-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--text-label-sm);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: var(--space-xxs) var(--space-sm);
  border-radius: var(--radius-lg);
  background: var(--bg-tinted);
  color: var(--fg-muted);
}
.kw-timer-panel-badge.running {
  background: var(--orange-wash);
  color: var(--orange-text);
}
.kw-timer-panel-badge.paused {
  background: var(--lavender-100);
  color: var(--fg);
}
.kw-timer-panel-badge.break {
  background: color-mix(in srgb, var(--success) 12%, transparent);
  color: var(--success-text);
}
/* ========== Timer status bar (tasks page) ========== */
.kw-timer-bar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  margin-bottom: var(--space-md);
  font-size: var(--text-body-md);
  flex-wrap: wrap;
}
.kw-timer-bar-mode {
  font-weight: 600;
  color: var(--fg-muted);
  font-size: var(--text-label-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.kw-timer-bar-time {
  font-family: var(--font-display);
  font-size: var(--text-title-row);
  color: var(--fg);
  flex-shrink: 0;
  line-height: 1;
}
.kw-timer-bar-task {
  color: var(--fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.kw-timer-bar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-shrink: 0;
}

/* ========== Page header ========== */
.kw-page {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}
.kw-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}
.kw-page-title {
  font-size: var(--text-h3);
  font-weight: 600;
  letter-spacing: -0.005em;
}
.kw-page-sub {
  font-size: var(--text-body-md);
  color: var(--fg-muted);
  margin-top: var(--space-xxxs);
}
.kw-eyebrow {
  font-size: var(--text-eyebrow);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--orange-text);
}

/* ========== Alpine ========== */
[x-cloak] { display: none !important; }

/* ========== Layout shell variants ========== */
.kw-frame.layout-sidebar {
  display: grid;
  grid-template-columns: var(--nav-drawer-width) 1fr;
  grid-template-rows: 1fr;
}
.kw-frame.layout-rail {
  display: grid;
  grid-template-columns: var(--nav-rail-width) 1fr;
  grid-template-rows: 1fr;
}

/* ========== Layout picker ========== */
.kw-layout-picker {
  position: absolute;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  min-width: 220px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}
.kw-layout-picker-label {
  font-size: var(--text-eyebrow);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
  padding: var(--space-xxs) var(--space-xxxs) var(--space-xxxs);
}
.kw-layout-picker-options {
  display: flex;
  gap: var(--space-xxs);
}
.kw-layout-picker-options + .kw-layout-picker-label { margin-top: var(--space-xxs); }
.kw-layout-picker-anchor { position: relative; }
.kw-layout-picker-opt {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xxs);
  padding: var(--space-xs) var(--space-xxs);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  font-size: var(--text-label-sm);
  font-weight: 500;
  color: var(--fg-muted);
  font-family: inherit;
  line-height: 1;
}
.kw-layout-picker-opt.active {
  background: var(--lavender-surface);
  border-color: var(--lavender-100);
  color: var(--fg);
}
.kw-layout-picker-opt .material-symbols-rounded { font-size: 18px; }
