:root {
  color-scheme: light;
  color: #172033;
  background: #f6f8fb;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: #f6f8fb;
}

button,
input,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  padding: 14px 28px;
  background: rgba(246, 248, 251, 0.94);
  border-bottom: 1px solid #dbe3ee;
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  color: #111827;
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: #ffffff;
  background: #1e3a8a;
  border-radius: 8px;
  font-size: 13px;
}

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid #cbd6e2;
  border-radius: 8px;
  color: #243044;
  background: #ffffff;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.button.primary {
  color: #ffffff;
  background: #2563eb;
  border-color: #2563eb;
}

.button:hover {
  border-color: #9caec4;
}

.button.primary:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

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

.shell {
  width: min(1180px, calc(100% - 44px));
  margin: 0 auto;
  padding: 30px 0 54px;
}

.head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 7px;
  color: #667085;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin: 0;
  color: #101828;
  font-size: 32px;
  line-height: 1.15;
}

.lede {
  max-width: 760px;
  margin: 9px 0 0;
  color: #586474;
  line-height: 1.55;
}

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

.unit-card,
.panel,
.timeline-item {
  background: #ffffff;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.unit-card {
  display: grid;
  gap: 12px;
  min-height: 190px;
  padding: 18px;
  text-align: left;
  cursor: pointer;
}

.unit-card:hover,
.timeline-item:hover {
  border-color: #9caec4;
  box-shadow: 0 10px 26px rgba(16, 24, 40, 0.08);
}

.unit-card h2,
.timeline-item h3 {
  margin: 0;
  color: #182230;
}

.unit-card p,
.timeline-item p {
  margin: 0;
  color: #4f5d70;
  line-height: 1.5;
}

.meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: auto;
  color: #667085;
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 8px;
  color: #344054;
  background: #edf2f7;
  font-size: 12px;
  font-weight: 780;
}

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

.panel {
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid #edf1f5;
}

.panel-head h2 {
  margin: 0;
  color: #172033;
  font-size: 19px;
  line-height: 1.25;
}

.markdown {
  padding: 24px 28px 32px;
  color: #263244;
  overflow-wrap: anywhere;
}

.markdown h1 {
  margin: 0 0 18px;
  font-size: 28px;
}

.markdown h2 {
  margin: 28px 0 10px;
  padding-top: 14px;
  border-top: 1px solid #e5ebf2;
  font-size: 18px;
}

.markdown h3 {
  margin: 20px 0 8px;
  font-size: 15px;
}

.markdown p,
.markdown li {
  color: #3d4959;
  line-height: 1.66;
}

.markdown ul,
.markdown ol {
  margin: 8px 0 16px;
  padding-left: 22px;
}

