/*
 * VibeRevise: app chrome.
 *
 * Deliberately quiet. The document being edited supplies its own typography and
 * colour, and anything assertive here would compete with it: the user is
 * looking at their file, not at this. Mobile-first: the layout below is the
 * phone layout, and the desktop one is the same thing with more room.
 */
:root {
  --ink: #16191c;
  --muted: #5f6672;
  --line: #dfe2e6;
  --paper: #f6f7f8;
  --accent: #2f5fd0;
  --accent-ink: #ffffff;
  --panel: #ffffff;
  --tint: #e8eefb;
  --font-display: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --warn: #9a3412;
  --warn-bg: #fff3e8;
  --chrome-h: 52px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e8eaed;
    --muted: #9aa1ac;
    --line: #2c3238;
    --paper: #15181b;
    --accent: #7ba3f5;
    --accent-ink: #10131a;
    --panel: #1c2024;
    --tint: #1d2840;
    --warn: #f0b088;
    --warn-bg: #2d1e14;
  }
}

* { box-sizing: border-box; }

/*
 * The hidden attribute has to win.
 *
 * [hidden] { display: none } is a UA rule, so any class here that sets display
 * .welcome is flex, .chrome is flex, silently beats it and the element stays
 * on screen. That is what happened: the welcome panel never went away when a
 * file opened, so it and the document shared the flex row and pushed the page
 * off the side of a phone.
 */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}
body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  overscroll-behavior: none;
}

/* ---- top bar --------------------------------------------------------- */
.chrome {
  flex: none;
  min-width: 0;
  height: var(--chrome-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.brand {
  font-weight: 650;
  letter-spacing: -.01em;
  flex: none;
}
.file {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.spacer { flex: 1 1 auto; }

.btn {
  font: inherit;
  font-size: 14px;
  border: 1px solid var(--line);
  background: transparent;
  color: inherit;
  border-radius: 8px;
  /* 44px is the smallest target both Apple and Android call reliable on touch. */
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
  flex: none;
}
.btn:hover:not(:disabled) { background: rgba(127, 127, 127, .12); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.big { min-height: 48px; padding: 0 22px; font-size: 16px; }

/* ---- stage ------------------------------------------------------------ */
#stage {
  flex: 1 1 auto;
  min-height: 0;
  /* A flex item will not shrink below its content by default, and a document
     is as wide as it likes. Without this the stage refuses to be narrower than
     the widest thing in the file and pushes the whole app off the side of the
     screen: taking Save with it. */
  min-width: 0;
  position: relative;
  display: flex;
  overflow: hidden;
}
#frame {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  border: 0;
  background: #fff;   /* the document brings its own; never show ours through */
}

/* ---- welcome ----------------------------------------------------------
 *
 * The one screen that is ours rather than the document's, so it can say a
 * little more: what the tool does, a picture of it doing it, and a sample to
 * try it on. It all goes away the moment a file opens.
 */
.welcome {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 28px 20px 56px;
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 36px;
  /* A tinted wash behind the hero, for some depth without an image. */
  background:
    radial-gradient(60rem 26rem at 85% -6rem, var(--tint), transparent 70%),
    var(--paper);
}
.welcome > * {
  width: 100%;
  max-width: 68rem;
  margin-left: auto;
  margin-right: auto;
}

.hero {
  display: grid;
  gap: 32px;
  align-items: center;
}
.hero-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
}
.eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
}
.welcome h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 3.1rem);
  line-height: 1.08;
  letter-spacing: -.025em;
  margin: 0;
  text-wrap: balance;
}
.lede {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  max-width: 44ch;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}
.hero-actions .btn:not(.primary) { background: var(--panel); }
.drop-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.assure {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 13px;
  color: var(--muted);
}
.assure li::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 1px;
}

/* The picture: a page of a document mid-edit, with notes in its margin. */
.preview {
  position: relative;
  margin: 0;
  padding: 26px 0 104px;
  min-width: 0;
}
.page {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 18px 48px -18px rgba(0, 0, 0, .28);
  overflow: hidden;
  width: min(100%, 29rem);
}
.page-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.page-bar span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--line);
}
.page-bar b { font-weight: 500; margin-left: 8px; }
.page-body {
  padding: 18px 22px 22px;
  font: 14px/1.6 Georgia, Charter, Cambria, serif;
}
.page-body p { margin: 0 0 9px; }
.page-body .p-title {
  font: 700 17px/1.3 system-ui, -apple-system, "Segoe UI", sans-serif;
  margin-bottom: 12px;
}
.page-body del {
  color: var(--accent);
  text-decoration-thickness: 2px;
}
.page-body ins {
  text-decoration: none;
  color: var(--accent);
  background: var(--tint);
  border-bottom: 2px solid var(--accent);
  padding: 0 2px;
  border-radius: 2px;
}
.page-body mark {
  background: rgba(245, 200, 75, .38);
  color: inherit;
  border-radius: 2px;
}
.p-rows { display: grid; gap: 7px; margin-top: 14px; }
.p-rows i {
  display: block;
  height: 8px;
  border-radius: 4px;
  background: var(--line);
}
.p-rows i:nth-child(2) { width: 86%; }
.p-rows i:nth-child(3) { width: 64%; }

.note {
  position: absolute;
  width: min(15.5rem, 62%);
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, .35);
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink);
}
.note b {
  display: block;
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 3px;
}
.note-comment {
  right: 0;
  top: 0;
  width: min(13.5rem, 52%);
  border-left: 3px solid #e0a82e;
}
.note-ai {
  right: 0;
  bottom: 0;
  border-left: 3px solid var(--accent);
}
.note-ai b { color: var(--accent); }
.note-actions { display: flex; gap: 6px; margin-top: 8px; }
.chip {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
}
.chip.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

