:root {
  /* Tells the platform this is a dark surface, so native scrollbars and
     controls are drawn dark instead of a bright white bar down a dark panel. */
  color-scheme: dark;

  --bg: #16161a;
  --bg-panel: #1c1c21;
  --bg-raised: #24242b;
  --bg-hover: #2c2c35;
  --border: #32323c;
  --text: #e6e6ea;
  --text-dim: #9a9aa8;
  --text-faint: #6a6a78;
  --accent: #7c6cff;
  --accent-dim: #4b3fa8;
  --warn: #e0a44a;
  --danger: #e05a5a;
  --ok: #4aab6e;
  --radius: 6px;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, "Courier New", monospace;
  --sans: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  cursor: pointer;
}
button:hover:not(:disabled) {
  background: var(--bg-hover);
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button.primary {
  background: var(--accent-dim);
  border-color: var(--accent);
}
button.primary:hover:not(:disabled) {
  background: var(--accent);
}
button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
}
button.ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
}

input,
select,
textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 9px;
  width: 100%;
}
/*
 * The full width above is meant for text fields. A checkbox is a fixed glyph,
 * and stretching one to fill its container makes it a 590px hit area that
 * shoves every label beside it off to the right -- which is exactly what
 * happened to the sync panel before this rule existed.
 */
input[type='checkbox'],
input[type='radio'] {
  width: auto;
  flex: none;
  padding: 0;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}
label.field {
  display: block;
  margin-bottom: 14px;
}
label.field > span {
  display: block;
  margin-bottom: 5px;
  color: var(--text-dim);
  font-size: 12px;
}
label.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  cursor: pointer;
}
label.check input {
  width: auto;
}
.hint {
  color: var(--text-faint);
  font-size: 12px;
  margin-top: 4px;
  line-height: 1.5;
}
.error {
  color: var(--danger);
  font-size: 12px;
  margin-top: 8px;
}

/* --------------------------------------------------------------- app shell */

.app {
  display: flex;
  height: 100%;
}

.sidebar {
  width: 290px;
  flex: none;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sidebar-head h1 {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-head .sub {
  font-size: 11px;
  color: var(--text-faint);
}

.outline {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 24px;
}

.episode-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}
.episode-row:hover {
  background: var(--bg-hover);
}
.episode-row.active {
  color: var(--accent);
}
.episode-row .file {
  font-weight: 400;
  font-size: 11px;
  color: var(--text-faint);
  margin-left: auto;
}

.beat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 30px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
}
.beat-row:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.beat-row .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
}
.beat-row .title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.beat-row .kind {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-faint);
  flex: none;
}
.beat-row.unwritten .title {
  font-style: italic;
  color: var(--text-faint);
}

.empty-note {
  padding: 14px;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.6;
}

/* -------------------------------------------------------------------- main */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tabbar {
  display: flex;
  align-items: stretch;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  min-height: 36px;
}
.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-right: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
}
.tab:hover {
  background: var(--bg-hover);
}
.tab.active {
  background: var(--bg);
  color: var(--text);
  box-shadow: inset 0 2px 0 var(--accent);
}
.tab .close {
  color: var(--text-faint);
  font-size: 15px;
  line-height: 1;
}
.tab .close:hover {
  color: var(--text);
}
.tab .dirty {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
}

.mode-switch {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
}
.mode-switch .seg {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.mode-switch .seg button {
  border: none;
  border-radius: 0;
  padding: 4px 12px;
  font-size: 12px;
  background: transparent;
}
.mode-switch .seg button.on {
  background: var(--accent-dim);
  color: #fff;
}

.editor-area {
  flex: 1;
  min-height: 0;
  position: relative;
}
.cm-host {
  position: absolute;
  inset: 0;
}
.cm-host .cm-editor {
  height: 100%;
}
.cm-host .cm-scroller {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
}

.placeholder {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-faint);
  text-align: center;
  padding: 32px;
}
.placeholder h2 {
  color: var(--text-dim);
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}
.placeholder p {
  margin: 0;
  font-size: 13px;
  max-width: 460px;
  line-height: 1.6;
}

