:root {
  color-scheme: light;
  --ink: #1f2533;
  --ink-soft: #606879;
  --paper: #f6f2e9;
  --paper-bright: #fffdf8;
  --line: #ded8cb;
  --line-strong: #c7bead;
  --accent: #5b4cf0;
  --accent-deep: #4434c7;
  --accent-wash: #ebe8ff;
  --coral: #e76855;
  --success: #24765d;
  --success-wash: #e2f2ec;
  --danger: #a74343;
  --danger-wash: #f7e7e3;
  --shadow: 0 22px 60px rgba(47, 40, 25, 0.09);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 75% 0%, rgba(91, 76, 240, 0.1), transparent 28rem),
    var(--paper);
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(100%, 430px);
}

.login-card {
  padding: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 253, 248, 0.94);
  box-shadow: var(--shadow);
}

.login-brand {
  display: grid;
  width: 52px;
  height: 52px;
  margin-bottom: 28px;
  place-items: center;
  border-radius: 16px;
  color: white;
  background: var(--ink);
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  transform: rotate(-3deg);
}

.login-card h1 {
  margin: 8px 0 0;
  font-size: clamp(1.8rem, 7vw, 2.45rem);
  letter-spacing: -0.04em;
}

.login-intro {
  margin: 14px 0 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
  line-height: 1.7;
}

.login-form {
  display: grid;
  margin-top: 26px;
  gap: 16px;
}

.login-form label > span {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 800;
}

.login-form input {
  width: 100%;
}

.login-submit {
  width: 100%;
  margin-top: 4px;
}

.login-card .notice {
  margin-top: 18px;
}

.login-footer-link {
  margin: 20px 0 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
  text-align: center;
}

.login-footer-link a {
  color: var(--accent-deep);
  font-weight: 700;
}

.login-password-help {
  margin: -4px 0 0;
  color: var(--ink-soft);
  font-size: 0.72rem;
  line-height: 1.6;
}

.admin-invitation-panel {
  display: grid;
  margin: 18px 0;
  padding: 16px;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper-bright);
}

.admin-invitation-panel strong,
.admin-invitation-panel small {
  display: block;
}

.admin-invitation-panel small {
  margin-top: 4px;
  color: var(--ink-soft);
}

.admin-invitation-result {
  display: grid;
  gap: 8px;
}

.admin-invitation-result textarea {
  width: 100%;
  resize: vertical;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
summary {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

.page-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 78px;
  padding: 0 30px;
  border-bottom: 1px solid rgba(199, 190, 173, 0.7);
  background: rgba(246, 242, 233, 0.88);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  color: white;
  background: var(--ink);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  transform: rotate(-3deg);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 0.94rem;
  letter-spacing: -0.01em;
}

.brand small {
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  background: rgba(255, 253, 248, 0.66);
  font-size: 0.76rem;
}

.llm-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid #e5bbb2;
  border-radius: 999px;
  color: var(--danger);
  background: var(--danger-wash);
  font-size: 0.72rem;
  font-weight: 800;
}

.llm-status-pill[data-state="online"] {
  border-color: #bcdccc;
  color: var(--success);
  background: var(--success-wash);
}

.llm-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentcolor;
  box-shadow: 0 0 0 4px color-mix(in srgb, currentcolor 13%, transparent);
}

.connection-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #36a379;
  box-shadow: 0 0 0 4px rgba(54, 163, 121, 0.13);
}

.settings-dialog {
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: var(--radius-lg);
  color: var(--ink);
  background: transparent;
  box-shadow: 0 28px 90px rgba(31, 37, 51, 0.28);
}

.settings-dialog::backdrop {
  background: rgba(31, 37, 51, 0.5);
  backdrop-filter: blur(5px);
}

.settings-card {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper-bright);
}

.admin-runtime-dialog {
  width: min(760px, calc(100vw - 32px));
}

