@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("/fonts/PlusJakartaSans-400.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("/fonts/PlusJakartaSans-600.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("/fonts/PlusJakartaSans-800.ttf") format("truetype");
  font-weight: 800;
  font-display: swap;
}

:root {
  --desk: #eeecf5;
  --paper: #fffdfa;
  --ink: #2b2a35;
  --muted: #6b6779;
  --line: #e3dff2;
  --accent: #7c6cf0;
  --accent-deep: #5b4bd6;
  --peach: #ffd9c7;
  --pink: #f3d4f0;
  --sky: #cfdcff;
  --rose-bg: #ffe6ea;
  --rose: #a8324a;
  --radius: 14px;
  --bar-h: 64px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  display: grid;
  grid-template-rows: var(--bar-h) auto 1fr auto;
  background: var(--desk);
  color: var(--ink);
  font:
    400 15px / 1.5 "Plus Jakarta Sans",
    system-ui,
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
select,
.file-button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

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

/* ---------------------------------------------------------------- top bar */

.bar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 24px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

/* A tiny page with the soft cover band: the product in one glyph. */
.mark {
  width: 22px;
  height: 26px;
  border-radius: 5px;
  background:
    linear-gradient(120deg, var(--peach), var(--pink) 50%, var(--sky)) top / 100% 42% no-repeat,
    var(--paper);
  box-shadow:
    inset 0 0 0 1px var(--line),
    0 2px 6px rgba(91, 75, 214, 0.12);
}

.wordmark {
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.03em;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

select {
  appearance: none;
  border: 1px solid var(--line);
  background:
    var(--paper)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%236b6779' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E")
    right 10px center / 12px no-repeat;
  border-radius: 10px;
  padding: 8px 32px 8px 12px;
  cursor: pointer;
}

.primary {
  border: 0;
  border-radius: 10px;
  padding: 9px 16px;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.primary:hover:not(:disabled) {
  background: var(--accent-deep);
}

.primary:disabled {
  opacity: 0.4;
  cursor: default;
}

.ghost {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 13px;
  background: var(--paper);
  font-size: 14px;
  cursor: pointer;
}

.ghost:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
}

/* ---------------------------------------------------------------- workspace */

.tabs {
  display: none;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 40%) 1fr;
  min-height: 0;
}

.write {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 20px 0 20px 24px;
}

#editor {
  flex: 1;
  min-height: 0;
  width: 100%;
  resize: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 20px 22px;
  color: var(--ink);
  font:
    13.5px / 1.65 ui-monospace,
    "SF Mono",
    Menlo,
    Consolas,
    monospace;
  tab-size: 2;
}

#editor:focus {
  outline: none;
  border-color: #cbc4f4;
  box-shadow: 0 0 0 4px rgba(124, 108, 240, 0.12);
}

.write-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 12px;
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-button:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hint {
  margin: 0 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

.desk {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
  padding: 16px 24px 48px;
  /* the one flourish: the cover band's colours, glowing behind the pages */
  background:
    radial-gradient(40% 32% at 50% 14%, rgba(255, 217, 199, 0.55), transparent 70%),
    radial-gradient(36% 30% at 62% 22%, rgba(207, 220, 255, 0.6), transparent 70%), var(--desk);
  background-attachment: local;
}

.desk-head {
  position: sticky;
  top: -16px;
  z-index: 1;
  display: flex;
  justify-content: center;
  padding: 4px 0 14px;
}

#status {
  margin: 0;
  padding: 5px 12px;
  border-radius: 99px;
  background: rgba(255, 253, 250, 0.85);
  backdrop-filter: blur(6px);
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.error {
  align-self: center;
  width: min(820px, 100%);
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--rose-bg);
  color: var(--rose);
  font-size: 14px;
}

.pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.pages canvas {
  display: block;
  width: min(820px, 100%);
  height: auto;
  border-radius: 4px;
  background: #fff;
  box-shadow:
    0 1px 2px rgba(43, 42, 53, 0.06),
    0 14px 40px rgba(91, 75, 214, 0.14);
}

.pages[hidden] {
  display: none;
}

/* While typing (live preview on): the page as HTML, scaled to the same width as the pages. */
.live {
  align-self: center;
  flex-shrink: 0; /* it clips its frame, so flexbox would otherwise squeeze it into the panel */
  width: min(820px, 100%);
  overflow: hidden;
  border-radius: 4px;
  background: #fff;
  box-shadow:
    0 1px 2px rgba(43, 42, 53, 0.06),
    0 14px 40px rgba(91, 75, 214, 0.14);
}

.live[hidden] {
  display: none;
}

.live iframe {
  display: block;
  border: 0;
  transform-origin: 0 0;
  pointer-events: none;
}

.empty {
  margin: 18vh 0 0;
  color: var(--muted);
}

.foot {
  padding: 10px 24px;
  border-top: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  font-size: 13px;
}

.drop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(238, 236, 245, 0.88);
  backdrop-filter: blur(4px);
}

.drop[hidden] {
  display: none;
}

.drop p {
  padding: 28px 36px;
  border: 2px dashed var(--accent);
  border-radius: 18px;
  background: var(--paper);
  font-weight: 600;
  font-size: 18px;
}

/* ---------------------------------------------------------------- small screens */

@media (max-width: 860px) {
  body {
    grid-template-rows: auto auto 1fr auto;
  }

  .bar {
    flex-wrap: wrap;
    gap: 6px 14px;
    padding: 12px 16px;
  }

  .tagline {
    order: 3;
    width: 100%;
    font-size: 13px;
  }

  .tabs {
    display: flex;
    gap: 4px;
    margin: 12px 16px 0;
    padding: 4px;
    border-radius: 12px;
    background: rgba(255, 253, 250, 0.7);
  }

  .tabs button {
    flex: 1;
    border: 0;
    border-radius: 9px;
    padding: 8px;
    background: transparent;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
  }

  .tabs button[aria-pressed="true"] {
    background: var(--paper);
    color: var(--ink);
    box-shadow: 0 1px 3px rgba(43, 42, 53, 0.1);
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .write {
    padding: 12px 16px 16px;
  }

  .desk {
    padding: 12px 16px 32px;
  }

  body[data-view="write"] .desk,
  body[data-view="preview"] .write {
    display: none;
  }

  .hint {
    display: none;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .pages canvas {
    animation: settle 0.18s ease-out;
  }

  @keyframes settle {
    from {
      opacity: 0.6;
    }
  }
}
