:root {
  color-scheme: light;
  --bg: #f5f6f2;
  --surface: #ffffff;
  --ink: #18211d;
  --muted: #657067;
  --line: #d9ded7;
  --soft: #eef2ee;
  --strong: #0f6b4f;
  --strong-hover: #0a563f;
  --blue: #255ea8;
  --blue-strong: #1f66ff;
  --nav: #172033;
  --warn: #8a5a10;
  --error: #9f302b;
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

.shell {
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  padding: 8px 0 22px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--strong);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
  font-weight: 760;
}

h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.3;
}

h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
}

p {
  line-height: 1.65;
}

.top-status {
  min-height: 28px;
  color: var(--muted);
  font-size: 14px;
  text-align: right;
}

.surface {
  margin-top: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.dashboard {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 720px;
}

.workbench-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 760px;
  background: #f7f9fc;
}

.workbench-sidebar {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 18px;
  padding: 20px;
  color: #fff;
  background: linear-gradient(180deg, #1f66ff 0%, #1b4fd6 52%, #172033 100%);
}

.brand-panel {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  font-weight: 800;
}

.brand-panel strong,
.brand-panel span {
  display: block;
}

.brand-panel span,
.sidebar-note p {
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.access-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.1);
}

.access-card label {
  color: rgba(255, 255, 255, 0.82);
}

.access-card input {
  border-color: rgba(255, 255, 255, 0.22);
}

.access-card button {
  background: #fff;
  color: #153b9d;
}

.access-card button.secondary {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.workbench-nav {
  display: grid;
  align-content: start;
  gap: 8px;
}

.workbench-nav button {
  min-height: 58px;
  display: grid;
  justify-items: start;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
}

.workbench-nav button span {
  color: rgba(255, 255, 255, 0.58);
  font-size: 12px;
  font-weight: 650;
}

.workbench-nav button.active {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.16);
}

.workbench-nav button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.workbench-nav button.active:hover {
  background: rgba(255, 255, 255, 0.2);
}

.sidebar-note {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.14);
}

.sidebar-note p {
  margin: 6px 0 0;
}

.workbench-main {
  min-width: 0;
  background: #f7f9fc;
}

.workspace-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border: 1px solid #e1e7f2;
  border-radius: var(--radius);
  background: #fff;
}

.workspace-hero h2 {
  font-size: 24px;
}

.compact-hero h2 {
  font-size: 22px;
}

.workbench-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.primary-column {
  min-width: 0;
  display: grid;
  gap: 16px;
}

.tool-panel,
.task-center-panel,
.detail-panel,
.script-library-shell {
  border: 1px solid #e1e7f2;
  border-radius: var(--radius);
  background: #fff;
}

.tool-panel {
  padding: 18px;
}

.panel-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-title-row p {
  margin: 4px 0 0;
}

.tool-tips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tool-tips span {
  padding: 5px 8px;
  border-radius: 6px;
  background: #eef4ff;
  color: #2456bd;
  font-size: 12px;
  font-weight: 700;
}

.task-center-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.task-center-panel .section-subhead p {
  margin: 4px 0 0;
}

.task-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid #e1e7f2;
  border-radius: var(--radius);
  background: #fff;
}

.stat-card strong {
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
}

.detail-panel {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 16px;
  padding: 18px;
}

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

.detail-head h3 {
  margin-top: 3px;
}

.detail-link {
  font-size: 13px;
}

