/* App shell: boot, auth, sidebar, header, banners */
.boot { min-height: 100vh; display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--text-2); }
.logo-mark {
  position: relative; display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none;
  border-radius: 9px; background: var(--navy); color: #fff; font-family: var(--font-head); font-weight: 700; font-size: 16px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.logo-mark::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 9px; height: 9px; border-radius: 50%; background: #14B8A6; box-shadow: 0 0 0 2px var(--surface); }
.side .logo-mark::after { box-shadow: 0 0 0 2px var(--side-bg); }

/* ---------------- auth ---------------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-aside {
  position: relative; overflow: hidden; background: var(--navy); color: #E6EDF6; padding: 48px 56px; display: flex; flex-direction: column; gap: 9vh;
}
.auth-copy { position: relative; z-index: 1; }
.auth-aside .brand { display: flex; align-items: center; gap: 12px; font-family: var(--font-head); font-size: 20px; font-weight: 600; }
.auth-aside .logo-mark { background: #fff; color: var(--navy); }
.auth-aside .logo-mark::after { box-shadow: 0 0 0 2px var(--navy); }
.auth-aside h1 { font-size: clamp(28px, 3.2vw, 40px); font-weight: 600; line-height: 1.12; letter-spacing: -.02em; max-width: 15ch; margin: 0 0 18px; color: #fff; }
.auth-aside p.lede { max-width: 44ch; color: #B9C8DB; font-size: 16px; }
.auth-trace { position: absolute; inset: auto 0 0 0; height: 30%; opacity: .8; pointer-events: none; }
.auth-trace path { fill: none; stroke-width: 1.6; }
.auth-facts { position: relative; display: grid; gap: 10px; font-size: 14px; color: #C9D6E6; max-width: 46ch; margin-top: 28px; }
.auth-facts div { display: flex; gap: 10px; align-items: flex-start; }
.auth-facts .icon { color: #5EEAD4; margin-top: 2px; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h2 { font-size: var(--fs-2xl); margin-bottom: 6px; }
.auth-card .sub { color: var(--text-2); margin-bottom: var(--s6); }
.auth-card form { margin-top: var(--s5); }
.auth-card .alt { margin-top: var(--s5); font-size: var(--fs-md); color: var(--text-2); text-align: center; }
.auth-mobile-brand { display: none; align-items: center; gap: 10px; font-family: var(--font-head); font-weight: 600; font-size: 18px; margin-bottom: var(--s6); }
.pw-rules { list-style: none; padding: 0; margin: 4px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; font-size: var(--fs-xs); color: var(--text-3); }
.pw-rules li { display: flex; align-items: center; gap: 6px; }
.pw-rules li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); flex: none; }
.pw-rules li.ok { color: var(--signal-text); }
.pw-rules li.ok::before { background: var(--signal); }
.pw-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 6px; }
.pw-meter span { height: 4px; border-radius: 2px; background: var(--surface-3); }
.pw-meter[data-score="1"] span:nth-child(-n+1) { background: var(--danger); }
.pw-meter[data-score="2"] span:nth-child(-n+2) { background: #D97706; }
.pw-meter[data-score="3"] span:nth-child(-n+3) { background: var(--primary); }
.pw-meter[data-score="4"] span { background: var(--signal); }
.otp-input { font-family: var(--font-mono); font-size: 22px; letter-spacing: .4em; text-align: center; }
.state-card { text-align: left; }
.state-card .state-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-weak); color: var(--primary-text); margin-bottom: var(--s4); }
.state-card .state-icon .icon { width: 22px; height: 22px; }
@media (max-width: 900px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { display: none; }
  .auth-mobile-brand { display: flex; }
  .auth-main { align-items: flex-start; padding-top: 48px; }
}

/* ---------------- shell ---------------- */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); height: 100vh; height: 100dvh; overflow: hidden; }
.shell.side-collapsed { grid-template-columns: 0 minmax(0, 1fr); }
.shell.side-collapsed .side { visibility: hidden; }
.main-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }

