:root {
  color-scheme: light;
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-soft: #fbfdff;
  --ink: #050a1c;
  --text: #122038;
  --muted: #53627a;
  --muted-soft: #8b98aa;
  --line: #dfe6f0;
  --line-soft: #edf2f8;
  --blue: #1769ee;
  --blue-2: #2f7df4;
  --blue-5: #eaf3ff;
  --red: #c93636;
  --green: #008c55;
  --shadow-card: 0 10px 28px rgba(15, 33, 64, 0.045);
  --radius: 12px;
  --radius-sm: 9px;
  --sidebar: 244px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background: radial-gradient(circle at 50% 0%, rgba(23, 105, 238, 0.035), transparent 34rem), var(--bg);
  font-family: var(--font);
  letter-spacing: 0;
}

button,
input,
textarea,
a {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.dashboard-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  width: 100%;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 34px 12px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(16px);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin: 0 auto 26px;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--blue), #7db0ff);
  box-shadow: 0 16px 32px rgba(23, 105, 238, 0.2);
}

.brand-mark span {
  width: 18px;
  height: 18px;
  border: 3px solid #ffffff;
  border-top-color: rgba(255, 255, 255, 0.42);
  border-radius: 50%;
  transform: rotate(-25deg);
}

.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.icon path,
.icon circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primary-action,
.control-button,
.mini-select,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(23, 39, 66, 0.035);
  font-size: 16px;
  font-weight: 560;
  white-space: nowrap;
}

.primary-action {
  width: 100%;
  margin-bottom: 22px;
  color: #ffffff;
  border-color: var(--blue);
  background: var(--blue);
}

.control-button,
.mini-select {
  padding: 0 18px;
}

.icon-button {
  width: 50px;
  padding: 0;
}

.control-button:hover,
.mini-select:hover,
.icon-button:hover {
  border-color: #cfd9e7;
  box-shadow: var(--shadow-card);
}

.danger {
  color: var(--red);
}

.nav-list {
  display: grid;
  gap: 10px;
  overflow-y: auto;
  padding-right: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 58px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  color: #23314a;
  font-size: 15px;
  font-weight: 560;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.nav-item:hover {
  color: var(--blue);
  background: #f0f6ff;
}

.nav-item--active {
  color: var(--blue);
  background: #edf5ff;
  box-shadow: inset 0 0 0 1px rgba(23, 105, 238, 0.04);
}

.nav-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-item {
  justify-content: flex-start;
  text-align: left;
}

.nav-item--settings {
  margin-top: auto;
  border-top: 1px solid var(--line);
  border-radius: 0;
  padding-top: 28px;
}

.workspace {
  width: min(100%, 1740px);
  min-width: 0;
  margin: 0 auto;
  padding: 42px 36px 36px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.editor-header {
  align-items: end;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: var(--ink);
  font-size: clamp(38px, 4vw, 58px);
  line-height: 1;
  font-weight: 790;
}

.title-block {
  min-width: 0;
  flex: 1;
}

.eyebrow,
.pane-note,
.status-pill {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.title-input {
  width: 100%;
  margin-top: 6px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: clamp(38px, 4vw, 58px);
  line-height: 1;
  font-weight: 790;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
}

.status-pill.is-dirty {
  color: #8a5a00;
  background: #fff8e6;
  border-color: #f1d894;
}

.status-pill.is-saved {
  color: var(--green);
  background: #edf9f4;
  border-color: #bfe7d7;
}

.share-strip,
.auth-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid #cfe0fb;
  border-radius: var(--radius-sm);
  color: #123b7a;
  background: var(--blue-5);
}

.auth-strip {
  justify-content: flex-start;
  color: var(--text);
  background: #fff8e6;
  border-color: #f1d894;
}

.auth-strip label {
  flex: 0 0 auto;
  font-weight: 700;
}

.auth-strip input {
  min-width: 260px;
  flex: 1;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: 0;
}

.auth-strip input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 105, 238, 0.12);
}

.share-strip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.86fr);
  gap: 18px;
  min-height: calc(100vh - 188px);
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.98)), var(--panel);
  box-shadow: var(--shadow-card);
}

.editor-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 520px;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line-soft);
}

.panel-header h2 {
  color: var(--ink);
  font-size: 19px;
  font-weight: 760;
}

.rendered-editor,
.markdown-editor {
  width: 100%;
  min-width: 0;
  min-height: 0;
  padding: 24px;
  border: 0;
  outline: 0;
  background: transparent;
  overflow: auto;
}

.markdown-editor {
  resize: none;
  color: #15223a;
  font: 15px/1.7 "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

.rendered-editor:focus,
.markdown-editor:focus {
  box-shadow: inset 0 0 0 2px rgba(23, 105, 238, 0.18);
}

.prose {
  color: var(--text);
  line-height: 1.68;
  font-size: 17px;
}

.prose h1,
.prose h2,
.prose h3 {
  margin: 0 0 14px;
  color: var(--ink);
  line-height: 1.12;
}

.prose h1 {
  font-size: 38px;
}

.prose h2 {
  font-size: 30px;
}

.prose h3 {
  font-size: 23px;
}

.prose p,
.prose ul,
.prose blockquote,
.prose pre {
  margin: 0 0 18px;
}

.prose ul {
  padding-left: 24px;
}

.prose blockquote {
  padding: 12px 16px;
  border-left: 4px solid var(--blue);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: #f4f8ff;
}

.prose code {
  padding: 2px 6px;
  border-radius: 6px;
  background: #eef3fa;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.92em;
}

.prose pre {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #0f172a;
  color: #f8fafc;
  overflow: auto;
}

.prose pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.public-view {
  max-width: 980px;
  margin: 0 auto;
}

.public-mode .dashboard-shell {
  grid-template-columns: 1fr;
}

.public-mode .sidebar {
  display: none;
}

.public-document {
  padding: 38px;
}

.empty-state {
  padding: 16px;
  color: var(--muted);
  font-size: 15px;
}

@media (max-width: 1120px) {
  .dashboard-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 18px;
  }

  .nav-list {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    overflow: visible;
  }

  .nav-item--settings {
    margin-top: 16px;
  }

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

@media (max-width: 700px) {
  .workspace {
    padding: 28px 14px;
  }

  .page-header,
  .editor-header {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions {
    justify-content: stretch;
  }

  .control-button {
    flex: 1 1 100%;
    justify-content: space-between;
  }

  .title-input,
  h1 {
    font-size: 38px;
  }

  .share-strip,
  .auth-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .auth-strip input {
    min-width: 0;
    width: 100%;
  }

  .public-document {
    padding: 24px;
  }
}
