/* Layout ownership: app viewport -> page scroll -> bounded local lists. */
html, body { width: 100%; height: 100%; overflow: hidden; }
body { letter-spacing: 0; }
[hidden] { display: none !important; }
button, input, select, textarea, .field { min-width: 0; }
button { touch-action: manipulation; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline-color: var(--accent); }
.app { min-width: 0; width: 100%; height: var(--app-height); }
.sidebar { flex: 0 0 var(--sidebar-width); min-width: 0; height: 100%; position: relative; padding: 20px 12px; }
.sidebar-foot { margin: auto -12px 0; padding: 12px 12px 0; }
.main-area { flex: 1 1 0; min-width: 0; min-height: 0; container: workspace / inline-size; }
.topbar { flex: 0 0 64px; min-width: 0; padding: 0 var(--page-gap); }
.sheet-switcher { min-width: 0; max-width: 100%; gap: 18px; }
.sheet-switcher > span:first-child { min-width: 0; }
.sheet-switcher strong { overflow: hidden; text-overflow: ellipsis; }
.chevron { flex-shrink: 0; }
.top-actions { flex-wrap: wrap; }
.page { min-width: 0; min-height: 0; overflow-x: hidden; overflow-y: auto; padding: var(--page-gap); overscroll-behavior-y: contain; }
.page-inner { width: 100%; max-width: 1600px; min-width: 0; }
.page-heading { align-items: center; flex-wrap: wrap; gap: 12px; }
.page-heading > div { min-width: 0; }
.page-heading h1 { font-size: 24px; line-height: 1.4; }
.page-heading p { line-height: 1.6; overflow-wrap: anywhere; }
.btn.primary, .prep-send, .logo { background: var(--accent); border-color: var(--accent); }
.btn.primary:hover, .prep-send:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn { min-height: 38px; height: auto; }
.login-card, .modal-card, .prep-workspace, .prep-composer, .prep-message.user { border-radius: 8px; }
.login-screen, .auth-restore-screen { height: var(--app-height); overflow-y: auto; background: var(--canvas); }
.login-card { margin: auto; }
.login-form input { min-height: 44px; }
.auth-restore-spinner { border-color: var(--accent-border); border-top-color: var(--accent); }
.nav-button.active, .action-filter.active, .prep-session.active { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent-strong); }
.nav-button, .user-menu button, .prep-context-copy, .prep-info-copy, .prep-modal-checklist li { color: var(--text); }
.nav-button.active { color: var(--accent-strong); }
.overview-head span { color: var(--muted); }
.user-avatar, .action-icon, .list-icon, .week-icon, .resume-file, .prep-mark.apply { background: var(--accent-soft); color: var(--accent-strong); }
.prep-composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(19,127,187,.12); }
.prep-message.user { background: var(--accent-soft); border-color: var(--accent-border); color: var(--text); }
.prep-message.assistant, .prep-markdown-heading, .prep-markdown-list strong, .prep-markdown-paragraph strong { color: var(--text); }
.prep-message-role, .prep-context-btn { color: var(--muted); }
.assistant-tab.active { border-color: var(--accent); color: var(--accent-strong); }
.assistant-summary { background: var(--accent-soft); color: var(--text); border-color: var(--line); }
.assistant-search-form input:focus, .assistant-search-form select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(19,127,187,.12); }
.action-command-apply { background: var(--accent-soft); color: var(--accent-strong); }

