:root {
  --bg: #efe8db;
  --bg-accent: #d7e0d4;
  --panel: rgba(249, 248, 244, 0.96);
  --panel-strong: #fbfaf7;
  --ink: #1c241f;
  --muted: #5f675d;
  --line: rgba(38, 58, 44, 0.14);
  --line-strong: rgba(32, 58, 44, 0.24);
  --accent: #255f4a;
  --accent-2: #8f3b24;
  --soft: #ecf3ec;
  --warn: #8b3120;
  --shadow: 0 22px 50px rgba(24, 34, 26, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(143, 59, 36, 0.08), transparent 28%),
    radial-gradient(circle at top right, rgba(37, 95, 74, 0.10), transparent 34%),
    linear-gradient(180deg, #f4efe4 0%, var(--bg) 46%, #e6ede5 100%);
  font-family: "Trebuchet MS", "Gill Sans", "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

code,
pre,
.meta-code {
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

.page-shell {
  max-width: 1560px;
  margin: 0 auto;
  padding: 22px 22px 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,0.72), rgba(249,248,244,0.95));
  box-shadow: var(--shadow);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #214f40, #547a62);
  color: #f8fbf8;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.eyebrow,
.panel-eyebrow,
.section-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 11px;
  color: var(--muted);
}

.title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 32px;
  font-weight: 700;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.btn,
.btn-secondary,
.btn-small,
.btn-danger {
  appearance: none;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  padding: 11px 16px;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:hover,
.btn-secondary:hover,
.btn-small:hover,
.btn-danger:hover,
button:hover {
  transform: translateY(-1px);
}

.btn.primary,
button.primary,
.top-actions .btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 12px 24px rgba(37, 95, 74, 0.22);
}

.btn.ghost,
.btn-secondary,
button.ghost {
  background: rgba(255,255,255,0.82);
  color: var(--accent);
}

.btn.danger,
.btn-danger,
button.danger {
  background: rgba(255,255,255,0.82);
  color: var(--warn);
  border-color: rgba(139, 49, 32, 0.3);
}

.meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 16px 0 20px;
}

.meta-pill {
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 10px 14px;
  border-radius: 999px;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.9fr);
  gap: 22px;
  align-items: start;
}

.dashboard-main,
.dashboard-side {
  min-width: 0;
}

.dashboard-side {
  display: grid;
  gap: 22px;
}

.dashboard-stack,
.status-grid,
.control-grid,
.camera-grid {
  display: grid;
  gap: 18px;
}

.control-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.camera-grid {
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.95fr);
}

.status-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 18px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.panel.strong {
  background: linear-gradient(180deg, rgba(255,255,255,0.88), var(--panel-strong));
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-header h2,
.panel-header h3,
.panel h4,
.panel h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
}

.panel-copy,
.meta,
.subtle {
  color: var(--muted);
}

.preview-shell {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at top left, rgba(37,95,74,0.12), transparent 28%),
    linear-gradient(180deg, #dde8df 0%, #cfd9cc 100%);
}

.preview-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 0%, rgba(18, 28, 22, 0.10) 100%);
  pointer-events: none;
}

.camera-preview {
  width: 100%;
  display: none;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #d6ded3;
}

.preview-placeholder {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  color: var(--muted);
  text-align: center;
  padding: 20px;
}

.preview-toolbar,
.inline-actions,
.action-row,
.resolution-row,
.selector-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.selector-row select,
.resolution-row select,
.selector-row input,
.resolution-row input {
  min-width: 110px;
  max-width: 100%;
}

select,
input,
textarea {
  appearance: none;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 11px 14px;
  background: rgba(255,255,255,0.9);
  color: var(--ink);
}

textarea.script-editor {
  width: 100%;
  height: 260px;
  margin-top: 6px;
  border-radius: 18px;
  font-family: "IBM Plex Mono", Consolas, monospace;
}

.status-box,
.info-box,
.raw-box {
  margin-top: 12px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.62), rgba(236,243,236,0.92));
}

.status-box {
  white-space: pre-wrap;
}

.raw-box {
  white-space: pre-wrap;
  overflow: auto;
  max-height: 260px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}

