:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #111827;
  --hover: #f4f4f5;
  --code-bg: #f6f8fa;
  --quote: #6b7280;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--fg);
}
button:hover { background: var(--hover); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { opacity: .9; background: var(--accent); }
button.danger-text { color: #dc2626; border-color: transparent; }
button.danger-text:hover { background: #fef2f2; }
input[type="text"] {
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--fg);
  background: var(--bg);
}
input[type="text"]:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

/* ---- top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.topbar .logo {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  color: var(--fg);
  letter-spacing: -0.5px;
}
.topbar .spacer { flex: 1; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: block; }

/* ---- drive ---- */
.drive { max-width: 860px; margin: 0 auto; padding: 32px 20px 80px; }
.drive-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 4px; }
.drive-head h1 { font-size: 22px; font-weight: 650; margin: 0; }
.quota-note { color: var(--muted); font-size: 13px; margin: 4px 0 20px; }
.doc-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.doc-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.doc-row:last-child { border-bottom: none; }
.doc-row:hover { background: var(--hover); }
.doc-row .doc-main { flex: 1; min-width: 0; cursor: pointer; }
.doc-row .doc-title { font-weight: 550; }
.doc-row .doc-meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.doc-row .doc-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .12s; }
.doc-row:hover .doc-actions { opacity: 1; }
.empty-state {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}
.empty-state code { font-family: ui-monospace, Menlo, monospace; background: var(--code-bg); padding: 2px 6px; border-radius: 4px; color: var(--fg); }

/* ---- editor ---- */
.editor-wrap { display: flex; flex-direction: column; height: 100vh; }
.title-row { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
#doc-title-input {
  border: 1px solid transparent;
  background: transparent;
  font-weight: 600;
  font-size: 15px;
  padding: 4px 8px;
  border-radius: 6px;
  min-width: 0;
  max-width: 380px;
}
#doc-title-input:hover { border-color: var(--border); }
#doc-title-input:focus { border-color: transparent; outline: 1px solid var(--border); background: var(--bg); }

.peers { display: flex; align-items: center; gap: 6px; }
.peer-dot {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; font-weight: 700;
  border: 2px solid var(--bg);
  margin-left: -6px;
}
.peer-dot img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

.panes { flex: 1; display: flex; min-height: 0; }
.pane { flex: 1; min-width: 0; overflow: hidden; position: relative; }
.pane + .pane { border-left: 1px solid var(--border); }
#editor-textarea {
  width: 100%; height: 100%;
  resize: none; border: none; outline: none;
  padding: 28px 32px 60vh;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--fg);
  background: var(--bg);
  tab-size: 4;
}
#preview {
  height: 100%;
  overflow-y: auto;
  padding: 28px 36px 60vh;
}
.statusline {
  border-top: 1px solid var(--border);
  padding: 4px 20px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 16px;
  font-family: ui-monospace, Menlo, monospace;
}
.statusline .saved { color: #059669; }

/* ---- markdown preview ---- */
#preview { font-size: 15.5px; line-height: 1.7; }
#preview h1, #preview h2, #preview h3, #preview h4 { font-weight: 650; line-height: 1.3; margin: 1.4em 0 .5em; }
#preview h1 { font-size: 1.8em; border-bottom: 1px solid var(--border); padding-bottom: .3em; }
#preview h2 { font-size: 1.4em; border-bottom: 1px solid var(--border); padding-bottom: .25em; }
#preview h3 { font-size: 1.15em; }
#preview p, #preview ul, #preview ol, #preview blockquote, #preview pre, #preview table { margin: .7em 0; }
#preview a { color: #2563eb; }
#preview code { font-family: ui-monospace, Menlo, monospace; font-size: .88em; background: var(--code-bg); padding: .15em .4em; border-radius: 4px; }
#preview pre { background: var(--code-bg); border-radius: 8px; padding: 14px 16px; overflow-x: auto; }
#preview pre code { background: none; padding: 0; }
#preview blockquote { border-left: 3px solid var(--border); color: var(--quote); padding: .1em 0 .1em 1em; margin-left: 0; }
#preview table { border-collapse: collapse; }
#preview th, #preview td { border: 1px solid var(--border); padding: 6px 12px; }
#preview th { background: var(--code-bg); }
#preview img { max-width: 100%; }
#preview hr { border: none; border-top: 1px solid var(--border); margin: 1.6em 0; }

/* ---- login ---- */
.login-page {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100vh; gap: 14px; text-align: center; padding: 20px;
}
.login-page .logo-big { font-family: ui-monospace, Menlo, monospace; font-size: 42px; font-weight: 700; letter-spacing: -2px; }
.login-page .tagline { color: var(--muted); max-width: 420px; line-height: 1.6; }
.login-page .feat { color: var(--muted); font-size: 13px; display: flex; gap: 18px; }
.login-page .feat span::before { content: "# "; color: var(--border); }

/* ---- landing page ---- */
.landing { min-height: 100vh; }
.landing-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 32px; max-width: 1000px; margin: 0 auto;
}
.landing .logo { font-size: 17px; }
.nav-signin { font-size: 14px; color: var(--fg); text-decoration: none; font-weight: 550; }
.nav-signin:hover { text-decoration: underline; }