.admin-runtime-toolbar,
.admin-runtime-item-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-runtime-toolbar {
  margin-top: 20px;
  color: var(--ink-soft);
  font-size: 0.72rem;
}

.admin-runtime-list {
  display: grid;
  max-height: 52vh;
  margin-top: 14px;
  overflow-y: auto;
  gap: 10px;
}

.admin-runtime-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
}

.admin-runtime-item-heading strong {
  font-size: 0.78rem;
}

.admin-runtime-item-heading span {
  padding: 4px 7px;
  border-radius: 999px;
  color: var(--accent-deep);
  background: var(--accent-wash);
  font-size: 0.62rem;
  font-weight: 800;
}

.admin-runtime-item p,
.admin-runtime-item small {
  display: block;
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 0.68rem;
  line-height: 1.55;
}

.admin-runtime-item small {
  overflow-wrap: anywhere;
}

.settings-heading,
.settings-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.settings-heading h2 {
  margin: 7px 0 0;
  font-size: 1.35rem;
}

.dialog-close {
  display: grid;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-soft);
  background: var(--paper);
  cursor: pointer;
  font-size: 1.3rem;
  place-items: center;
}

.settings-intro {
  margin: 18px 0 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.7;
}

.settings-current {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  background: var(--paper);
  font-size: 0.75rem;
  line-height: 1.55;
}

.settings-form {
  display: grid;
  margin-top: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.settings-form label > span {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-soft);
  font-size: 0.7rem;
  font-weight: 800;
}

.settings-full-field {
  grid-column: 1 / -1;
}

.settings-checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.settings-checkbox-field input {
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
}

.settings-form .settings-checkbox-field > span {
  margin: 0;
  font-weight: 600;
  line-height: 1.5;
}

.settings-help {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.7rem;
  line-height: 1.6;
}

.workspace {
  display: grid;
  min-height: calc(100vh - 78px);
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
}

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 54px 32px 28px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(rgba(255, 253, 248, 0.82), rgba(255, 253, 248, 0.82)),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 12px,
      rgba(31, 37, 51, 0.025) 12px,
      rgba(31, 37, 51, 0.025) 13px
    );
}

.sidebar-intro h1 {
  margin: 12px 0 16px;
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: clamp(2rem, 3vw, 3.1rem);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.045em;
}

.sidebar-intro > p:last-child {
  max-width: 29rem;
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.91rem;
  line-height: 1.75;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.sidebar-section {
  margin-top: 48px;
}

.section-heading,
.panel-heading,
.canvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-heading {
  margin-bottom: 14px;
}

.section-heading h2,
.panel-heading h3,
.review-copy h3 {
  margin: 0;
}

.section-heading h2 {
  font-size: 0.95rem;
}

.section-index {
  color: var(--line-strong);
  font-family: Georgia, serif;
  font-size: 0.84rem;
}

.project-card {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper-bright);
  box-shadow: 0 10px 28px rgba(52, 45, 31, 0.06);
}

.project-card-empty {
  box-shadow: none;
}

.project-monogram {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  color: var(--accent-deep);
  background: var(--accent-wash);
  font-weight: 800;
}

.project-card strong,
.project-card p {
  overflow-wrap: anywhere;
}

.project-card strong {
  font-size: 0.88rem;
}

.project-card p {
  display: -webkit-box;
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.75rem;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.project-actions {
  display: grid;
  margin-top: 9px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.project-actions .button {
  min-width: 0;
  padding: 0 8px;
}

.disclosure {
  margin-top: 12px;
  border-top: 1px solid var(--line);
}

.disclosure summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 2px 10px;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 0.79rem;
  font-weight: 700;
  list-style: none;
}

.disclosure summary::-webkit-details-marker {
  display: none;
}

.disclosure summary::after {
  content: "+";
  color: var(--accent);
  font-size: 1rem;
}

.disclosure[open] summary::after {
  content: "−";
}

.project-library {
  margin-top: 18px;
}

.library-toolbar,
.content-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.library-toolbar {
  margin-top: 12px;
}

.library-toolbar select {
  min-width: 0;
  flex: 1;
}

.library-list {
  display: grid;
  margin-top: 10px;
  gap: 7px;
}

.library-item {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--paper-bright);
  cursor: pointer;
  text-align: left;
}

