:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #172019;
  --muted: #667064;
  --line: #d9ded6;
  --accent: #176b5b;
  --accent-strong: #0f4c41;
  --danger: #b23b3b;
  --warn: #946100;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

.login-dialog { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(23, 32, 25, 0.32); }
.login-dialog[hidden] { display: none; }
.login-box { width: min(380px, 100%); display: grid; gap: 14px; padding: 26px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); box-shadow: 0 18px 50px rgba(25, 38, 30, 0.2); }
.login-box h2, .login-box p { margin: 0; }
.login-box input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.login-error { min-height: 20px; color: var(--danger); font-size: 14px; }

.shell {
  width: min(980px, calc(100vw - 32px));
  margin: 32px auto;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

h1 {
  margin: 0 0 8px;
  font-size: 30px;
  font-weight: 760;
  letter-spacing: 0;
}

p {
  margin: 0;
  color: var(--muted);
}

.badge {
  min-width: 96px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef4ef;
  text-align: center;
  font-weight: 700;
}

.badge.recording {
  background: #e7f4ee;
  color: var(--accent-strong);
  border-color: #b8dacd;
}

.badge.error {
  background: #f7eaea;
  color: var(--danger);
  border-color: #ecc2c2;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 12px 34px rgba(25, 38, 30, 0.08);
}

form.panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.field {
  position: relative;
  display: grid;
  gap: 8px;
  min-width: 0;
}

.history-list {
  position: absolute;
  z-index: 10;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow: auto;
  border: 1px solid #b8dacd;
  border-radius: 8px;
  background: #fbfff8;
  box-shadow: 0 16px 38px rgba(25, 38, 30, 0.18);
}

.history-item {
  display: block;
  width: 100%;
  height: auto;
  min-height: 48px;
  padding: 9px 12px;
  border: 0;
  border-bottom: 1px solid #e3eadf;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 500;
}

.history-item:hover,
.history-item:focus {
  background: #e8f4ef;
}

.history-item:last-child {
  border-bottom: 0;
}

.history-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  color: var(--ink);
}

.history-url {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--muted);
}

.wide {
  grid-column: 1 / -1;
}

label span,
legend {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

input[type="url"],
input[type="text"],
input[type="datetime-local"] {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  font: inherit;
  background: #fff;
}

input:disabled {
  background: #f1f3ef;
  color: #8b9388;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segmented label {
  position: relative;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: grid;
  place-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
  color: var(--ink);
  font-size: 15px;
}

.segmented input:checked + span {
  border-color: var(--accent);
  background: #e8f4ef;
  color: var(--accent-strong);
}

.subtitle-options {
  gap: 12px;
}

.check-row,
.inline-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-row span {
  color: var(--ink);
  font-weight: 500;
}

.inline-field select {
  height: 36px;
  min-width: 140px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.save-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

button {
  height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 760;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button.secondary {
  background: #2d4d70;
}

button.danger {
  background: var(--danger);
}

button:disabled {
  cursor: not-allowed;
  background: #a9b0a8;
}

.actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 12px;
}

.status-panel {
  margin-top: 18px;
}

.batch-panel {
  margin-top: 18px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.section-heading h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.muted {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.batch-controls {
  display: grid;
  gap: 14px;
}

.batch-controls .save-row {
  display: grid;
}

.batch-controls input[type="text"] {
  min-width: 0;
}

.batch-controls .inline-field {
  justify-content: flex-start;
}

.batch-controls .inline-field button {
  margin-left: auto;
}

.status-grid {
  display: grid;
  grid-template-columns: 160px 1fr 180px 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.status-grid div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
}

.status-grid span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.status-grid strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 14px;
}

pre {
  min-height: 180px;
  max-height: 320px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border-radius: 6px;
  background: #101611;
  color: #d7e7dc;
  font: 13px/1.5 Consolas, "Courier New", monospace;
  white-space: pre-wrap;
}

@media (max-width: 760px) {
  .topbar,
  form.panel,
  .status-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
    align-items: start;
  }

  .save-row {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-direction: column;
  }
}
