:root {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color-scheme: light;
  --bg: #ffffff;
  --sidebar: #f7f7f5;
  --surface: #ffffff;
  --soft: #f5f5f3;
  --hover: #eeeeeb;
  --selected: #e9e9e6;
  --border: #e7e7e3;
  --text: #252521;
  --muted: #73736f;
  --muted-strong: #55554f;
  --accent: #22221e;
  --focus: #7b9ccb;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, textarea, select, input { font: inherit; }
button { cursor: pointer; color: inherit; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, textarea:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px;
}
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.app-shell, .codex-shell { min-height: 100dvh; width: 100%; }
.codex-shell { display: flex; height: 100dvh; overflow: hidden; }
.icon-rail { width: 62px; flex: 0 0 62px; background: #fbfaf9; border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; gap: 11px; padding: 52px 6px 14px; }
.rail-button { width: 43px; height: 43px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 12px; color: #80807d; background: transparent; }
.rail-button:hover, .rail-button.rail-active { background: #efeeec; color: #262622; }
.rail-button svg { width: 22px; height: 22px; }
.rail-spacer { flex: 1; }
.rail-avatar { width: 31px; height: 31px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: #1b9e8c; color: #fff; font-size: 11px; font-weight: 650; }
.sidebar { width: 430px; flex: 0 0 430px; background: #fbfaf9; border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.sidebar-top { height: 65px; padding: 0 19px; display: flex; align-items: center; justify-content: space-between; }
.sidebar-brand { display: flex; align-items: center; gap: 9px; font-size: 20px; font-weight: 640; letter-spacing: -.035em; }
.codex-mark, .welcome-symbol, .message-mark { display: inline-flex; align-items: center; justify-content: center; }
.codex-mark svg { width: 23px; height: 23px; stroke-width: 1.55; }
.new-chat-button { margin: 8px 12px 19px; display: flex; align-items: center; gap: 11px; min-height: 40px; width: calc(100% - 24px); padding: 0 10px; background: transparent; border: 0; border-radius: 8px; font-weight: 500; text-align: left; }
.new-chat-button:hover, .sidebar-row:hover { background: var(--hover); }
.new-chat-button svg { width: 18px; height: 18px; }
.sidebar-scroll { flex: 1; min-height: 0; overflow: auto; padding: 0 12px 20px; scrollbar-color: #d6d6d2 transparent; scrollbar-width: thin; }
.sidebar-section { margin-bottom: 22px; }
.sidebar-section h2 { color: #858580; font-size: 14px; line-height: 1.4; font-weight: 600; margin: 0 9px 8px; }
.sidebar-list { display: grid; gap: 2px; }
.sidebar-row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 37px; border: 0; border-radius: 8px; background: transparent; padding: 6px 9px; text-align: left; font-size: 14px; }
.sidebar-row.selected { background: var(--selected); font-weight: 600; }
.row-icon { flex: 0 0 18px; display: inline-flex; }
.row-icon svg, .sidebar-footer svg { width: 17px; height: 17px; }
.row-label { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex: 1; }
.sidebar-running { width: 6px; height: 6px; background: #4b8f66; border-radius: 50%; flex: 0 0 6px; }
.sidebar-empty { color: var(--muted); font-size: 13px; margin: 4px 10px 0; }
.sidebar-footer { padding: 11px 12px 16px; border-top: 1px solid var(--border); }
.main-panel { display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; background: var(--bg); }
.codex-topbar { height: 65px; min-height: 65px; display: flex; align-items: center; gap: 13px; padding: 0 28px; border-bottom: 1px solid var(--border); }
.topbar-title { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.topbar-title strong { font-size: 16px; font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-title span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-status { margin-left: auto; flex: none; color: var(--muted-strong); font-size: 12px; }
.topbar-status.running { color: #26754c; }
.topbar-status.failed { color: #aa453f; }
.welcome-panel { flex: 1; min-height: 0; overflow: auto; display: flex; align-items: center; justify-content: center; padding: 42px 24px 80px; }
.welcome-inner { width: min(100%, 720px); text-align: center; margin-top: -50px; }
.welcome-symbol svg { width: 36px; height: 36px; stroke-width: 1.25; }
.welcome-inner h1 { margin: 19px 0 3px; font-size: clamp(25px, 4vw, 32px); font-weight: 600; letter-spacing: -.045em; line-height: 1.22; }
.welcome-inner p { color: var(--muted); margin: 0 0 31px; font-size: 14px; }
.codex-composer { width: min(100%, 920px); background: var(--surface); border: 1px solid #e4e4e1; border-radius: 22px; box-shadow: 0 5px 22px rgba(25,25,20,.045); padding: 12px 17px 11px; text-align: left; }
.codex-composer:focus-within { border-color: #aaa9a3; box-shadow: 0 8px 34px rgba(25,25,20,.075); }
.project-selector-label { display: flex; align-items: center; gap: 8px; color: var(--muted-strong); font-size: 12px; font-weight: 600; margin: 1px 1px 10px; }
.project-selector-label select { max-width: min(100%, 330px); min-height: 30px; padding: 2px 24px 2px 8px; color: var(--text); background: var(--soft); border: 1px solid var(--border); border-radius: 7px; font-size: 12px; }
.codex-composer textarea { display: block; width: 100%; min-height: 70px; max-height: 240px; resize: vertical; background: transparent; border: 0; outline: 0; color: var(--text); padding: 3px 5px; font-size: 15px; line-height: 1.5; }
.codex-composer textarea::placeholder { color: #969690; }
.codex-composer textarea:disabled { cursor: not-allowed; }
.composer-bottom { display: flex; justify-content: space-between; align-items: end; gap: 12px; min-height: 34px; }
.composer-hint { color: #92928d; font-size: 11px; padding: 0 5px 4px; }
.send-button { width: 32px; height: 32px; flex: 0 0 32px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 9px; background: var(--accent); color: #fff; }
.send-button:hover:not(:disabled) { background: #454540; }
.send-button:disabled { opacity: .35; cursor: not-allowed; }
.send-button svg { width: 17px; height: 17px; }
.chat-main { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.codex-messages { width: 100%; flex: 1; overflow: auto; padding: 38px max(28px, calc((100% - 760px)/2)) 16px; scroll-behavior: smooth; }
.codex-message { display: flex; align-items: flex-start; gap: 12px; margin: 0 0 29px; max-width: 100%; }
.codex-message.user { justify-content: flex-end; }
.message-content { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.66; font-size: 14px; max-width: 100%; }
.codex-message.user .message-content { background: var(--soft); border-radius: 14px; padding: 10px 14px; max-width: min(100%, 620px); }
.message-mark { width: 24px; height: 24px; flex: 0 0 24px; border-radius: 7px; color: var(--text); }
.message-mark svg { width: 19px; height: 19px; }
.codex-message.system .message-content { color: var(--muted); font-size: 12px; }
.codex-activity { display: flex; align-items: center; gap: 9px; color: var(--muted-strong); font-size: 13px; margin: 5px 0 22px 36px; }
.pulse-dot { width: 7px; height: 7px; background: #57916c; border-radius: 50%; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; transform: scale(.7); } }
.chat-input-area { width: 100%; padding: 12px max(28px, calc((100% - 920px)/2)) 18px; background: linear-gradient(0deg,#fff 85%,rgba(255,255,255,.92)); }
.chat-input-area .codex-composer { width: 100%; }
.chat-input-area .codex-composer { padding-top: 10px; padding-bottom: 8px; }
.chat-input-area .codex-composer textarea { min-height: 34px; }
.running-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; margin: 0 0 10px; color: var(--muted); font-size: 12px; }
.stop-button { min-height: 32px; border: 1px solid var(--border); border-radius: 7px; padding: 3px 12px; background: var(--surface); }
.stop-button:hover { background: var(--hover); }
.privacy-note { text-align: center; font-size: 11px; margin: 9px 0 0; color: #9b9b96; }
.toast { position: fixed; z-index: 90; bottom: 25px; left: 50%; transform: translateX(-50%); max-width: min(90vw,500px); padding: 10px 16px; background: var(--text); color: #fff; box-shadow: 0 10px 30px #0002; border-radius: 8px; font-size: 13px; }
.mobile-only { display: none; }
.icon-button { border: 0; background: transparent; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 8px; }
.icon-button.mobile-only { display: none; }
.icon-button:hover { background: var(--hover); }
.sidebar-scrim { display: none; }

.login-screen { display: flex; min-height: 100dvh; align-items: center; justify-content: center; padding: 24px; background: var(--sidebar); }
.login-card { width: min(100%, 380px); background: #fff; border: 1px solid var(--border); box-shadow: 0 18px 55px rgba(20,20,15,.07); border-radius: 18px; padding: 32px; }
.login-card .brand-mark { display: inline-flex; width: 36px; height: 36px; align-items: center; justify-content: center; }
.login-card .brand-mark svg { width: 30px; height: 30px; }
.login-card h1 { font-size: 24px; line-height: 1.2; margin: 17px 0 6px; letter-spacing: -.035em; }
.login-card p { color: var(--muted); margin: 0 0 23px; font-size: 14px; }
.login-card .field { display: grid; gap: 7px; margin-bottom: 16px; font-size: 13px; font-weight: 600; }
.login-card input { width: 100%; height: 44px; border: 1px solid #d8d8d4; border-radius: 8px; padding: 0 12px; background: #fff; color: var(--text); }
.primary-button { min-height: 42px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; padding: 9px 15px; }
.primary-button:hover { background: #44443e; }
.primary-button:disabled { opacity: .5; cursor: not-allowed; }
.login-card .primary-button { width: 100%; }
.error-text { color: #a93833 !important; margin: 13px 0 0 !important; font-size: 13px !important; }

@media (max-width: 760px) {
  .icon-rail { display: none; }
  .sidebar { position: fixed; z-index: 60; top: 0; bottom: 0; left: 0; width: min(82vw, 290px); transform: translateX(-100%); transition: transform .2s ease; box-shadow: 12px 0 30px #00000012; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim.visible { display: block; position: fixed; inset: 0; z-index: 50; background: #0006; }
  .icon-button.mobile-only { display: inline-flex; }
  .codex-topbar { padding: 0 13px; height: 58px; min-height: 58px; }
  .topbar-title { flex: 1; }
  .topbar-status { max-width: 85px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .welcome-panel { padding: 30px 20px 55px; align-items: center; }
  .welcome-inner { margin-top: -30px; }
  .welcome-inner p { margin-bottom: 22px; }
  .codex-messages { padding: 24px 18px 10px; }
  .chat-input-area { padding: 10px 13px calc(12px + env(safe-area-inset-bottom)); }
  .composer-hint { display: none; }
  .codex-composer textarea { min-height: 68px; font-size: 16px; }
  .new-chat-button, .sidebar-row { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Desktop layout follows the four-pane Codex window reference. */
.codex-shell { display: grid; grid-template-columns: 62px 430px minmax(0,1fr); grid-template-rows: 47px minmax(0,1fr); }
.codex-shell:has(.preview-panel) { grid-template-columns: 62px 430px minmax(0,1fr) 403px; }
.window-bar { grid-column: 1 / -1; grid-row: 1; min-width: 0; display: flex; align-items: center; gap: 17px; padding: 0 17px; background: #edf2f5; border-bottom: 1px solid #dfe4e7; color: #40464a; font-size: 13px; }
.window-navigation, .window-menu { display: flex; align-items: center; gap: 8px; }
.window-menu { gap: 20px; }
.window-icon { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 6px; background: transparent; }
.window-icon:hover { background: #dce3e7; }
.window-icon svg { width: 16px; height: 16px; }
.forward-icon svg { transform: rotate(180deg); }
.window-divider { width: 1px; height: 18px; background: #cbd3d8; margin: 0 3px; }
.window-name { margin-left: auto; color: #7b8388; font-size: 12px; }
.icon-rail { grid-column: 1; grid-row: 2; width: 62px; min-height: 0; padding-top: 16px; }
.sidebar { grid-column: 2; grid-row: 2; width: 430px; min-height: 0; }
.main-panel { grid-column: 3; grid-row: 2; min-width: 0; }
.sidebar-top { justify-content: flex-start; gap: 7px; }
.sidebar-brand { margin-right: auto; font-size: 18px; }
.brand-chevron { color: #858585; font-size: 22px; line-height: 1; margin-top: -7px; font-weight: 400; }
.sidebar-search-button { width: 34px; height: 34px; }
.sidebar-search { padding: 0 14px 8px; }
.sidebar-search[hidden] { display: none; }
.sidebar-search input { width: 100%; height: 36px; border: 1px solid var(--border); border-radius: 8px; background: #fff; padding: 0 10px; outline: none; }
.show-more-button { width: 100%; min-height: 33px; border: 0; border-radius: 7px; background: transparent; text-align: left; padding: 5px 10px; color: var(--muted); font-size: 13px; }
.show-more-button:hover { background: var(--hover); color: var(--text); }
.chat-link { padding-left: 10px; }
.sidebar-list { grid-template-columns: minmax(0,1fr); }
.sidebar-row, .row-label { min-width: 0; }
.chat-link[hidden] { display: none; }
.topbar-folder { display: inline-flex; color: #7d7d78; }
.topbar-folder svg { width: 19px; height: 19px; }
.topbar-panel-button { margin-left: auto; }
.topbar-status + .topbar-panel-button { margin-left: 0; }
.preview-panel { grid-column: 4; grid-row: 2; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #fff; border-left: 1px solid #e4e4e1; }
.preview-tabs { height: 65px; min-height: 65px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 11px 0 15px; }
.preview-tab { display: inline-flex; align-items: center; gap: 9px; padding: 0 10px; height: 41px; border-radius: 8px; background: #f4f4f2; font-size: 13px; font-weight: 550; }
.preview-tab svg { width: 16px; height: 16px; }
.preview-toolbar { display: flex; align-items: center; gap: 9px; height: 54px; min-height: 54px; padding: 0 14px; border-bottom: 1px solid var(--border); }
.preview-site-icon { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; border-radius: 5px; background: #151515; color: white; font-size: 12px; font-weight: 700; }
.preview-address { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: #6f6f6c; font-size: 12px; }
.preview-toolbar .icon-button svg { width: 16px; height: 16px; }
.preview-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; }
.preview-symbol { width: 58px; height: 58px; display: inline-flex; align-items: center; justify-content: center; border-radius: 17px; background: #f3f3f1; color: #50504b; }
.preview-symbol svg { width: 27px; height: 27px; }
.preview-body h2 { font-size: 16px; font-weight: 600; margin: 20px 0 5px; }
.preview-body p { color: var(--muted); font-size: 13px; margin: 0 0 23px; overflow-wrap: anywhere; }
.preview-body p strong { color: var(--text); font-weight: 550; }
.preview-open { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 13px; border-radius: 8px; background: #262622; color: #fff; font-size: 13px; }
.preview-open:hover { background: #474741; }
.preview-open svg { width: 15px; height: 15px; }
.chat-input-area { padding-bottom: 19px; }
.chat-input-area .codex-composer { min-height: 103px; }
.chat-input-area .codex-composer textarea { min-height: 39px; }
@media (max-width: 1500px) {
  .codex-shell:has(.preview-panel) { grid-template-columns: 62px 430px minmax(0,1fr); }
  .preview-panel, .topbar-panel-button, #window-panel { display: none; }
}
@media (max-width: 950px) {
  .codex-shell, .codex-shell:has(.preview-panel) { grid-template-columns: 62px 280px minmax(0,1fr); }
  .sidebar { width: 280px; }
  .window-menu { display: none; }
}
@media (max-width: 760px) {
  .codex-shell, .codex-shell:has(.preview-panel) { display: flex; flex-direction: column; }
  .window-bar { height: 33px; min-height: 33px; padding: 0 13px; }
  .window-navigation { display: none; }
  .window-name { margin: 0; }
  .sidebar { width: min(82vw, 290px); }
  .main-panel { flex: 1; min-height: 0; }
  .topbar-folder { display: none; }
  .topbar-panel-button { display: none; }
}

/* A single dedicated workspace needs no project navigation or picker. */
.single-workspace .sidebar-section:has(#projects-heading),
.single-workspace #rail-projects,
.single-workspace .project-selector-label,
.single-workspace .welcome-inner > p,
.single-workspace .topbar-title span { display: none; }
