/* The editor at /app. Uses the tokens, fonts and brand mark from styles.css.
   One column at every width: top bar, canvas (takes what is left), dock.
   The dock is capped at 820px and centred on wide screens. */

body[data-page="editor"] {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--paper-2);
}

.ed-sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---- top bar ---- */
.ed-top {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 12px;
  min-height: 52px; padding: 0 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  background: var(--paper);
  border-bottom: 1px solid var(--rule-strong);
}
.ed-title {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 13px; color: var(--ink-3); cursor: pointer;
}
.ed-title:hover { color: var(--ink); text-decoration: underline; }
.ed-top-links { margin-left: auto; display: flex; gap: 14px; font-size: 13px; }
.ed-top-links a { color: var(--ink-3); text-decoration: none; }
.ed-top-links a:hover { color: var(--ink); }

/* ---- main ---- */
.ed-main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

.ed-stage { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.ed-rendered { position: absolute; inset: 0; }
.ed-rendered > .reactflow-mount,
.ed-rendered > .sequence-mount { width: 100%; height: 100%; }

/* Empty state: the first screen. */
.ed-empty {
  position: absolute; inset: 0; overflow-y: auto;
  display: flex; flex-direction: column; justify-content: center;
  max-width: 720px; margin: 0 auto; padding: 24px 16px;
}
.ed-empty[hidden] { display: none; }
.ed-empty-title {
  font-family: var(--f-serif); font-weight: 500;
  font-size: clamp(28px, 6vw, 40px); line-height: 1.1; margin: 0 0 10px;
}
.ed-empty-sub { margin: 0 0 20px; color: var(--ink-3); font-size: 15px; line-height: 1.5; }
.ed-empty-label { margin: 0 0 8px; font-family: var(--f-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-4); }
.ed-starters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ed-starter {
  text-align: left; padding: 12px 14px; min-height: 44px;
  font: inherit; font-size: 14px; color: var(--ink);
  background: var(--paper); border: 1px solid var(--rule-strong); cursor: pointer;
}
.ed-starter:hover, .ed-starter:focus-visible { border-color: var(--ink); }
.ed-empty-foot { margin: 16px 0 0; font-size: 14px; color: var(--ink-3); }
.ed-empty-foot a { color: var(--signal); }

/* Selected box: a small card over the canvas. */
.ed-inspector {
  position: absolute; top: 12px; left: 12px; z-index: 5;
  display: flex; flex-direction: column; gap: 8px;
  width: min(280px, calc(100% - 24px)); padding: 10px 12px;
  background: var(--paper); border: 1px solid var(--rule-strong); box-shadow: var(--shadow);
}
.ed-inspector[hidden] { display: none; }
.ed-insp-kind { font-family: var(--f-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-4); }
.ed-insp-label { font: inherit; font-size: 16px; padding: 8px; border: 1px solid var(--rule-strong); background: var(--paper); }
.ed-swatches { display: flex; gap: 8px; }
.ed-swatches .color-swatch { width: 28px; height: 28px; }

.ed-zoom {
  position: absolute; right: 12px; bottom: 12px; z-index: 5;
  display: flex; background: var(--paper); border: 1px solid var(--rule-strong);
}
.ed-zoom[hidden] { display: none; }
.ed-zoom button {
  min-width: 40px; height: 40px; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 14px; color: var(--ink);
}
.ed-zoom button + button { border-left: 1px solid var(--rule); }

/* ---- dock ---- */
.ed-dock {
  flex: 0 0 auto;
  width: 100%; max-width: 820px; margin: 0 auto;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px;
}
.ed-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ed-actions[hidden] { display: none; }
.ed-saved { font-size: 12px; color: var(--ink-4); margin-left: auto; }

.ed-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 0 14px;
  font: inherit; font-size: 14px; font-weight: 500; color: var(--ink);
  background: var(--paper); border: 1px solid var(--rule-strong); cursor: pointer;
  list-style: none;
}
.ed-btn::-webkit-details-marker { display: none; }
.ed-btn:hover:not(:disabled) { border-color: var(--ink); }
.ed-btn:disabled { color: var(--ink-4); cursor: default; }
.ed-btn--primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.ed-btn--primary:hover:not(:disabled) { background: var(--signal); border-color: var(--signal); }
.ed-btn--primary:disabled { background: var(--ink-4); border-color: var(--ink-4); color: var(--paper); }

