:root {
  color-scheme: light;
  --canvas: #f2f4f1;
  --surface: #ffffff;
  --surface-muted: #f7f8f6;
  --text: #18211d;
  --muted: #657068;
  --border: #d9e0db;
  --green: #176b4d;
  --green-dark: #10523a;
  --blue: #2d628a;
  --rust: #9d4b32;
  --amber: #a36b12;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-bar { background: #14201a; color: #fff; border-bottom: 3px solid var(--green); }
.app-bar__inner { width: min(1180px, calc(100% - 32px)); min-height: 74px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand img { border-radius: 8px; flex: 0 0 auto; }
.brand h1 { margin: 0; font-size: 20px; line-height: 1.25; letter-spacing: 0; }
.brand span { display: block; margin-top: 2px; color: #afbbb4; font-size: 12px; }
.app-actions { display: flex; align-items: center; gap: 8px; }
.service-chip { min-height: 30px; display: inline-flex; align-items: center; padding: 5px 9px; border: 1px solid #435149; border-radius: 6px; color: #dce5df; font-size: 12px; white-space: nowrap; }
.service-chip.ok { border-color: #358565; color: #b9ead6; }
.service-chip.pending { border-color: #79653e; color: #e7d4a8; }

.workspace { width: min(1180px, calc(100% - 32px)); margin: 22px auto 40px; display: grid; grid-template-columns: minmax(0, 0.92fr) minmax(420px, 1.08fr); gap: 18px; align-items: start; }
.capture-section, .jobs-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.eyebrow { color: var(--muted); font-size: 12px; line-height: 1.2; }
h2 { margin: 3px 0 0; font-size: 19px; line-height: 1.3; letter-spacing: 0; }
.share-badge { border: 1px solid #b9d8ca; border-radius: 6px; background: #edf7f2; color: var(--green-dark); padding: 5px 8px; font-size: 12px; white-space: nowrap; }

.capture-form, .dialog-form { display: grid; gap: 14px; }
.field-row { display: grid; grid-template-columns: 0.75fr 1.25fr; gap: 12px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { color: var(--muted); font-size: 13px; }
input, select, textarea { width: 100%; min-width: 0; border: 1px solid var(--border); border-radius: 7px; background: #fff; color: var(--text); outline: none; padding: 10px 11px; line-height: 1.45; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 107, 77, 0.12); }
.form-footer { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.form-message { color: var(--muted); font-size: 13px; line-height: 1.4; }
.form-message.error { color: var(--rust); }

.primary-button, .secondary-button, .job-action, .icon-button { border-radius: 7px; font-weight: 650; }
.primary-button { min-height: 42px; border: 1px solid var(--green); background: var(--green); color: #fff; padding: 9px 16px; }
.primary-button:hover { background: var(--green-dark); border-color: var(--green-dark); }
.primary-button:disabled { opacity: 0.55; cursor: wait; }
.secondary-button { min-height: 34px; border: 1px solid #58655e; background: transparent; color: #fff; padding: 6px 11px; }
.icon-button { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--border); background: #fff; color: var(--text); font-size: 20px; line-height: 1; }

.status-legend { display: flex; gap: 14px; flex-wrap: wrap; margin: -6px 0 14px; color: var(--muted); font-size: 12px; }
.status-legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.dot--active { background: var(--blue); }
.dot--saved { background: var(--green); }
.dot--attention { background: var(--rust); }
.jobs-list { display: grid; border-top: 1px solid var(--border); }
.empty-state { padding: 30px 8px; text-align: center; color: var(--muted); font-size: 14px; }
.job-row { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 14px 2px; border-bottom: 1px solid var(--border); }
.job-main { min-width: 0; }
.job-title-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.job-title { font-size: 14px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-badge { flex: 0 0 auto; border-radius: 5px; padding: 3px 6px; background: #edf1ee; color: var(--muted); font-size: 11px; }
.status-badge.active { background: #eaf2f8; color: var(--blue); }
.status-badge.saved { background: #e9f5ef; color: var(--green); }
.status-badge.attention { background: #f9ece7; color: var(--rust); }
.job-meta, .job-error, .job-path { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.job-error { color: var(--rust); }
.job-path { color: var(--green-dark); }
.job-actions { display: flex; align-items: center; gap: 6px; }
.job-action { min-height: 32px; border: 1px solid var(--border); background: #fff; color: var(--text); padding: 5px 9px; font-size: 12px; white-space: nowrap; }

dialog { width: min(500px, calc(100% - 28px)); border: 1px solid var(--border); border-radius: var(--radius); padding: 0; color: var(--text); box-shadow: 0 18px 60px rgba(24, 33, 29, 0.22); }
dialog::backdrop { background: rgba(16, 24, 20, 0.55); }
.dialog-form { padding: 20px; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-heading h2 { margin: 0; }

@media (max-width: 860px) {
  .app-bar__inner, .workspace { width: min(100% - 22px, 680px); }
  .app-bar__inner { min-height: 68px; }
  .workspace { grid-template-columns: 1fr; margin-top: 12px; gap: 12px; }
  .capture-section, .jobs-section { padding: 15px; }
  #ai-state { display: none; }
  #siyuan-state { min-height: 28px; padding: 4px 7px; font-size: 11px; }
  .field-row { grid-template-columns: 1fr; }
  .form-footer { align-items: stretch; flex-direction: column; }
  .primary-button { width: 100%; }
  .job-row { grid-template-columns: 1fr; }
  .job-actions { justify-content: flex-end; }
}

@media (max-width: 420px) {
  .app-bar__inner { gap: 8px; }
  .brand { gap: 8px; }
  .brand h1 { font-size: 16px; }
  .brand span { display: none; }
  .brand img { width: 36px; height: 36px; }
  .app-actions { flex: 0 0 auto; gap: 4px; }
  #siyuan-state { min-height: 26px; padding-inline: 5px; }
  .secondary-button { min-height: 30px; padding-inline: 6px; }
  .section-heading { align-items: flex-start; }
}