.library-item:hover {
  border-color: var(--accent);
}

.library-item strong,
.library-item span {
  display: block;
}

.library-item strong {
  overflow: hidden;
  font-size: 0.74rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-item span,
.library-empty {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 0.65rem;
}

.stack-form {
  display: grid;
  gap: 12px;
  padding: 4px 0 10px;
}

label > span {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 700;
}

label em {
  color: #8b91a0;
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 500;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.95);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

input {
  height: 42px;
  padding: 0 12px;
}

select {
  height: 38px;
  padding: 0 34px 0 11px;
  cursor: pointer;
}

textarea {
  min-height: 84px;
  padding: 11px 12px;
  line-height: 1.55;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(91, 76, 240, 0.7);
  background: white;
  box-shadow: 0 0 0 4px rgba(91, 76, 240, 0.1);
}

input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.inline-form {
  display: grid;
  padding: 2px 0 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease,
    opacity 150ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.button-primary {
  color: white;
  background: var(--accent);
  box-shadow: 0 10px 24px rgba(91, 76, 240, 0.22);
}

.button-primary:hover:not(:disabled) {
  background: var(--accent-deep);
  box-shadow: 0 13px 28px rgba(91, 76, 240, 0.28);
}

.button-secondary {
  border-color: var(--line);
  color: var(--ink);
  background: var(--paper-bright);
}

.button-ghost {
  border-color: var(--line);
  color: var(--ink-soft);
  background: transparent;
}

.button-small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.72rem;
}

.button-success {
  color: white;
  background: var(--success);
}

.button-danger {
  border-color: #e5bbb2;
  color: var(--danger);
  background: var(--danger-wash);
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 40px;
  color: #898e98;
  font-size: 0.67rem;
}

.sidebar-footer a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.canvas {
  min-width: 0;
  padding: 54px clamp(24px, 5vw, 74px) 72px;
}

.canvas-header {
  align-items: flex-end;
}

.canvas-header h2 {
  margin: 9px 0 0;
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: clamp(1.8rem, 3vw, 2.7rem);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.04em;
}

.run-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  background: rgba(255, 253, 248, 0.74);
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.state-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a7abb4;
}

.run-state[data-state="created"] .state-dot,
.run-state[data-state="queued"] .state-dot,
.run-state[data-state="running"] .state-dot,
.run-state[data-state="active"] .state-dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-wash);
  animation: pulse 1.35s ease-in-out infinite;
}

.run-state[data-state="waiting_review"] .state-dot {
  background: #d58e27;
}

.run-state[data-state="completed"] .state-dot {
  background: var(--success);
}

.run-state[data-state="failed"] .state-dot,
.run-state[data-state="indeterminate"] .state-dot {
  background: var(--danger);
}

@keyframes pulse {
  50% {
    opacity: 0.45;
    transform: scale(0.8);
  }
}

.notice {
  margin-top: 20px;
  padding: 13px 15px;
  border: 1px solid #c8c1ff;
  border-radius: var(--radius-sm);
  color: var(--accent-deep);
  background: var(--accent-wash);
  font-size: 0.8rem;
  line-height: 1.5;
}

.notice[data-tone="error"] {
  border-color: #e5bbb2;
  color: var(--danger);
  background: var(--danger-wash);
}

.notice[data-tone="success"] {
  border-color: #bcdccc;
  color: var(--success);
  background: var(--success-wash);
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 253, 248, 0.9);
  box-shadow: var(--shadow);
}