/* Dashboard uses the available content width, including sidebar changes. */
.overview-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.overview-card { min-width: 0; padding: 16px; }
.funnel-layout, .donut-layout { gap: 12px; }
.funnel-chart { flex-basis: 132px; }
.funnel-step { max-width: 100%; }
.dashboard-grid { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
.pipeline { grid-template-columns: repeat(6, minmax(0, 1fr)); padding: 14px; gap: 10px; overflow: hidden; }
.pipeline-title { gap: 6px; min-height: 38px; margin-bottom: 8px; }
.pipeline-title > span { overflow-wrap: anywhere; line-height: 1.4; }
.pipeline-title small { flex-shrink: 0; }
.pipeline-list { grid-template-columns: minmax(0, 1fr); height: 350px; padding: 2px 1px; align-content: start; }
.pipeline-card { min-width: 0; max-width: 100%; width: 100%; min-height: 65px; box-sizing: border-box; }
.pipeline-card:hover { transform: none; box-shadow: none; background: var(--surface-subtle); }
.panel-head { gap: 10px; padding: 12px 16px; flex-wrap: wrap; }
.panel-head h2 { line-height: 1.5; }
.action-list { grid-template-columns: minmax(0, 1fr); max-height: 350px; padding: 0; }
.action-item { gap: 8px; min-height: 62px; }
.action-command { font-size: 10px; padding: 0 7px; }
.dashboard-lower { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dashboard-scroll-list { grid-template-columns: minmax(0, 1fr); height: 300px; padding: 4px 16px 12px; }
.upcoming-open { gap: 7px; min-width: 0; }
.upcoming-entry { min-width: 0; grid-template-columns: minmax(0, 1fr); gap: 0; padding: 4px 0; }
.upcoming-confirm { justify-self: end; margin-bottom: 6px; }
.pipeline-list, .action-list, .dashboard-scroll-list { scrollbar-width: none; overflow-x: hidden; }

/* Company information collapses into readable rows instead of being removed. */
.company-toolbar { flex-wrap: wrap; }
.search-wrap { min-width: 0; max-width: none; flex: 1 1 280px; }
.filter-select { width: 170px; }
.company-head, .company-row { grid-template-columns: minmax(160px, 1.5fr) 130px minmax(100px, 1fr) minmax(90px, .8fr) minmax(120px, 1fr) 32px; gap: 12px; }
.company-title strong { min-width: 0; }
.company-row { min-width: 0; }
.company-row:focus-visible { outline-offset: -3px; }
.company-cell-muted { min-width: 0; }
.row-menu { width: 32px; height: 36px; }
.status-pill { min-width: 0; max-width: 100%; white-space: normal; text-align: center; padding: 2px 8px; }
.company-status { justify-self: start; }
.assistant-page { max-width: 1320px; }
.assistant-search-form { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.assistant-search-form .btn { justify-self: end; grid-column: 1 / -1; }
.assistant-panel-head { flex-wrap: wrap; }
.assistant-panel-title { flex: 1 1 220px; }
.assistant-result { grid-template-columns: minmax(0, 1fr) auto; gap: 16px; padding: 14px 0; }
.assistant-result-title strong { white-space: normal; overflow-wrap: anywhere; }
.assistant-result-actions { flex-wrap: wrap; justify-content: flex-end; }
.assistant-result-reason { max-width: none; white-space: normal; overflow-wrap: anywhere; }
.resume-toolbar { gap: 12px; flex-wrap: wrap; }
.resume-card { min-width: 0; }
.resume-actions { flex-wrap: wrap; }

/* Fixed workspace height: only the rail and messages scroll on desktop. */
.page.prep-page-host { padding: 16px; overflow: hidden; }
.prep-page { max-width: 1600px; height: 100%; }
.prep-workspace { height: 100%; min-height: 0; grid-template-columns: 250px minmax(0, 1fr); }
.prep-rail { min-width: 0; min-height: 0; overflow-x: hidden; overflow-y: auto; }
.prep-conversation { min-width: 0; min-height: 0; }
.prep-context-bar { flex: 0 0 auto; min-width: 0; max-height: 35%; overflow-y: auto; padding: 14px 20px; }
.prep-context-top { gap: 12px; }
.prep-context-meta { min-width: 0; }
.prep-context-title strong { font-size: 18px; }
.prep-context-controls { align-items: center; gap: 4px; }
.prep-context-btn { min-height: 34px; height: auto; }
.prep-chat { flex: 1 1 0; min-height: 0; min-width: 0; padding: 18px 20px 14px; position: relative; }
.prep-chat-body { flex: 1 1 0; min-height: 0; }
.prep-chat-messages { min-height: 0; grid-template-columns: minmax(0, 1fr); grid-auto-rows: max-content; overflow-x: hidden; overflow-y: auto; padding: 0 26px 16px 0; }
.prep-message-content { overflow-wrap: anywhere; word-break: normal; }
.prep-message { min-width: 0; max-width: 100%; }
.prep-message.assistant { max-width: 920px; }
.prep-starters { flex: 0 0 auto; margin: 10px 0; }
.prep-starter { min-height: 32px; line-height: 1.5; padding: 5px 10px; white-space: normal; }
.prep-composer { flex: 0 0 auto; grid-template-columns: minmax(0, 1fr) 38px; }
.prep-composer textarea { resize: none; min-height: 42px; max-height: 110px; }
.prep-send { height: 38px; width: 38px; }
.prep-mobile-toolbar { display: none; }
.prep-context-meta .prep-context-chip { max-width: 190px; }
.prep-new-reply { left: 50%; transform: translateX(-50%); white-space: nowrap; }

/* Dialog header and actions stay visible while the body scrolls. */
.modal { padding: 20px; }
.modal-card { display: flex; flex-direction: column; min-width: 0; max-height: min(820px, calc(var(--app-height) - 40px)); overflow: hidden; }
.modal-head, .modal-foot { flex: 0 0 auto; }
.modal-head h2 { min-width: 0; overflow-wrap: anywhere; }
.modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }
.modal-foot { flex-wrap: wrap; }
.prep-info-modal-body { max-height: none; }
.settings-block { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 0 0 18px; }
.settings-block:last-child { border-bottom: 0; }
.setting-grid, .drawer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field input, .field select, .field textarea { max-width: 100%; }
.sheet-item { min-width: 0; flex-wrap: wrap; }
.sheet-item-info { flex: 1 1 180px; }
.drawer-panel { max-height: var(--app-height); }
.drawer-head, .drawer-foot { flex: 0 0 auto; }
.drawer-foot, .drawer-foot-right { flex-wrap: wrap; }
.drawer-body { min-height: 0; overscroll-behavior: contain; overflow-x: hidden; }
.notice { max-width: calc(100% - 24px); text-align: center; }

@container workspace (max-width: 1250px) {
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
  .dashboard-lower { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container workspace (max-width: 1050px) {
  .overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-card:last-child { grid-column: 1 / -1; min-height: 0; }
  .week-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
  .week-stat { grid-template-columns: 26px 1fr; gap: 6px; }
  .week-label { grid-column: 2; }
}
@container workspace (max-width: 940px) {
  .pipeline { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pipeline-list { height: 270px; }
  .company-head { display: none; }
  .company-row { grid-template-columns: minmax(0, 1fr) auto 32px; gap: 8px 12px; padding: 14px 16px; }
  .company-name { grid-column: 1; grid-row: 1; }
  .company-status { grid-column: 2; grid-row: 1; }
  .row-menu { grid-column: 3; grid-row: 1; }
  .company-row > :nth-child(3) { grid-column: 1 / 3; grid-row: 2; }
  .company-row > :nth-child(4) { grid-column: 1; grid-row: 3; }
  .company-row > :nth-child(5) { grid-column: 2 / 4; grid-row: 3; }
  .prep-workspace { grid-template-columns: 210px minmax(0, 1fr); }
  .prep-context-top { flex-wrap: wrap; }
  .prep-context-meta { justify-content: flex-start; }
  .prep-message-nav { display: none; }
  .prep-chat-messages { padding-right: 4px; }
  .prep-starters, .prep-composer { max-width: none; }
}
@container workspace (max-width: 620px) {
  .assistant-result { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .overview-grid, .dashboard-lower { grid-template-columns: minmax(0, 1fr); }
  .week-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pipeline { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 12px; }
  .pipeline-list { height: 250px; }
  .company-row { grid-template-columns: minmax(0, 1fr) 32px; }
  .company-name { grid-column: 1; }
  .row-menu { grid-column: 2; }
  .company-status { grid-column: 1 / -1; grid-row: 2; }
  .company-row > :nth-child(3) { grid-column: 1 / -1; grid-row: 3; }
  .company-row > :nth-child(4) { grid-column: 1 / -1; grid-row: 4; }
  .company-row > :nth-child(5) { grid-column: 1 / -1; grid-row: 5; }
  .company-cell-muted { white-space: normal; overflow-wrap: anywhere; }
  .resume-card { grid-template-columns: 36px minmax(0, 1fr); gap: 10px; }
  .resume-actions { grid-column: 1 / -1; }
  .assistant-search-form { grid-template-columns: minmax(0, 1fr); }
  .assistant-search-form .btn { width: 100%; }
}
@media (max-width: 1150px) and (min-width: 761px) {
  :root { --page-gap: 18px; }
}
@media (max-width: 760px) {
  :root { --page-gap: 14px; }
  .app { display: block; position: relative; padding-bottom: calc(62px + env(safe-area-inset-bottom)); }
  .main-area { height: 100%; }
  .sidebar { position: absolute; inset: auto 0 0; height: auto; padding: 0; border: 0; background: transparent; z-index: 25; }
  .sidebar > .brand { display: none; }
  .nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); background: var(--surface); }
  .nav-button { width: 100%; height: 54px; gap: 3px; flex-direction: column; padding: 6px 0; font-size: 10px; }
  .nav-button > span:last-child { display: block; }
  .nav-icon { font-size: 19px; width: 22px; height: 22px; }
  .sidebar-foot { position: fixed; top: env(safe-area-inset-top); right: 10px; border: 0; margin: 0; padding: 6px 0; width: 44px; }
  .user-card { width: 44px; height: 44px; padding: 6px; }
  .user-copy, .user-chevron { display: none; }
  .user-menu { top: calc(100% + 6px); bottom: auto; left: auto; right: 0; width: 190px; }
  .user-menu button { min-height: 44px; }
  .topbar { flex-basis: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 64px 0 12px; }
  .sheet-switcher { width: 100%; padding: 8px 0; }
  .sheet-switcher strong { font-size: 14px; }
  .page-heading h1 { font-size: 22px; }
  .btn, .filter-select, .login-form input, .field input, .field select { min-height: 42px; }
  input, select, textarea, .field input, .field select, .field textarea, .search-input, .assistant-search-form input, .assistant-search-form select, .prep-composer textarea { font-size: 16px; }
  .company-toolbar { gap: 8px; }
  .search-wrap { flex-basis: 100%; }
  .filter-select { flex: 1 1 150px; }
  .assistant-tabs { gap: 20px; }
  .assistant-panel-head, .assistant-search-form { padding: 14px; }
  .assistant-result-list { padding: 0 14px; }
  .action-filter { line-height: 32px; font-size: 12px; }
  .action-deferred-toggle { min-height: 42px; }
  .list-copy strong, .action-copy strong, .company-title strong { font-size: 14px; }
  .pipeline-title { font-size: 12px; }
  .pipeline-card { min-height: 65px; }
  .panel-head { padding: 12px 14px; }
  .page.prep-page-host { padding: 8px; }
  .prep-workspace { display: flex; flex-direction: column; }
  .prep-mobile-toolbar { display: flex; flex: 0 0 42px; align-items: center; border-bottom: 1px solid var(--line); background: var(--surface-subtle); padding: 4px 12px; }
  .prep-mobile-toggle { display: flex; align-items: center; gap: 8px; background: transparent; border: 0; color: var(--accent-strong); min-height: 34px; padding: 0; font-size: 13px; }
  .prep-prompts-toggle { margin-left: auto; }
  .selecting-company .prep-prompts-toggle { display: none; }
  .prep-rail { display: none; flex: 1 1 0; border: 0; padding: 16px 12px; }
  .prep-workspace.selecting-company .prep-rail { display: block; }
  .prep-workspace.selecting-company .prep-conversation { display: none; }
  .prep-conversation { flex: 1 1 0; }
  .prep-rail-label { min-height: 44px; padding: 4px; }
  .prep-rail-head { padding: 0 4px 14px; }
  .prep-session { min-height: 64px; }
  .prep-session-copy strong { font-size: 14px; }
  .prep-session-copy span { font-size: 12px; }
  .prep-context-bar { max-height: 30%; padding: 10px 12px; }
  .prep-context-title strong { font-size: 16px; }
  .prep-context-meta { display: none; }
  .prep-context-controls { margin-top: 8px; }
  .prep-context-btn { padding: 0 6px; min-height: 34px; }
  .prep-resume-select { max-width: 100%; min-width: 0; }
  .prep-chat { padding: 12px 12px 8px; }
  .prep-starters { display: none; }
  .prep-starters.mobile-open { display: grid; position: absolute; bottom: 88px; left: 12px; right: 12px; max-height: 50%; overflow-y: auto; padding: 10px; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(24,54,74,.12); z-index: 5; }
  .prep-starters.mobile-open .prep-starter { min-height: 40px; text-align: left; }
  .prep-message.user { max-width: 92%; }
  .prep-composer { margin-top: 8px; }
  .prep-message-actions { opacity: 1; }
  .prep-message-action { width: 32px; height: 32px; }
  .modal { padding: 10px; }
  .modal-card { width: 100%; max-height: calc(var(--app-height) - 20px); }
  .modal-head { padding: 0 14px; }
  .modal-body { padding: 14px; }
  .modal-foot { padding: 10px 14px; }
  .setting-grid, .drawer-grid { grid-template-columns: minmax(0, 1fr); }
  .drawer-grid .full { grid-column: auto; }
  .drawer-panel { width: 100%; max-width: none; height: var(--app-height); }
  .drawer-body { padding: 14px; }
  .drawer-foot { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .notice { bottom: calc(72px + env(safe-area-inset-bottom)); }
}
@media (hover: none) { .prep-message-actions { opacity: 1; } }
@media (max-height: 540px) {
  .topbar { flex-basis: 44px; }
  .page.prep-page-host { padding: 6px; }
  .prep-context-bar { max-height: 28%; padding: 6px 12px; }
  .prep-context-meta, .prep-starters { display: none; }
  .prep-context-controls { margin-top: 4px; }
  .prep-chat { padding: 8px 12px; }
  .prep-composer textarea { min-height: 32px; max-height: 64px; padding-block: 4px; }
  .prep-mobile-toolbar { flex-basis: 34px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation-duration: .01ms !important; } }