.stat-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  padding-bottom: 6px;
  border-bottom: 1px dashed rgba(38, 58, 44, 0.12);
}

.stat-line b {
  color: var(--ink);
  text-align: right;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.78);
  border: 1px solid var(--line);
  color: var(--muted);
}

.chip strong {
  color: var(--ink);
}

.replay-list {
  display: grid;
  gap: 12px;
}

.audio-prompt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.audio-prompt-recorder {
  display: grid;
  gap: 12px;
  padding: 14px;
  margin: 14px 0;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.58);
}

.audio-prompt-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.74);
  box-shadow: 0 12px 24px rgba(24, 34, 26, 0.06);
}

.audio-prompt-card.ready {
  background: linear-gradient(180deg, rgba(236,243,236,0.98), rgba(255,255,255,0.92));
}

.audio-prompt-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.audio-prompt-title {
  font-weight: 800;
  font-size: 15px;
}

.audio-prompt-key {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

.audio-prompt-text {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.84);
  border: 1px dashed rgba(38, 58, 44, 0.14);
  color: var(--ink);
  line-height: 1.45;
}

.audio-prompt-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.audio-prompt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.audio-prompt-actions .btn {
  padding: 8px 12px;
  font-size: 13px;
}

.prompt-editor {
  width: 100%;
  min-height: 112px;
  resize: vertical;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  padding: 12px 14px;
  background: rgba(255,255,255,0.88);
  color: var(--ink);
}

.replay-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.72);
}

.replay-row.active {
  border-color: rgba(37, 95, 74, 0.32);
  background: linear-gradient(180deg, rgba(236,243,236,0.98), rgba(255,255,255,0.92));
}

.replay-main {
  min-width: 0;
}

.replay-title {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.replay-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.replay-tags,
.replay-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.replay-tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1;
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--line);
  color: var(--muted);
}

.replay-tag.active {
  background: rgba(37, 95, 74, 0.12);
  border-color: rgba(37, 95, 74, 0.28);
  color: var(--accent);
}

.replay-tag.warn {
  background: rgba(139, 49, 32, 0.08);
  border-color: rgba(139, 49, 32, 0.24);
  color: var(--warn);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.people-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

.person-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.78), rgba(236,243,236,0.94));
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 12px 26px rgba(24, 34, 26, 0.08);
}

.person-card-head {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: rgba(38, 58, 44, 0.08);
}

.person-card-head img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: #d7dfd5;
}

.person-card-body {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.person-title {
  font-weight: 800;
  font-size: 15px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.person-meta {
  color: var(--muted);
  font-size: 13px;
  white-space: pre-wrap;
}

.person-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.person-actions .btn,
.person-actions .btn-secondary,
.person-actions .btn-danger {
  padding: 8px 12px;
  font-size: 13px;
}

.card {
  background: rgba(255,255,255,0.72);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 12px 24px rgba(24, 34, 26, 0.07);
}

.card .thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  cursor: pointer;
  background: #d7dfd5;
}

.card-body {
  padding: 14px;
}

.card .name {
  font-weight: 700;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.photo-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.actions,
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.actions a,
.modal-actions a {
  color: var(--accent);
  text-decoration: none;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 18, 13, 0.62);
  backdrop-filter: blur(8px);
}

.modal-content {
  position: relative;
  width: min(960px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: #fbfaf7;
  border-radius: 24px;
  padding: 18px;
  box-shadow: 0 30px 60px rgba(0,0,0,0.24);
}

.modal-content img {
  width: 100%;
  border-radius: 18px;
}

.modal-wide {
  width: min(1000px, 100%);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.92);
  cursor: pointer;
}

.script-row {
  display: block;
}

@media (max-width: 1180px) {
  .dashboard-layout,
  .camera-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .topbar,
  .panel-header,
  .selector-row,
  .resolution-row,
  .preview-toolbar,
  .action-row,
  .top-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .control-grid,
  .status-grid,
  .info-grid {
    grid-template-columns: 1fr;
  }

  .page-shell {
    padding: 14px 14px 28px;
  }

  .title {
    font-size: 24px;
  }

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

  .replay-tags,
  .replay-row-actions {
    justify-content: flex-start;
  }
}