.hero { text-align: center; padding: 60px 24px 30px; max-width: 760px; margin: 0 auto; }
.hero h1 {
  font-size: clamp(34px, 5.5vw, 52px);
  font-weight: 700; letter-spacing: -1.5px; line-height: 1.12; margin: 0 0 18px;
}
.hero h1 em { font-style: normal; border-bottom: 4px solid #fde68a; }
.hero-sub { font-size: 17px; color: var(--muted); line-height: 1.65; margin: 0 auto 28px; max-width: 560px; }
.cta {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 15.5px; padding: 12px 26px; border-radius: 8px;
}
.cta-note { color: var(--muted); font-size: 12.5px; margin-top: 12px; }

.demo {
  display: flex; gap: 0; max-width: 900px; margin: 40px auto 0; padding: 0 20px;
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  box-shadow: 0 10px 40px rgba(0,0,0,.06);
}
.demo-pane { flex: 1; min-width: 0; padding: 18px 22px; text-align: left; }
.demo-pane + .demo-pane { border-left: 1px solid var(--border); background: #fcfcfd; }
.demo-label {
  font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; color: var(--muted);
  text-transform: lowercase; margin-bottom: 12px;
}
.demo-code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; line-height: 1.65;
  white-space: pre-wrap; margin: 0; color: var(--fg);
}
.demo-output { font-size: 14px; }
.demo-output :is(h1, h2, h3) { margin: .2em 0 .3em; }
.demo-output p, .demo-output ul { margin: .3em 0; }
.demo-output h1 { font-size: 1.35em; }
@media (max-width: 700px) { .demo { flex-direction: column; } .demo-pane + .demo-pane { border-left: none; border-top: 1px solid var(--border); } }

.features {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px;
  max-width: 980px; margin: 0 auto; padding: 60px 24px 10px;
}
.feature { border: 1px solid var(--border); border-radius: 12px; padding: 22px; }
.feature-icon { font-size: 24px; margin-bottom: 10px; }
.feature h3 { font-size: 15.5px; font-weight: 640; margin: 0 0 8px; }
.feature p { font-size: 13.5px; color: var(--muted); line-height: 1.6; margin: 0; }
.feature code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; font-size: .9em; }

.how { text-align: center; padding: 60px 24px 30px; }
.how h2 { font-size: 26px; font-weight: 680; letter-spacing: -.5px; margin: 0 0 34px; }
.steps {
  list-style: none; display: flex; gap: 18px; justify-content: center; flex-wrap: wrap;
  max-width: 900px; margin: 0 auto; padding: 0;
}
.steps li {
  flex: 1; min-width: 220px; max-width: 280px; text-align: left;
  border: 1px solid var(--border); border-radius: 12px; padding: 20px;
  font-size: 13.5px; color: var(--muted); line-height: 1.6;
}
.steps li span {
  display: inline-flex; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; margin-bottom: 12px;
}
.steps strong { color: var(--fg); }
.steps code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }

.landing-footer {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 50px 24px 30px; color: var(--muted); font-size: 13px;
}

/* ---- onboarding ---- */
.onboarding-overlay {
  position: fixed; inset: 0; background: rgba(15, 15, 20, .5); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.onboarding-card {
  background: var(--bg); border-radius: 16px; padding: 40px 38px 30px;
  width: 430px; max-width: 100%; text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,.3);
}
.onboarding-mark {
  width: 54px; height: 54px; margin: 0 auto 18px; border-radius: 14px;
  background: var(--accent); color: #fff;
  font-family: ui-monospace, Menlo, monospace; font-size: 30px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.onboarding-card h2 { font-size: 22px; margin: 0 0 8px; letter-spacing: -.4px; }
.onboarding-card > p { color: var(--muted); font-size: 14.5px; line-height: 1.6; margin: 0 0 22px; }
.onboarding-actions { display: flex; flex-direction: column; gap: 10px; }
.onboarding-actions button { padding: 11px 18px; font-size: 14.5px; }
.link-btn { border: none; background: none; color: var(--muted); font-size: 13px !important; padding: 6px !important; }
.link-btn:hover { background: none; color: var(--fg); text-decoration: underline; }
.onboarding-hints {
  display: flex; flex-direction: column; gap: 6px; margin-top: 24px; padding-top: 18px;
  border-top: 1px solid var(--border); color: var(--muted); font-size: 12.5px;
}

/* ---- empty drive state ---- */
.empty-state { padding: 46px 24px; }
.empty-state .empty-mark {
  font-family: ui-monospace, Menlo, monospace; font-size: 34px; font-weight: 700;
  color: var(--border); margin-bottom: 10px;
}
.empty-state p { color: var(--muted); line-height: 1.7; margin: 4px 0; }

@media (max-width: 800px) {
  .pane.preview-pane { display: none; }
}