.workflow-composer {
  margin-top: 30px;
  padding: 26px;
  overflow: hidden;
  background:
    linear-gradient(120deg, rgba(91, 76, 240, 0.04), transparent 45%),
    var(--paper-bright);
}

.panel-heading h3 {
  margin-top: 7px;
  font-size: 1.04rem;
}

.panel-hint,
.version-badge,
.trace-count {
  color: var(--ink-soft);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.workflow-advanced-settings {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(246, 242, 233, 0.48);
}

.workflow-advanced-settings > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 0 15px;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 800;
  list-style: none;
}

.workflow-advanced-settings > summary::-webkit-details-marker {
  display: none;
}

.workflow-advanced-settings > summary::after {
  content: "+";
  color: var(--accent);
  font-size: 1rem;
}

.workflow-advanced-settings[open] > summary::after {
  content: "−";
}

.workflow-advanced-content {
  padding: 0 15px 15px;
  border-top: 1px solid var(--line);
}

.workflow-mode-label {
  display: grid;
  margin-top: 14px;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 0.68rem;
  font-weight: 800;
}

.workflow-mode-label select {
  min-width: 150px;
  border-color: #d1cafb;
  color: var(--accent-deep);
  background: var(--accent-wash);
  font-size: 0.72rem;
  font-weight: 800;
}

.composer-field {
  display: block;
  margin-top: 20px;
}

.composer-field textarea {
  min-height: 126px;
  border: 0;
  border-radius: 14px;
  background: #f3efe6;
  font-size: 1rem;
}

.composer-field textarea:focus {
  background: white;
  box-shadow:
    inset 0 0 0 1px rgba(91, 76, 240, 0.65),
    0 0 0 4px rgba(91, 76, 240, 0.1);
}

.demo-fields {
  display: grid;
  margin-top: 14px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(246, 242, 233, 0.72);
  grid-template-columns: 1fr 1fr 1.3fr 0.7fr 0.8fr;
  gap: 10px;
}

.demo-fields input,
.demo-fields textarea {
  height: 39px;
  background: var(--paper-bright);
  font-size: 0.76rem;
}

.demo-fields textarea {
  height: auto;
  min-height: 78px;
  line-height: 1.6;
  resize: vertical;
}

.prompt-fields {
  padding: 18px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.prompt-wide-field {
  grid-column: span 2;
}

.prompt-full-field {
  grid-column: 1 / -1;
}

.character-editor {
  padding: 15px;
  border: 1px solid #d8d2c6;
  border-radius: 12px;
  background: rgba(255, 253, 248, 0.8);
}

.character-editor-heading,
.character-card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.character-editor-heading strong,
.character-editor-heading span {
  display: block;
}

.character-editor-heading strong {
  font-size: 0.84rem;
}

.character-editor-heading span {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 0.68rem;
}

.character-list {
  display: grid;
  margin-top: 14px;
  gap: 12px;
}

.character-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-bright);
}

.character-card-heading strong {
  color: var(--accent-deep);
  font-size: 0.74rem;
}

.character-remove {
  border: 0;
  color: var(--danger);
  background: transparent;
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 800;
}

.character-remove:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.character-card-fields {
  display: grid;
  margin-top: 11px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.character-card-fields input {
  width: 100%;
  height: 39px;
  background: #f7f4ed;
  font-size: 0.72rem;
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  margin-top: 15px;
}

.review-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 700;
}

.review-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.toggle-track {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: #c9c5ba;
  transition: background 160ms ease;
}

.toggle-track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  content: "";
  transition: transform 160ms ease;
}

.review-toggle input:checked + .toggle-track {
  background: var(--accent);
}

.review-toggle input:checked + .toggle-track::after {
  transform: translateX(14px);
}

.button-run {
  min-width: 170px;
}

.content-manager {
  margin-top: 22px;
  padding: 24px;
}

.content-toolbar select {
  min-width: 110px;
}

.content-list {
  display: grid;
  margin-top: 18px;
  grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr));
  gap: 12px;
}