/* How it works, in three. */
.steps {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 10px;
}
.steps li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  font-size: 14px;
  color: var(--muted);
}
.steps b { color: var(--ink); }
.step-n {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--tint);
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
}

.how {
  display: grid;
  gap: 26px 28px;
}
.how > div {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.how svg {
  width: 22px;
  height: 22px;
  margin-bottom: 6px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.how dt {
  font-weight: 650;
  font-size: 14px;
  margin-bottom: 3px;
}
.how dd {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 52ch;
}
.linkish {
  font: inherit;
  color: var(--accent);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.keys {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 16px 18px;
}
.keys h2 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 650;
}
.keys ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px 24px;
  font-size: 13.5px;
  color: var(--muted);
}
.keys li { display: flex; align-items: center; gap: 10px; }
.keys .combo { flex: none; display: inline-flex; gap: 3px; }
kbd {
  font: 600 11.5px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--ink);
  padding: 4px 6px;
  min-width: 22px;
  text-align: center;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--paper);
}

@media (min-width: 700px) {
  .steps { grid-template-columns: repeat(3, 1fr); }
  .how { grid-template-columns: repeat(2, 1fr); }
  .keys ul { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 960px) {
  .welcome { padding-top: 56px; gap: 48px; }
  .hero { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 48px; }
  .how { grid-template-columns: repeat(3, 1fr); }
  .keys ul { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 520px) {
  .preview { padding: 0; }
  .note { position: static; width: auto; margin-top: 10px; }
}

/* Phone: the filename and the two controls earn their space; the wordmark does
   not, once you are looking at your own document. */
@media (max-width: 460px) {
  body.editing .brand { display: none; }
  .chrome { gap: 8px; }
  .btn { padding: 0 12px; }
}

/* ---- toast ------------------------------------------------------------ */
.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 10;
  max-width: min(92vw, 34rem);
  padding: 10px 15px;
  border-radius: 999px;
  background: rgba(22, 22, 27, .94);
  color: #f2f3f5;
  font-size: 13px;
  box-shadow: 0 3px 18px rgba(0, 0, 0, .3);
}
.toast.warn { background: var(--warn-bg); color: var(--warn); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---- opening from your own network ------------------------------------ */
.network {
  border-top: 1px solid var(--line);
  padding-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
}

#net-form {
  width: 100%;
  max-width: 34rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#net-form label {
  font-size: 13px;
  font-weight: 600;
}
#net-url {
  font: inherit;
  font-size: 16px;            /* below 16px, iOS zooms the page on focus */
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  min-height: 44px;
}
#net-url:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.net-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.net-msg {
  font-size: 13px;
  color: var(--muted);
  flex: 1 1 14rem;
  min-width: 0;
}
.net-msg.warn { color: var(--warn); }

.hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  max-width: 52ch;
}
.hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .92em;
  background: rgba(127, 127, 127, .14);
  padding: .08em .3em;
  border-radius: 3px;
}

.recents-title {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 6px;
}
.recents {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 34rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.recents li {
  display: flex;
  align-items: stretch;
  gap: 4px;
}
.recent-open {
  font: inherit;
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-height: 44px;
  justify-content: center;
}
.recent-open:hover { background: rgba(127, 127, 127, .1); }
.recent-name {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recent-host {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recent-forget {
  font: inherit;
  flex: none;
  width: 44px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}
.recent-forget:hover { background: rgba(127, 127, 127, .1); color: var(--ink); }

/* ---- settings --------------------------------------------------------- */
.settings {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0;
  width: min(30rem, calc(100vw - 32px));
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 12px 48px rgba(0, 0, 0, .25);
}
.settings::backdrop { background: rgba(10, 12, 16, .45); }
.settings-body { padding: 20px; display: flex; flex-direction: column; gap: 6px; }
.settings h2 { margin: 0 0 6px; font-size: 18px; letter-spacing: -.01em; }
.settings label { font-weight: 600; font-size: 13px; margin-top: 10px; }
.settings .opt { font-weight: 400; color: var(--muted); }
.settings input, .settings select {
  font: inherit; font-size: 16px;            /* below 16px, iOS zooms on focus */
  width: 100%; box-sizing: border-box; min-height: 44px;
  padding: 9px 11px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
}
.settings input:focus-visible, .settings select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.settings .hint { margin: 2px 0 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.settings #set-status.good { color: #15803d; }
.settings #set-status.bad { color: var(--warn); }
.settings-actions { display: flex; gap: 8px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.settings-body { max-height: calc(100dvh - 48px); overflow: auto; }
.settings .set-section {
  margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--line);
  font-size: 15px;
}
.settings fieldset.ai-access { border: 0; padding: 0; margin: 12px 0 0; }
.settings fieldset.ai-access legend { font-weight: 600; font-size: 13px; padding: 0; }
.settings label.choice { display: flex; gap: 9px; align-items: flex-start; font-weight: 400;
  font-size: 13px; line-height: 1.5; margin-top: 8px; }
.settings label.choice input { width: auto; min-height: 0; margin: 3px 0 0; flex: none; }

/* ---- brand: VibeRevise (added by sites/brand-app.js) ---------------- */
:root { --paper: #f7f7fb; --panel: #ffffff; --tint: #eeedfd; --ink: #15151f; --muted: #5b5d72; --line: #e2e2ee; --accent: #4f46e5; --accent-ink: #ffffff; --font-display: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --paper: #0f1020; --panel: #181a2e; --tint: #22224a; --ink: #e9e9f5; --muted: #a3a5bd; --line: #2a2c45; --accent: #a5a1ff; --accent-ink: #10101c; }
}
.brand { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: inherit; text-decoration: none; }
