:root {
  --draft-bg: #1d2021;
  --draft-bg-soft: #282828;
  --draft-bg-raised: #3c3836;
  --draft-fg: #ebdbb2;
  --draft-fg-bright: #fbf1c7;
  --draft-muted: #928374;
  --draft-green: #b8bb26;
  --draft-yellow: #fabd2f;
  --draft-red: #fb4934;
  --draft-aqua: #8ec07c;
  --draft-blue: #83a598;
  --draft-purple: #d3869b;
  --draft-border: #504945;
  --draft-preview-width: min(46vw, 48rem);
  --draft-outline-width: 15rem;
}

.draft-editor-bootstrap {
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: 100vw;
  height: 100dvh;
  margin: 0;
  padding: 1rem;
  color: var(--draft-muted);
  background: var(--draft-bg);
  font-family: "Maple Mono", "JetBrains Mono", "Iosevka", monospace;
  font-size: 0.9rem;
}

.draft-editor-bootstrap[data-state="error"] {
  color: var(--draft-fg);
}

.draft-editor-bootstrap-card {
  display: grid;
  gap: 0.8rem;
  width: min(34rem, calc(100vw - 2rem));
  padding: 1rem;
  border: 1px solid var(--draft-border);
  border-radius: 0.35rem;
  background: var(--draft-bg-soft);
}

.draft-editor-bootstrap-card strong {
  color: var(--draft-red);
  font-size: 1rem;
}

.draft-editor-bootstrap-card p {
  margin: 0;
  color: var(--draft-muted);
  line-height: 1.5;
}

.draft-editor-bootstrap-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.draft-editor-bootstrap-actions button {
  min-height: 2rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--draft-border);
  border-radius: 0.2rem;
  color: var(--draft-fg);
  background: var(--draft-bg);
  font: inherit;
}

.draft-editor-bootstrap-actions button:hover,
.draft-editor-bootstrap-actions button:focus-visible {
  color: var(--draft-fg-bright);
  background: var(--draft-bg-raised);
  outline: none;
}

html,
body.draft-editor-document {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--draft-bg);
}

body.draft-editor-document {
  max-width: none;
  color: var(--draft-fg);
  font-family: "Maple Mono", "JetBrains Mono", "Iosevka", monospace;
}

.draft-editor-shell {
  display: grid;
  grid-template-rows: 2.5rem 2.25rem minmax(0, 1fr) 1.8rem;
  width: 100vw;
  height: 100dvh;
  margin: 0;
  padding: 0;
  background: var(--draft-bg);
}

.draft-editor-topbar,
.draft-editor-toolbar,
.draft-editor-statusbar {
  display: flex;
  align-items: center;
  box-sizing: border-box;
  width: 100%;
  color: var(--draft-fg);
  background: var(--draft-bg-soft);
  font-size: 0.78rem;
  line-height: 1;
  user-select: none;
}

.draft-editor-topbar {
  gap: 0.65rem;
  padding: 0 0.75rem;
  border-bottom: 1px solid var(--draft-border);
}

.draft-editor-toolbar {
  gap: 0.3rem;
  padding: 0.28rem 0.55rem;
  border-bottom: 1px solid #3c3836;
  background: #242424;
  overflow-x: auto;
  scrollbar-width: none;
}

.draft-editor-toolbar::-webkit-scrollbar {
  display: none;
}

.draft-editor-statusbar {
  justify-content: space-between;
  gap: 1rem;
  padding: 0 0.7rem;
  border-top: 1px solid var(--draft-border);
  color: var(--draft-fg-bright);
  background: var(--draft-bg-raised);
}