.content-empty {
  grid-column: 1 / -1;
  padding: 30px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  color: var(--ink-soft);
  text-align: center;
  font-size: 0.75rem;
}

.content-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #f8f5ee;
  gap: 11px;
}

.content-item-heading,
.content-item-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.content-item-heading strong {
  min-width: 0;
  flex: 1 1 0;
  overflow: hidden;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-kind {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 4px 7px;
  border-radius: 999px;
  color: var(--accent-deep);
  background: var(--accent-wash);
  font-size: 0.58rem;
  font-weight: 800;
}

.content-item-meta {
  color: var(--ink-soft);
  font-size: 0.65rem;
}

.content-item-preview {
  min-width: 0;
  overflow-wrap: anywhere;
  min-height: 3.1em;
  margin: 0;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.68rem;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.content-item-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.content-item-actions button {
  padding: 0;
  border: 0;
  color: var(--accent-deep);
  background: transparent;
  cursor: pointer;
  font-size: 0.65rem;
  font-weight: 800;
}

.content-item-actions button[data-action="delete"] {
  color: var(--danger);
}

.content-editor-dialog {
  width: min(820px, calc(100vw - 32px));
}

.dashboard-grid {
  display: grid;
  margin-top: 22px;
  grid-template-columns: minmax(0, 1.12fr) minmax(300px, 0.88fr);
  gap: 22px;
}

.artifact-panel,
.trace-panel {
  min-height: 470px;
  padding: 24px;
}

.version-badge {
  padding: 7px 9px;
  border-radius: 7px;
  color: var(--accent-deep);
  background: var(--accent-wash);
}

.empty-state {
  display: grid;
  min-height: 340px;
  place-items: center;
  align-content: center;
  padding: 30px;
  color: var(--ink-soft);
  text-align: center;
}

.empty-state.compact {
  min-height: 310px;
}

.empty-glyph {
  display: grid;
  width: 58px;
  height: 58px;
  margin-bottom: 15px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--accent);
  background: #f7f3eb;
  font-size: 1.3rem;
}

.empty-state strong {
  color: var(--ink);
  font-size: 0.9rem;
}

.empty-state p {
  max-width: 310px;
  margin: 8px 0 0;
  font-size: 0.76rem;
  line-height: 1.65;
}

.artifact-view {
  margin-top: 20px;
}

.artifact-meta {
  display: grid;
  padding: 12px 0 18px;
  border-bottom: 1px solid var(--line);
  grid-template-columns: 1.2fr 0.8fr 1fr;
  gap: 15px;
}

.artifact-meta span,
.artifact-meta strong {
  display: block;
}

.artifact-meta span {
  margin-bottom: 4px;
  color: var(--ink-soft);
  font-size: 0.64rem;
}

.artifact-meta strong {
  overflow-wrap: anywhere;
  font-size: 0.75rem;
}

.artifact-view pre {
  max-height: 500px;
  margin: 18px 0 0;
  overflow: auto;
  color: #32394a;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", "Microsoft YaHei", monospace;
  font-size: 0.77rem;
  line-height: 1.72;
  white-space: pre-wrap;
  word-break: break-word;
}

.prompt-output {
  display: grid;
  margin-top: 18px;
  gap: 12px;
}

.segmented-prompt-output {
  display: grid;
  margin-top: 18px;
  gap: 12px;
}

.segment-summary {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.72rem;
  line-height: 1.6;
}

.segment-list {
  display: grid;
  gap: 12px;
}

.segment-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8f5ee;
}

.segment-card-heading {
  display: grid;
  align-items: center;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
}

.segment-card-heading strong {
  overflow-wrap: anywhere;
  font-size: 0.76rem;
}

.segment-card-heading span {
  color: var(--ink-soft);
  font-size: 0.66rem;
}

.segment-card-heading button {
  border: 0;
  color: var(--accent-deep);
  background: transparent;
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 800;
}