.statusbar {
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
  padding: 4px 12px;
  font-size: 11px;
  color: var(--text-faint);
  display: flex;
  gap: 16px;
  align-items: center;
}
.statusbar .spacer {
  margin-left: auto;
}

/* --------------------------------------------------------------- gate/modal */

.gate {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  overflow-y: auto;
}
.gate-card {
  width: 100%;
  max-width: 620px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px;
}
.gate-card h1 {
  font-size: 19px;
  margin: 0 0 4px;
}
.gate-card > .hint {
  margin-bottom: 22px;
}

.project-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}
.project-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
.project-item:hover {
  border-color: var(--accent);
}
.project-item .meta {
  min-width: 0;
}
.project-item .name {
  font-weight: 600;
}
.project-item .path {
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-item .actions {
  margin-left: auto;
  flex: none;
}

.row {
  display: flex;
  gap: 8px;
}
.row > * {
  flex: 1;
}
.row > .none {
  flex: none;
}
.actions-row {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  z-index: 50;
}
.modal {
  width: 100%;
  max-width: 520px;
  max-height: 100%;
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
}
.modal h2 {
  margin: 0 0 18px;
  font-size: 16px;
}

.seg-choice {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.seg-choice button {
  flex: 1;
  text-align: left;
  padding: 10px 12px;
}
.seg-choice button.on {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.seg-choice .t {
  display: block;
  font-weight: 600;
  font-size: 13px;
}
.seg-choice .d {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ------------------------------------------------------------ project switcher */

.switcher {
  position: relative;
}
.switcher-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 2px 4px;
  background: transparent;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}
.switcher-trigger:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border);
}
.switcher-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.switcher-caret {
  margin-left: auto;
  flex: none;
  font-size: 8px;
  color: var(--text-faint);
}

.popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 300px;
  max-width: 420px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  padding: 6px;
  z-index: 40;
}
.popover-label {
  padding: 4px 8px 6px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.popover-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  padding: 7px 8px;
  font-weight: 400;
}
.popover-item:hover:not(:disabled) {
  background: var(--bg-hover);
}
.popover-item.current {
  opacity: 1;
  position: relative;
}
.popover-item.current .pi-name {
  color: var(--accent);
}
.pi-name {
  display: block;
  font-size: 13px;
}
.pi-path {
  display: block;
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: rtl;
  text-align: left;
}
.pi-check {
  position: absolute;
  right: 8px;
  top: 7px;
  color: var(--accent);
  font-size: 12px;
}
.popover-empty {
  padding: 6px 8px 10px;
  font-size: 12px;
  color: var(--text-faint);
}
.popover-sep {
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}

/* ----------------------------------------------------------------- writer */

.writer {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.writer-toolbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-faint);
}
.wt-hint kbd {
  font-family: var(--mono);
  font-size: 10px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 4px;
  color: var(--text-dim);
}
.wt-toggle {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.wt-toggle input {
  width: auto;
}

/* Fills the pane; the screenplay indents are proportional to the column.
   Positioned so children measure offsetTop against it, not against .writer. */
.writer-page {
  position: relative;
  flex: 1;
  overflow-y: auto;
  padding: 36px 5% 60vh;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}

.blk-blank {
  height: 12px;
}

.blk-label {
  margin: 30px 0 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  color: var(--text);
}
.blk-label span {
  cursor: text;
}
.blk-label-input {
  width: 100%;
  font: inherit;
  text-transform: uppercase;
  background: var(--bg-raised);
  border: 1px solid var(--accent);
  color: inherit;
  padding: 2px 6px;
}

.blk-action {
  margin: 10px 0;
  color: var(--text-dim);
  max-width: 78%;
}

.blk-choice {
  margin: 8px 0 8px 14%;
  display: flex;
  gap: 8px;
  color: #d9c68f;
}
.blk-choice-mark {
  flex: none;
  color: var(--text-faint);
}

.blk-dialogue {
  margin: 12px 0;
}
.blk-character {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 30%;
}
.blk-character-name {
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: text;
}
.blk-character-name.narrator {
  color: var(--text-faint);
  font-weight: 400;
  font-style: italic;
}
.blk-text {
  padding-left: 18%;
  padding-right: 16%;
}

.blk-view {
  display: block;
  cursor: text;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 1.6em;
}
.blk-view.empty {
  color: var(--text-faint);
  font-style: italic;
}

.blk-input {
  display: block;
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 1px 6px;
  resize: none;
  overflow: hidden;
  white-space: pre-wrap;
}

.blk-raw {
  margin: 3px 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-panel);
  border-left: 2px solid var(--border);
  padding: 1px 8px;
}

