:root {
  color-scheme: light;
  --ops-sidebar: #101217;
  --ops-sidebar-soft: #181c23;
  --ops-sidebar-line: #2b313c;
  --ops-chat-bg: #ffffff;
  --ops-page-bg: #f4f6fa;
  --ops-border: #dbe1ea;
  --ops-muted: #6c7686;
  --ops-text: #202632;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ops-page-bg);
  color: var(--ops-text);
}

.login-screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  border-radius: 16px;
  box-shadow: 0 22px 70px rgba(28, 36, 50, .16);
}

.setup-card { width: min(520px, 100%); }

.qr-wrap {
  display: grid;
  place-items: center;
  padding: 14px;
  margin: 0 0 14px;
  border: 1px solid var(--ops-border);
  border-radius: 14px;
  background: #fff;
}

.qr-wrap img {
  width: 220px;
  height: 220px;
  display: block;
}

.error,
.schedule-error {
  color: var(--tblr-danger);
  min-height: 20px;
  margin: 10px 0 0;
  font-size: 14px;
}

.app-root {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 304px minmax(440px, 1fr) minmax(430px, 34vw);
  background: var(--ops-chat-bg);
}

.browser-hidden .app-root {
  grid-template-columns: 304px minmax(0, 1fr) 0;
}

.app-sidebar {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 18px;
  padding: 16px;
  overflow: hidden;
  color: #f4f6fb;
  background: var(--ops-sidebar);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.sidebar-brand strong {
  display: block;
  font-size: 16px;
  line-height: 1.15;
}

.sidebar-brand span {
  display: block;
  margin-top: 3px;
  color: #aab2c0;
  font-size: 12px;
}

.schedule-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.schedule-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.schedule-title strong {
  display: block;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #d7dbe3;
}

.schedule-title small {
  display: block;
  margin-top: 7px;
  color: #97a1b2;
}

.schedule-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
  padding-right: 2px;
}

.schedule-card {
  border: 1px solid var(--ops-sidebar-line);
  border-radius: 14px;
  padding: 12px;
  background: var(--ops-sidebar-soft);
}

.schedule-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.schedule-card-head a {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  line-height: 1.25;
}

.schedule-card-head a:hover { text-decoration: underline; }

.schedule-badge {
  min-width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 99px;
  background: #2c3340;
  color: #ccd3de;
  font-size: 12px;
  font-weight: 800;
}

.schedule-badge.checked {
  color: #b2f4df;
  background: rgba(32, 201, 151, .18);
}

.schedule-badge.not_connected {
  color: #ffe0a3;
  background: rgba(245, 159, 0, .18);
}

.schedule-note {
  margin: 10px 0 0;
  color: #c1c7d2;
  font-size: 12.5px;
  line-height: 1.45;
}

.post-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.post-link {
  display: grid;
  gap: 2px;
  padding: 8px;
  border: 1px solid var(--ops-sidebar-line);
  border-radius: 10px;
  background: #11161f;
  color: #fff;
  text-decoration: none;
}

.post-link small { color: #aab2c0; }

.sidebar-footer {
  display: grid;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--ops-sidebar-line);
  color: #aab2c0;
  font-size: 12px;
}

.chat-shell {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #fff;
}

.chat-toolbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ops-border);
  background: rgba(255, 255, 255, .98);
}

.pane-tabs {
  padding: 4px;
  border: 1px solid var(--ops-border);
  border-radius: 12px;
  background: #f6f8fb;
}

.pane-tab {
  border: 0;
  box-shadow: none;
}