.segment-card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.segment-card details {
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 9px;
}

.segment-card summary {
  color: var(--accent-deep);
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 800;
}

.prompt-quality-report,
.quality-dimension-list {
  display: grid;
  gap: 12px;
}

.prompt-quality-report {
  margin-top: 18px;
}

.quality-gate-summary {
  padding: 11px 13px;
  border: 1px solid var(--danger);
  border-radius: 10px;
  background: #fff1ee;
  color: var(--danger);
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1.55;
}

.quality-gate-summary[data-state="passed"] {
  border-color: #548a68;
  background: #edf8f0;
  color: #376448;
}

.quality-report-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.quality-report-actions span {
  color: var(--ink-muted);
  font-size: 0.66rem;
}

.quality-dimension-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8f5ee;
}

.quality-dimension-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.quality-dimension-heading strong,
.quality-dimension-heading span {
  font-size: 0.74rem;
}

.quality-dimension-card p {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 0.68rem;
  line-height: 1.65;
}

.quality-finding {
  padding-left: 9px;
  border-left: 3px solid var(--accent);
}

.quality-finding.quality-critical {
  border-left-color: var(--danger);
}

.quality-finding.quality-p0,
.quality-finding.quality-p1 {
  border-left-color: var(--danger);
}

.quality-finding.quality-p2 {
  border-left-color: #c9821b;
}

.quality-finding.quality-p3 {
  border-left-color: var(--ink-soft);
}

.quality-optional-card {
  border-style: dashed;
  background: color-mix(in srgb, var(--accent-wash) 35%, transparent);
}

.segment-card pre,
.artifact-view .segment-card pre {
  max-height: 340px;
  margin-top: 10px;
  font-size: 0.72rem;
}

.prompt-output-heading,
.prompt-card > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.prompt-output-heading {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--accent-wash);
}

.prompt-output-heading span,
.prompt-output-heading strong {
  display: block;
}

.prompt-output-heading span {
  color: var(--accent);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.prompt-output-heading strong {
  margin-top: 3px;
  font-size: 0.84rem;
}

.dynamic-prompt-controls {
  display: grid;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbf8f1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

.dynamic-prompt-controls label {
  display: grid;
  color: var(--ink-muted);
  font-size: 0.66rem;
  font-weight: 700;
  gap: 5px;
}

.dynamic-prompt-controls select {
  width: 100%;
}

.dynamic-prompt-controls .dynamic-audio-option {
  display: flex;
  align-items: center;
  color: var(--ink);
  grid-column: 1 / -1;
  flex-direction: row;
}

.dynamic-prompt-controls .dynamic-audio-option input {
  width: auto;
  margin: 0;
}

.dynamic-prompt-controls p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.68rem;
  line-height: 1.6;
  grid-column: 1 / -1;
}

.prompt-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8f5ee;
}

.prompt-card > div strong {
  font-size: 0.76rem;
}

.prompt-card > div button {
  border: 0;
  color: var(--accent-deep);
  background: transparent;
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 800;
}

.prompt-card > div button:hover {
  text-decoration: underline;
}

.prompt-card pre,
.artifact-view .prompt-card pre {
  max-height: 260px;
  margin-top: 10px;
  font-size: 0.72rem;
  font-family: inherit;
  line-height: 1.72;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow-y: auto;
}

.dashboard-grid > *,
.prompt-card {
  min-width: 0;
}

.prompt-card-compact pre,
.artifact-view .prompt-card-compact pre {
  max-height: 150px;
}

.timeline {
  display: grid;
  max-height: 530px;
  margin: 22px 0 0;
  padding: 0 2px 0 0;
  overflow-y: auto;
  list-style: none;
  gap: 0;
}

.timeline-item {
  position: relative;
  display: grid;
  padding: 0 0 22px 28px;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
}