.writer-empty {
  color: var(--text-faint);
  font-style: italic;
}

/* ------------------------------------------------------- speaker completion */

.speaker-wrap {
  position: relative;
}
.blk-character-input {
  width: 230px;
  font: inherit;
  font-weight: 700;
  background: var(--bg-raised);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 1px 6px;
}
.blk-expression {
  width: auto;
  font-family: var(--sans);
  font-size: 11px;
  padding: 1px 4px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.speaker-suggest {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  min-width: 260px;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.55);
  z-index: 30;
  max-height: 240px;
  overflow-y: auto;
}
.speaker-suggest li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
}
.speaker-suggest li.on {
  background: var(--accent-dim);
}
.speaker-suggest li:hover {
  background: var(--bg-hover);
}
.ss-var {
  color: var(--text);
}
.ss-name {
  margin-left: auto;
  font-family: var(--sans);
  color: var(--text-faint);
}

/* ---------------------------------------------------- outline collapse */

.ep-caret {
  flex: none;
  width: 12px;
  font-size: 9px;
  color: var(--text-faint);
  transition: transform 0.1s ease;
  display: inline-block;
}
.ep-caret:hover {
  color: var(--text);
}
.ep-caret.collapsed {
  transform: rotate(-90deg);
}
.ep-count {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-faint);
  background: var(--bg-raised);
  border-radius: 8px;
  padding: 0 6px;
}

/* ------------------------------------------------------ character variant */

.blk-variant {
  margin-left: 7px;
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: lowercase;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 6px;
  vertical-align: middle;
}

/* ------------------------------------------------------ expression picker */

.expr {
  position: relative;
}
.expr-trigger {
  font-family: var(--sans);
  font-size: 11px;
  padding: 1px 8px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 10px;
}
.expr-trigger.unknown {
  border-color: var(--warn);
  color: var(--warn);
}

.expr-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 32;
  margin: 0;
  padding: 4px;
  list-style: none;
  min-width: 170px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.55);
  font-family: var(--sans);
  font-size: 12px;
}
.expr-list li {
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-dim);
}
.expr-list li:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.expr-list li.on {
  color: var(--accent);
}
.expr-list li.unknown {
  color: var(--warn);
}
.expr-list li.empty {
  cursor: default;
  color: var(--text-faint);
  font-style: italic;
}

.expr-preview {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  z-index: 33;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}
.expr-preview img {
  display: block;
  max-width: 190px;
  max-height: 240px;
  border-radius: 4px;
}
.expr-preview span {
  font-family: var(--sans);
  font-size: 10px;
  color: var(--text-faint);
}

/* --------------------------------------------------------- format toolbar */

.blk-edit {
  position: relative;
}
.fmt-bar {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  z-index: 31;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}
.fmt-bar button {
  font-family: var(--sans);
  font-size: 12px;
  min-width: 26px;
  padding: 2px 6px;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-dim);
}
.fmt-bar button:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
}
.fmt-sep {
  width: 1px;
  align-self: stretch;
  background: var(--border);
  margin: 0 3px;
}

/* -------------------------------------------------------- reference panel */

