:root {
  color-scheme: light;
  --ink: #18221f;
  --muted: #63706b;
  --paper: #f2f0e9;
  --panel: #fbfaf6;
  --line: #d8d7cf;
  --accent: #ff5c35;
  --accent-dark: #d74320;
  --forest: #153c34;
  --shadow: 0 22px 65px rgba(24, 34, 31, 0.13);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: var(--paper); color: var(--ink); }
button, input { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .32;
  background-image: radial-gradient(rgba(24, 34, 31, .12) .65px, transparent .65px);
  background-size: 5px 5px;
}

.app-shell { min-height: 100vh; position: relative; }

.topbar {
  height: 68px;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(242, 240, 233, .9);
  backdrop-filter: blur(14px);
  position: relative;
  z-index: 5;
}

.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 750; width: max-content; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 30px; background: var(--ink); color: var(--paper); border-radius: 4px; font: 700 11px/1 ui-monospace, monospace; letter-spacing: -.06em; }
.file-meta { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; min-width: 0; }
.file-name { color: var(--ink); font-weight: 650; max-width: 32vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--accent); }
.quiet-button { justify-self: end; border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; background: transparent; cursor: pointer; font-size: 13px; font-weight: 650; }
.quiet-button:hover { border-color: var(--ink); }

.landing { min-height: calc(100vh - 68px); display: grid; grid-template-columns: minmax(0, .9fr) minmax(380px, 1.1fr); gap: clamp(40px, 7vw, 110px); align-items: center; padding: clamp(42px, 7vw, 100px); max-width: 1480px; margin: 0 auto; }
.intro-copy { max-width: 650px; }
.eyebrow { margin: 0 0 18px; color: var(--accent-dark); text-transform: uppercase; letter-spacing: .13em; font: 750 11px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; }
h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(60px, 7.7vw, 116px); font-weight: 500; letter-spacing: -.065em; line-height: .88; }
.lede { margin: 30px 0 0; max-width: 570px; color: var(--muted); font-size: clamp(17px, 1.6vw, 22px); line-height: 1.55; }

