:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #667085;
  --line: #d8dee8;
  --panel: #ffffff;
  --soft: #f3f6f9;
  --accent: #2563eb;
  --accent-strong: #1e40af;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #b91c1c;
  font-family: "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: #eef2f7;
}

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

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px 1fr;
}

.sidebar {
  background: #111827;
  color: #f8fafc;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e8eefc;
  color: #1e40af;
  font-weight: 800;
}

.brand h1,
.topbar h2,
.result-header h3 {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #9aa4b2;
  font-size: 12px;
  letter-spacing: 0;
}

.tabs {
  display: grid;
  gap: 6px;
}

.tab {
  border: 0;
  border-radius: 6px;
  padding: 12px 14px;
  text-align: left;
  color: #dbe4f0;
  background: transparent;
  cursor: pointer;
}

.tab:hover,
.tab.is-active {
  background: #243044;
  color: #ffffff;
}

.engine-card {
  margin-top: auto;
  border: 1px solid #314158;
  border-radius: 8px;
  padding: 16px;
  background: #182235;
}

.status-row {
  display: flex;
  gap: 10px;
  align-items: center;
  font-weight: 700;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #94a3b8;
}

.status-dot.ok {
  background: #22c55e;
}

.status-dot.warn {
  background: #f59e0b;
}

.status-dot.fail {
  background: #ef4444;
}

.engine-card p {
  color: #cbd5e1;
  font-size: 13px;
  line-height: 1.55;
}

.button-row,
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.engine-help {
  margin: 14px 0 0;
  padding-left: 18px;
  color: #cbd5e1;
  font-size: 13px;
  line-height: 1.55;
}

.engine-help strong {
  color: #ffffff;
}

.workspace {
  padding: 28px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.topbar h2 {
  font-size: 28px;
}

.privacy-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  padding: 8px 12px;
  white-space: nowrap;
}

.panel,
.result-area {
  display: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
}

.panel.is-active,
.result-area {
  display: block;
}

.tool-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr auto;
  align-items: center;
}

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

.dropzone {
  border: 1px dashed #9aa7b8;
  border-radius: 8px;
  background: var(--soft);
  min-height: 86px;
  padding: 16px;
  display: grid;
  gap: 10px;
  align-content: center;
}

.dropzone span,
.generator label {
  color: #344054;
  font-weight: 700;
}

.dropzone input {
  max-width: 100%;
}

.button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

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

.button.ghost {
  border-color: #4b5c75;
  background: transparent;
  color: #f8fafc;
}

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

.actions.inline {
  margin-top: 14px;
}

.candidate-list,
.form-fields {
  margin-top: 16px;
  display: grid;
  gap: 8px;
}

.candidate,
.field-row {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
}

.field-row {
  grid-template-columns: minmax(120px, 180px) 1fr;
}

.field-row input {
  width: 100%;
}

.generator {
  display: grid;
  gap: 14px;
  max-width: 760px;
}

.generator label {
  display: grid;
  gap: 8px;
}

.generator input,
.generator select,
.generator textarea,
.field-row input {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #ffffff;
}

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

#resultMeta {
  color: var(--muted);
  font-size: 13px;
}

.progress-box {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e1e7ef;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 160ms ease;
}

.progress-bar.fail {
  background: var(--danger);
}

.progress-bar.done {
  background: var(--ok);
}

#resultOutput,
.rich-output {
  margin: 0;
  min-height: 260px;
  max-height: 48vh;
  overflow: auto;
  border-radius: 6px;
  padding: 14px;
}

#resultOutput {
  background: #0b1020;
  color: #e5edf7;
  line-height: 1.55;
  white-space: pre-wrap;
}

.rich-output {
  background: #ffffff;
  color: var(--ink);
  line-height: 1.65;
}

.rich-output h1,
.rich-output h2,
.rich-output h3 {
  margin: 0 0 12px;
}

.rich-output p {
  margin: 0 0 10px;
}

.rich-output table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 14px;
}

.rich-output th,
.rich-output td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  vertical-align: top;
}

.rich-output th {
  background: #f3f6f9;
  font-weight: 700;
}

.rich-output ul,
.rich-output ol {
  margin: 8px 0 12px 22px;
}

.rich-output figure {
  margin: 18px 0;
}

.rich-output img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.rich-output figcaption,
.image-placeholder {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

.raw-output {
  margin-top: 12px;
}

.raw-output summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  margin-bottom: 8px;
}

.app-footer {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  padding: 4px 2px 16px;
}

.app-footer p {
  margin: 0 0 4px;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .tool-grid,
  .tool-grid.two {
    grid-template-columns: 1fr;
  }

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