/* ---------------- sidebar ---------------- */
.side {
  background: var(--side-bg); color: var(--side-text); display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  border-right: 1px solid var(--side-border);
}
.side :focus-visible { outline-color: #8CB2FF; }
.side-top { padding: 12px 12px 8px; display: flex; flex-direction: column; gap: 10px; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 2px 4px; }
.side-brand .name { font-family: var(--font-head); font-weight: 600; font-size: 17px; color: #fff; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side .icon-btn { color: var(--side-text-2); }
.side .icon-btn:hover { background: var(--side-hover); color: #fff; }
.new-chat {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 38px; padding: 0 12px; border-radius: var(--r-sm);
  background: var(--blue); border: 0; color: #fff; font-weight: 600; font-size: var(--fs-md); cursor: pointer;
}
.new-chat:hover { background: #1D4ED8; }
.new-chat kbd { margin-left: auto; background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.2); color: #E2EAF7; }
.side-search { position: relative; }
.side-search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--side-text-2); width: 16px; height: 16px; }
.side-search input {
  width: 100%; height: 34px; border-radius: var(--r-sm); border: 1px solid var(--side-border); background: rgba(255,255,255,.05); color: #fff;
  padding: 0 52px 0 32px; font-size: var(--fs-md);
}
.side-search input::placeholder { color: var(--side-text-2); }
.side-search input:focus-visible { outline: 2px solid #8CB2FF; outline-offset: 0; }
.side-search kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: transparent; border-color: rgba(255,255,255,.18); color: var(--side-text-2); }
.side-scroll { flex: 1; overflow-y: auto; padding: 4px 8px 12px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
.side-section { margin-top: 10px; }
.side-section-head {
  display: flex; align-items: center; gap: 4px; padding: 6px 6px 4px 8px; font-size: 12px; font-weight: 600; color: var(--side-text-2);
}
.side-section-head button.toggle { all: unset; display: flex; align-items: center; gap: 4px; cursor: pointer; flex: 1; border-radius: 4px; }
.side-section-head button.toggle:focus-visible { outline: 2px solid #8CB2FF; }
.side-section-head button.toggle .icon { width: 14px; height: 14px; transition: transform .15s; }
.side-section-head button.toggle[aria-expanded="false"] .icon { transform: rotate(-90deg); }
.side-section-head .icon-btn { width: 24px; height: 24px; }
.side-section-head .icon-btn .icon { width: 15px; height: 15px; }
.group-label { padding: 10px 8px 4px; font-size: 12px; color: var(--side-text-2); }
.side-list { list-style: none; margin: 0; padding: 0; }
.side-item { position: relative; display: flex; align-items: center; border-radius: var(--r-sm); }
.side-item > a, .side-item > button.link {
  all: unset; box-sizing: border-box; flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 7px 8px; cursor: pointer;
  font-size: var(--fs-md); color: var(--side-text); border-radius: var(--r-sm);
}
.side-item > a:focus-visible, .side-item > button.link:focus-visible { outline: 2px solid #8CB2FF; outline-offset: -2px; }
.side-item .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-item .mode-glyph { width: 18px; flex: none; text-align: center; font-size: 12px; color: var(--side-text-2); font-family: var(--font-mono); }
.side-item .meta { font-size: 11px; color: var(--side-text-2); flex: none; }
.side-item:hover { background: var(--side-hover); }
.side-item.active { background: var(--side-active); }
.side-item.active > a { color: #fff; }
.side-item .more { opacity: 0; width: 26px; height: 26px; margin-right: 2px; }
.side-item:hover .more, .side-item.active .more, .side-item .more:focus-visible, .side-item .more[aria-expanded="true"] { opacity: 1; }
@media (hover: none) { .side-item .more { opacity: 1; } }
.side-empty { padding: 8px 10px; font-size: var(--fs-sm); color: var(--side-text-2); }
.side-foot { border-top: 1px solid var(--side-border); padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.side-user { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--r-sm); cursor: pointer; width: 100%; }
.side-user:hover { background: var(--side-hover); }
.side-user:focus-visible { outline: 2px solid #8CB2FF; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #1F4F82; color: #fff; font-size: 12px; font-weight: 600; flex: none; }
.side-user .who { min-width: 0; flex: 1; }
.side-user .who div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: var(--fs-md); color: #fff; }
.side-user .who small { display: block; color: var(--side-text-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-pill { display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 999px; font-size: 11px; background: rgba(94,234,212,.14); color: #5EEAD4; }
.archived-toggle { all: unset; font-size: 12px; color: var(--side-text-2); cursor: pointer; padding: 6px 8px; border-radius: 4px; }
.archived-toggle:hover { color: #fff; }
.archived-toggle:focus-visible { outline: 2px solid #8CB2FF; }
.project-filter { display: flex; align-items: center; gap: 6px; margin: 2px 4px 4px; padding: 6px 8px; background: rgba(77,132,245,.16); border-radius: var(--r-sm); font-size: 12px; color: #DCE6F2; }
.project-filter .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* drawer behaviour for small screens */
.side-backdrop { display: none; }
@media (max-width: 899.98px) {
  .shell, .shell.side-collapsed { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: min(300px, 86vw); z-index: 250; transform: translateX(-102%); transition: transform .2s var(--ease); visibility: hidden; }
  .shell.side-open .side { transform: none; visibility: visible; box-shadow: var(--shadow-2); }
  .shell.side-open .side-backdrop { display: block; position: fixed; inset: 0; background: var(--overlay); z-index: 240; }
  .shell.side-collapsed .side { visibility: hidden; }
}

/* ---------------- header ---------------- */
.topbar {
  height: var(--header-h); flex: none; display: flex; align-items: center; gap: 8px; padding: 0 12px 0 12px;
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.topbar .title-zone { min-width: 0; display: flex; align-items: center; gap: 8px; flex: 1; overflow: hidden; }
.model-btn .model-ico { display: none; }
.mode-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px 0 8px; border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-weight: 600; font-size: var(--fs-md); min-width: 0; max-width: 100%;
}
.mode-btn:hover { background: var(--surface-2); }
.mode-btn .glyph { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; background: var(--primary-weak); color: var(--primary-text); font-size: 13px; font-family: var(--font-mono); flex: none; }
.mode-btn .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--font-head); }
.model-btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; border-radius: var(--r-sm); border: 1px solid transparent; background: transparent; cursor: pointer; font-size: var(--fs-sm); color: var(--text-2); min-width: 0; }
.model-btn:hover { background: var(--surface-2); }
.model-btn .v { font-family: var(--font-mono); font-size: 12px; color: var(--text); white-space: nowrap; }
.conv-title { font-size: var(--fs-md); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar .actions { display: flex; align-items: center; gap: 4px; flex: none; }
.user-chip { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 4px 0 4px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.user-chip .avatar { width: 28px; height: 28px; background: var(--navy); }
.user-chip:hover { background: var(--surface-2); }
@media (max-width: 899.98px) { .conv-title { display: none; } }
@media (max-width: 560px) {
  .model-btn .v, .model-btn .label-text, .model-btn .badge { display: none; }
  .model-btn .model-ico { display: block; }
  .model-btn { padding: 0 4px; }
  .readiness-banner { font-size: 12px; padding: 6px 12px; }
  .readiness-banner .badge { display: none; }
  .mode-btn .lbl { max-width: 34vw; }
  .topbar { gap: 4px; padding: 0 8px; }
  .hide-sm { display: none !important; }
}

/* readiness banner */
.readiness-banner {
  display: flex; align-items: center; gap: 10px; padding: 7px 16px; font-size: var(--fs-sm); flex: none;
  background: var(--warn-bg); color: var(--warn-text); border-bottom: 1px solid var(--warn-border);
}
.readiness-banner .icon { width: 16px; height: 16px; flex: none; }
.readiness-banner .grow { line-height: 1.4; }

/* generic page layout (account) */
.page { flex: 1; overflow-y: auto; }
.page-inner { max-width: 1040px; margin: 0 auto; padding: var(--s6) var(--s6) var(--s8); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s5); flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
@media (max-width: 640px) { .page-inner { padding: var(--s4) var(--s4) var(--s8); } .panel { padding: var(--s4); } }