.dropzone { min-height: 440px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 50px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); box-shadow: var(--shadow); cursor: pointer; text-align: center; transition: transform .2s ease, border-color .2s ease, background .2s ease; }
.dropzone:hover, .dropzone:focus-visible, .dropzone.dragging { transform: translateY(-3px); border-color: var(--accent); outline: none; background: #fffaf4; }
.dropzone strong { margin: 24px 0 7px; font-family: Georgia, "Times New Roman", serif; font-size: 31px; font-weight: 500; }
.dropzone > span:not(.drop-icon) { color: var(--muted); }
.dropzone small { margin-top: 48px; color: #7a817e; font-size: 12px; }
.drop-icon { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; background: var(--accent); color: white; font-size: 34px; line-height: 1; }

.workspace { height: calc(100vh - 68px); display: grid; grid-template-columns: 1fr 1fr; gap: 1px; overflow: hidden; background: var(--line); }
.pane { min-width: 0; min-height: 0; display: grid; grid-template-rows: 58px minmax(0, 1fr); background: var(--panel); }
.pane-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 20px; border-bottom: 1px solid var(--line); background: rgba(251, 250, 246, .94); }
.pane-header > div:first-child { display: flex; align-items: baseline; gap: 8px; }
.pane-kicker { color: var(--muted); font: 700 10px/1 ui-monospace, monospace; letter-spacing: .12em; text-transform: uppercase; }
.pane-header strong { font-size: 14px; }
.sync-note { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.sync-light { width: 7px; height: 7px; border-radius: 50%; background: #2c9b6f; box-shadow: 0 0 0 3px rgba(44, 155, 111, .13); }
.pane-scroll { min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-color: #a5aaa7 transparent; scrollbar-width: thin; }
.pdf-scroll { background: #d9d9d4; }
.page-stack { width: min(92%, 820px); margin: 24px auto; display: grid; gap: 18px; }
.pdf-page { position: relative; width: 100%; background: white; box-shadow: 0 4px 18px rgba(16, 22, 20, .16); overflow: hidden; }
.pdf-page canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; }
.page-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font: 11px/1 ui-monospace, monospace; }
.page-label { position: absolute; z-index: 2; top: 10px; left: 10px; min-width: 24px; height: 24px; padding: 0 7px; display: grid; place-items: center; border-radius: 4px; background: rgba(21, 60, 52, .88); color: white; font: 700 10px/1 ui-monospace, monospace; }

.markdown-actions { display: flex; align-items: center; gap: 7px; }
.mode-toggle { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); }
.mode-button, .icon-button { border: 0; background: transparent; cursor: pointer; font-size: 11px; font-weight: 700; }
.mode-button { padding: 6px 9px; border-radius: 4px; color: var(--muted); }
.mode-button.active { background: var(--ink); color: white; }
.icon-button { padding: 8px 5px; color: var(--muted); }
.icon-button:hover { color: var(--ink); }
.markdown-scroll { background: var(--panel); }
.markdown-pages { width: min(86%, 760px); margin: 24px auto 220px; display: grid; gap: 26px; }
.markdown-page { position: relative; min-height: 64vh; padding: 46px 44px 52px; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.markdown-page-label { top: 12px; left: auto; right: 12px; background: var(--paper); color: var(--muted); border: 1px solid var(--line); }
.markdown-body { font-family: Georgia, "Times New Roman", serif; font-size: 17px; line-height: 1.68; overflow-wrap: anywhere; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { color: var(--forest); font-family: Inter, ui-sans-serif, sans-serif; line-height: 1.16; letter-spacing: -.025em; }
.markdown-body h1 { font-size: 35px; }
.markdown-body h2 { margin-top: 1.8em; font-size: 27px; }
.markdown-body h3 { margin-top: 1.6em; font-size: 21px; }
.markdown-body a { color: var(--accent-dark); }
.markdown-body blockquote { margin-left: 0; padding-left: 18px; border-left: 3px solid var(--accent); color: var(--muted); }
.markdown-body code { padding: .12em .32em; border-radius: 3px; background: var(--paper); font: .83em ui-monospace, SFMono-Regular, Consolas, monospace; }
.markdown-body pre { overflow: auto; padding: 18px; border-radius: 5px; background: var(--ink); color: #eef1ed; }
.markdown-body pre code { padding: 0; background: transparent; }
.markdown-body table { width: 100%; border-collapse: collapse; font-family: Inter, ui-sans-serif, sans-serif; font-size: 13px; }
.markdown-body th, .markdown-body td { padding: 9px 10px; border: 1px solid var(--line); text-align: left; }
.markdown-body img { max-width: 100%; }
.markdown-source { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: #25312d; font: 13px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace; }

.status-overlay { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(21, 29, 26, .74); backdrop-filter: blur(8px); }
.status-card { width: min(460px, 100%); padding: 44px; border-radius: 8px; background: var(--panel); box-shadow: var(--shadow); text-align: center; }
.status-card .eyebrow { margin-top: 22px; }
.status-card strong { display: block; font-family: Georgia, "Times New Roman", serif; font-size: 30px; font-weight: 500; }
.status-card p:last-child { margin: 12px auto 0; max-width: 330px; color: var(--muted); line-height: 1.5; }
.processing-mark { display: inline-block; width: 38px; height: 38px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; z-index: 30; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: min(560px, calc(100vw - 32px)); padding: 12px 17px; border-radius: 5px; background: var(--forest); color: white; box-shadow: var(--shadow); font-size: 13px; }
.toast[data-kind="error"] { background: #a73522; }

@media (max-width: 920px) {
  .landing { grid-template-columns: 1fr; padding: 54px 28px; }
  .dropzone { min-height: 320px; }
  .markdown-actions { gap: 3px; }
  .icon-button { display: none; }
}

@media (max-width: 820px) {
  .topbar { grid-template-columns: 1fr auto; }
  .file-meta { display: none; }
  .workspace { height: auto; min-height: calc(100vh - 68px); grid-template-columns: 1fr; }
  .pane { height: 72vh; }
  .sync-note { display: none; }
  .markdown-page { padding: 44px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