.ref-toggle {
  font-size: 12px;
  padding: 4px 12px;
  margin-right: 8px;
  background: transparent;
}
.ref-toggle.on {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #fff;
}

.refpanel {
  width: 380px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  min-height: 0;
}

.ref-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 12px;
  border-bottom: 1px solid var(--border);
}
.ref-tabs {
  display: flex;
  gap: 2px;
  flex: 1;
}
.ref-tabs button {
  flex: 1;
  font-size: 12px;
  padding: 4px 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
}
.ref-tabs button:hover:not(:disabled) {
  background: var(--bg-hover);
}
.ref-tabs button.on {
  background: var(--bg-raised);
  border-color: var(--border);
  color: var(--text);
}

.ref-search {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.ref-search input {
  font-size: 12px;
  padding: 4px 8px;
}

.ref-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.ref-actions {
  padding: 8px 12px 0;
}
.ref-actions button {
  width: 100%;
  font-size: 12px;
  padding: 4px 8px;
}

.ref-list {
  list-style: none;
  margin: 0;
  padding: 6px;
}
.ref-list li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.ref-list li:hover {
  background: var(--bg-hover);
}
.ref-list li.on {
  background: var(--accent-dim);
}
.ref-list li.ref-empty {
  cursor: default;
  color: var(--text-faint);
  font-size: 12px;
  font-style: italic;
}
.ref-list li.ref-empty:hover {
  background: transparent;
}
.rl-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rl-var {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
}
.rl-tag {
  margin-left: auto;
  font-size: 10px;
  color: var(--warn);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 6px;
  flex: none;
}

.ref-detail {
  padding: 10px 12px 24px;
  border-top: 1px solid var(--border);
}
.rd-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}
.rd-title {
  font-size: 14px;
  font-weight: 600;
}
.rd-var {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
}
.rd-delete {
  margin-left: auto;
  font-size: 11px;
  color: var(--danger);
}

.ref-field {
  display: block;
  margin-bottom: 12px;
}
.rf-label {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 3px;
}
.rf-hint {
  display: block;
  font-size: 10px;
  color: var(--text-faint);
  margin-top: 3px;
  line-height: 1.45;
}
.rf-view {
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: var(--bg);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  cursor: text;
}
.rf-view:hover {
  border-color: var(--border);
}
.rf-view.empty {
  color: var(--text-faint);
  font-style: italic;
}
.ref-field textarea,
.ref-field input {
  font-size: 13px;
  padding: 4px 8px;
}

.wikilink {
  display: inline;
  padding: 0;
  background: none;
  border: none;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.wikilink:hover:not(:disabled) {
  background: none;
  color: #a99bff;
}
.wikilink.unresolved {
  color: var(--text-faint);
  text-decoration-style: dotted;
}

.rd-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.rd-chip {
  font-size: 10px;
  color: var(--text-dim);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1px 7px;
}

/* ------------------------------------------------- character editor (tab) */

.tab-kind {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 5px;
}

.chareditor {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  background: var(--bg);
}
.ce-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 40px 25vh;
}
.ce-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 22px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.ce-head h1 {
  margin: 0;
  font-size: 22px;
}
.ce-var {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
}

/* Long fields hold pages of prose, so they get a readable measure and a
   generous minimum height in the full-size view. */
.charfields.full .ref-field {
  margin-bottom: 22px;
}
.charfields.full .rf-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 5px;
}
.charfields.full .rf-view,
.charfields.full input,
.charfields.full .rf-long {
  font-size: 14px;
  line-height: 1.65;
  padding: 8px 11px;
}
.charfields.full .rf-view.long {
  min-height: 220px;
}
.charfields.full .rf-long {
  min-height: 460px;
}

.charfields.panel .rf-view.long {
  min-height: 72px;
  max-height: 320px;
  overflow-y: auto;
}
.charfields.panel .rf-long {
  min-height: 180px;
}

