:root {
  --navy: #31425b;
  --ink: #16263d;
  --blue: #587286;
  --blue-soft: #d8e2e5;
  --cream: #e9ded3;
  --cream-light: #f7f2ed;
  --ochre: #bd8a3a;
  --terracotta: #c97954;
  --sage: #8fa89c;
  --line: rgba(49, 66, 91, 0.12);
  --surface: #fffdfb;
  --bg: var(--cream-light);
  --text: var(--ink);
  --muted: rgba(22, 38, 61, 0.6);
  --radius: 14px;
  --font: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Iowan Old Style", Georgia, serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }

.app {
  display: grid;
  grid-template-columns: minmax(320px, 400px) 1fr;
  height: 100vh;
  height: 100dvh;
}

/* --- Chat ------------------------------------------------------------------------------ */

.chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-mark { font: 24px var(--display); color: var(--navy); }
.brand-sub { font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

.status { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue-soft); }
.status[data-status="ready"] .dot { background: var(--sage); }
.status[data-status="starting"] .dot,
.status[data-status="sleeping"] .dot,
.status[data-status="working"] .dot,
.status[data-status="publishing"] .dot { background: var(--ochre); animation: pulse 1.2s ease-in-out infinite; }
.status[data-status="failed"] .dot { background: var(--terracotta); }
@keyframes pulse { 50% { opacity: 0.35; } }

.messages {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message { max-width: 92%; padding: 10px 14px; border-radius: var(--radius); white-space: pre-wrap; overflow-wrap: anywhere; }
.message.user { align-self: flex-end; background: var(--navy); color: var(--cream-light); border-bottom-right-radius: 4px; }
.message.assistant { align-self: flex-start; background: var(--cream); border-bottom-left-radius: 4px; }
.message.notice { align-self: center; max-width: 100%; background: transparent; color: var(--muted); font-size: 13px; text-align: center; padding: 4px 8px; }
.message.notice.intro { text-align: left; background: var(--cream-light); border: 1px solid var(--line); color: var(--text); font-size: 14px; padding: 12px 14px; }

.message.working { align-self: flex-start; background: var(--cream-light); border: 1px dashed var(--line); white-space: normal; }
.working-title { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--navy); }
.working-title::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ochre); border-right-color: transparent; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.working ul { margin: 6px 0 0; padding: 0; list-style: none; font-size: 13px; color: var(--muted); }
.working li::before { content: "· "; }
.working .thought { color: var(--text); font-size: 14px; margin-top: 6px; white-space: pre-wrap; }

