:root {
  --bg: #fff9f2;
  --ink: #1f1f1f;
  --panel: #ffffff;
  --panel-border: #d8d2c7;
  --brand: #0e7c66;
  --brand-soft: #ddf2ec;
  --warn: #a9480f;
  --muted: #59544b;
  --shadow: 0 14px 28px rgba(31, 31, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% 8%, #ffe9d3 0, rgba(255, 233, 211, 0) 36%),
    radial-gradient(circle at 93% 16%, #d7efe9 0, rgba(215, 239, 233, 0) 30%),
    linear-gradient(180deg, #fff9f2, #f9f4ee);
}

.layout {
  width: min(1120px, 100% - 2.5rem);
  margin: 2.5rem auto 3rem;
  display: grid;
  gap: 1.25rem;
  grid-template-columns: 1fr;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 1.2rem 1.2rem 1.4rem;
  box-shadow: var(--shadow);
}

.panel-accent {
  border-color: #c8ddd7;
  background:
    linear-gradient(120deg, rgba(214, 238, 232, 0.55), rgba(255, 255, 255, 0) 36%),
    var(--panel);
}

.eyebrow {
  margin: 0;
  font-family: "IBM Plex Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  color: var(--muted);
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.1;
}

h1 {
  margin-top: 0.45rem;
  font-size: clamp(1.55rem, 2.8vw, 2.25rem);
}

h2 {
  font-size: clamp(1.2rem, 2vw, 1.55rem);
}

h3 {
  font-size: 1rem;
  margin-bottom: 0.7rem;
}

.lead {
  margin: 0.8rem 0 1.25rem;
  color: var(--muted);
  max-width: 72ch;
}

.form-grid {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 0.4rem;
}

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

.field span {
  font-size: 0.9rem;
  font-weight: 600;
}

.field-checkbox {
  align-content: end;
}

.field-checkbox .toggle-inline {
  margin-top: 0.24rem;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid #beb8ad;
  border-radius: 10px;
  padding: 0.66rem 0.72rem;
  background: #fff;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px #d9f0ea;
}

textarea {
  resize: vertical;
}

.actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

button {
  border: 0;
  border-radius: 11px;
  padding: 0.72rem 1.05rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--brand);
  color: white;
  transition: transform 120ms ease, background-color 120ms ease;
}

button:hover {
  background: #0b6b57;
  transform: translateY(-1px);
}

button:disabled {
  background: #7ea79d;
  cursor: not-allowed;
  transform: none;
}

.message {
  margin: 0;
  color: var(--warn);
  min-height: 1rem;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.8rem;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.33rem 0.72rem;
  background: #ebedf0;
  color: #253043;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
}

.badge.is-live {
  background: var(--brand-soft);
  color: #0f5f4e;
}

.badge.is-finished {
  background: #f2ece5;
  color: #4d4438;
}

.meta {
  margin: 0.95rem 0 1.15rem;
  padding: 0.85rem;
  border-radius: 12px;
  border: 1px solid #e0dbd1;
  background: #fbf9f6;
  display: grid;
  gap: 0.68rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.meta div {
  min-width: 0;
}

.meta dt {
  font-family: "IBM Plex Mono", monospace;
  color: var(--muted);
  font-size: 0.76rem;
}

.meta dd {
  margin: 0.2rem 0 0;
  word-break: break-word;
}

.monitor-row {
  margin: 0 0 1rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.monitor-row-document-upload {
  align-items: stretch;
}

.monitor-row-document-upload #documentTitleInput {
  flex: 1 1 260px;
  min-width: 220px;
}

.monitor-row-document-upload #uploadDocumentButton {
  min-height: 42px;
  white-space: nowrap;
}

.monitor-row-document-upload #clearDocumentFileButton {
  min-height: 42px;
  white-space: nowrap;
}

.document-dropzone {
  flex: 1 1 100%;
  min-width: 220px;
  margin: 0;
  padding: 0.78rem 0.85rem;
  border: 1px dashed #bcd2cb;
  border-radius: 12px;
  background:
    linear-gradient(155deg, rgba(221, 242, 236, 0.4), rgba(255, 255, 255, 0) 48%),
    #ffffff;
  display: grid;
  gap: 0.2rem;
  text-align: left;
  cursor: pointer;
  user-select: none;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.document-dropzone:hover {
  border-color: #0e7c66;
}

.document-dropzone:focus-visible {
  outline: none;
  border-color: #0e7c66;
  box-shadow: 0 0 0 3px #d9f0ea;
}

.document-dropzone-title,
.document-dropzone-subtitle,
.document-dropzone-selected {
  margin: 0;
}

.document-dropzone-title {
  font-weight: 700;
  color: #184f43;
}

.document-dropzone-subtitle {
  color: var(--muted);
  font-size: 0.84rem;
}

.document-dropzone-selected {
  margin-top: 0.2rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.76rem;
  color: #4a665f;
}

.document-dropzone.has-file .document-dropzone-selected {
  color: #0f5f4e;
}

.document-dropzone.is-drag-active {
  border-color: #0e7c66;
  background: #ddf2ec;
  box-shadow: 0 0 0 3px #d9f0ea;
}

.document-dropzone.is-disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.toggle-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.34rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.toggle-inline input {
  margin: 0;
}

.ghost-button {
  background: #e7f4ef;
  color: #145344;
}

.ghost-button:hover {
  background: #d9ede6;
}

.inject-panel {
  margin: 0 0 1rem;
  padding: 0.85rem;
  border: 1px solid #d7d1c6;
  border-radius: 12px;
  background: #fbf9f6;
  display: grid;
  gap: 0.7rem;
}

.inject-panel .eyebrow {
  margin-bottom: 0.05rem;
}

.inject-controls {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
}

#injectButton {
  height: 42px;
  white-space: nowrap;
}

.dashboard-panel {
  margin: 0.9rem 0 1rem;
  padding: 0.85rem;
  border: 1px solid #d7d1c6;
  border-radius: 12px;
  background: #fbf9f6;
}

.p8-plan-monitor {
  background:
    linear-gradient(150deg, rgba(221, 242, 236, 0.46), rgba(255, 255, 255, 0) 46%),
    #fbf9f6;
}

.p8-plan-monitor .status-row {
  align-items: center;
}

.p8-plan-monitor-meta {
  margin-top: 0.7rem;
  margin-bottom: 0.9rem;
}

.p8-plan-check {
  display: grid;
  gap: 0.22rem;
}

.p8-plan-check-status {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.p8-plan-check-status.pass {
  color: #0f5f4e;
}

.p8-plan-check-status.waiting,
.p8-plan-check-status.review {
  color: #7a5e18;
}

.p8-plan-check-status.fail {
  color: #a9480f;
}

.p8-plan-monitor-badge-pass {
  background: var(--brand-soft);
  color: #0f5f4e;
}

.p8-plan-monitor-badge-review,
.p8-plan-monitor-badge-waiting {
  background: #f6efe1;
  color: #6d5b2e;
}

.p8-plan-monitor-badge-fail {
  background: #f8e7df;
  color: #8c3710;
}

.dashboard-filters {
  display: flex;
  gap: 0.5rem;
  margin: 0.5rem 0;
  flex-wrap: wrap;
}
.dashboard-filters select {
  flex: 1 1 0;
  min-width: 120px;
}

.session-dashboard {
  list-style: none;
  padding-left: 0;
  margin-top: 0.7rem;
  gap: 0.7rem;
}

.session-card {
  border: 1px solid #d7d1c6;
  border-radius: 12px;
  background: #fff;
  padding: 0.72rem;
  display: grid;
  gap: 0.45rem;
}

.session-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.55rem;
}

.session-card-header strong {
  display: block;
  margin-bottom: 0.2rem;
}

.session-card-context,
.session-card-snippet {
  margin: 0;
}

.session-card-snippet {
  font-size: 0.9rem;
  color: #2c2c2c;
}

.session-card-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.session-card-actions .ghost-button {
  padding: 0.5rem 0.7rem;
}

.session-card-export {
  background: #f2ece1;
  color: #4f4537;
}

.session-card-export:hover {
  background: #e7ddcf;
}

.document-list-item {
  border: 1px solid #d7d1c6;
  border-radius: 10px;
  background: #fff;
  padding: 0.55rem 0.65rem;
}

.question-bank-role-button {
  margin-left: auto;
  padding: 0.36rem 0.56rem;
  font-size: 0.74rem;
  white-space: nowrap;
}

.stream-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stream {
  border: 1px solid #d7d1c6;
  border-radius: 12px;
  padding: 0.85rem;
  background: #fff;
}

.list {
  margin: 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.48rem;
  font-size: 0.96rem;
}

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

.label {
  display: inline-block;
  padding: 0.14rem 0.45rem;
  margin-right: 0.3rem;
  border-radius: 999px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #ece8e1;
  color: #584e41;
}

.value-subtle {
  color: var(--muted);
  font-size: 0.88rem;
  word-break: break-word;
}

.inline-link {
  color: #0b6b57;
  text-decoration: underline;
}

.debug-log {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #2c2c2c;
  background: #fbfbfb;
}

.ui-busy-indicator {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  border: 1px solid #cfd8d3;
  background: rgba(255, 255, 255, 0.96);
  color: #1f1f1f;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.75rem;
  box-shadow: 0 6px 16px rgba(31, 31, 31, 0.14);
  backdrop-filter: blur(4px);
}

.ui-busy-spinner {
  width: 0.95rem;
  height: 0.95rem;
  border: 2px solid #cde8e1;
  border-top-color: #0e7c66;
  border-radius: 50%;
  animation: ui-busy-spin 0.8s linear infinite;
}

@keyframes ui-busy-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 920px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .inject-controls {
    grid-template-columns: 1fr;
  }

  .meta,
  .stream-grid {
    grid-template-columns: 1fr;
  }

  .monitor-row-document-upload #documentTitleInput {
    min-width: 0;
    flex-basis: 100%;
  }

  .monitor-row-document-upload #uploadDocumentButton {
    width: 100%;
  }

  .monitor-row-document-upload #clearDocumentFileButton {
    width: 100%;
  }
}