.ed-more { position: relative; }
.ed-more-panel {
  position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 20;
  display: flex; flex-direction: column; min-width: 220px;
  background: var(--paper); border: 1px solid var(--rule-strong); box-shadow: var(--shadow);
}
.ed-more-panel button {
  text-align: left; padding: 12px 14px; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 14px; color: var(--ink);
}
.ed-more-panel button[hidden] { display: none; }
.ed-more-panel button:hover { background: var(--paper-2); }

.ed-prompt {
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px; background: var(--paper); border: 1px solid var(--ink);
}
.ed-prompt textarea {
  width: 100%; resize: none; border: 0; outline: none; background: transparent;
  font: inherit; font-size: 16px; /* 16px stops iOS zooming on focus */
  line-height: 1.45; color: var(--ink); min-height: 48px; max-height: 220px;
}
.ed-prompt-row { display: flex; align-items: center; gap: 8px; }
.ed-type[hidden] { display: none; }
.ed-type select {
  min-height: 40px; padding: 0 8px; font: inherit; font-size: 14px;
  background: var(--paper); border: 1px solid var(--rule-strong); color: var(--ink-3);
}
.ed-send { margin-left: auto; min-width: 150px; }

.ed-allowance, .ed-status { margin: 0; font-size: 13px; line-height: 1.4; color: var(--ink-3); }
.ed-allowance:empty, .ed-status:empty { display: none; }
.ed-allowance[data-tone="low"] { color: #B45309; }
.ed-allowance[data-tone="empty"] { color: #9f1e1e; }
.ed-allowance a, .ed-link { color: var(--signal); }
.ed-link { background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; cursor: pointer; }
.ed-status[data-tone="ok"] { color: var(--moss); }
.ed-status[data-tone="error"] { color: #9f1e1e; }

/* ---- dialog ---- */
.ed-dialog { border: 0; padding: 0; background: transparent; max-width: calc(100vw - 32px); }
.ed-dialog::backdrop { background: rgba(10, 12, 16, .45); }
.ed-dialog-card {
  width: min(460px, calc(100vw - 32px)); padding: 22px;
  background: var(--paper); border: 1px solid var(--ink); box-shadow: 4px 4px 0 var(--ink);
}
.ed-dialog-title { font-family: var(--f-serif); font-weight: 500; font-size: 24px; line-height: 1.2; margin: 0 0 12px; }
.ed-dialog-body p { margin: 0 0 10px; font-size: 15px; line-height: 1.5; color: var(--ink-2); }
.ed-dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.ed-dialog-actions [hidden] { display: none; }

/* ---- phones ---- */
@media (max-width: 600px) {
  .ed-hide-narrow { display: none; }
  .ed-top { gap: 8px; }
  .ed-top .brand-mark span:last-child { display: none; } /* glyph only */
  .ed-title { flex: 1 1 auto; }
  .ed-starters { grid-template-columns: 1fr; }
  .ed-empty { justify-content: flex-start; padding-top: 20px; }
  .ed-empty-sub { font-size: 14px; }
  .ed-dock { padding-left: 10px; padding-right: 10px; gap: 6px; }
  .ed-actions .ed-btn { flex: 1 1 auto; padding: 0 10px; }
  .ed-actions .ed-more { flex: 1 1 auto; }
  .ed-actions .ed-more > summary { width: 100%; }
  .ed-more-panel { left: auto; right: 0; }
  .ed-saved { width: 100%; margin-left: 0; }
  .ed-send { min-width: 0; flex: 1 1 auto; }
  .ed-inspector { top: 8px; left: 8px; }
}