.draft-editor-file-area {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.draft-editor-file {
  max-width: min(44vw, 42rem);
  overflow: hidden;
  color: var(--draft-fg-bright);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.draft-editor-language {
  padding: 0.18rem 0.4rem;
  border: 1px solid var(--draft-border);
  border-radius: 999px;
  color: var(--draft-aqua);
  background: #1d2021;
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.draft-editor-top-spacer {
  flex: 1;
}

.draft-editor-local,
.draft-editor-sync {
  color: var(--draft-muted);
  white-space: nowrap;
}

.draft-editor-local[data-kind="ok"],
.draft-editor-sync[data-kind="ok"] {
  color: var(--draft-green);
}

.draft-editor-local[data-kind="working"],
.draft-editor-sync[data-kind="dirty"],
.draft-editor-sync[data-kind="working"] {
  color: var(--draft-yellow);
}

.draft-editor-local[data-kind="error"],
.draft-editor-sync[data-kind="error"] {
  color: var(--draft-red);
}

.draft-editor-button,
.draft-editor-dialog button,
.draft-editor-dialog select,
.draft-editor-dialog input,
.draft-editor-dialog textarea {
  box-sizing: border-box;
  border: 1px solid var(--draft-border);
  border-radius: 0.2rem;
  color: var(--draft-fg);
  background: #1d2021;
  font: inherit;
}

.draft-editor-button {
  min-height: 1.65rem;
  padding: 0.15rem 0.55rem;
  white-space: nowrap;
}

.draft-editor-button:hover,
.draft-editor-button:focus-visible,
.draft-editor-dialog button:hover,
.draft-editor-dialog button:focus-visible {
  color: var(--draft-fg-bright);
  background: var(--draft-bg-raised);
  outline: none;
}

.draft-editor-button:disabled {
  color: var(--draft-muted);
  opacity: 0.45;
}

.draft-editor-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.draft-editor-workspace.with-outline {
  grid-template-columns: var(--draft-outline-width) minmax(0, 1fr);
}

.draft-editor-workspace.with-preview {
  grid-template-columns: minmax(0, 1fr) 5px var(--draft-preview-width);
}

.draft-editor-workspace.with-outline.with-preview {
  grid-template-columns: var(--draft-outline-width) minmax(0, 1fr) 5px var(--draft-preview-width);
}

.draft-editor-outline {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--draft-border);
  background: #202020;
}

.draft-editor-outline[hidden] {
  display: none;
}

.draft-editor-panel-header,
.draft-editor-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
  min-height: 1.9rem;
  padding: 0 0.65rem;
  border-bottom: 1px solid var(--draft-border);
  color: var(--draft-fg);
  background: var(--draft-bg-soft);
  font-size: 0.74rem;
  user-select: none;
}

.draft-editor-outline-list {
  height: calc(100% - 1.9rem);
  padding: 0.4rem 0.25rem 2rem;
  overflow: auto;
}

.draft-editor-outline-item {
  display: block;
  width: 100%;
  min-height: 1.55rem;
  padding: 0.2rem 0.45rem;
  overflow: hidden;
  border: 0;
  color: var(--draft-fg);
  background: transparent;
  text-align: left;
  text-overflow: ellipsis;
}

.draft-editor-outline-empty {
  padding: 0.6rem;
  color: var(--draft-muted);
  font-size: 0.75rem;
}

.draft-editor-pane,
.draft-editor-host {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.draft-editor-host,
.draft-editor-host .cm-editor {
  height: 100%;
}

.draft-editor-host .cm-editor.cm-focused {
  outline: none;
}

.draft-editor-host .cm-scroller {
  scrollbar-color: var(--draft-border) var(--draft-bg);
}

.draft-editor-resize {
  cursor: col-resize;
  background: #3c3836;
  border-left: 1px solid #282828;
  border-right: 1px solid #504945;
  touch-action: none;
}

.draft-editor-resize:hover,
.draft-editor-resize:focus-visible {
  background: var(--draft-blue);
  outline: none;
}

.draft-editor-resize[hidden] {
  display: none;
}

.draft-editor-preview {
  display: grid;
  grid-template-rows: 1.9rem minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #202020;
}

.draft-editor-preview[hidden] {
  display: none;
}

.draft-editor-preview-state {
  color: var(--draft-muted);
}

.draft-editor-preview-state[data-kind="working"] {
  color: var(--draft-yellow);
}

.draft-editor-preview-state[data-kind="ok"] {
  color: var(--draft-green);
}

.draft-editor-preview-state[data-kind="error"] {
  color: var(--draft-red);
}

.draft-editor-preview-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: white;
}

.draft-editor-preview-error {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 1rem;
  overflow: auto;
  color: var(--draft-red);
  background: var(--draft-bg);
  font: 0.78rem/1.45 "Maple Mono", "JetBrains Mono", monospace;
  white-space: pre-wrap;
}

.draft-editor-dialog {
  width: min(92vw, 42rem);
  max-height: 84vh;
  padding: 0;
  border: 1px solid var(--draft-border);
  border-radius: 0.35rem;
  color: var(--draft-fg);
  background: var(--draft-bg-soft);
  box-shadow: 0 1.2rem 4rem #000a;
}

.draft-editor-dialog::backdrop {
  background: #0008;
}

.draft-editor-dialog-card {
  display: grid;
  gap: 0.8rem;
  box-sizing: border-box;
  padding: 1rem;
  color: var(--draft-fg);
  background: var(--draft-bg-soft);
  font: 0.82rem/1.45 "Maple Mono", "JetBrains Mono", monospace;
}

.draft-editor-dialog-title {
  color: var(--draft-fg-bright);
  font-size: 0.92rem;
  font-weight: 700;
}

.draft-editor-dialog label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.draft-editor-dialog input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
}

.draft-editor-dialog input[type="range"] {
  width: min(16rem, 50vw);
}

.draft-editor-dialog select,
.draft-editor-dialog input[type="search"],
.draft-editor-dialog textarea {
  min-height: 2rem;
  padding: 0.35rem 0.5rem;
}

.draft-editor-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
}

.draft-editor-dialog-actions button,
.draft-editor-convert-controls button {
  min-height: 1.9rem;
  padding: 0.25rem 0.65rem;
}