.timeline-item::before {
  position: absolute;
  top: 2px;
  left: 6px;
  z-index: 1;
  width: 9px;
  height: 9px;
  border: 3px solid var(--paper-bright);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  content: "";
}

.timeline-item::after {
  position: absolute;
  top: 15px;
  bottom: -2px;
  left: 10px;
  width: 1px;
  background: var(--line);
  content: "";
}

.timeline-item:last-child::after {
  display: none;
}

.timeline-item.decision::before {
  background: var(--coral);
  box-shadow: 0 0 0 1px var(--coral);
}

.timeline-item strong {
  overflow-wrap: anywhere;
  font-size: 0.78rem;
}

.timeline-item time {
  color: #989da7;
  font-size: 0.62rem;
}

.timeline-item p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.72rem;
  line-height: 1.55;
}

.timeline-meta {
  grid-column: 1 / -1;
  color: var(--accent);
  font-size: 0.62rem;
  font-weight: 700;
}

.review-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  margin-top: 22px;
  padding: 24px 26px;
  background:
    linear-gradient(100deg, rgba(231, 104, 85, 0.08), transparent 50%),
    var(--paper-bright);
}

.review-copy h3 {
  margin-top: 7px;
  font-size: 1.02rem;
}

.review-copy > p:last-child {
  margin: 7px 0 0;
  color: var(--ink-soft);
  font-size: 0.73rem;
}

.review-form {
  display: grid;
  min-width: min(100%, 580px);
  align-items: end;
  grid-template-columns: 120px minmax(150px, 1fr) auto;
  gap: 10px;
}

.review-actions {
  display: flex;
  gap: 7px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .canvas {
    padding-right: 28px;
    padding-left: 28px;
  }

  .dashboard-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .demo-fields {
    grid-template-columns: 1fr 1fr;
  }

  .artifact-panel,
  .trace-panel {
    min-height: 420px;
  }

  .review-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .prompt-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .prompt-full-field {
    grid-column: 1 / -1;
  }

  .character-card-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .review-form {
    min-width: 0;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    height: auto;
    min-height: 68px;
    padding: 10px 16px;
    gap: 8px;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 6px;
  }

  .topbar-actions > * {
    min-width: 0;
  }

  .topbar-actions .button {
    flex: 1 1 auto;
  }

  .connection-pill {
    display: none;
  }

  .llm-status-pill {
    max-width: 100%;
    flex: 1 1 150px;
    overflow: hidden;
    white-space: nowrap;
  }

  .settings-card {
    padding: 22px;
  }

  .settings-form {
    grid-template-columns: 1fr;
  }

  .settings-full-field {
    grid-column: auto;
  }

  .workspace {
    display: block;
  }

  .sidebar {
    padding: 34px 20px 24px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-intro h1 {
    font-size: 2.25rem;
  }

  .sidebar-section {
    margin-top: 32px;
  }

  .sidebar-footer {
    margin-top: 24px;
    padding-top: 12px;
  }

  .canvas {
    padding: 34px 16px 54px;
  }

  .canvas-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .canvas-header h2 {
    font-size: 2rem;
  }

  .workflow-composer,
  .artifact-panel,
  .trace-panel {
    padding: 20px;
    border-radius: 18px;
  }

  .composer-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .content-manager .panel-heading,
  .content-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .content-toolbar select,
  .content-toolbar .button {
    width: 100%;
  }

  .panel-heading {
    align-items: flex-start;
  }

  .workflow-mode-label select {
    min-width: 130px;
  }

  .demo-fields {
    grid-template-columns: 1fr;
  }

  .prompt-wide-field {
    grid-column: auto;
  }

  .prompt-full-field {
    grid-column: auto;
  }

  .character-editor-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .character-card-fields {
    grid-template-columns: 1fr;
  }

  .button-run {
    width: 100%;
  }

  .artifact-meta {
    grid-template-columns: 1fr;
  }

  .review-form {
    grid-template-columns: 1fr;
  }

  .review-actions .button {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