.rf-long {
  resize: vertical;
  font-family: var(--sans);
  line-height: 1.6;
}

.rd-expand {
  margin-left: auto;
  font-size: 11px;
}
.rd-expand + .rd-delete {
  margin-left: 8px;
}

/* ------------------------------------------------ character profiles */

.ref-list li.draggable {
  position: relative;
}
.ref-list li.dragging {
  opacity: 0.4;
}
.ref-list li.dragover {
  box-shadow: inset 0 2px 0 var(--accent);
}
.rl-grip {
  flex: none;
  cursor: grab;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1;
  padding: 0 2px;
  user-select: none;
}
.rl-grip:hover {
  color: var(--text);
}
.rl-grip:active {
  cursor: grabbing;
}

.ref-unassigned {
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
.ru-head {
  padding: 10px 12px 2px;
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.pick-list {
  list-style: none;
  margin: 0;
  padding: 4px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.pick-list li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
.pick-list li:hover {
  background: var(--bg-hover);
}
.pick-list li.on {
  background: var(--accent-dim);
}
.pick-list input {
  width: auto;
}
.pl-var {
  font-family: var(--mono);
}
.pl-name {
  color: var(--text-dim);
}
.pl-count {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-faint);
}

/* ------------------------------------- script variables in the full editor */

.ce-vars {
  margin-top: 34px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.ce-vars h2 {
  font-size: 13px;
  margin: 0 0 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.ce-empty {
  color: var(--text-faint);
  font-style: italic;
  font-size: 13px;
}
.ce-varlist {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}
.ce-varlist li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  background: var(--bg-panel);
}
.cv-name {
  font-family: var(--mono);
  font-size: 13px;
  min-width: 160px;
}
.cv-script {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  font-size: 13px;
  padding: 2px 8px;
}
.cv-script:hover:not(:disabled) {
  border-color: var(--border);
  color: var(--text);
}
.cv-script-input {
  width: 220px;
  font-size: 13px;
  padding: 2px 8px;
}
.cv-count {
  font-size: 11px;
  color: var(--text-faint);
}
.cv-remove {
  margin-left: auto;
  font-size: 11px;
}
.cv-missing .cv-name {
  color: var(--text-faint);
  text-decoration: line-through;
}
.cv-warn {
  font-size: 11px;
  color: var(--warn);
}
.ce-assign {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.ce-assign select {
  max-width: 380px;
}

/* ------------------------------------------------------- image hover tip */

.cm-tooltip.cm-tooltip-hover {
  background: transparent;
  border: none;
}
.img-tip {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.6);
  max-width: 460px;
}
.img-tip img {
  display: block;
  max-width: 440px;
  max-height: 300px;
  border-radius: 4px;
}
.img-tip-swatch {
  width: 120px;
  height: 70px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.img-tip-note {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--text-dim);
  padding: 10px 12px;
}
.img-tip-note.missing {
  color: var(--warn);
}
.img-tip-caption {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
  margin-top: 5px;
  text-align: center;
  word-break: break-all;
}

/* ------------------------------------------------------------- plot board */

.plot {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.plot-note {
  flex: none;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 14px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
}
.plot-note.error {
  color: var(--danger);
}
.pn-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.pn-warn {
  color: var(--warn);
}

.plot-board {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 14px;
  padding: 18px;
  overflow-x: auto;
  overflow-y: hidden;
}

.plot-col {
  flex: none;
  width: 280px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.plot-col.dragging {
  opacity: 0.5;
}

.plot-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 4px;
}
.plot-title {
  flex: 1;
  text-align: left;
  background: transparent;
  border: none;
  padding: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.plot-title:hover:not(:disabled) {
  background: transparent;
  color: var(--accent);
}
.plot-status {
  flex: none;
  font-size: 10px;
  padding: 1px 8px;
  border-radius: 9px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-faint);
}
.plot-status.draft {
  border-color: var(--warn);
  color: var(--warn);
}
.plot-file {
  padding: 0 12px 8px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border);
}

.plot-cards {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
}

.plot-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
  margin-bottom: 7px;
  cursor: grab;
}
.plot-card:hover {
  border-color: var(--accent);
}
.plot-card.dragging {
  opacity: 0.4;
}
.plot-card.unwritten .pc-title {
  font-style: italic;
  color: var(--text-faint);
}
.pc-title {
  font-size: 12.5px;
  line-height: 1.4;
  word-break: break-word;
}
.pc-meta {
  margin-top: 4px;
  display: flex;
  gap: 8px;
}
.pc-kind {
  font-size: 10px;
  color: var(--text-faint);
}

.plot-drop {
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
  margin: 3px 0 6px;
}
.plot-empty {
  color: var(--text-faint);
  font-size: 12px;
  font-style: italic;
  padding: 10px;
}

.plot-busy {
  position: absolute;
  bottom: 16px;
  right: 20px;
  background: var(--bg-raised);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-dim);
}

.episode-row.dragover {
  box-shadow: inset 0 2px 0 var(--accent);
}
.episode-row.dragging {
  opacity: 0.45;
}
.ep-draft {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--warn);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 5px;
  font-weight: 400;
}