.markdown code {
  padding: 2px 5px;
  color: #9f1239;
  background: #fff1f2;
  border: 1px solid #ffe4e6;
  border-radius: 6px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.markdown pre {
  overflow-x: auto;
  padding: 14px;
  color: #e5ecf6;
  background: #111827;
  border-radius: 8px;
}

.markdown pre code {
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
}

.side {
  display: grid;
  gap: 14px;
}

.side .panel {
  padding: 17px;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  display: block;
  padding: 14px;
  color: inherit;
  text-decoration: none;
}

.timeline-item.active {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.empty {
  padding: 34px;
  text-align: center;
}

.notice {
  width: min(1180px, calc(100% - 44px));
  margin: 16px auto 0;
  padding: 12px 14px;
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
}

.modal-layer {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(15, 23, 42, 0.52);
}

.modal {
  width: min(1120px, 100%);
  max-height: calc(100vh - 44px);
  overflow: auto;
  padding: 20px;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

.modal.compact {
  width: min(460px, 100%);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.modal-head h2 {
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
}

.fields {
  display: grid;
  gap: 12px;
  align-content: start;
}

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

.field span {
  color: #405168;
  font-size: 13px;
  font-weight: 720;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #172033;
  background: #ffffff;
  outline: none;
}

.field input {
  min-height: 40px;
  padding: 0 11px;
}

.editor-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
}

.field textarea,
.preview {
  min-height: 560px;
  max-height: 560px;
}

.field textarea {
  padding: 14px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.62;
}

.preview {
  overflow: auto;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  background: #fbfcfe;
}

.preview .markdown {
  padding: 16px;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.error {
  color: #b42318;
}

[data-theme="dark"] {
  color-scheme: dark;
  color: #d7deea;
  background: #101318;
}

[data-theme="dark"] body {
  background: #101318;
}

[data-theme="dark"] .topbar {
  background: rgba(16, 19, 24, 0.94);
  border-bottom-color: #2b333f;
}

[data-theme="dark"] .brand,
[data-theme="dark"] h1,
[data-theme="dark"] .unit-card h2,
[data-theme="dark"] .timeline-item h3,
[data-theme="dark"] .panel-head h2,
[data-theme="dark"] .modal-head h2,
[data-theme="dark"] .markdown h1,
[data-theme="dark"] .markdown h2,
[data-theme="dark"] .markdown h3 {
  color: #f4f7fb;
}

[data-theme="dark"] .brand-mark {
  color: #101318;
  background: #e5edf8;
}

[data-theme="dark"] .lede,
[data-theme="dark"] .unit-card p,
[data-theme="dark"] .timeline-item p,
[data-theme="dark"] .markdown p,
[data-theme="dark"] .markdown li,
[data-theme="dark"] .meta,
[data-theme="dark"] .eyebrow {
  color: #a8b4c5;
}

[data-theme="dark"] .unit-card,
[data-theme="dark"] .panel,
[data-theme="dark"] .timeline-item,
[data-theme="dark"] .modal {
  background: #181d25;
  border-color: #2b333f;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
}

[data-theme="dark"] .unit-card:hover,
[data-theme="dark"] .timeline-item:hover {
  border-color: #526174;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.26);
}

[data-theme="dark"] .button {
  color: #d7deea;
  background: #1d232c;
  border-color: #3a4554;
}

[data-theme="dark"] .button:hover {
  border-color: #64748b;
  background: #242b36;
}

[data-theme="dark"] .button.primary {
  color: #ffffff;
  background: #2563eb;
  border-color: #2563eb;
}

[data-theme="dark"] .button.primary:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

[data-theme="dark"] .badge {
  color: #d7deea;
  background: #27303b;
}

[data-theme="dark"] .panel-head,
[data-theme="dark"] .markdown h2 {
  border-color: #2b333f;
}

[data-theme="dark"] .markdown {
  color: #d7deea;
}

[data-theme="dark"] .markdown code {
  color: #fda4af;
  background: #3b1420;
  border-color: #5f2230;
}

[data-theme="dark"] .markdown pre {
  color: #e5ecf6;
  background: #0b0f17;
  border: 1px solid #2b333f;
}

[data-theme="dark"] .markdown pre code {
  color: inherit;
  background: transparent;
  border: 0;
}

[data-theme="dark"] .timeline-item.active {
  border-color: #8fb7ff;
  box-shadow: 0 0 0 3px rgba(143, 183, 255, 0.14);
}

[data-theme="dark"] .notice {
  color: #bfdbfe;
  background: #172554;
  border-color: #1d4ed8;
}

[data-theme="dark"] .modal-layer {
  background: rgba(3, 7, 18, 0.66);
}

[data-theme="dark"] .field span {
  color: #c2ccda;
}

[data-theme="dark"] .field input,
[data-theme="dark"] .field textarea {
  color: #e7ecf5;
  background: #11161d;
  border-color: #3a4554;
}

[data-theme="dark"] .preview {
  background: #141a22;
  border-color: #2b333f;
}

[data-theme="dark"] .error {
  color: #fda4af;
}

@media (max-width: 900px) {
  .unit-layout,
  .form-grid,
  .editor-pair {
    grid-template-columns: 1fr;
  }

  .side {
    order: -1;
  }
}

@media (max-width: 680px) {
  .topbar,
  .head,
  .panel-head,
  .modal-head {
    align-items: stretch;
    flex-direction: column;
  }

  .shell,
  .notice {
    width: min(100% - 30px, 1180px);
  }

  h1 {
    font-size: 27px;
  }
}
