@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@300;400;500&family=Manrope:wght@400;500;600&display=swap');

:root {
  --paper: #f3f3ef;
  --ink: #11120f;
  --muted: #73746e;
  --line: #d4d5ce;
  --soft: #e9e9e3;
  --accent: #cadc3c;
  --white: #fafaf7;
  font-family: Manrope, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; background: var(--paper); }
button, input, textarea { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }
a { color: inherit; }

.site-header {
  height: 76px;
  padding: 0 36px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.wordmark { font-size: 18px; font-weight: 600; letter-spacing: -.04em; text-decoration: none; }
.header-note, .eyebrow, .key-line, .fine-print, .save-state, .section-bar, .principles, .file-row small {
  font-family: 'DM Mono', monospace;
}
.header-note { margin: 0; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
#app { min-height: calc(100vh - 76px); }

.hero {
  min-height: calc(100vh - 76px);
  padding: 12vh 8vw 8vh;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.eyebrow { margin: 0 0 28px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; }
.hero h1 { margin: 0; font-size: clamp(58px, 10vw, 146px); line-height: .84; letter-spacing: -.075em; font-weight: 500; }
.hero-copy { margin: 56px 0 28px; max-width: 510px; color: #44453f; line-height: 1.8; font-size: 14px; }
.primary-action { border: 0; background: var(--ink); color: var(--white); padding: 17px 20px; min-width: 250px; display: flex; justify-content: space-between; }
.primary-action:hover { background: var(--accent); color: var(--ink); }
.fine-print { color: var(--muted); font-size: 10px; margin-top: 18px; }
.principles { position: fixed; right: 36px; bottom: 30px; font-size: 10px; color: var(--muted); }
.principles p { margin: 8px 0; }
.principles span { display: inline-block; width: 30px; color: var(--ink); }

.workspace, .editor-shell { max-width: 1280px; margin: 0 auto; padding: 70px 36px 100px; }
.workspace-header { margin-bottom: 78px; }
.title-row { display: flex; align-items: center; gap: 18px; }
.title-input, .page-title-input {
  width: 100%; border: 0; padding: 0; background: transparent; outline: none;
  letter-spacing: -.055em; font-weight: 500;
}
.title-input { font-size: clamp(42px, 7vw, 90px); }
.page-title-input { font-size: clamp(38px, 6vw, 76px); margin: 50px 0 12px; }
.title-input:focus, .page-title-input:focus { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 7px; }
.icon-button, .quiet-button, .mode-button {
  border: 1px solid var(--line); background: transparent; padding: 9px 12px; font-family: 'DM Mono', monospace; font-size: 10px; text-transform: uppercase;
}
.icon-button:hover, .quiet-button:hover, .mode-button:hover, .mode-button.is-active { background: var(--ink); color: var(--white); border-color: var(--ink); }
.icon-button.danger:hover { background: #ad2b1f; border-color: #ad2b1f; }
.key-line { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 9px; letter-spacing: .08em; word-break: break-all; }
.key-line span { width: 22px; height: 1px; background: var(--accent); }
.section-bar { border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); min-height: 52px; display: flex; align-items: center; justify-content: space-between; font-size: 10px; text-transform: uppercase; }
.section-bar p { margin: 0; }
.quiet-button { border: 0; }
.page-list { border-bottom: 1px solid var(--line); }
.page-row { min-height: 72px; display: grid; grid-template-columns: 54px 1fr auto 26px; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); text-decoration: none; }
.page-row:last-child { border: 0; }
.page-row:hover { padding-left: 10px; background: var(--soft); }
.page-row strong { font-weight: 500; }
.page-row time, .page-index { color: var(--muted); font-family: 'DM Mono', monospace; font-size: 10px; }
.list-empty, .empty-state { padding: 80px 0; color: var(--muted); }
.list-empty p { margin: 4px 0; font-size: 13px; }
.empty-state { max-width: 600px; margin: 0 auto; padding: 18vh 36px; }
.empty-state h1 { font-size: 64px; color: var(--ink); letter-spacing: -.06em; margin: 0; }
.empty-state p { line-height: 1.7; }
.text-link { display: inline-block; margin-top: 20px; }

.editor-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.editor-header .eyebrow { margin: 18px 0 0; }
.back-link { font-family: 'DM Mono', monospace; color: var(--muted); text-decoration: none; font-size: 10px; text-transform: uppercase; }
.back-link:hover { color: var(--ink); }
.editor-actions { display: flex; align-items: center; gap: 8px; }
.save-state { font-size: 9px; color: var(--muted); margin-right: 8px; }
.mode-switch { margin-top: 46px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); min-height: 50px; display: flex; align-items: center; gap: 6px; }
.mode-button { border: 0; }
.upload-button { margin-left: auto; padding: 9px 12px; background: var(--accent); font-family: 'DM Mono', monospace; font-size: 10px; text-transform: uppercase; cursor: pointer; }
.upload-button:hover { background: var(--ink); color: var(--white); }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; min-height: 620px; border-bottom: 1px solid var(--line); }
.editor-grid[data-mode='write'] { grid-template-columns: 1fr; }
.editor-grid[data-mode='write'] .markdown-body { display: none; }
.editor-grid[data-mode='preview'] { grid-template-columns: 1fr; }
.editor-grid[data-mode='preview'] textarea { display: none; }
#markdown-input { resize: vertical; min-height: 620px; border: 0; border-right: 1px solid var(--line); outline: none; background: transparent; padding: 32px 32px 60px 0; font-family: 'DM Mono', monospace; font-size: 13px; line-height: 1.8; }
.markdown-body { min-width: 0; padding: 24px 0 60px 36px; line-height: 1.75; overflow-wrap: anywhere; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { letter-spacing: -.035em; line-height: 1.2; margin: 1.5em 0 .6em; }
.markdown-body h1 { font-size: 42px; }
.markdown-body h2 { font-size: 28px; }
.markdown-body h3 { font-size: 20px; }
.markdown-body p, .markdown-body li { color: #34352f; font-size: 14px; }
.markdown-body code { background: var(--soft); padding: 2px 5px; font-family: 'DM Mono', monospace; font-size: .9em; }
.markdown-body pre { background: var(--ink); color: var(--white); padding: 18px; overflow: auto; }
.markdown-body pre code { background: none; padding: 0; }
.markdown-body blockquote { border-left: 2px solid var(--accent); margin-left: 0; padding-left: 18px; color: var(--muted); }
.markdown-body table { border-collapse: collapse; width: 100%; font-size: 13px; }
.markdown-body th, .markdown-body td { border: 1px solid var(--line); padding: 8px; text-align: left; }
.markdown-body img, .file-embed video, .file-embed iframe { display: block; max-width: 100%; }
.file-embed { margin: 26px 0; border: 1px solid var(--line); background: var(--white); }
.file-embed img, .file-embed video { width: 100%; height: auto; }
.file-embed audio { width: calc(100% - 32px); margin: 24px 16px; }
.file-embed iframe { width: 100%; min-height: 480px; border: 0; }
.file-embed figcaption { padding: 10px 14px; border-top: 1px solid var(--line); font-family: 'DM Mono', monospace; font-size: 9px; color: var(--muted); }
.generic-file { min-height: 140px; padding: 26px; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; }
.generic-file span { color: var(--muted); font-family: 'DM Mono', monospace; font-size: 9px; }
.generic-file strong { font-weight: 500; }
.generic-file small { color: var(--muted); }
.file-drawer { margin-top: 70px; }
.file-list { border-bottom: 1px solid var(--line); }
.file-row { min-height: 58px; display: grid; grid-template-columns: 1fr auto 30px; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.file-row:last-child { border: 0; }
.file-insert { border: 0; background: transparent; padding: 10px 0; text-align: left; display: flex; flex-direction: column; gap: 3px; }
.file-insert:hover strong { text-decoration: underline; }
.file-insert strong { font-weight: 500; }
.file-row a { font-family: 'DM Mono', monospace; font-size: 9px; text-transform: uppercase; }
.file-delete { border: 0; background: transparent; font-size: 18px; color: var(--muted); }
.file-delete:hover { color: #ad2b1f; }
.file-empty { padding: 28px 0; margin: 0; color: var(--muted); font-size: 12px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 16px); padding: 11px 16px; background: var(--ink); color: var(--white); opacity: 0; pointer-events: none; transition: .2s ease; font-family: 'DM Mono', monospace; font-size: 10px; z-index: 20; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .site-header { height: 62px; padding: 0 18px; }
  #app { min-height: calc(100vh - 62px); }
  .header-note, .principles { display: none; }
  .hero { min-height: calc(100vh - 62px); padding: 13vh 20px 50px; }
  .hero h1 { font-size: clamp(54px, 19vw, 90px); }
  .hero-copy { margin-top: 44px; }
  .workspace, .editor-shell { padding: 48px 18px 80px; }
  .workspace-header { margin-bottom: 52px; }
  .title-row { align-items: flex-end; }
  .title-input { font-size: 42px; }
  .page-title-input { font-size: 38px; margin-top: 40px; }
  .page-row { grid-template-columns: 34px 1fr 20px; }
  .page-row time { display: none; }
  .editor-header { flex-direction: column; }
  .editor-actions { width: 100%; }
  .editor-actions .save-state { margin-right: auto; }
  .editor-grid { grid-template-columns: 1fr; }
  .editor-grid[data-mode='split'] textarea { min-height: 400px; border-right: 0; border-bottom: 1px solid var(--line); padding-right: 0; }
  .editor-grid[data-mode='split'] .markdown-body { display: block; }
  #markdown-input { border-right: 0; padding-right: 0; }
  .markdown-body { padding-left: 0; min-height: 400px; }
  .mode-switch { overflow-x: auto; }
  .file-embed iframe { min-height: 360px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