.status-rail {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.status-rail span {
  min-height: 32px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #edf1f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.status-rail .done {
  background: #dff1e8;
  color: #07543d;
}

.status-rail .current {
  background: #fff1d5;
  color: var(--warn);
}

.failed-rail {
  grid-template-columns: 1fr 1fr;
}

.status-rail .failed {
  background: #f8dddd;
  color: var(--error);
}

.detail-section {
  display: grid;
  gap: 8px;
}

.detail-section h4 {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
}

.detail-section p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.result-placeholder,
.detail-empty {
  padding: 16px;
  border: 1px dashed #cdd6e5;
  border-radius: var(--radius);
  background: #fbfcff;
  color: var(--muted);
  font-size: 14px;
}

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

.secondary-link {
  background: #e8eef8;
  color: var(--ink);
}

.secondary-link:hover {
  background: #d8e2f1;
}

.script-library-shell {
  padding: 20px;
}

.sidebar {
  padding: 22px;
  border-right: 1px solid var(--line);
  background: var(--soft);
}

.workspace {
  min-width: 0;
}

.workspace-section {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.section-head,
.section-subhead,
.task-meta,
.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-head p {
  margin: 4px 0 0;
}

.access-form,
.submit-panel,
.feedback-form {
  display: grid;
  gap: 14px;
}

.submit-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  line-height: 1.4;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

select {
  min-height: 42px;
}

input:focus,
textarea:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 2px solid rgba(15, 107, 79, 0.28);
  outline-offset: 2px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.actions.compact {
  gap: 8px;
}

button,
.button-link {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  background: var(--strong);
  color: #fff;
  font: inherit;
  font-weight: 720;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:hover,
.button-link:hover {
  background: var(--strong-hover);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button.secondary {
  background: #e2e8e4;
  color: var(--ink);
}

button.secondary:hover {
  background: #d6dfd9;
}

button.small,
.button-link.small {
  min-height: 32px;
  padding: 7px 10px;
  font-size: 13px;
}

.workbench-nav button {
  min-height: 58px;
  display: grid;
  justify-content: stretch;
  justify-items: start;
  align-content: center;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  text-align: left;
}

.tab-nav {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.tab-nav button {
  justify-content: flex-start;
  background: transparent;
  color: var(--ink);
  border: 1px solid transparent;
}

.tab-nav button.active {
  background: #fff;
  border-color: var(--line);
}

.muted {
  color: var(--muted);
}

.privacy-note,
.notice {
  color: var(--muted);
  font-size: 14px;
}

.privacy-note {
  margin: 0;
}

.notice {
  border-top: 1px solid var(--line);
  padding: 14px 24px;
  background: #fafbf8;
}

.empty-state,
.state {
  padding: 42px 24px;
  text-align: center;
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e7ece8;
  color: var(--ink);
  font-size: 13px;
  font-weight: 720;
  white-space: nowrap;
}

.status-pill.delivered {
  background: #dff1e8;
  color: #07543d;
}

.status-pill.pending {
  background: #fff1d5;
  color: var(--warn);
}

.status-pill.failed {
  background: #f8dddd;
  color: var(--error);
}

.task-grid {
  display: grid;
  gap: 12px;
}

.task-card {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.task-card.active {
  border-color: #8fb2ff;
  box-shadow: inset 3px 0 0 var(--blue-strong);
}

.thumb,
.material-cover {
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 6px;
  background: #e4e8e1;
}

.thumb img,
.material-cover img,
.result-title-row img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cover-placeholder {
  background: #e4e8e1;
}

.task-body,
.material-body {
  min-width: 0;
  display: grid;
  gap: 8px;
  align-content: start;
}

.task-meta {
  color: var(--muted);
  font-size: 13px;
}

.task-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.failure {
  margin: 0;
  color: var(--error);
  font-size: 14px;
}

.task-progress {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

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

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

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

.material-card {
  min-width: 0;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.material-card.selectable {
  cursor: pointer;
}

.material-card.selectable input {
  width: 18px;
  height: 18px;
}

.material-title {
  color: var(--ink);
  font-weight: 720;
  line-height: 1.35;
}

details {
  color: var(--ink);
}

summary {
  cursor: pointer;
  color: var(--blue);
  font-weight: 700;
}

.analysis-block {
  margin-top: 10px;
}

.analysis-block p {
  margin: 4px 0 0;
  white-space: pre-wrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(24, 33, 29, 0.42);
}

.modal-panel {
  width: min(640px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  display: grid;
  gap: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.material-summary {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
}

.reason-group {
  margin: 0;
  padding: 0;
  border: 0;
}

.reason-group legend {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.reason-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.checkbox-label {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font-size: 13px;
  font-weight: 650;
}

.checkbox-label input {
  width: 16px;
  height: 16px;
}

.result-header {
  display: grid;
  gap: 12px;
  padding: 24px;
  border-bottom: 1px solid var(--line);
  background: #fafbf8;
}

.result-title-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.result-title-row img,
.result-cover {
  aspect-ratio: 16 / 10;
  border-radius: var(--radius);
  overflow: hidden;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.result-block {
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.result-block:nth-child(odd) {
  border-right: 1px solid var(--line);
}

.result-block.full {
  grid-column: 1 / -1;
  border-right: 0;
}

.script-text {
  margin: 12px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
  line-height: 1.75;
  font-size: 15px;
}

.link {
  color: var(--blue);
  text-decoration: none;
  word-break: break-all;
}

.link:hover {
  text-decoration: underline;
}

@media (max-width: 980px) {
  .dashboard,
  .workbench-shell,
  .workbench-grid,
  .submit-panel.thin,
  .form-row,
  .material-summary,
  .result-grid,
  .result-title-row {
    grid-template-columns: 1fr;
  }

  .workbench-sidebar {
    grid-template-rows: auto;
  }

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

  .detail-panel {
    position: static;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .result-block:nth-child(odd) {
    border-right: 0;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100vw - 20px, 1240px);
    padding-top: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-status {
    text-align: left;
  }

  .workspace-section,
  .workbench-sidebar,
  .sidebar,
  .result-header,
  .result-block {
    padding: 16px;
  }

  .workspace-hero,
  .panel-title-row,
  .detail-head {
    flex-direction: column;
  }

  .workbench-nav,
  .task-stats,
  .task-card,
  .material-grid,
  .compact-grid,
  .search-row {
    grid-template-columns: 1fr;
  }

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