/* 草莓大棚 · 与 App 同协议，偏农场清爽风 */

:root {
  --bg: #f4f7f0;
  --card: #ffffff;
  --text: #1a2e1a;
  --muted: #5c6b5c;
  --accent: #2d6a4f;
  --accent-hover: #236050;
  --danger: #b42318;
  --border: #d8e4d4;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(26, 46, 26, 0.08);
  --font: "DM Sans", "Noto Sans SC", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: linear-gradient(165deg, #eef5ea 0%, var(--bg) 45%, #e8efe4 100%);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--accent);
}

header {
  padding: 1.25rem 1.5rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

header p {
  margin: 0.35rem 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem;
}

.page-layout {
  display: grid;
  grid-template-columns: 1fr minmax(280px, 380px);
  gap: 1rem;
  align-items: start;
}

.layout-main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.layout-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 0.75rem;
  align-self: start;
  max-height: calc(100vh - 1.5rem);
  overflow-y: auto;
  padding-bottom: 0.25rem;
}

.card--sidebar {
  padding: 1rem;
}

.card--sidebar h2 {
  font-size: 0.95rem;
}

.layout-sidebar .hint {
  font-size: 0.75rem;
  padding: 0.5rem 0.6rem;
}

.layout-sidebar .grid.grid-2 {
  grid-template-columns: 1fr;
}

.hint--inline {
  margin: 0 !important;
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.5rem !important;
  font-size: 0.72rem;
}

.preview-wrap--sidebar {
  min-height: 140px;
  margin-top: 0.5rem;
}

.preview-wrap--sidebar .preview-img {
  min-height: 120px;
}

@media (max-width: 960px) {
  .page-layout {
    grid-template-columns: 1fr;
  }
  .layout-sidebar {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
}

.hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 1rem;
  padding: 0.65rem 0.75rem;
  background: #f0f6ed;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* 滑块开关：横向轨道 + 圆形滑钮（锁定 / 定时预览 / MJPEG） */
label.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0;
  cursor: pointer;
  user-select: none;
  min-width: 0;
}

label.switch-row .switch-label {
  display: inline;
  margin-bottom: 0;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

/* 轨道尺寸：略扁长胶囊，便于看出「滑」的动作 */
.switch {
  position: relative;
  display: inline-block;
  width: 3.125rem;
  height: 1.75rem;
  flex-shrink: 0;
  vertical-align: middle;
}

.switch-input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
  margin: 0;
}

.switch-track {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: linear-gradient(180deg, #dbe5d6 0%, #c5d1c1 100%);
  border-radius: 999px;
  border: 1px solid rgba(26, 46, 26, 0.2);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.07);
  transition: background 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}

/* 滑钮：沿轨道左右滑动 */
.switch-track::after {
  content: "";
  position: absolute;
  width: 1.375rem;
  height: 1.375rem;
  border-radius: 50%;
  left: 0.1875rem;
  top: 50%;
  transform: translateY(-50%);
  background: linear-gradient(180deg, #ffffff 0%, #f0f4ee 100%);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.14),
    0 2px 6px rgba(0, 0, 0, 0.1);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 开启：轨道着色 + 滑钮滑到右侧（行程 = 轨宽 − 左右边距 − 滑钮直径） */
.switch-input:checked + .switch-track {
  background: linear-gradient(180deg, #3a966f 0%, var(--accent) 100%);
  border-color: rgba(26, 46, 26, 0.28);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.12);
}

.switch-input:checked + .switch-track::after {
  transform: translateY(-50%) translateX(1.375rem);
}

.switch-input:focus-visible + .switch-track {
  outline: 2px solid rgba(45, 106, 79, 0.5);
  outline-offset: 3px;
}

label.switch-row:hover .switch-input:not(:disabled) + .switch-track {
  filter: brightness(1.03);
}

.switch-input:disabled + .switch-track {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.15);
}

.switch-input:disabled + .switch-track::after {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.grid {
  display: grid;
  gap: 0.75rem;
}

@media (min-width: 520px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

select.input-select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: #fafcf9;
  color: var(--text);
  cursor: pointer;
}

select.input-select:focus {
  outline: 2px solid rgba(45, 106, 79, 0.25);
  border-color: var(--accent);
}

input[type="text"],
input[type="password"],
textarea.input-block {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: #fafcf9;
}

textarea.input-block {
  min-height: 4.5rem;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
textarea.input-block:focus {
  outline: 2px solid rgba(45, 106, 79, 0.25);
  border-color: var(--accent);
}

.cmd-ref {
  font-size: 0.8rem;
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0 0;
}
.cmd-ref th,
.cmd-ref td {
  border: 1px solid var(--border);
  padding: 0.35rem 0.5rem;
  text-align: left;
  vertical-align: top;
}
.cmd-ref th {
  background: #eef4ea;
  color: var(--muted);
  font-weight: 600;
}
.cmd-ref code {
  font-size: 0.78rem;
  word-break: break-all;
}

.details-ref {
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  background: #fafcf9;
}
.details-ref summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}
.details-ref[open] summary {
  margin-bottom: 0.5rem;
}

kbd {
  font: inherit;
  font-size: 0.85em;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #fff;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font-weight: 500;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: #e4ebe1;
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: #d5dfd2;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.status-line {
  font-size: 0.9rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.status-ok {
  color: var(--accent);
  font-weight: 600;
}

.status-bad {
  color: var(--danger);
  font-weight: 600;
}

.error-box {
  margin-top: 0.5rem;
  padding: 0.5rem 0.65rem;
  font-size: 0.8rem;
  color: var(--danger);
  background: #fdeeee;
  border-radius: 8px;
  display: none;
}

.error-box.visible {
  display: block;
}

.log {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.72rem;
  line-height: 1.45;
  max-height: 220px;
  overflow: auto;
  padding: 0.75rem;
  background: #1a241c;
  color: #c8e6c8;
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-all;
}

.preview-wrap {
  margin-top: 0.75rem;
  border-radius: 8px;
  overflow: hidden;
  background: #0f140f;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-wrap img {
  max-width: 100%;
  height: auto;
  display: block;
}

.preview-placeholder {
  color: #6a7a6a;
  font-size: 0.85rem;
  padding: 1rem;
  text-align: center;
}

.preview-row {
  display: grid;
  gap: 1rem;
}

@media (min-width: 640px) {
  .preview-row {
    grid-template-columns: 1fr 1fr;
  }
}

.preview-pane {
  min-width: 0;
}

.preview-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.preview-wrap--tall {
  min-height: 200px;
}

.preview-img {
  max-width: 100%;
  height: auto;
  display: block;
  min-height: 160px;
  object-fit: contain;
}

canvas.preview-canvas {
  background: #0f140f;
  width: 100%;
  max-height: 70vh;
}

.recognition-out {
  border-left: 3px solid #2d6a4f;
}

.analysis-out {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  margin: 0;
  padding: 0.75rem;
  background: #f7faf6;
  border: 1px solid var(--border);
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow: auto;
}

.agent-reply-title {
  margin: 1rem 0 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
}

.agent-reply-out {
  font-family: "Noto Sans SC", "DM Sans", system-ui, sans-serif;
  font-size: 0.82rem;
  line-height: 1.55;
  margin: 0;
  padding: 0.75rem;
  background: #f0f7fb;
  border: 1px solid #b8d4e8;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow: auto;
  color: var(--text);
}

footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.75rem;
  color: var(--muted);
}
