.page-operator { background-color: var(--page-bg, var(--canvas)); }

.page-operator > main > [role="status"]:not(:empty):not([hidden]),
.page-operator > main > .form-error:not(:empty):not([hidden]) {
  display: block;
  background: var(--surface);
  border-radius: var(--radius-control);
  padding: 8px 12px;
  margin-bottom: 8px;
}

.page-operator > main > .form-error:not(:empty) { color: var(--danger); }

.quest-layout, .engine-layout, .connections-layout, .agent-layout, .setup-main, .result-main {
  width: min(1080px, calc(100% - 32px));
  margin: 8px auto 48px;
  padding: 8px 0 24px;
  color: var(--ink);
}

.subnav + main { margin-top: 0; }

.engine-layout,
.connections-layout,
.agent-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.quest-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 28px 32px;
}

.quest-compose {
  grid-column: 1 / -1;
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 20px;
}

.quest-history, .quest-detail, .engine-layout > .panel, .connections-layout > .panel, .agent-layout > .panel, .setup-main .panel {
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-card);
  padding: 20px;
}

.mode-switch, .auth-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  border: 0;
  margin: 0 0 16px;
  padding: 0;
}

.mode-option, .auth-option {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  column-gap: 10px;
  row-gap: 2px;
  align-items: center;
  min-height: 48px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}

.mode-option input,
.auth-option input {
  grid-column: 1;
  grid-row: 1;
  align-self: center;
}

.mode-option span,
.auth-option span {
  grid-column: 2;
  grid-row: 1;
  font-weight: 700;
}

.mode-option small,
.auth-option small {
  grid-column: 2;
  grid-row: 2;
  color: var(--body);
  font-weight: 400;
  line-height: 1.4;
}

.mode-question input { accent-color: var(--primary); }
.mode-command input { accent-color: var(--amber-line); }

.mode-question:has(input:checked),
.auth-option:has(input:checked) {
  border-color: var(--primary);
  background: var(--accent-weak);
}

.mode-command:has(input:checked) {
  border-color: var(--amber-line);
  background: var(--amber-bg);
}

.engine-layout input:not([type="checkbox"]):not([type="radio"]),
.engine-layout select,
.engine-layout textarea,
.connections-layout input:not([type="checkbox"]):not([type="radio"]),
.connections-layout select,
.quest-compose textarea {
  width: 100%;
  margin: 4px 0 12px;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.history-item, .secret-row, .engine-row {
  display: grid;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 10px;
  background: transparent;
  padding: 10px 8px;
  margin: 0;
  gap: 4px;
}

.history-item + .history-item,
.secret-row + .secret-row,
.engine-row + .engine-row { border-top: 1px solid var(--line); }

.history-item.is-selected { background: var(--accent-weak); }

.history-item.is-command strong { color: var(--amber); }
.history-item.is-question strong { color: var(--ink); }

.fact-list { display: grid; gap: 6px; margin-bottom: 16px; }

.fact-list div { display: flex; gap: 8px; }

.fact-list dt { color: var(--muted); min-width: 4.5em; font-weight: 600; }

#detail-answer, .action-result {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.action-result {
  max-height: 220px;
  overflow: auto;
  margin: 6px 0 0;
  padding: 10px;
  background: var(--canvas);
  border-radius: var(--radius-control);
}

.engine-layout details { margin: 8px 0 12px; }

.login-command {
  white-space: pre-wrap;
  margin: 4px 0 8px;
  padding: 10px;
  border-radius: var(--radius-control);
  background: var(--canvas);
}

#claude-login-panel { margin-bottom: 12px; }

#page-status:empty, #result-status:empty { display: none; }

@media (max-width: 800px) {
  .quest-layout { grid-template-columns: minmax(0, 1fr); }
  .mode-switch, .auth-switch { grid-template-columns: minmax(0, 1fr); }
  .quest-layout, .engine-layout, .connections-layout, .agent-layout, .setup-main, .result-main {
    width: min(100% - 24px, 1080px);
  }
}

