:root {
  --navy: #163A5F;
  --navy-deep: #102C49;
  --page: #F4F7FA;
  --surface: #FFFFFF;
  --selected: #E6EFF6;
  --text: #243746;
  --muted: #657789;
  --border: #D4DEE7;
  --green: #2F765E;
  --green-bg: #E7F2EE;
  --green-border: #BBDACF;
  --bronze-dark: #98733D;
  --bronze-on-dark: #C09A52;
  --danger: #A74444;
  --warning: #A66A28;
  --topbar-height: 64px;
  color: var(--text);
  font-family: "Golos Text", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; background: var(--page); }
html, body { overflow-x: hidden; }
button, input, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { color: inherit; }
a { color: var(--navy); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible { outline: 3px solid rgba(28,103,160,.55); outline-offset: 2px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.mobile-only { display: none; }
.empty-copy { margin: 0; color: var(--muted); font-size: .9rem; }
.eyebrow { margin: 0 0 8px; color: var(--bronze-dark); font-size: .72rem; font-weight: 700; }

.app-shell {
  height: 100vh;
  height: 100dvh;
  height: var(--visual-viewport-height, 100dvh);
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(236px, 280px) minmax(420px, 1fr) minmax(280px, 340px);
  grid-template-rows: var(--topbar-height) minmax(0, 1fr);
  grid-template-areas: "top top top" "left main right";
}

.topbar {
  grid-area: top;
  display: grid;
  grid-template-columns: minmax(230px, 280px) 1fr auto;
  align-items: center;
  min-height: var(--topbar-height);
  padding: 0 24px;
  background: var(--navy-deep);
  color: #fff;
  border-bottom: 3px solid var(--bronze-on-dark);
  z-index: 30;
}
.brand { display: inline-flex; gap: 7px; align-items: baseline; width: max-content; color: inherit; text-decoration: none; font-size: 1.2rem; font-weight: 750; }
.brand b { color: var(--bronze-on-dark); font-weight: 750; }
@keyframes rc-brand-shimmer {
  0%, 82% { background-position: 140% 0; }
  100% { background-position: -40% 0; }
}
.brand > span, .brand > b {
  color: transparent;
  background: linear-gradient(105deg, currentColor 0 38%, #fff4b8 47%, currentColor 56% 100%);
  background-size: 260% 100%;
  background-position: 140% 0;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: rc-brand-shimmer 7s ease-in-out infinite;
}
.brand > span { --brand-base: #fff; background-image: linear-gradient(105deg, #fff 0 38%, #fff4b8 47%, #fff 56% 100%); }
.brand > b { background-image: linear-gradient(105deg, var(--bronze-on-dark) 0 38%, #fff4b8 47%, var(--bronze-on-dark) 56% 100%); }

.app-rail {
  grid-area: rail;
  position: relative;
  z-index: 70;
  display: grid;
  grid-template-rows: 64px 1fr auto;
  justify-items: center;
  min-width: 64px;
  min-height: 0;
  color: #d9e6f0;
  background: #0b2742;
  border-right: 1px solid rgba(255,255,255,.12);
}
.app-rail-home {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-top: 10px;
  color: #fff;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 12px;
  text-decoration: none;
  font-size: .78rem;
  font-weight: 800;
}
.app-rail-links, .app-rail-account { display: grid; align-content: start; justify-items: center; gap: 10px; padding: 14px 0; }
.app-rail-account { align-content: end; }
.app-rail-links a, .app-rail-account a {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: #d9e6f0;
  border: 1px solid transparent;
  border-radius: 10px;
  text-decoration: none;
}
.app-rail-links a:hover, .app-rail-account a:hover { color: #fff; background: rgba(255,255,255,.08); }
.app-rail-links a.is-active, .app-rail-account a.is-active { color: #fff; border-color: rgba(111,174,224,.28); background: #194b78; box-shadow: inset 0 0 18px rgba(37,117,181,.22); }
.app-rail-backdrop { position: fixed; inset: 0; z-index: 65; background: rgba(8,26,42,.42); }
.mobile-workspace-header, .mobile-section-links { display: none; }
.has-app-rail {
  display: grid;
  grid-template-columns: 64px minmax(0,1fr);
  grid-template-rows: 64px minmax(0,1fr);
  grid-template-areas: "rail header" "rail content";
  min-height: 100vh;
}
.has-app-rail > :is(.settings-header, .profile-topbar) { grid-area: header; }
.has-app-rail > :is(.settings-content, .profile-content) { grid-area: content; width: min(1240px, calc(100% - 56px)); }
.system-status { justify-self: end; display: flex; align-items: center; gap: 8px; font-size: .82rem; }
.system-status i { width: 9px; height: 9px; border-radius: 50%; background: #5CB590; box-shadow: 0 0 0 3px rgba(92,181,144,.15); }
.system-status span { color: #B9C8D5; font-weight: 450; }
.system-status span b { color: #DCE5EC; }

.left-panel, .right-panel { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.left-panel { grid-area: left; display: flex; flex-direction: column; background: var(--page); border-right: 1px solid var(--border); padding: 24px 18px 18px; }
.right-panel { grid-area: right; background: #F6F8FA; border-left: 1px solid var(--border); padding: 24px 20px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.panel-heading h1, .panel-heading h2 { margin: 0; color: var(--navy-deep); font-size: 1.08rem; line-height: 1.25; }
.panel-heading p { margin: 5px 0 0; color: var(--muted); font-size: .79rem; }
.right-heading { padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.right-heading h2 { font-size: 1.08rem; }

.new-task-button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; width: 100%; min-height: 42px; margin-top: 22px; color: #fff; border: 1px solid var(--navy); border-radius: 6px; background: var(--navy); cursor: pointer; font-weight: 650; }
.new-task-button:hover { background: var(--navy-deep); }
.new-task-button svg { width: 17px; height: 17px; }
.sections { display: grid; gap: 5px; margin: 14px 0 18px; }
.section-button { position: relative; display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: center; min-height: 44px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; text-align: left; cursor: pointer; font-weight: 600; }
.section-button::before { content: ""; position: absolute; inset: 6px auto 6px 0; width: 3px; border-radius: 2px; background: transparent; }
.section-button:hover { background: #EDF2F6; }
.section-button.is-active { color: var(--navy); background: var(--selected); }
.section-button.is-active::before { background: var(--navy); }

.project-summary { display: grid; gap: 2px; margin-bottom: 14px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.project-summary > span { color: var(--bronze-dark); font-size: .65rem; font-weight: 750; }
.project-summary strong { color: var(--navy-deep); font-size: .82rem; }
.project-summary small { color: var(--muted); font-size: .7rem; }
.project-detail-card { display: grid; gap: 16px; margin: 18px 0 28px; padding: 20px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.project-detail-card p { margin: 0; color: var(--muted); }
.project-detail-card .primary-button { width: fit-content; text-decoration: none; }
.collection-subtitle { margin: 24px 0 12px; color: var(--navy-deep); font-size: 1.1rem; }
.conversation-heading, .section-title { display: flex; align-items: center; justify-content: space-between; }
.conversation-heading { padding: 10px 4px 8px; border-top: 1px solid var(--border); }
.conversation-heading h2, .section-title h2 { margin: 0; color: var(--navy-deep); font-size: .93rem; }
.conversation-list { display: grid; gap: 4px; padding: 4px 0 14px; }
.imported-history-notice { display: grid; gap: 4px; margin: 12px 20px 20px; padding: 14px 16px; border: 1px solid #d7dce5; border-radius: 14px; background: #f6f8fb; color: #445064; }
.imported-history-notice strong { color: #182033; }
.conversation-item { display: grid; gap: 2px; width: 100%; min-height: 48px; padding: 8px 10px; border: 0; border-radius: 5px; background: transparent; color: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.conversation-item:hover { background: #EDF2F6; }
.conversation-item.is-active { background: var(--selected); box-shadow: inset 3px 0 var(--navy); }
.conversation-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .87rem; }
.conversation-item span { color: var(--muted); font-size: .72rem; }
.account-area { margin-top: auto; border-top: 1px solid var(--border); padding-top: 14px; }
.settings-link { display: grid; grid-template-columns: 36px 1fr 20px; gap: 10px; align-items: center; color: var(--text); text-decoration: none; }
.settings-link small { display: block; color: var(--muted); }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: #fff; background: var(--navy); font-weight: 700; }

.workspace { grid-area: main; position: relative; min-width: 0; min-height: 0; height: calc(100vh - var(--topbar-height)); height: calc(100dvh - var(--topbar-height)); height: calc(var(--visual-viewport-height, 100dvh) - var(--topbar-height)); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; background: var(--surface); }
.workspace.is-empty { grid-template-rows: minmax(0, 1fr) 0 auto; }
.welcome { align-self: center; width: min(760px, calc(100% - 48px)); margin: 0 auto; padding: 40px 0 24px; text-align: center; }
.welcome h2 { margin: 0; color: var(--navy-deep); font-size: clamp(1.8rem, 3vw, 2.5rem); line-height: 1.15; }
.welcome > p:not(.eyebrow) { margin: 14px auto 22px; max-width: 600px; color: var(--muted); }
.quick-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; width: min(620px, 100%); margin: 0 auto; }
.quick-actions button { min-height: 54px; padding: 12px 16px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); cursor: pointer; color: var(--navy); font-weight: 600; }
.quick-actions button:hover { border-color: #9CB5C9; background: #F8FAFC; }
.task-context-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 94px; padding: 18px clamp(24px, 5vw, 64px); border-bottom: 1px solid var(--border); background: #FBFCFD; }
.task-context-header h2 { margin: 0; color: var(--navy-deep); font-size: 1.18rem; line-height: 1.25; overflow-wrap: anywhere; }
.task-context-header p:not(.eyebrow) { margin: 5px 0 0; color: var(--muted); font-size: .76rem; }
.conversation-scroll { width: 100%; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.conversation-stage { display: grid; align-content: start; gap: 10px; padding: 24px clamp(24px, 7vw, 96px) 32px; }
.dialog-message { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; align-items: start; padding: 14px 0; border-bottom: 1px solid #E7EDF2; background: transparent; }
.dialog-message > span { color: var(--muted); font-size: .82rem; font-weight: 700; }
.dialog-message > p { margin: 0; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-content { min-width: 0; overflow-wrap: anywhere; }
.message-content > :first-child { margin-top: 0; }
.message-content > :last-child { margin-bottom: 0; }
.message-content h1, .message-content h2, .message-content h3 { margin: 14px 0 7px; color: var(--navy-deep); line-height: 1.25; overflow-wrap: anywhere; }
.message-content h1 { font-size: 1.28rem; }
.message-content h2 { font-size: 1.15rem; }
.message-content h3 { font-size: 1.04rem; }
.message-content p { margin: 7px 0; white-space: pre-wrap; line-height: 1.5; }
.message-content ul, .message-content ol { margin: 7px 0; padding-left: 1.35rem; }
.message-content li { margin: 3px 0; }
.message-content code { max-width: 100%; padding: .1em .32em; border-radius: 4px; background: #eef3f7; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.dialog-message.user { width: min(720px, 92%); margin-left: auto; padding: 14px 16px; border: 1px solid #CBD9E4; border-radius: 7px; background: var(--selected); }
.dialog-message.assistant { background: transparent; }
.dialog-message > small { grid-column: 2; color: var(--green); font-weight: 600; }
.task-card { display: grid; gap: 10px; padding: 16px 0; border-bottom: 1px solid #E7EDF2; background: var(--surface); }
.task-request, .task-answer { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 10px; align-items: start; }
.task-request span, .task-answer > span { color: var(--muted); font-size: .82rem; font-weight: 700; }
.task-request p, .task-answer p { margin: 0; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.task-answer { padding-top: 10px; border-top: 1px solid var(--border); }
.task-answer small { grid-column: 2; color: var(--green); font-weight: 600; }
.task-card[data-task-state="failed"] .task-answer small,
.task-card[data-task-state="cancelled"] .task-answer small { color: var(--danger); }

.composer-dock { position: relative; z-index: 8; padding: 12px clamp(20px, 5vw, 64px) calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: #F8FAFC; box-shadow: 0 -10px 28px rgba(16,44,73,.045); }
.composer { width: min(860px, 100%); margin: 0 auto; }
.composer-input-shell { position: relative; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: 0 8px 24px rgba(16,44,73,.07); overflow: visible; }
.composer textarea { display: block; width: 100%; min-height: 82px; max-height: 220px; resize: vertical; padding: 18px 164px 68px 144px; color: var(--text); border: 0; outline: 0; background: transparent; }
.composer textarea::placeholder { color: #8393A2; }
.composer-input-shell:focus-within { border-color: #8CAAC2; box-shadow: 0 0 0 3px rgba(22,58,95,.09), 0 12px 32px rgba(16,44,73,.08); }
.attachment-list { display: flex; flex-wrap: wrap; gap: 7px; min-height: 0; padding: 0 12px; }
.attachment-list:not(:empty) { padding-top: 10px; }
.attachment-chip { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-height: 44px; padding: 5px 5px 5px 9px; color: var(--navy); border: 1px solid var(--border); border-radius: 6px; background: #F4F7FA; font-size: .78rem; }
.attachment-copy { display: grid; min-width: 0; gap: 1px; }
.attachment-copy strong, .attachment-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-copy small { color: var(--muted); font-size: .68rem; font-weight: 400; }
.attachment-copy .attachment-state { color: var(--green); }
.attachment-chip > svg { flex: 0 0 auto; width: 15px; height: 15px; }
.attachment-chip progress { width: 46px; height: 6px; accent-color: var(--navy); }
.attachment-chip button { display: grid; place-items: center; flex: 0 0 auto; width: 24px; height: 24px; padding: 0; color: var(--muted); border: 0; background: transparent; cursor: pointer; }
.attachment-chip button svg { width: 14px; height: 14px; }
.attachment-chip.is-uploading { opacity: .65; }
.attachment-chip.is-error { color: var(--danger); border-color: #E7BABA; background: #FFF7F7; }
.attachment-chip.is-error .attachment-state { color: var(--danger); white-space: normal; }
.composer-actions { position: absolute; bottom: 10px; display: flex; align-items: center; gap: 6px; }
.composer-actions-start { left: 12px; }
.composer-actions-end { right: 12px; }
.mobile-task-controls-button, .mobile-task-controls-close { display: none; }
.mobile-task-controls-button svg { width: 19px; height: 19px; }
.composer-actions [data-voice-controls] { display: flex; align-items: center; gap: 6px; }
.attachment-tooltip { position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 12; width: max-content; max-width: min(310px, calc(100vw - 32px)); padding: 8px 10px; color: #fff; border-radius: 6px; background: var(--navy-deep); box-shadow: 0 6px 16px rgba(16,44,73,.2); font-size: .72rem; line-height: 1.35; opacity: 0; pointer-events: none; transform: translateY(4px); transition: opacity 150ms ease, transform 150ms ease; }
.attach-button:hover + .attachment-tooltip, .attach-button:focus-visible + .attachment-tooltip, .attachment-tooltip.is-open { opacity: 1; pointer-events: auto; transform: translateY(0); }
.model-label { margin-right: 4px; color: var(--muted); font-size: .78rem; }
.icon-button { display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1px solid transparent; border-radius: 5px; background: transparent; cursor: pointer; }
.icon-button.mobile-only { display: none; }
.icon-button:hover { background: #EDF2F6; border-color: var(--border); }
.voice-button { width: 36px; height: 36px; color: var(--navy); background: #EEF3F7; }
.send-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 0 14px; color: #fff; border: 1px solid var(--navy); border-radius: 6px; background: var(--navy); cursor: pointer; font-weight: 650; }
.send-button:hover { background: var(--navy-deep); }
.send-button svg { width: 17px; height: 17px; }
.form-error { margin: 0 14px 10px; color: var(--danger); font-size: .82rem; }

.task-progress { padding: 18px 0 24px; border-bottom: 1px solid var(--border); }
.task-progress h3 { margin: 12px 0 8px; color: var(--navy-deep); font-size: 1rem; line-height: 1.35; }
.task-progress p { margin: 0; color: var(--muted); font-size: .85rem; }
.status-badge { display: inline-flex; align-items: center; min-height: 28px; padding: 4px 9px; color: var(--green); border: 1px solid var(--green-border); border-radius: 8px; background: var(--green-bg); font-size: .74rem; font-weight: 700; }
.progress-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; margin-top: 16px; }
progress { width: 100%; height: 9px; border: 0; border-radius: 5px; overflow: hidden; background: #DFE7ED; }
progress::-webkit-progress-bar { background: #DFE7ED; }
progress::-webkit-progress-value { background: var(--green); }
progress::-moz-progress-bar { background: var(--green); }
.progress-row span { color: var(--green); font-size: .78rem; font-weight: 700; }
.task-action-button { width: 100%; min-height: 36px; margin-top: 14px; padding: 6px 10px; color: var(--navy); border: 1px solid var(--border); border-radius: 6px; background: var(--surface); cursor: pointer; font-size: .8rem; font-weight: 650; }
.task-action-button:hover { border-color: #9FB3C3; background: #F4F7FA; }
.approval-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.approval-actions button { min-height: 34px; padding: 5px 10px; color: var(--navy); border: 1px solid var(--border); border-radius: 6px; background: var(--surface); cursor: pointer; font-size: .78rem; font-weight: 650; }
.approval-actions button:first-child { color: #fff; border-color: var(--navy); background: var(--navy); }
.approval-actions button:disabled { cursor: wait; opacity: .55; }
.ready-section { padding-top: 22px; }
.section-title span { color: var(--muted); font-size: .8rem; }
.file-panel-notice { margin: 6px 0 0; color: var(--green); font-size: .78rem; font-weight: 700; }
.ready-files { display: grid; gap: 8px; margin-top: 13px; }
.file-card { position: relative; display: grid; grid-template-columns: 38px minmax(0,1fr) 34px; gap: 10px; align-items: center; min-height: 68px; padding: 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); }
.file-card:hover { background: #F8FAFC; border-color: #B7C7D4; }
.file-card h3 { margin: 0; overflow-wrap: anywhere; font-size: .82rem; line-height: 1.25; }
.file-card p { margin: 4px 0 0; color: var(--green); font-size: .7rem; }
.file-card small { color: var(--muted); font-size: .66rem; }
.file-icon { display: grid; place-items: center; width: 36px; height: 42px; border-radius: 4px; color: #fff; background: #28577f; font-size: .72rem; font-weight: 700; }
.file-icon.excel { background: #217346; }
.file-icon.word { background: #2B579A; }
.file-icon.powerpoint { background: #B7472A; }
.file-icon.pdf { background: #A74444; }
.file-actions { position: absolute; top: 50px; right: 8px; z-index: 12; display: grid; width: max-content; max-width: min(250px, calc(100vw - 32px)); padding: 6px; border: 1px solid var(--border); border-radius: 7px; background: #fff; box-shadow: 0 12px 28px rgba(16,44,73,.16); }
.file-actions a, .file-actions button { min-height: 36px; padding: 7px 10px; color: var(--text); border: 0; border-radius: 4px; background: transparent; cursor: pointer; font: inherit; font-size: .78rem; text-align: left; text-decoration: none; }
.file-actions a:hover, .file-actions button:hover { background: #EDF2F6; }
.file-actions .danger-action { color: var(--danger); }

.portal-login { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-rows: 68px 1fr 46px; background: var(--page); }
.portal-topbar { display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(24px, 6vw, 86px); color: #fff; border-bottom: 3px solid var(--bronze-on-dark); background: var(--navy-deep); }
.portal-topbar .brand-login { color: #fff; }
.portal-topbar .brand-login b { color: var(--bronze-on-dark); }
.portal-status { display: inline-flex; align-items: center; gap: 9px; color: #D6E0E8; font-size: .82rem; font-weight: 600; }
.portal-status i { width: 9px; height: 9px; border-radius: 50%; background: #5CB590; box-shadow: 0 0 0 4px rgba(92,181,144,.13); }
.portal-body { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(380px, .8fr); width: min(1180px, calc(100% - 48px)); min-height: 0; margin: 0 auto; }
.portal-statement { align-self: center; max-width: 630px; padding: 52px clamp(24px, 5vw, 72px) 52px 12px; }
.portal-seal { display: grid; place-items: center; width: 70px; height: 70px; margin-bottom: 28px; color: #fff; border: 1px solid #2C5274; border-radius: 5px; background: var(--navy); box-shadow: inset 0 -4px var(--bronze-on-dark); font-size: 1.22rem; font-weight: 800; }
.portal-statement h1 { max-width: 560px; margin: 0; color: var(--navy-deep); font-size: clamp(2.1rem, 4vw, 3.35rem); line-height: 1.08; }
.portal-statement > p:not(.eyebrow) { max-width: 570px; margin: 22px 0 0; color: var(--muted); font-size: 1.04rem; line-height: 1.7; }
.portal-features { display: grid; gap: 0; margin: 36px 0 0; border-top: 1px solid var(--border); }
.portal-features div { display: grid; grid-template-columns: 38px 1fr; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.portal-features dt { color: var(--bronze-dark); font-size: .73rem; font-weight: 750; }
.portal-features dd { margin: 0; color: var(--text); font-size: .83rem; font-weight: 600; }
.portal-access { align-self: center; width: min(430px, 100%); max-height: calc(100dvh - 140px); overflow-y: auto; margin: 32px 0 32px auto; padding: 36px; border: 1px solid var(--border); border-top: 4px solid var(--navy); border-radius: 6px; background: var(--surface); box-shadow: 0 20px 46px rgba(16,44,73,.09); }
.portal-access h2 { margin: 0; color: var(--navy-deep); font-size: 1.5rem; }
.portal-access-lead { margin: 8px 0 24px; color: var(--muted); font-size: .86rem; }
.portal-footer { display: flex; align-items: center; justify-content: center; padding: 0 24px; color: var(--muted); border-top: 1px solid var(--border); background: #EDF2F6; font-size: .74rem; }
.approval-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--page); }
.approval-panel { width: min(430px, 100%); padding: 36px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: 0 18px 42px rgba(16,44,73,.1); }
.brand-login { color: var(--navy-deep); font-size: 1.35rem; }
.brand-login b { color: var(--bronze-dark); }
.brand-tagline { margin: 5px 0 28px; color: var(--muted); }
.approval-panel h1 { margin: 0 0 22px; color: var(--navy-deep); font-size: 1.5rem; }
.login-form { display: grid; gap: 8px; }
.login-form label { margin-top: 8px; font-size: .84rem; font-weight: 650; }
.login-form input { min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 5px; color: var(--text); background: #fff; }
.login-form input:focus { outline: 3px solid rgba(22,58,95,.1); border-color: var(--navy); }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border-radius: 6px; font-weight: 650; text-decoration: none; cursor: pointer; }
.primary-button { margin-top: 14px; color: #fff; border: 1px solid var(--navy); background: var(--navy); }
.secondary-button { color: var(--navy); border: 1px solid var(--border); background: #fff; }
.registration-toggle { display: block; width: 100%; margin-top: 18px; padding: 8px; color: var(--navy); border: 0; background: transparent; cursor: pointer; font-weight: 650; }
.registration-toggle:hover { text-decoration: underline; }
.registration-form { margin-top: 4px; }
.registration-form .secondary-button { margin-top: 4px; }
.registration-success { padding: 18px 0 0; text-align: center; }
.registration-success p { margin: 6px 0 18px; color: var(--green); font-weight: 650; }
[hidden] { display: none !important; }
.approval-icon { display: grid; place-items: center; width: 46px; height: 46px; margin-bottom: 20px; color: var(--warning); background: #F8EFE4; border-radius: 6px; }
.approval-panel > p:not(.eyebrow) { color: var(--muted); }
.approval-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

.settings-page { min-height: 100vh; background: var(--page); }
.settings-header { display: flex; justify-content: space-between; align-items: center; min-height: 64px; padding: 0 5vw; color: #fff; background: var(--navy-deep); border-bottom: 3px solid var(--bronze-on-dark); }
.settings-header > a:last-child { color: #fff; }
.settings-content { width: min(1080px, 90vw); margin: 0 auto; padding: 52px 0; }
.settings-content h1 { margin: 0 0 30px; color: var(--navy-deep); }
.settings-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; border: 1px solid var(--border); background: var(--border); }
.settings-grid-member { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.settings-grid section { padding: 24px; background: var(--surface); }
.settings-card-link { color: inherit; text-decoration: none; background: var(--surface); }
.settings-card-link section { height: 100%; }
.settings-card-link:hover section { background: var(--active); }
.count-badge { display: inline-grid; min-width: 24px; height: 24px; place-items: center; margin-left: 6px; padding: 0 6px; border-radius: 6px; color: #fff; background: var(--navy); font-size: .8rem; }
.settings-grid h2 { margin: 0 0 8px; color: var(--navy); font-size: 1rem; }
.settings-grid p { margin: 0; color: var(--muted); }
.account-actions { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center; margin-top: 28px; padding: 24px; border: 1px solid var(--border); background: var(--surface); }
.account-actions h2 { margin: 2px 0 6px; color: var(--navy-deep); }
.account-actions p { margin: 0; color: var(--muted); }
.account-actions .form-error { grid-column: 1 / -1; }
.account-action-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.settings-lead { max-width: 720px; margin: -16px 0 28px; color: var(--muted); }
.sessions-section { border: 1px solid var(--border); background: var(--surface); }
.session-row { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center; padding: 20px 24px; border-top: 1px solid var(--border); }
.session-row:first-child { border-top: 0; }
.session-title { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--navy-deep); }
.session-row p, .session-row small { display: block; margin: 5px 0 0; color: var(--muted); }
.sessions-footer { display: flex; justify-content: flex-end; padding: 20px 24px; border-top: 1px solid var(--border); }
.sessions-section > .form-error { margin: 0; padding: 0 24px 20px; }
.security-notice { position: fixed; top: calc(var(--topbar-height) + 12px); left: 50%; z-index: 60; width: min(620px, calc(100vw - 32px)); padding: 12px 16px; color: #174C3B; border: 1px solid #BBDACF; border-radius: 6px; background: #E7F2EE; box-shadow: 0 8px 24px rgba(16,44,73,.14); transform: translateX(-50%); }
.users-section { margin-top: 28px; padding: 24px; border: 1px solid var(--border); background: var(--surface); }
.users-section h2 { margin: 0 0 18px; color: var(--navy-deep); }
.user-row { display: grid; grid-template-columns: minmax(220px, 1fr) auto; gap: 20px; align-items: center; padding: 18px 0; border-top: 1px solid var(--border); }
.user-row:first-of-type { border-top: 0; }
.user-row strong, .user-row small { display: block; }
.user-row small { margin-top: 5px; color: var(--muted); }
.user-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.pending-users { margin-top: 28px; padding: 24px; border: 1px solid var(--border); background: var(--surface); }
.pending-users-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.pending-users-heading h2 { margin: 0; color: var(--navy-deep); font-size: 1.12rem; }
.pending-users-heading > span { display: grid; place-items: center; min-width: 30px; height: 30px; color: #fff; border-radius: 5px; background: var(--navy); font-weight: 700; }
.pending-users-list { display: grid; gap: 10px; padding-top: 16px; }
.pending-user { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px; border: 1px solid var(--border); border-radius: 6px; background: #F8FAFC; }
.pending-user strong, .pending-user small { display: block; }
.pending-user small { margin-top: 3px; color: var(--muted); }
.pending-user-actions { display: flex; gap: 8px; }
.pending-user-actions .primary-button { margin-top: 0; }
.danger-button { color: var(--danger); border-color: #DDBFBF; }
.capability-user-row { align-items: start; }
.capability-form { grid-column: 1 / -1; width: 100%; padding: 16px; border: 1px solid var(--border); border-radius: 6px; background: #F8FAFC; }
.capability-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.capability-option, .capability-field { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 58px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); }
.capability-option strong, .capability-option small, .capability-field span { display: block; }
.capability-option small { margin-top: 3px; color: var(--muted); font-size: .72rem; }
.capability-option.is-unavailable { color: var(--muted); background: #F1F4F6; }
.capability-option input { width: 19px; height: 19px; accent-color: var(--navy); }
.capability-field { flex-direction: column; align-items: stretch; justify-content: center; font-weight: 650; }
.capability-field select { min-height: 38px; padding: 0 10px; color: var(--text); border: 1px solid var(--border); border-radius: 5px; background: #fff; }
.capability-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.capability-actions .primary-button { margin-top: 0; }
.capability-editor { width: 100%; }
.capability-editor summary { cursor: pointer; color: var(--navy); font-weight: 650; }
.capability-editor .capability-form { margin-top: 10px; text-align: left; }

.drawer-backdrop { position: fixed; inset: var(--topbar-height) 0 0; background: rgba(16,44,73,.35); z-index: 35; }

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 230px minmax(390px, 1fr) 290px; }
  .conversation-stage { padding-inline: 28px; }
  .composer-dock { padding-inline: 24px; }
  .model-label { display: none; }
}

@media (max-width: 820px) {
  :root { --topbar-height: 58px; }
  .mobile-only, .icon-button.mobile-only { display: inline-grid; }
  .app-shell { display: grid; grid-template-columns: 1fr; grid-template-areas: "top" "main"; grid-template-rows: var(--topbar-height) minmax(0,1fr); }
  .topbar { grid-template-columns: 42px 1fr 42px; padding: 0 10px; }
  .topbar .brand { justify-self: center; font-size: 1rem; }
  .system-status { display: none; }
  .left-panel, .right-panel { position: fixed; top: var(--topbar-height); bottom: 0; z-index: 40; width: min(88vw, 340px); transform: translateX(-105%); transition: transform .2s ease; box-shadow: 0 18px 50px rgba(16,44,73,.18); }
  .left-panel { left: 0; }
  .right-panel { right: 0; transform: translateX(105%); }
  .left-panel.is-open, .right-panel.is-open { transform: translateX(0); }
  .workspace { min-height: 0; height: calc(100dvh - var(--topbar-height)); padding: 0; }
  .welcome { width: calc(100% - 32px); padding: 28px 0 16px; }
  .welcome h2 { font-size: 1.8rem; }
  .quick-actions { grid-template-columns: 1fr; }
  .task-context-header { min-height: 78px; padding: 13px 16px; }
  .task-context-header h2 { font-size: 1rem; }
  .task-context-header .status-badge { display: none; }
  .conversation-stage { padding: 14px 16px 22px; }
  .dialog-message { grid-template-columns: 48px minmax(0, 1fr); }
  .dialog-message.user { width: 96%; }
  .task-request, .task-answer { grid-template-columns: 48px minmax(0, 1fr); }
  .composer-dock { padding: 9px 12px calc(10px + env(safe-area-inset-bottom)); }
  .composer textarea { min-height: 66px; padding: 13px 124px 66px 68px; }
  .composer-actions { bottom: 9px; }
  .send-label { display: none; }
  .send-button { width: 40px; padding: 0; }
  .attachment-tools { gap: 2px; }
  .settings-grid { grid-template-columns: 1fr; }
  .account-actions { grid-template-columns: 1fr; }
  .account-action-buttons { justify-content: stretch; }
  .account-action-buttons > * { flex: 1; }
  .session-row { grid-template-columns: 1fr; }
  .sessions-footer { justify-content: stretch; }
  .sessions-footer > button { width: 100%; }
  .user-row { grid-template-columns: 1fr; }
  .user-actions { justify-content: flex-start; }
  .capability-grid { grid-template-columns: 1fr; }
  .capability-actions { align-items: stretch; flex-direction: column; }
  .pending-user { align-items: stretch; flex-direction: column; }
  .pending-user-actions > button { flex: 1; }
  .portal-login { grid-template-rows: 58px 1fr auto; }
  .portal-topbar { padding: 0 16px; }
  .portal-status { font-size: 0; }
  .portal-body { grid-template-columns: 1fr; width: min(100% - 28px, 520px); padding: 26px 0; }
  .portal-statement { padding: 10px 4px 24px; }
  .portal-seal, .portal-features { display: none; }
  .portal-statement h1 { font-size: 1.75rem; }
  .portal-statement > p:not(.eyebrow) { margin-top: 12px; font-size: .88rem; line-height: 1.5; }
  .portal-access { max-height: none; margin: 0; padding: 26px 22px; }
  .portal-footer { min-height: 40px; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

/* Stage 4: approved compact workspace */
.rc-workspace { grid-template-columns: 64px 328px minmax(0,1fr) 330px; grid-template-areas: "rail top top top" "rail left main right"; transition: grid-template-columns 200ms ease; }
.rc-workspace .topbar { grid-template-columns: 328px minmax(0,1fr) auto auto; }
.top-title { justify-self: center; color: #d8e3eb; font-size: .82rem; }
.top-state { position: relative; }
.server-status-button { display: inline-flex; align-items: center; gap: 8px; padding: 0; border: 0; color: inherit; background: transparent; cursor: pointer; }
.server-dot { position: relative; display: inline-block; flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; background: #38a77a; box-shadow: 0 0 0 0 rgba(56,167,122,.4); animation: rc-server-pulse 1.9s ease-out infinite; }
.server-dot.mini { width: 7px; height: 7px; animation: none; }
@keyframes rc-server-pulse { 0% { box-shadow: 0 0 0 0 rgba(56,167,122,.42); } 70% { box-shadow: 0 0 0 8px rgba(56,167,122,0); } 100% { box-shadow: 0 0 0 0 rgba(56,167,122,0); } }
.top-divider { width: 1px; height: 20px; background: rgba(255,255,255,.3); }
.server-popover { position: absolute; top: 38px; right: 0; z-index: 80; width: 285px; padding: 16px; color: var(--text); background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 16px 36px rgba(16,44,73,.2); }
.server-popover h3 { margin: 0 0 12px; color: var(--text); }
.server-popover dl { display: grid; grid-template-columns: 1fr auto; gap: 7px 14px; margin: 0; }
.server-popover dd { margin: 0; font-weight: 700; }
.server-state-amber .server-dot { background: #d89a32; animation-name: rc-server-pulse-amber; }
.server-state-red .server-dot { background: #c94b4b; animation: none; box-shadow: none; }
.server-state-gray .server-dot { background: #8c98a3; animation: none; box-shadow: none; }
@keyframes rc-server-pulse-amber { 0% { box-shadow: 0 0 0 0 rgba(216,154,50,.42); } 70% { box-shadow: 0 0 0 8px rgba(216,154,50,0); } 100% { box-shadow: 0 0 0 0 rgba(216,154,50,0); } }
.notification-center { position: relative; justify-self: end; }
.notification-button { position: relative; display: grid; place-items: center; width: 36px; height: 36px; padding: 0; color: #fff; border: 1px solid rgba(255,255,255,.25); border-radius: 7px; background: transparent; cursor: pointer; }
.notification-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.notification-button > span { position: absolute; top: -6px; right: -7px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; color: #fff; background: #c94b4b; font-size: .65rem; font-weight: 750; line-height: 18px; }
.notification-button > span[aria-busy="true"] { background: #7d8b96; }
.notification-popover { position: absolute; top: 42px; right: 0; z-index: 90; width: min(360px, calc(100vw - 24px)); max-height: min(520px, calc(100vh - 90px)); overflow: hidden; color: var(--text); border: 1px solid var(--border); border-radius: 10px; background: #fff; box-shadow: 0 16px 36px rgba(16,44,73,.2); }
.notification-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 15px; border-bottom: 1px solid var(--border); }
.notification-head h3 { margin: 0; font-size: 1rem; }
.notification-head button { padding: 4px; color: var(--navy); border: 0; background: transparent; font-size: .75rem; cursor: pointer; }
.notification-list { display: grid; max-height: 430px; overflow-y: auto; }
.notification-item { display: grid; gap: 4px; width: 100%; padding: 12px 15px; color: var(--text); border: 0; border-bottom: 1px solid var(--border); border-left: 3px solid #2475b5; background: #f5f9fc; text-align: left; cursor: pointer; }
.notification-item.priority-high { border-left-color: #d89a32; }
.notification-item.priority-critical { border-left-color: #c94b4b; }
.notification-item.is-read { border-left-color: transparent; background: #fff; }
.notification-item span, .notification-item small { color: var(--muted); }
.notification-item small { font-size: .68rem; }

.rc-workspace .left-panel { position: relative; display: grid; min-height: 0; grid-template-rows: minmax(0, 178px) minmax(0, 1fr) minmax(0, 64px); padding: 0; overflow: hidden; transition: width 200ms ease; }
.sidebar-top { min-height: 0; padding: 15px 16px 12px; border-bottom: 1px solid var(--border); overflow: hidden; }
.sidebar-top .new-task-button { height: 48px; min-height: 48px; margin-top: 10px; }
.history-search-rail { display: none; }
.conversation-row { position: relative; display: flex; align-items: stretch; }
.conversation-row .conversation-item { flex: 1 1 auto; min-width: 0; padding-right: 34px; }
.conversation-delete-button { position: absolute; top: 50%; right: 3px; width: 30px; height: 30px; transform: translateY(-50%); border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; opacity: 0; visibility: hidden; pointer-events: none; }
.conversation-item:hover .conversation-delete-button,
.conversation-item:focus-within .conversation-delete-button,
.conversation-row:has(.conversation-item:hover) .conversation-delete-button,
.conversation-row:focus-within .conversation-delete-button { opacity: 1; visibility: visible; pointer-events: auto; }
.conversation-delete-button:hover { background: #f5e8e8; color: var(--danger); }
@media (hover: none), (pointer: coarse) {
  .conversation-delete-button { min-width: 44px; min-height: 44px; width: 44px; height: 44px; opacity: 1; visibility: visible; pointer-events: auto; }
}
.sidebar-history { min-height: 0; overflow: hidden; padding: 12px 16px 0; }
.history-scroll { position: relative; height: 100%; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 14px; }
.history-heading { position: sticky; top: 0; z-index: 5; background: var(--page); }
.history-search { width: 100%; height: 40px; min-height: 40px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px; background: #fff; color: var(--text); }
.history-heading > button { width: 100%; padding: 9px 0; border: 0; color: var(--muted); background: transparent; text-align: left; font-size: .74rem; font-weight: 750; text-transform: uppercase; cursor: pointer; }
.history-menu { position: fixed; z-index: 90; display: grid; width: 190px; max-width: calc(100vw - 24px); padding: 5px; border: 1px solid var(--border); border-radius: 9px; background: #fff; box-shadow: 0 12px 28px rgba(23,49,72,.18); }
.history-menu button { padding: 8px; border: 0; border-radius: 5px; background: transparent; text-align: left; cursor: pointer; }
.history-menu button:hover { background: var(--selected); }
.history-group-title { width: 100%; padding: 7px 2px; border: 0; color: var(--muted); background: transparent; text-align: left; font-size: .7rem; font-weight: 750; }
.history-empty { display: grid; gap: 8px; margin: 14px 2px; color: var(--muted); font-size: .82rem; }
.history-empty button { justify-self: start; padding: 0; border: 0; background: transparent; color: var(--link); font: inherit; text-decoration: underline; cursor: pointer; }
.history-empty-state { display: grid; gap: 5px; margin: 12px 2px; }
.history-empty-state a { color: var(--link); font-size: .76rem; line-height: 1.35; text-decoration: none; }
.history-empty-state a:hover { text-decoration: underline; }
.conversation-item { position: relative; min-height: 64px; padding: 7px 9px; }
.left-panel:not(.is-collapsed) .conversation-item { min-height: 64px; overflow: hidden; }
.conversation-title { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; white-space: normal; line-height: 1.18; }
.conversation-meta, .conversation-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-meta { color: var(--muted); font-size: .7rem; }
.conversation-preview { color: var(--muted); font-size: .67rem; line-height: 1.1; }
.history-refresh-error { margin: 8px 2px; color: var(--danger); font-size: .75rem; }
.history-refresh-error button { padding: 0; border: 0; color: var(--link); background: transparent; font: inherit; text-decoration: underline; cursor: pointer; }
.conversation-mark { display: none; }
.conversation-mark svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.conversation-item.is-active::before { content: ""; position: absolute; inset: 5px auto 5px 0; width: 3px; border-radius: 3px; background: #2475b5; }
.unread-dot { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: #1976d2; }
.sidebar-bottom { display: grid; min-height: 0; grid-template-rows: minmax(0,1fr); overflow: hidden; background: #fff; }
.sidebar-identity-card { display: grid; min-height: 0; grid-template-rows: minmax(0,64px); border-top: 1px solid var(--border); background: #fff; }
.sidebar-profile-link { display: grid; min-width: 0; grid-template-columns: 36px minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 0 16px; color: var(--text); text-decoration: none; }
.sidebar-profile-link:hover { background: var(--selected); color: var(--navy); }
.profile-copy { display: grid; min-width: 0; overflow: hidden; }
.profile-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-edge-button { position: absolute; z-index: 20; width: 28px; height: 40px; border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer; }
.left-edge-button { top: 12px; right: -14px; }

.rc-workspace .workspace { display: flex; min-height: 0; flex-direction: column; padding: 0; overflow: hidden; }
.conversation-header { flex: 0 0 auto; padding: 14px 22px 8px; border-bottom: 1px solid var(--border); background: #fff; }
.task-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.task-heading h2 { margin: 0; color: var(--navy-deep); font-size: 1.25rem; }
.task-heading p { margin: 3px 0 0; color: var(--muted); font-size: .78rem; }
.status-badge.completed { color: #2b765d; background: var(--green-bg); border-color: var(--green-border); }
.task-controls-summary { display: flex; align-items: center; justify-content: space-between; width: 100%; height: 46px; margin-top: 8px; padding: 0 12px; border: 0; border-radius: 8px; color: #24445c; background: #f1f5f7; cursor: pointer; }
.task-controls-panel { max-height: 220px; margin-top: 6px; padding: 8px 10px; border-radius: 8px; background: #f1f5f7; overflow: hidden; transition: max-height 180ms ease, opacity 180ms ease; }
.controls-main, .controls-extra { display: flex; align-items: center; gap: 10px; }
.ai-chat-controls { display: flex; align-items: end; gap: 10px; }
.ai-selection-control { display: grid; gap: 2px; color: var(--muted); font-size: .76rem; }
.ai-selection-switch { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid #c4d2dd; border-radius: 8px; background: #fff; }
.ai-selection-switch button { min-height: 30px; padding: 4px 10px; color: var(--navy); border: 1px solid transparent; border-radius: 6px; background: transparent; cursor: pointer; }
.ai-selection-switch button.is-active { color: #fff; border-color: var(--navy); background: var(--navy); }
.ai-selection-switch button:disabled { color: #8493a0; background: #eef2f5; cursor: not-allowed; }
.ai-selection-switch button:focus-visible { outline: 3px solid rgba(36,117,181,.3); outline-offset: 2px; }
.mode-control { display: grid; gap: 2px; }
.mode-switch-label { color: var(--muted); font-size: .76rem; }
.mode-switch { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid #c4d2dd; border-radius: 8px; background: #fff; }
.mode-switch button { min-width: 78px; min-height: 30px; padding: 4px 14px; color: var(--navy); border: 1px solid transparent; border-radius: 6px; background: transparent; cursor: pointer; }
.mode-switch button.is-active { color: #fff; border-color: var(--navy); background: var(--navy); box-shadow: 0 1px 3px rgba(16,44,73,.2); }
.mode-switch button.is-active:hover { background: var(--navy-deep); }
.mode-switch button:focus-visible { outline: 3px solid rgba(36,117,181,.3); outline-offset: 2px; }
.task-controls-panel label { min-width: 120px; color: var(--muted); font-size: .76rem; }
.task-controls-panel select { display: block; max-width: 180px; margin-top: 2px; padding: 5px 24px 5px 7px; border: 1px solid #c4d2dd; border-radius: 6px; background: #fff; }
.extra-toggle { display: flex; justify-content: space-between; width: 100%; margin-top: 5px; padding: 6px 0 2px; border: 0; border-top: 1px solid #d8e1e7; color: var(--muted); background: transparent; cursor: pointer; }
.controls-extra { margin-top: 5px; padding-top: 5px; border-top: 1px solid #d8e1e7; }
.conversation-stage { min-height: 0; flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: auto; padding: 14px max(20px, calc((100% - 840px)/2)); }
.starter-actions { display: grid; gap: 10px; max-width: 680px; margin: auto; padding: 20px 0; }
.starter-actions p { margin: 0; color: var(--muted); font-size: .88rem; }
.starter-actions > div { display: flex; flex-wrap: wrap; gap: 8px; }
.starter-actions button, .starter-actions a { min-height: 36px; padding: 7px 10px; border: 1px solid #c4d2dd; border-radius: 7px; color: var(--navy); background: #fff; font: inherit; font-size: .84rem; font-weight: 650; text-decoration: none; cursor: pointer; }
.starter-actions button:hover, .starter-actions a:hover { border-color: #8eafc7; background: #f6f9fb; }
.starter-actions button:disabled { color: var(--muted); border-color: var(--border); background: #f6f8fa; cursor: not-allowed; }
.starter-next-step { padding-left: 10px; border-left: 3px solid #8eafc7; color: #35566e !important; }
.message-identity { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.message-role-avatar { display: grid; place-items: center; flex: 0 0 auto; width: 30px; height: 30px; color: #1b4565; border: 1px solid #a9c3d5; border-radius: 50%; background: #f3f8fc; font-size: .68rem; font-weight: 800; line-height: 1; }
[data-message-role-avatar="user"] { color: #fff; border-color: #397eae; background: #236b9f; }
[data-message-role-avatar="roman-codex"] { color: #174d76; border-color: #8db7d4; background: #fff; }
[data-message-role-avatar="local"] { color: #2d5f50; border-color: #9ec9bb; background: #f1faf6; }
[data-message-role-avatar="imported-mac"] { color: #555f70; border-color: #bdc7d2; background: #f7f8fa; }
.message-author { color: var(--muted); font-size: .72rem; font-weight: 700; line-height: 1.25; }
.dialog-message, .task-card { margin: 6px 0; padding: 10px 13px; border-radius: 7px; }
.dialog-message.user, .task-request { max-width: 84%; margin-left: auto; border: 1px solid #8fb8d4; background: #e0f0ff; }
.dialog-message.assistant, .task-answer { background: #fff; border-left: 3px solid #2d77b3; }
.dialog-message small, .task-card small { color: var(--muted); font-size: .72rem; }
.dialog-message .message-author, .task-card .message-author { color: var(--muted); font-size: .72rem; font-weight: 700; }
.dialog-message p, .task-card p { margin: 5px 0; white-space: pre-wrap; line-height: 1.5; }
.assistant-markdown-table-wrap { width: 100%; max-width: 100%; margin: 8px 0; overflow-x: auto; overscroll-behavior-inline: contain; -webkit-overflow-scrolling: touch; }
.assistant-markdown-table-wrap table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: .88rem; line-height: 1.4; }
.assistant-markdown-table-wrap th, .assistant-markdown-table-wrap td { max-width: 32rem; padding: 7px 9px; border: 1px solid #cfdae3; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.assistant-markdown-table-wrap th { color: var(--navy-deep); background: #f2f7fa; font-weight: 750; }
.conversation-stage .dialog-message { display: block; }
.conversation-stage .dialog-message > small { display: block; }
.conversation-stage .task-card { display: block; }
.conversation-stage .task-request, .conversation-stage .task-answer { display: block; padding: 10px 13px; }
.conversation-stage .task-answer { margin-top: 8px; }
.message-sources { margin-top: 12px; border-top: 1px solid #d6e2ec; padding-top: 9px; }
.message-sources summary { width: max-content; cursor: pointer; color: #315b7c; font-size: .82rem; font-weight: 750; }
.message-source-list { display: grid; gap: 7px; margin-top: 9px; }
.message-source { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px; min-height: 38px; padding: 7px 10px; border: 1px solid #d6e2ec; border-radius: 9px; background: #f8fbfd; color: #163b5b; text-decoration: none; }
.message-source:hover, .message-source:focus-visible { border-color: #7db4da; background: #eff7fc; }
.message-source span { display: grid; place-items: center; min-width: 28px; height: 24px; padding-inline: 5px; border-radius: 999px; background: #dceefa; color: #145983; font-size: .72rem; font-weight: 800; }
.message-source strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .82rem; }
.agent-badge { display: inline-flex; align-items: center; width: max-content; max-width: 100%; margin: 8px 0 2px !important; padding: 5px 9px; border: 1px solid #bad8ca; border-radius: 999px; color: #245d4b; background: #edf8f3; font-size: .75rem; font-weight: 750; }
.conversation-stage [data-task-state-label] { display: inline-block; margin-top: 5px; color: var(--green); font-size: .75rem; font-weight: 700; }
.result-files { display: grid; gap: 8px; margin-top: 12px; }
.result-file-card { display: grid; grid-template-columns: 42px minmax(0,1fr) auto; gap: 11px; align-items: center; min-height: 62px; padding: 9px 11px; border: 1px solid #c8d8e4; border-radius: 9px; background: #f7fafc; }
.result-file-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 8px; color: #174d76; background: #e4f0f8; font-size: .68rem; font-weight: 800; letter-spacing: .03em; }
.result-file-copy { min-width: 0; }
.result-file-copy strong, .result-file-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-file-copy small { margin-top: 3px; color: var(--muted); font-size: .72rem; }
.result-file-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.result-file-actions a { min-height: 36px; padding: 8px 11px; border: 1px solid #b7cbd9; border-radius: 7px; color: var(--navy); background: #fff; text-decoration: none; font-weight: 700; }
.result-file-actions a:last-child { color: #fff; border-color: var(--navy); background: var(--navy); }
.new-result-jump { position: absolute; left: 50%; bottom: 95px; z-index: 10; transform: translateX(-50%); padding: 8px 14px; border: 1px solid #b9ccd9; border-radius: 20px; background: #fff; box-shadow: 0 5px 16px rgba(16,44,73,.16); }
.workspace .composer { flex: 0 0 auto; width: 100%; margin: 0; padding: 8px 22px calc(9px + env(safe-area-inset-bottom)); border: 0; border-top: 1px solid var(--border); border-radius: 0; background: #fff; box-shadow: none; }
.composer-meta { margin-bottom: 4px; color: var(--muted); font-size: .72rem; }
.workspace .composer textarea { min-height: 82px; max-height: 220px; padding: 18px 164px 68px 144px; border: 0; border-radius: 0; resize: vertical; }
.composer-tools { margin-top: 5px; }
.attach-button { display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 5px 9px; border: 0; color: var(--navy); background: transparent; cursor: pointer; }

@media (max-width: 820px) {
  .workspace .composer textarea { min-height: 66px; padding: 13px 124px 66px 68px; }
  .result-file-card { grid-template-columns: 38px minmax(0,1fr); }
  .result-file-icon { width: 38px; height: 38px; }
  .result-file-actions { grid-column: 1 / -1; justify-content: stretch; }
  .result-file-actions a { flex: 1 1 120px; min-height: 44px; text-align: center; }
}

.rc-workspace .right-panel { position: relative; padding: 14px 16px; overflow: visible; }
.right-edge-button { top: 12px; left: -14px; }
.detail-panel { border-bottom: 1px solid var(--border); }
.detail-title { display: flex; justify-content: space-between; width: 100%; padding: 10px 0; border: 0; color: var(--navy-deep); background: transparent; text-align: left; cursor: pointer; }
.detail-title small { display: block; margin-top: 4px; color: var(--muted); font-weight: 450; }
.detail-body { padding: 0 0 12px; }
.detail-body dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.detail-body dd { margin: 0; text-align: right; }
.file-row { position: relative; display: grid; grid-template-columns: 38px minmax(0,1fr) 32px; gap: 9px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.file-row small { display: block; color: var(--muted); }
.file-row > button { width: 32px; height: 32px; border: 0; background: transparent; }
.file-actions { position: absolute; top: 39px; right: 0; z-index: 80; display: grid; width: 210px; max-width: min(250px, calc(100vw - 32px)); padding: 5px; border: 1px solid var(--border); border-radius: 8px; background: #fff; box-shadow: 0 12px 24px rgba(16,44,73,.17); }
.file-actions a, .file-actions button { padding: 8px; border: 0; color: var(--text); background: transparent; text-align: left; text-decoration: none; }
.right-preview { height: 100%; padding: 4px; background: #fff; }
.preview-head { display: flex; align-items: center; justify-content: space-between; }
.preview-head button { width: 30px; height: 30px; }
.preview-sheet { min-height: 340px; margin-top: 16px; padding: 18px; border: 1px solid var(--border); background: #f8fafb; color: var(--muted); }
.preview-frame { width: 100%; min-height: 520px; margin-top: 14px; border: 1px solid var(--border); background: #fff; }
.preview-links { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; font-size: .8rem; }
.right-rail { display: flex; height: 100%; flex-direction: column; align-items: center; gap: 18px; }
.file-rail-indicator { display: flex; align-items: center; gap: 4px; color: var(--muted); line-height: 1; }
.file-rail-indicator svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.file-rail-count { display: grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: #E5ECF2; color: var(--navy); font-size: .7rem; font-weight: 700; }

@media (min-width: 861px) {
  .left-panel.is-collapsed { width: 64px; grid-template-rows: 112px minmax(0,1fr) 64px; }
  .rc-workspace:has(.left-panel.is-collapsed) { grid-template-columns: 64px 64px minmax(0,1fr) 330px; }
  .left-panel.is-collapsed .panel-heading,
  .left-panel.is-collapsed .profile-copy,
  .left-panel.is-collapsed .sidebar-profile-link > b,
  .left-panel.is-collapsed .new-task-button span,
  .left-panel.is-collapsed .history-heading,
  .left-panel.is-collapsed .history-group-title,
  .left-panel.is-collapsed .conversation-item > strong,
  .left-panel.is-collapsed .conversation-item > span:not(.conversation-mark),
  .left-panel.is-collapsed .conversation-delete-button { display: none; }
  .left-panel.is-collapsed .sidebar-top { display: grid; align-content: start; justify-items: center; gap: 8px; padding: 14px 8px; }
  .left-panel.is-collapsed .new-task-button,
  .left-panel.is-collapsed .history-search-rail { display: flex; justify-content: center; width: 40px; min-width: 40px; min-height: 40px; margin: 0; padding: 7px; }
  .left-panel.is-collapsed .sidebar-history { display: block; padding: 8px; }
  .left-panel.is-collapsed .history-scroll { padding: 0; }
  .left-panel.is-collapsed .conversation-list { gap: 4px; padding: 0; }
  .left-panel.is-collapsed .conversation-row { justify-content: center; }
  .left-panel.is-collapsed .conversation-item { display: grid; place-items: center; flex: 0 0 40px; width: 40px; min-height: 40px; padding: 0; }
  .left-panel.is-collapsed .conversation-mark { display: grid; place-items: center; color: var(--navy); }
  .left-panel.is-collapsed .sidebar-bottom { grid-template-rows: 64px; }
  .left-panel.is-collapsed .sidebar-identity-card { grid-template-rows: minmax(0,1fr); }
  .left-panel.is-collapsed .sidebar-profile-link { grid-template-columns: 1fr; justify-items: center; padding: 0 8px; }
  .right-panel.is-collapsed { padding: 10px 6px; }
  .rc-workspace:has(.right-panel.is-collapsed) { grid-template-columns: 64px 328px minmax(0,1fr) 48px; }
  .rc-workspace:has(.left-panel.is-collapsed):has(.right-panel.is-collapsed) { grid-template-columns: 64px 64px minmax(0,1fr) 48px; }
}

.unified-settings {
  min-height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: 64px 250px minmax(0,1fr);
  grid-template-rows: 64px minmax(0,1fr);
  grid-template-areas: "rail top top" "rail settings-nav settings-main";
  overflow: hidden;
  background: var(--page);
}
.settings-topbar {
  grid-area: top;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 22px;
  min-height: 64px;
  padding: 0 28px;
  color: #fff;
  background: var(--navy-deep);
  border-bottom: 3px solid var(--bronze-on-dark);
}
.settings-topbar > a:last-child { color: #fff; }
.settings-topbar-title { justify-self: center; color: #c8d5df; font-size: .82rem; }
.settings-nav {
  grid-area: settings-nav;
  display: flex;
  min-height: 0;
  flex-direction: column;
  padding: 24px 14px 16px;
  border-right: 1px solid var(--border);
  background: #edf3f7;
  overflow-y: auto;
}
.settings-nav > p { margin: 0 10px 10px; color: var(--muted); font-size: .68rem; font-weight: 800; letter-spacing: .08em; }
.settings-nav > button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  color: var(--text);
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.settings-nav > button:hover { color: var(--navy); background: rgba(255,255,255,.72); }
.settings-nav > button[aria-current="page"] { color: var(--navy); background: #fff; box-shadow: inset 3px 0 var(--navy), 0 4px 14px rgba(16,44,73,.06); font-weight: 750; }
.settings-nav-footer { margin-top: auto; padding: 16px 8px 0; border-top: 1px solid var(--border); }
.settings-logout { width: 100%; min-height: 42px; color: var(--danger); border: 1px solid #e2bcbc; border-radius: 8px; background: #fff; cursor: pointer; }
.settings-nav-footer .form-error { margin: 8px 0 0; }
.settings-main { grid-area: settings-main; min-width: 0; min-height: 0; padding: 30px clamp(24px,4vw,58px) 64px; overflow-y: auto; overflow-x: hidden; }
.settings-main-header { display: flex; align-items: end; justify-content: space-between; gap: 20px; width: min(1100px,100%); margin: 0 auto 22px; }
.settings-main-header h1 { margin: 0; color: var(--navy-deep); line-height: 1.15; }
.settings-mobile-select { display: none; }
.settings-panel { width: min(1100px,100%); margin: 0 auto; }
.settings-stack { display: grid; gap: 16px; }
.settings-card, .settings-overview-primary {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(16,44,73,.035);
}
.settings-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.settings-card-heading h2, .settings-overview-primary h2 { margin: 0; color: var(--navy-deep); font-size: 1.12rem; }
.settings-card-heading p, .settings-overview-primary p { margin: 4px 0 0; color: var(--muted); }
.settings-overview { display: grid; gap: 16px; }
.settings-overview-primary { display: grid; grid-template-columns: 68px minmax(0,1fr) auto; gap: 18px; align-items: center; }
.settings-summary-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.settings-summary-grid :is(button,a) { display: grid; gap: 5px; min-height: 132px; padding: 20px; color: var(--text); border: 1px solid var(--border); border-radius: 11px; background: #fff; text-align: left; text-decoration: none; cursor: pointer; }
.settings-summary-grid :is(button,a):hover { border-color: #9fb8cb; background: #fafdff; }
.settings-summary-grid span { color: var(--muted); font-size: .75rem; font-weight: 750; text-transform: uppercase; }
.settings-summary-grid strong { color: var(--navy-deep); font-size: 1rem; }
.settings-summary-grid small { color: var(--muted); }
.settings-card .profile-layout { grid-template-columns: 68px minmax(0,1fr); }
.settings-card .inline-account-form { margin-top: 18px; }
.settings-card .card-action { align-self: flex-start; margin-top: 16px; }
.settings-card progress { width: 100%; margin-bottom: 12px; accent-color: var(--navy); }
.settings-card .session-row { border-right: 0; border-left: 0; border-radius: 0; }
.system-settings-form { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 15px; }
.system-settings-form label { display: grid; gap: 6px; color: var(--muted); font-size: .78rem; font-weight: 700; }
.system-settings-form :is(input,select) { width: 100%; min-height: 42px; padding: 8px 10px; color: var(--text); border: 1px solid var(--border); border-radius: 7px; background: #fff; }
.system-settings-form .system-checkbox { display: flex; align-items: center; flex-direction: row; gap: 9px; }
.system-settings-form .system-checkbox input { width: 20px; min-height: 20px; }
.system-settings-form > :is(button,.form-error,.form-success) { grid-column: 1 / -1; }
.users-heading { padding: 20px 22px; border: 1px solid var(--border); border-radius: 11px; background: #fff; }
.user-filter-bar { display: grid; grid-template-columns: minmax(220px,1fr) 220px; gap: 12px; margin: 16px 0; padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.user-filter-bar label { display: grid; gap: 5px; color: var(--muted); font-size: .75rem; font-weight: 700; }
.user-filter-bar :is(input,select) { min-height: 42px; padding: 8px 10px; color: var(--text); border: 1px solid var(--border); border-radius: 7px; background: #fff; }
.settings-panel .users-section { margin-top: 16px; }
.settings-confirm-dialog label { display: grid; gap: 6px; margin: 12px 0; color: var(--muted); font-size: .78rem; font-weight: 700; }
.settings-confirm-dialog input { min-height: 42px; padding: 8px 10px; color: var(--text); border: 1px solid var(--border); border-radius: 7px; background: #fff; }

.profile-page { min-height: 100vh; background: var(--page); }
.profile-topbar { display: flex; align-items: center; justify-content: space-between; min-height: 64px; padding: 0 28px; color: #fff; background: var(--navy-deep); border-bottom: 3px solid var(--bronze-on-dark); }
.profile-content { max-width: 1240px; margin: 0 auto; padding: 28px 34px 60px; }
.profile-content h1 { margin: 8px 0 20px; }
.cabinet-back { display: inline-block; margin-bottom: 12px; text-decoration: none; }
.account-summary { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; padding: 12px 16px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.account-state { color: var(--green); }
.profile-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.account-card { display: flex; min-height: 270px; flex-direction: column; padding: 24px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.account-card h2 { display: flex; align-items: center; gap: 10px; margin: -24px -24px 16px; padding: 16px 24px; border-bottom: 1px solid var(--border); font-size: 1.05rem; }
.account-card h2 svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.profile-layout { display: grid; grid-template-columns: 68px minmax(0,1fr) auto; gap: 18px; align-items: center; }
.profile-monogram { display: grid; place-items: center; width: 68px; height: 68px; border-radius: 50%; color: #fff; background: var(--navy); font-weight: 750; }
.profile-layout p, .profile-layout small { margin: 3px 0; overflow-wrap: anywhere; }
.account-row { display: grid; grid-template-columns: minmax(150px,.9fr) minmax(0,1.1fr); gap: 22px; align-items: start; padding: 9px 0; border-bottom: 1px solid var(--border); }
.account-row b { overflow-wrap: anywhere; }
.card-action { align-self: flex-start; margin-top: auto; }
.notification-row { display: grid; grid-template-columns: minmax(0,1fr) auto 42px; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); }
.notification-row small { display: block; color: var(--muted); }
.roman-switch { position: relative; width: 38px; height: 22px; padding: 2px; border: 0; border-radius: 22px; background: #aab5bf; }
.roman-switch i { display: block; width: 18px; height: 18px; margin-left: 0; border-radius: 50%; background: #fff; transition: margin 160ms ease; }
.roman-switch.is-on { background: #2a6f9f; }
.roman-switch.is-on i { margin-left: 16px; }
.inline-account-form, .security-details form { display: grid; gap: 10px; margin: 14px 0; padding: 14px; border: 1px solid var(--border); border-radius: 8px; background: #f8fafc; }
.inline-account-form[hidden] { display: none; }
.inline-account-form label, .security-details label { display: grid; gap: 5px; color: var(--muted); font-size: .82rem; }
.inline-account-form input, .security-details input { min-height: 40px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.security-details { margin: 12px 0; }
.security-details summary { cursor: pointer; color: var(--navy); font-weight: 650; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.account-card progress { width: 100%; height: 10px; margin: 0 0 10px; accent-color: var(--navy); }
.ai-periods { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.ai-periods .secondary-button { min-height: 36px; padding: 7px 12px; }
.ai-periods .is-active { color: #fff; background: var(--navy); border-color: var(--navy); }
.ai-metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.ai-metric-grid div { padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: #f8fafc; }
.ai-metric-grid span { display: block; color: var(--muted); font-size: .74rem; }
.ai-metric-grid b { display: block; margin-top: 3px; color: var(--navy-deep); font-size: 1.05rem; }
.plugin-update-card { margin-top: 16px; }
.plugin-update-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.plugin-update-grid > div { display: grid; gap: 4px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: #f8fafb; }
.plugin-update-grid span, .plugin-update-candidate span { color: var(--muted); font-size: .78rem; }
.plugin-update-grid small { color: var(--muted); }
.plugin-update-candidate { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 12px; align-items: start; }
.plugin-update-candidate code { overflow-wrap: anywhere; font-size: .78rem; }
.server-state-button { display: inline-flex; align-items: center; gap: 8px; color: inherit; border: 0; background: transparent; }
.form-success { color: var(--green); }
.connection-row > span { display: grid; grid-template-columns: 12px minmax(0,1fr); align-items: center; }
.connection-row > span small { grid-column: 2; color: var(--muted); font-weight: 400; }
.connection-row > div { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.connection-row .status-dot, .connection-row .ok-dot, .connection-row .warn-dot { display: inline-block; width: 8px; height: 8px; margin-right: 4px; border-radius: 50%; background: #38a77a; }
.connection-row .warn-dot { background: #d89a32; }
.connection-row .checking-dot { background: #8798a6; }
.connection-action { min-height: 32px; padding: 5px 9px; }
.action-list { display: grid; gap: 8px; }
.action-list button, .action-list a { padding: 9px 10px; color: var(--text); border: 1px solid var(--border); border-radius: 7px; background: #fff; text-align: left; text-decoration: none; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 12px; border-top: 1px solid #e3b8b8; }
.danger-zone p { display: grid; }
.collection-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.collection-list { display: grid; gap: 8px; }
.library-filters { display: grid; grid-template-columns: repeat(4,minmax(150px,1fr)); gap: 10px; margin-bottom: 16px; padding: 16px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.library-filters label { display: grid; gap: 5px; color: var(--muted); font-size: .78rem; }
.library-filters input, .library-filters select { min-width: 0; min-height: 38px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.library-filter-actions { display: flex; align-items: end; gap: 12px; }
.library-filter-actions a { padding: 8px 0; }
.collection-card { display: grid; grid-template-columns: 42px minmax(0,1fr) auto; gap: 12px; align-items: center; min-height: 72px; padding: 14px 16px; color: var(--text); border: 1px solid var(--border); border-radius: 8px; background: #fff; text-decoration: none; }
.collection-card:hover, .collection-card:focus-visible { border-color: #8eafc7; box-shadow: 0 4px 14px rgba(16,44,73,.08); }
.collection-card div { display: grid; gap: 4px; }
.collection-card small { color: var(--muted); }
.collection-card .collection-card-actions { display: flex; align-items: center; gap: 10px; }
.collection-card-actions a { color: var(--navy); font-weight: 700; text-decoration: none; }
.title-action { margin-left: 8px; padding: 2px 5px; color: var(--muted); border: 0; background: transparent; font-size: .85rem; }
.title-action:hover, .title-action:focus-visible { color: var(--navy); }
.dialog-message.is-streaming { border-color: #9dbdd4; }
.context-warning { margin: 4px 0 12px; padding: 8px 12px; color: #76520e; border: 1px solid #ead39c; border-radius: 7px; background: #fff9e9; font-size: .88rem; }
.ai-route-receipt { margin: 4px 0 12px; padding: 8px 12px; color: #24445c; border: 1px solid #bfd3e1; border-radius: 7px; background: #f2f8fc; font-size: .82rem; overflow-wrap: anywhere; }
.ai-route-receipt.is-model-mismatch { color: #8b1e1e; border-color: #e2a7a7; background: #fff1f1; }
.chat-progress-card { min-width: 0; overflow-wrap: anywhere; }
.task-stage { margin: 4px 0; border: 1px solid var(--border); border-radius: 7px; background: #fff; }
.task-stage summary { min-height: 38px; padding: 9px 12px; cursor: pointer; color: var(--muted); }
.task-stage p { margin: 0; padding: 0 12px 12px; }

@media (max-width: 860px) {
  .rc-workspace, .rc-workspace:has(.left-panel.is-collapsed), .rc-workspace:has(.right-panel.is-collapsed) { grid-template-columns: minmax(0,1fr); grid-template-areas: "top" "main"; }
  .rc-workspace .topbar { display: block; padding: 0 8px; }
  .rc-workspace .topbar > :not(.mobile-workspace-header) { display: none; }
  .rc-workspace .cabinet-app-rail-trigger { display: none !important; }
  .mobile-workspace-header { display: grid; grid-template-columns: 44px minmax(0,1fr) 20px 52px; gap: 8px; align-items: center; min-height: var(--topbar-height); }
  [data-mobile-chat-title] { min-width: 0; overflow: hidden; color: #fff; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; font-weight: 700; }
  .mobile-server-indicator { display: inline-grid; place-items: center; }
  .mobile-server-indicator .server-dot { width: 9px; height: 9px; }
  .mobile-files-trigger { position: relative; color: #fff; border-color: rgba(255,255,255,.25); }
  .mobile-files-trigger > span { position: absolute; top: 1px; right: 1px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; color: #fff; background: #2475b5; font-size: .65rem; font-weight: 750; line-height: 18px; text-align: center; }
  .conversation-header { display: none; }
  .conversation-header.is-mobile-controls-open { display: block; position: fixed; inset: calc(var(--topbar-height) + 8px) 8px auto; z-index: 55; box-sizing: border-box; max-height: calc(100dvh - var(--topbar-height) - 16px); padding: 8px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 18px 45px rgba(16,44,73,.22); }
  .conversation-header.is-mobile-controls-open .task-heading,
  .conversation-header.is-mobile-controls-open .task-controls-summary { display: none; }
  .conversation-header.is-mobile-controls-open .task-controls-panel { max-height: none; margin-top: 0; overflow: visible; }
  .mobile-task-controls-button { display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; color: var(--navy); border: 1px solid var(--border); border-radius: 7px; background: #fff; cursor: pointer; }
  .mobile-task-controls-close { display: grid; position: sticky; top: 0; z-index: 2; place-items: center; width: 44px; height: 44px; margin: 0 0 4px auto; padding: 0; color: var(--navy); border: 1px solid var(--border); border-radius: 7px; background: #fff; cursor: pointer; font-size: 1.3rem; }
  .app-rail { position: fixed; inset: 0 auto 0 0; z-index: 70; width: 72px; transform: translateX(-110%); transition: transform 180ms ease; box-shadow: 0 0 30px rgba(5,22,37,.3); }
  .rc-workspace .app-rail { display: none; }
  .app-rail.is-open { transform: translateX(0); }
  .app-rail-close { position: absolute; top: 8px; right: -46px; display: grid; place-items: center; width: 38px; height: 38px; padding: 0; color: var(--navy); border: 1px solid var(--border); border-radius: 9px; background: #fff; font-size: 1.2rem; }
  .app-rail:not(.is-open) .app-rail-close { visibility: hidden; pointer-events: none; }
  .has-app-rail { display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: 64px minmax(0,1fr); grid-template-areas: "header" "content"; }
  .has-app-rail > :is(.settings-content, .profile-content) { width: min(100% - 28px, 1240px); }
  .unified-settings { grid-template-columns: minmax(0,1fr); grid-template-rows: 64px minmax(0,1fr); grid-template-areas: "top" "settings-main"; }
  .settings-topbar { grid-template-columns: auto auto 1fr; padding: 0 14px; }
  .settings-topbar-title { display: none; }
  .settings-topbar > a:last-child { justify-self: end; font-size: .8rem; }
  .settings-nav { display: none; }
  .settings-main { padding: 22px 18px 50px; }
  .settings-main-header { align-items: stretch; flex-direction: column; }
  .settings-mobile-select { display: grid; gap: 5px; color: var(--muted); font-size: .76rem; font-weight: 700; }
  .settings-mobile-select select { min-height: 44px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
  .settings-overview-primary { grid-template-columns: 58px minmax(0,1fr); }
  .settings-overview-primary .profile-monogram { width: 58px; height: 58px; }
  .settings-overview-primary > button { grid-column: 1 / -1; }
  .settings-summary-grid, .system-settings-form { grid-template-columns: 1fr; }
  .user-filter-bar { grid-template-columns: 1fr; }
  .system-settings-form > :is(button,.form-error,.form-success) { grid-column: 1; }
  .top-state { display: none; }
  .rc-workspace .left-panel { display: grid; grid-template-rows: minmax(0, 178px) minmax(0, 1fr) minmax(0, 64px); position: fixed; inset: var(--topbar-height) auto 0 0; z-index: 60; width: min(86vw,320px); transform: translateX(-110%); transition: transform 180ms ease; box-shadow: 0 0 30px rgba(16,44,73,.22); }
  .rc-workspace .right-panel[data-mobile-file-sheet] { display: flex; position: fixed; inset: auto 0 0; z-index: 60; width: 100%; max-height: 75dvh; flex-direction: column; padding: 16px 16px calc(12px + env(safe-area-inset-bottom)); overflow-y: hidden; border: 1px solid var(--border); border-bottom: 0; border-radius: 18px 18px 0 0; transform: translateY(100%); transition: transform 180ms ease; box-shadow: 0 -10px 34px rgba(16,44,73,.22); }
  .rc-workspace .left-panel.is-open { transform: translateX(0); }
  .rc-workspace .right-panel[data-mobile-file-sheet].is-open { transform: translateY(0); }
  [data-mobile-file-sheet] > [data-right-panel-content] { display: flex; min-height: 0; flex: 1 1 auto; overflow-y: hidden; }
  [data-mobile-file-sheet] .ready-section { display: grid; width: 100%; min-height: 0; grid-template-rows: auto auto minmax(0,1fr); padding-top: 0; }
  [data-mobile-file-sheet] .section-title { padding-right: 52px; }
  [data-mobile-file-sheet] .ready-files { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  [data-mobile-file-sheet] .right-preview { width: 100%; min-height: 0; overflow-y: auto; }
  .rc-workspace .drawer-close { position: absolute; top: 8px; right: 8px; z-index: 3; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; border: 1px solid var(--border); border-radius: 6px; color: var(--navy); background: #fff; font-size: 1.1rem; line-height: 1; }
  .rc-workspace .sidebar-history { display: grid; grid-template-rows: auto minmax(0,1fr); padding: 0; }
  .rc-workspace .history-scroll { padding: 12px 16px 14px; }
  .rc-workspace .left-panel .history-search { height: 44px; min-height: 44px; }
  .rc-workspace .left-panel :is([data-history-filter], .history-menu button, .history-group-title, .history-refresh-error button, .history-empty button, .history-empty-state a) { min-width: 44px; min-height: 44px; }
  .rc-workspace .left-panel :is(.history-refresh-error button, .history-empty button, .history-empty-state a) { display: inline-flex; align-items: center; }
  .mobile-section-links { display: grid; gap: 2px; padding: 8px 48px 8px 10px; border-bottom: 1px solid var(--border); background: #fff; }
  .mobile-section-links a { display: grid; grid-template-columns: 22px minmax(0,1fr); gap: 10px; align-items: center; min-height: 44px; padding: 0 10px; color: var(--text); border-radius: 7px; text-decoration: none; font-weight: 650; }
  .mobile-section-links a:hover, .mobile-section-links a:focus-visible { color: var(--navy); background: var(--selected); }
  .mobile-section-links a.is-active { color: var(--navy); background: var(--selected); box-shadow: inset 3px 0 var(--navy); }
  .panel-edge-button { display: none; }
  .mobile-only { display: inline-flex; }
  .profile-grid { grid-template-columns: 1fr; }
  .collection-grid { grid-template-columns: 1fr; }
  .library-filters { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .profile-layout { grid-template-columns: 68px minmax(0,1fr); }
  .profile-layout > button { grid-column: 1 / -1; }
  .notification-popover { position: fixed; top: 58px; right: 8px; left: 8px; width: auto; }
  .icon-button, .notification-button, .drawer-close, .send-button, .attach-button { min-width: 44px; min-height: 44px; }
  [data-mobile-file-sheet] .file-row { grid-template-columns: 38px minmax(0,1fr) 44px; }
  [data-mobile-file-sheet] .file-row > button, [data-mobile-file-sheet] .preview-head button, .workspace .attachment-chip button { min-width: 44px; min-height: 44px; }
  [data-mobile-file-sheet] .file-actions a, [data-mobile-file-sheet] .file-actions button, [data-mobile-file-sheet] .preview-links a { display: flex; align-items: center; min-width: 44px; min-height: 44px; }
  [data-mobile-file-sheet] .file-actions { overscroll-behavior: contain; }
  [data-mobile-file-sheet] .file-actions.opens-up { top: auto; bottom: calc(100% - 4px); }
  .workspace .composer textarea { max-height: 120px; overflow-y: auto; resize: none; font-size: 16px; }
}

@media (max-width: 560px) {
  .library-filters { grid-template-columns: 1fr; }
  .conversation-header { padding-inline: 14px; }
  .controls-main, .controls-extra, .ai-chat-controls { align-items: stretch; flex-direction: column; }
  .task-controls-panel { max-height: 360px; }
  .task-controls-panel select { width: 100%; max-width: none; min-height: 44px; font-size: 16px; }
  .conversation-stage { padding-inline: 12px; }
  .workspace .composer { padding-inline: 12px; }
  .profile-content { padding: 20px 14px 50px; }
  .account-summary { align-items: flex-start; flex-direction: column; }
  .account-row { grid-template-columns: 1fr; gap: 3px; }
  .ai-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plugin-update-grid { grid-template-columns: 1fr; }
  .plugin-update-card [data-plugin-update-approve] { width: 100%; min-height: 44px; }
  .settings-main { padding-inline: 12px; }
  .settings-card { padding: 18px; }
  .settings-card-heading { align-items: stretch; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  .server-dot, .brand > span, .brand > b { animation: none !important; }
}