.composer { border-top: 1px solid var(--line); padding: 14px 16px 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.composer textarea {
  width: 100%;
  resize: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  font: inherit;
  background: var(--bg);
  color: var(--text);
}
.composer textarea:focus { outline: 2px solid var(--blue); outline-offset: 1px; background: #fff; }
.composer-actions { display: flex; justify-content: flex-end; gap: 8px; }

.selection { min-width: 0; display: flex; align-items: center; gap: 6px; font-size: 13px; background: var(--blue-soft); border-radius: 10px; padding: 6px 8px 6px 10px; }
.selection-label { font-weight: 600; color: var(--navy); }
.selection-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selection-clear { border: 0; background: none; font-size: 18px; line-height: 1; cursor: pointer; color: var(--navy); }

/* --- Buttons --------------------------------------------------------------------------- */

.button { border: 1px solid transparent; border-radius: 999px; padding: 8px 16px; cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap; }
.button:disabled { opacity: 0.45; cursor: default; }
.button.primary { background: var(--navy); color: var(--cream-light); }
.button.primary:hover:not(:disabled) { background: var(--blue); }
.button.accent { background: var(--ochre); color: #fff; }
.button.accent:hover:not(:disabled) { background: #a67830; }
.button.ghost { background: transparent; border-color: var(--line); color: var(--navy); }
.button.ghost:hover:not(:disabled) { background: var(--cream-light); }
.button.danger-ghost { background: transparent; border-color: rgba(201, 121, 84, 0.4); color: #a35a38; }
.button.danger-ghost[data-confirm="true"] { background: var(--terracotta); color: #fff; }

/* --- Preview --------------------------------------------------------------------------- */

.preview { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-wrap: wrap;
}
.page { font-size: 13px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 120px; }
.modes { display: inline-flex; background: var(--cream-light); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.modes button { border: 0; background: none; padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
.modes button[aria-checked="true"] { background: var(--navy); color: var(--cream-light); }

/* Which screen she is looking at. Same shape as the modes, one notch quieter:
   this changes what she sees, not what a click does. */
.devices { display: inline-flex; gap: 2px; border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.devices button {
  border: 0; background: none; padding: 5px 8px; border-radius: 999px; cursor: pointer;
  color: var(--muted); display: inline-flex; align-items: center;
}
.devices button[aria-checked="true"] { background: var(--blue-soft); color: var(--ink); }
/* Three glyphs instead of three words: the toolbar had grown into a sentence. */
.devices svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }

/* Not live yet / live before, in one dialog. They are the same question from two sides,
   and as two buttons in the toolbar they pushed everything else off the edge. */
.tabstrip { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px 0 14px; }
.tabstrip button {
  border: 0; background: none; cursor: pointer; padding: 8px 12px; font: inherit; font-weight: 600;
  font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabstrip button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ochre); }
.tabpanel { display: none; }
#changes-dialog[data-tab="draft"] .tabpanel[data-tab="draft"],
#changes-dialog[data-tab="live"] .tabpanel[data-tab="live"] { display: block; }

/* A photo on its way to a page. */
.attach { display: inline-flex; align-items: center; padding: 8px; border-radius: 999px; cursor: pointer; color: var(--muted); }
.attach:hover { background: var(--cream-light); color: var(--ink); }
.attach svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.attach[data-busy="true"] { opacity: 0.5; pointer-events: none; }
.attachment {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 13px;
}
.attachment img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; background: var(--cream-light); }
.attachment span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-remove { border: 0; background: none; cursor: pointer; font-size: 18px; line-height: 1; color: var(--muted); padding: 0 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* The frame itself is narrowed, so the site's own breakpoints do the rest: this
   is the real mobile layout, not a scaled picture of the wide one. */
.app[data-device="phone"] .frame iframe,
.app[data-device="tablet"] .frame iframe {
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 8px 30px rgba(22, 38, 61, 0.12);
  background: #fff;
}
.app[data-device="phone"] .frame { padding: 14px 0; background: var(--cream-light); overflow: auto; }
.app[data-device="phone"] .frame iframe { width: 390px; height: calc(100% - 28px); }
.app[data-device="tablet"] .frame { padding: 14px 0; background: var(--cream-light); overflow: auto; }
.app[data-device="tablet"] .frame iframe { width: 820px; max-width: 100%; height: calc(100% - 28px); }
.actions { display: flex; gap: 8px; }

.frame { position: relative; flex: 1; min-height: 0; background: #fff; }
.frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.frame-cover {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--cream-light);
  color: var(--navy);
  text-align: center;
  padding: 24px;
}
.frame-cover[hidden] { display: none; }
.frame-cover p { max-width: 36ch; margin: 0 auto 16px; }
.app[data-mode="text"] .frame { box-shadow: inset 0 0 0 3px var(--ochre); }
.app[data-mode="select"] .frame { box-shadow: inset 0 0 0 3px var(--blue); }

/* --- Dialog and toast ------------------------------------------------------------------ */

.dialog { border: 0; border-radius: 18px; padding: 0; width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 64px); color: var(--text); background: var(--surface); }
.dialog::backdrop { background: rgba(22, 38, 61, 0.35); }
.dialog form { padding: 24px; display: grid; gap: 14px; }
.dialog h2 { margin: 0; font: 26px var(--display); color: var(--navy); }
.muted { color: var(--muted); margin: 0; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.diff summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.diff pre { max-height: 300px; overflow: auto; font-size: 12px; background: var(--cream-light); padding: 12px; border-radius: 10px; }

/* What changed, per file. Closed by default: the list of files is the overview. */
.files { display: grid; gap: 6px; margin-top: 4px; }
.diff-file { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.diff-file > summary {
  cursor: pointer; padding: 8px 12px; font-size: 13px; font-weight: 600;
  display: flex; gap: 10px; align-items: baseline;
}
.diff-counts { margin-left: auto; font-weight: 400; font-variant-numeric: tabular-nums; color: var(--muted); }
.diff-file pre {
  margin: 0; max-height: 320px; overflow: auto; font-size: 12px; line-height: 1.5;
  padding: 10px 12px; border-top: 1px solid var(--line);
}
.diff-file .line { display: block; white-space: pre-wrap; }
/* Colour alone never carries it: the + and − stay in the text. */
.line.added { background: rgba(143, 168, 156, 0.18); }
.line.removed { background: rgba(201, 121, 84, 0.14); }
.line.place { color: var(--muted); }

/* What has been live before. */
/* The list scrolls, not the dialog: after a dozen versions the buttons underneath fell off
   the bottom of the screen, and "Sluiten" is not a button you want to have to hunt for. */
.versions { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; max-height: 45vh; overflow: auto; }
.versions li {
  display: flex; gap: 12px; align-items: center;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.version-when { color: var(--muted); font-size: 13px; white-space: nowrap; }
.version-what { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.version-now { color: var(--sage); font-size: 13px; font-weight: 600; white-space: nowrap; }
.versions .button { white-space: nowrap; }
.costs { margin-top: 10px; font-size: 13px; font-variant-numeric: tabular-nums; }

/* The paragraphs and lists the assistant writes. Tight, because a chat bubble is not a page. */
.message p { margin: 0 0 8px; }
.message p:last-child { margin-bottom: 0; }
.message .md-list { margin: 0 0 8px; padding-left: 18px; display: grid; gap: 4px; }
.message .md-list:last-child { margin-bottom: 0; }
.dialog-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 32px));
  background: var(--ink);
  color: var(--cream-light);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(22, 38, 61, 0.25);
  z-index: 10;
}

.tabs { display: none; }

/* --- Phone ----------------------------------------------------------------------------- */

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .app[data-view="chat"] .preview,
  .app[data-view="preview"] .chat { display: none; }
  .chat { border-right: 0; }
  .toolbar { padding: 8px 12px; gap: 8px; }
  .page { display: none; }
  .actions { width: 100%; justify-content: space-between; }
  .actions .button { padding: 7px 12px; font-size: 13px; }
  .tabs { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); background: var(--surface); }
  .tabs button { border: 0; background: none; padding: 12px; font-weight: 600; color: var(--muted); }
  .app[data-view="chat"] .tabs [data-view="chat"],
  .app[data-view="preview"] .tabs [data-view="preview"] { color: var(--navy); box-shadow: inset 0 2px 0 var(--navy); }
}

/* --- Sign-in --------------------------------------------------------------------------- */

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 28px; display: grid; gap: 16px; }
.login form { display: grid; gap: 14px; }
.login label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(--navy); }
.login input { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); }
.login input:focus { outline: 2px solid var(--blue); outline-offset: 1px; background: #fff; }
.login-error { margin: 0; color: #a35a38; font-size: 14px; }
.login .button { justify-self: start; }
.signout { border: 0; background: none; color: var(--muted); font-size: 12px; cursor: pointer; padding: 0; text-decoration: underline; }