.settings-shell > main.ops-page { gap: 20px; min-width: 0; }

.ops-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.ops-title {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.ops-head h2 { margin-bottom: 0; }

.ops-aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  max-width: 16em;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  text-align: right;
  overflow-wrap: anywhere;
}

.ops-engine { color: var(--ink); font-size: 14px; }

.ops-banner:empty { display: none; }

.ops-banner.stale,
.ops-banner.error {
  margin: 0;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 600;
}

.ops-banner.stale { background: var(--amber-bg); color: var(--amber); }
.ops-banner.error { background: var(--danger-bg); color: var(--danger); }

.ops-rows {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.ops-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--canvas);
}

.ops-severity {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.ops-severity.tone-ok { background: var(--solved-bg); color: var(--solved); }
.ops-severity.tone-wait { background: var(--amber-bg); color: var(--amber); }
.ops-severity.tone-bad { background: var(--danger-bg); color: var(--danger); }
.ops-severity.tone-info { background: var(--accent-weak); color: var(--primary); }
.ops-severity.tone-muted { background: var(--line); color: var(--body); }

.ops-copy { min-width: 0; }
.ops-cause { font-weight: 700; overflow-wrap: anywhere; }
.ops-remedy { color: var(--body); font-size: 14px; overflow-wrap: anywhere; }

.ops-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.ops-metric {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--canvas);
}

.ops-metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.ops-metric strong {
  color: var(--ink);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.ops-model-usage { margin-top: 28px; overflow-x: auto; }
.ops-model-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; }
.ops-model-table caption { text-align: left; font-size: 15px; font-weight: 700; padding-bottom: 14px; }
.ops-model-table th, .ops-model-table td { padding: 16px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.ops-model-table thead th { padding-top: 0; padding-bottom: 12px; color: var(--muted); font-size: 12px; font-weight: 600; }
.ops-model-table th:first-child { width: 23%; padding-left: 0; }
.ops-model-table th:nth-child(2), .ops-model-table th:nth-child(3) { width: 13%; text-align: right; }
.ops-model-table th:nth-child(4) { width: 31%; padding-left: 22px; }
.ops-model-table th:last-child { width: 20%; text-align: right; padding-right: 0; }
.ops-model-table tbody th { font-weight: 400; }
.ops-model-table tbody th strong { display: block; color: var(--ink); font-size: 14px; }
.ops-model-table small { display: block; color: var(--muted); font-size: 11px; line-height: 1.65; font-weight: 400; }
.ops-model-table .ops-model-tokens, .ops-model-table .ops-model-cost { text-align: right; font-variant-numeric: tabular-nums; }
.ops-model-table .ops-model-cost { padding-right: 0; }
.ops-model-table .ops-model-rates { padding-left: 22px; font-size: 12px; line-height: 1.65; }
.ops-model-rates p { margin: 0; }
.ops-model-rates a { display: inline-block; margin-top: 5px; font-size: 11px; }
.ops-rate-history summary { cursor: pointer; font-weight: 600; }
.ops-rate-entry { padding-top: 10px; }
.ops-rate-entry + .ops-rate-entry { border-top: 1px solid var(--line); margin-top: 10px; }
#ops-usage-notes { margin-top: 14px; }
#ops-usage-notes .ops-note { font-size: 12px; line-height: 1.7; }
#ops-selection-note { margin-top: 8px; font-size: 12px; }

.ops-status-link {
  display: inline-block;
  margin-top: 4px;
  font-weight: 700;
}

.ops-note { color: var(--body); font-size: 14px; overflow-wrap: anywhere; }
.ops-page a { overflow-wrap: anywhere; }

.ops-commands { margin-top: 4px; }
.ops-commands summary { font-weight: 700; cursor: pointer; }

.ops-command {
  margin: 4px 0 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--canvas);
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 13px;
  line-height: 1.45;
}