/* --------------------------------------------------------------- translate */

.pass-modal {
  max-width: 720px;
}
.tr-running {
  padding: 18px 0;
  color: var(--text-dim);
  font-size: 13px;
}
.tr-summary {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.tr-changes {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 44vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.tr-changes li {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.tr-changes li:last-child {
  border-bottom: none;
}
.tc-head {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 4px;
}
.tc-line {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
}
.tc-speaker {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}
.tc-before {
  font-size: 12.5px;
  color: var(--text-faint);
  text-decoration: line-through;
  margin-bottom: 2px;
}
.tc-after {
  font-size: 13px;
  color: var(--text);
}
.tr-none {
  color: var(--text-faint);
  font-style: italic;
  font-size: 12.5px;
}

/* -------------------------------------------------------------- context menu */

.ctxmenu {
  position: fixed;
  z-index: 60;
  min-width: 190px;
  padding: 4px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 7px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.6);
}
.ctx-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: nowrap;
}
.ctx-item:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
}
.ctx-item.separated {
  margin-top: 4px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  border-radius: 0 0 4px 4px;
}

/* --------------------------------------------------- beat action in the writer */

.blk-label {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.blk-label-name {
  flex: 1;
  min-width: 0;
}
.blk-label-actions {
  flex: none;
  margin-left: auto;
  display: flex;
  gap: 6px;
}
.blk-label-action {
  flex: none;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: none;
  padding: 1px 9px;
  border-radius: 9px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-faint);
  opacity: 0.55;
  transition: opacity 0.12s ease;
}
.blk-label:hover .blk-label-action {
  opacity: 1;
}
.blk-label-action:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: transparent;
}

/* ----------------------------------------------------------------- renders */