.pane-tab.active {
  background: #fff;
  color: var(--tblr-primary);
  box-shadow: 0 2px 8px rgba(28, 36, 50, .08);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.toolbar-actions .form-select {
  width: auto;
  min-width: 132px;
}

.toolbar-actions .active-model {
  min-width: 160px;
}

.codex-stage {
  min-height: 0;
  overflow: hidden;
}

.pane {
  height: 100%;
  min-height: 0;
  display: none;
  grid-template-rows: minmax(0, 1fr) auto;
  position: relative;
}

.pane.active { display: grid; }
.pane-head { display: none; }

.pane.dragging::after {
  content: "Drop files to attach";
  position: absolute;
  inset: 16px;
  z-index: 5;
  display: grid;
  place-items: center;
  border: 2px dashed var(--tblr-primary);
  border-radius: 18px;
  background: rgba(255, 255, 255, .94);
  color: var(--tblr-primary);
  font-weight: 700;
}

.messages {
  min-height: 0;
  overflow: auto;
  padding: 28px max(32px, calc((100% - 900px) / 2));
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: #fff;
  font-size: 15px;
  line-height: 1.62;
}

.msg {
  max-width: min(84%, 780px);
  white-space: pre-wrap;
}

.msg.user {
  align-self: flex-end;
}

.msg.user .msg-text {
  padding: 11px 15px;
  border-radius: 18px;
  background: #eff1f5;
  color: #1f2937;
}

.msg.assistant {
  align-self: flex-start;
  width: min(100%, 820px);
}

.msg.tool,
.msg.error {
  align-self: center;
  width: min(100%, 900px);
  max-width: 900px;
  border-radius: 12px;
  padding: 10px 12px;
}

.msg.tool {
  background: #f6f8fb;
  color: #4b5563;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.msg.error {
  color: var(--tblr-danger);
  background: #fff4f4;
  border: 1px solid rgba(214, 57, 57, .22);
}

.msg-text:empty::before {
  content: "Working...";
  color: #9ca3af;
}

.msg-files,
.attachment-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.msg-files {
  margin-top: 8px;
}

.msg-files span,
.attachment-chip {
  max-width: 100%;
  border: 1px solid var(--ops-border);
  border-radius: 99px;
  padding: 4px 8px;
  background: #fff;
  color: #344054;
  font-size: 11.5px;
  line-height: 1.2;
}

.attachment-chip {
  cursor: pointer;
  background: #f6f8fb;
}

.composer {
  width: min(900px, calc(100% - 32px));
  margin: 0 auto 18px;
  padding: 8px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  grid-template-areas:
    "files files files"
    "attach text send";
  gap: 8px;
  align-items: end;
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(28, 36, 50, .12);
}

.attachment-row {
  grid-area: files;
}

.composer textarea {
  grid-area: text;
  min-height: 48px;
  max-height: 190px;
  resize: vertical;
  border: 0;
  box-shadow: none;
}

.composer-actions { display: contents; }
.attach-btn { grid-area: attach; width: 44px; height: 44px; }
.send-btn { grid-area: send; min-width: 92px; height: 44px; }

.browser-dock {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  border-radius: 0;
  border-left: 1px solid var(--ops-border);
  background: #f7f9fc;
}

.browser-hidden .browser-dock { display: none; }

.browser-head {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--ops-border);
  background: #fff;
}

.browser-head strong {
  display: block;
  line-height: 1.2;
}

.browser-head span {
  display: block;
  margin-top: 3px;
  color: var(--ops-muted);
  font-size: 12px;
}

.browser-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--ops-border);
  background: #fff;
}

iframe {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: #111827;
}

@media (max-width: 1180px) {
  .app-root {
    grid-template-columns: 284px minmax(390px, 1fr) minmax(360px, 38vw);
  }

  .browser-hidden .app-root {
    grid-template-columns: 284px minmax(0, 1fr) 0;
  }
}

@media (max-width: 960px) {
  .app-root,
  .browser-hidden .app-root {
    height: auto;
    min-height: 100%;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(720px, 1fr) minmax(520px, 58vh);
  }

  .browser-hidden .app-root {
    grid-template-rows: auto minmax(720px, 1fr) 0;
  }

  .app-sidebar {
    overflow: visible;
  }

  .browser-dock {
    border-left: 0;
    border-top: 1px solid var(--ops-border);
  }
}

@media (max-width: 700px) {
  .app-sidebar {
    padding: 12px;
  }

  .chat-toolbar {
    align-items: stretch;
    flex-direction: column;
    padding: 10px;
  }

  .pane-tabs,
  .toolbar-actions {
    width: 100%;
  }

  .pane-tab {
    flex: 1 1 0;
  }

  .toolbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
  }

  .toolbar-actions .form-select,
  .toolbar-actions .active-model {
    width: 100%;
    min-width: 0;
  }

  .messages {
    padding: 18px 14px;
  }

  .msg,
  .msg.assistant {
    width: 100%;
    max-width: 100%;
  }

  .composer {
    width: calc(100% - 20px);
    margin-bottom: 12px;
  }
}

@media (max-width: 430px) {
  .toolbar-actions,
  .browser-bar {
    grid-template-columns: 1fr;
  }

  .composer {
    grid-template-columns: 44px minmax(0, 1fr);
    grid-template-areas:
      "files files"
      "text text"
      "attach send";
  }

  .send-btn {
    width: 100%;
  }
}