.draft-editor-convert-card {
  grid-template-rows: auto auto auto minmax(12rem, 42vh) auto;
}

.draft-editor-convert-controls {
  display: flex;
  align-items: end;
  gap: 0.6rem;
}

.draft-editor-convert-controls label {
  flex: 1;
}

.draft-editor-convert-status {
  color: var(--draft-muted);
}

.draft-editor-convert-output {
  width: 100%;
  min-height: 12rem;
  resize: vertical;
  color: var(--draft-fg-bright);
  background: var(--draft-bg);
  font: 0.8rem/1.5 "Maple Mono", "JetBrains Mono", monospace;
}

.draft-editor-command-card {
  gap: 0.5rem;
}

.draft-editor-command-search {
  width: 100%;
  color: var(--draft-fg-bright);
  background: var(--draft-bg);
}

.draft-editor-command-list {
  display: grid;
  gap: 0.2rem;
  max-height: 52vh;
  overflow: auto;
}

.draft-editor-command-item {
  width: 100%;
  min-height: 2rem;
  border: 0;
  text-align: left;
}

.draft-editor-files-card {
  max-height: 78vh;
  overflow: auto;
}

.draft-editor-dialog-title small {
  margin-left: 0.35rem;
  color: var(--draft-muted);
  font-size: 0.68rem;
  font-weight: 400;
}

.draft-editor-files-note,
.draft-editor-files-empty {
  margin: 0;
  color: var(--draft-muted);
}

.draft-editor-files-actions,
.draft-editor-project-file {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.draft-editor-project-file {
  min-height: 2.2rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--draft-border);
}

.draft-editor-project-file-name {
  flex: 1;
  overflow-wrap: anywhere;
  color: var(--draft-fg-bright);
}

.draft-editor-files-actions button,
.draft-editor-project-file button {
  min-height: 1.8rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--draft-border);
  border-radius: 0.2rem;
  color: var(--draft-fg);
  background: var(--draft-bg);
  font: inherit;
}

.draft-editor-file-edit-dialog {
  width: min(92vw, 58rem);
}

.draft-editor-file-edit-card {
  grid-template-rows: auto minmax(16rem, 60vh) auto;
}

.draft-editor-file-edit-card textarea {
  width: 100%;
  min-height: 16rem;
  resize: vertical;
  color: var(--draft-fg-bright);
  background: var(--draft-bg);
  font: 0.82rem/1.5 "Maple Mono", "JetBrains Mono", monospace;
}

@media (max-width: 1050px) {
  :root {
    --draft-outline-width: 12rem;
    --draft-preview-width: 44vw;
  }

  .draft-editor-local {
    display: none;
  }
}

@media (max-width: 850px) {
  .draft-editor-workspace.with-outline,
  .draft-editor-workspace.with-outline.with-preview,
  .draft-editor-workspace.with-preview {
    grid-template-columns: 1fr;
  }

  .draft-editor-workspace.with-preview {
    grid-template-rows: minmax(12rem, 1fr) minmax(12rem, 1fr);
  }

  .draft-editor-workspace.with-outline.with-preview {
    grid-template-rows: auto minmax(12rem, 1fr) minmax(12rem, 1fr);
  }

  .draft-editor-outline {
    max-height: 10rem;
    border-right: 0;
    border-bottom: 1px solid var(--draft-border);
  }

  .draft-editor-outline-list {
    height: auto;
    max-height: 8rem;
  }

  .draft-editor-resize {
    display: none !important;
  }

  .draft-editor-preview {
    border-top: 1px solid var(--draft-border);
  }
}

@media (max-width: 620px) {
  .draft-editor-shell {
    grid-template-rows: 2.4rem 2.2rem minmax(0, 1fr) 1.75rem;
  }

  .draft-editor-topbar {
    gap: 0.4rem;
    padding-inline: 0.45rem;
  }

  .draft-editor-file {
    max-width: 54vw;
  }

  .draft-editor-sync {
    display: none;
  }

  .draft-editor-toolbar {
    padding-inline: 0.35rem;
  }

  .draft-editor-button {
    padding-inline: 0.42rem;
  }

  .draft-editor-statusbar {
    padding-inline: 0.5rem;
    font-size: 0.7rem;
  }

  .draft-editor-dialog label {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.4rem;
  }

  .draft-editor-convert-controls {
    align-items: stretch;
    flex-direction: column;
  }
}

/* Keep the standard editor capable but visually small. The hidden actions are
   still present for keyboard shortcuts and the command palette. */
.draft-editor-toolbar > button:nth-of-type(3),
.draft-editor-toolbar > button:nth-of-type(4),
.draft-editor-toolbar > button:nth-of-type(5),
.draft-editor-toolbar > button:nth-of-type(6),
.draft-editor-toolbar > button:nth-of-type(9),
.draft-productivity-group > button:not(:last-child) {
  display: none;
}