.renders-modal {
  max-width: 760px;
}
.rs-config {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}
.rs-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rs-row input {
  flex: 1;
  min-width: 0;
}
.rs-fixed {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
  white-space: nowrap;
}
.rs-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.rs-count {
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 9px;
  border: 1px solid var(--border);
  color: var(--text-faint);
}
.rs-count.new {
  border-color: var(--accent);
  color: var(--accent);
}
.rs-count.stale {
  border-color: var(--warn);
  color: var(--warn);
}
.rs-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.rs-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.rs-list li:last-child {
  border-bottom: none;
}
.rs-badge {
  flex: none;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 6px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  color: var(--accent);
}
.rs-badge.stale {
  border-color: var(--warn);
  color: var(--warn);
}
.rs-name,
.rs-out {
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rs-name {
  flex: 1;
  min-width: 0;
}
.rs-out {
  flex: 1;
  min-width: 0;
  color: var(--text-faint);
}
.rs-arrow,
.rs-size {
  flex: none;
  color: var(--text-faint);
}
.rs-none,
.rs-done {
  font-size: 13px;
  color: var(--text-faint);
  margin: 0 0 12px;
}
.rs-failures {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  font-size: 12px;
}
.rs-failures li {
  display: flex;
  gap: 8px;
  padding: 2px 0;
}
.rs-err {
  color: var(--danger);
  overflow: hidden;
  text-overflow: ellipsis;
}

.error .retry {
  margin-left: 10px;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 8px;
  border: 1px solid currentColor;
  color: inherit;
  background: transparent;
}

.rs-encoder {
  margin-bottom: 14px;
}
.rs-candidates {
  list-style: none;
  margin: 8px 0;
  padding: 0;
  font-size: 12px;
}
.rs-candidates li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
.rs-cand-label {
  flex: none;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  min-width: 130px;
}
.rs-encoder-ok {
  font-size: 11px;
  color: var(--text-faint);
  margin: 0 0 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* -------------------------------------------------------------------- sync */

.sync-modal {
  max-width: 720px;
}
.sync-branch {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.sb-branch,
.sb-upstream {
  font-family: var(--mono);
}
.sb-arrow,
.sb-upstream {
  color: var(--text-faint);
}
.sb-count {
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--text-faint);
}
.sb-count.ahead {
  border-color: var(--accent);
  color: var(--accent);
}
.sb-count.behind {
  border-color: var(--warn);
  color: var(--warn);
}
.sync-groups {
  list-style: none;
  margin: 0 0 14px;
  padding: 0 10px 0 0;
  max-height: 300px;
  overflow-y: auto;
}
.sg-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0 3px;
  font-size: 12px;
}
.sg-name {
  font-weight: 600;
  flex: 1;
  min-width: 0;
}
.sg-count {
  color: var(--text-faint);
  font-size: 11px;
}
.sg-files {
  list-style: none;
  margin: 0 0 6px;
  padding: 0 0 0 18px;
  font-size: 11px;
}
.sg-files li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 1px 0;
}
.sg-state {
  flex: none;
  min-width: 62px;
  color: var(--text-faint);
}
.sg-state.untracked,
.sg-state.added {
  color: var(--accent);
}
.sg-state.deleted,
.sg-state.conflicted {
  color: var(--danger);
}
/*
 * A path is shown as a folder that may be trimmed and a file name that never
 * is: the file name is the part being recognised. An earlier attempt used
 * direction:rtl to trim the front instead, which reordered leading punctuation
 * and turned ".renpywriter/notes.json" into "renpywriter/notes.json."
 */
.sg-path {
  flex: 1;
  min-width: 0;
  display: flex;
  font-family: var(--mono);
}
.sg-dir {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-faint);
}
.sg-file {
  flex: none;
  white-space: nowrap;
}
.sg-more {
  color: var(--text-faint);
  padding-left: 22px;
}
.sync-ok {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 10px;
}
.sb-count.review {
  color: var(--accent);
  border-color: var(--accent);
}
.sb-review {
  margin: 8px 0 0;
}

/* The one thing to do next after a refused push, so it does not read as part
   of the sentence above it. */
.sync-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--accent);
}
.sync-detail {
  font-family: var(--mono);
  font-size: 11px;
  white-space: pre-wrap;
  color: var(--text-faint);
  margin: 6px 0 0;
  max-height: 120px;
  overflow-y: auto;
}

.rs-save {
  margin-top: 10px;
}
.rs-saved {
  font-size: 12px;
  color: var(--accent);
}

/* ------------------------------------------------------------------- phone */

/*
 * One pane at a time, with a bar of tabs along the bottom.
 *
 * The desktop lays three columns side by side, which on a 390px screen leaves
 * each of them too narrow to use. Here each is full width and only one is on
 * screen; the bar below switches between them.
 */
.app.phone {
  flex-direction: column;
  /* Real viewport height on iOS, where the address bar makes 100vh a lie. */
  height: 100dvh;
}

.app.phone .pane-hidden {
  display: none;
}

.app.phone .sidebar,
.app.phone .refpanel,
.app.phone .main {
  width: 100%;
  flex: 1;
  min-width: 0;
  min-height: 0;
  border: none;
}

.phone-nav {
  flex: none;
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
  /* Clear of the home indicator rather than under it. */
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.pn-tab {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  /* Comfortably past the 44px a thumb needs. */
  padding: 9px 4px 7px;
  background: transparent;
  border: none;
  border-radius: 0;
  color: var(--text-dim);
}
.pn-tab.on {
  color: var(--accent);
}
.pn-glyph {
  font-size: 17px;
  line-height: 1;
}
.pn-label {
  font-size: 10px;
  letter-spacing: 0.02em;
}
.pn-dot {
  position: absolute;
  top: 7px;
  right: 50%;
  margin-right: -16px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

/* Touch sizing: rows a finger can hit, and no hover-only affordances. */
@media (max-width: 820px) {
  .episode-row,
  .beat-row {
    padding-top: 11px;
    padding-bottom: 11px;
  }
  .ref-list li,
  .pick-list li {
    padding-top: 10px;
    padding-bottom: 10px;
  }
  /* The label actions are always reachable; hover means nothing here. */
  .blk-label-action {
    opacity: 1;
  }
  /* A tab strip that scrolls rather than crushing every tab. */
  .tabbar {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .tabbar::-webkit-scrollbar {
    display: none;
  }
  .tab {
    flex: none;
  }
  /* Room to read: the writer is the reason to be here. */
  .writer {
    padding-left: 14px;
    padding-right: 14px;
  }
  .blk-text .blk-view,
  .blk-text textarea {
    line-height: 1.5;
  }
  /* iOS zooms the page when a focused field is under 16px. */
  .blk-text textarea,
  .blk-text input,
  .blk-character-input,
  .ref-field input,
  .ref-field textarea,
  .gate-card input {
    font-size: 16px;
  }
  /* The formatting bar belongs above the keyboard, not floating mid-screen. */
  .fmt-bar {
    position: sticky;
    bottom: 0;
    z-index: 3;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
  }
  .fmt-bar button {
    min-width: 40px;
    min-height: 36px;
  }
  /* Modals fill the screen instead of floating in a corner. */
  .modal {
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    padding: 16px;
  }
  .modal-backdrop {
    padding: 0;
  }
}

@media (max-width: 820px) {
  /*
   * The top row carried Plot, Sync and Reference, which the bar along the
   * bottom already offers. On a 390px screen they pushed the Writer/Code
   * toggle clean off the edge, so here the row keeps only what is not
   * reachable from below.
   */
  .mode-switch .ref-toggle {
    display: none;
  }
  /* Keyboard shortcuts to a device with no Tab and no Ctrl. */
  .wt-hint {
    display: none;
  }
  .writer-toolbar {
    padding: 6px 10px;
  }
}

/* The element picker inside the formatting bar. */
.fmt-kinds {
  display: flex;
  gap: 2px;
  margin-right: 6px;
  padding-right: 6px;
  border-right: 1px solid var(--border);
}
.fmt-kind {
  font-family: var(--sans);
  font-size: 11px;
  padding: 2px 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
}
.fmt-kind.on {
  color: var(--accent);
  border-color: var(--accent);
}

@media (max-width: 820px) {
  /* On a phone this is the only way to change an element, so it gets room. */
  .fmt-kind {
    font-size: 13px;
    padding: 6px 10px;
    min-height: 36px;
  }
  .fmt-kinds {
    flex: 1;
  }
}

@media (max-width: 820px) {
  /*
   * Showing raw code lines is a desktop habit: on a phone the toolbar it sits
   * in is a whole row of a 390px screen, spent on something nobody reaches for
   * while writing on a train.
   */
  .wt-toggle {
    display: none;
  }
  /* With nothing left in it, the toolbar itself goes too. */
  .writer-toolbar {
    display: none;
  }
}
