:root {
  --bg: #fbfdff;
  --surface: #ffffff;
  --surface-soft: #eef6ff;
  --line: #dfe6ee;
  --line-soft: #edf1f6;
  --text: #07142d;
  --muted: #536076;
  --faint: #7c8799;
  --blue: #0868d7;
  --blue-soft: #e9f4ff;
  --teal: #10a79d;
  --teal-soft: #def8f3;
  --amber: #f28b14;
  --amber-soft: #fff2df;
  --red: #e63c46;
  --shadow: 0 16px 42px rgba(13, 35, 67, 0.07);
  --radius: 8px;
  --sidebar: 320px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 82% 12%, rgba(225, 241, 255, 0.64), transparent 31%),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
  color: var(--text);
  font-family: Inter, Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

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

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

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-icon,
.icon-bubble {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
}

.brand-icon {
  width: 42px;
  height: 42px;
  color: #fff;
  background: #0d8790;
}

.brand h1,
.public-page h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
  font-weight: 800;
}

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

.sidebar-actions,
.toolbar,
.header-actions,
.mode-row,
.doc-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sidebar-actions {
  margin-bottom: 12px;
}

.button,
.icon-button,
.field,
.segment,
.select {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  box-shadow: 0 10px 26px rgba(20, 41, 72, 0.04);
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
}

.button {
  gap: 8px;
  padding: 0 12px;
  font-weight: 600;
}

.button.primary {
  border-color: rgba(8, 104, 215, 0.22);
  background: var(--blue);
  color: #fff;
}

.button.soft {
  background: var(--blue-soft);
  color: var(--blue);
}

.button.danger {
  background: #fff7f8;
  color: var(--red);
}

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

.icon-button.active {
  background: var(--blue-soft);
  color: var(--blue);
}

.field {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  outline: none;
}

.search {
  margin-bottom: 14px;
}

.workspace-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 16px 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.nav-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.folder-item,
.doc-item,
.all-docs {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: #0b1730;
  text-align: left;
}

.folder-item.active,
.doc-item.active,
.all-docs.active {
  border-color: rgba(8, 104, 215, 0.14);
  background: var(--blue-soft);
  color: var(--blue);
}

.folder-item.drag-over {
  border-color: rgba(16, 167, 157, 0.32);
  background: var(--teal-soft);
}

.item-title {
  display: -webkit-box;
  overflow: hidden;
  line-height: 1.2;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
}

.item-meta {
  color: var(--faint);
  font-size: 12px;
}

.icon-bubble {
  width: 32px;
  height: 32px;
  color: var(--blue);
  background: var(--blue-soft);
}

.icon-bubble.mint {
  color: #058c86;
  background: var(--teal-soft);
}

.status-card {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.status-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
}

.status-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.main {
  min-width: 0;
  padding: 28px 30px 34px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

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

.title-input {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: clamp(28px, 4vw, 38px);
  line-height: 1.08;
  font-weight: 800;
}

.meta-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  flex-wrap: wrap;
}

.save-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.save-status.dirty {
  background: var(--amber-soft);
  color: #8b4c06;
}

.save-status.saved {
  background: var(--teal-soft);
  color: #05756f;
}

.save-status.error {
  background: #fff0f2;
  color: var(--red);
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 18px;
  align-items: start;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 28px rgba(18, 38, 72, 0.04);
}

.editor-panel {
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line-soft);
}

.segment {
  display: inline-flex;
  overflow: hidden;
}

.segment button {
  min-width: 108px;
  min-height: 40px;
  border: 0;
  background: transparent;
  color: #0c1730;
  font-weight: 600;
}

.segment button.active {
  background: var(--blue-soft);
  color: var(--blue);
}

.toolbar {
  justify-content: flex-end;
}

.editor-area {
  min-height: calc(100vh - 188px);
}

.markdown-input,
.wysiwyg {
  width: 100%;
  min-height: calc(100vh - 188px);
  padding: 24px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  line-height: 1.68;
}

.markdown-input {
  display: block;
  resize: vertical;
  font-family: Consolas, "SFMono-Regular", monospace;
}

.wysiwyg {
  overflow-wrap: anywhere;
  cursor: text;
}

.wysiwyg:focus {
  outline: 2px solid rgba(8, 104, 215, 0.18);
  outline-offset: -2px;
}

.wysiwyg:empty::before {
  color: var(--faint);
  content: attr(data-placeholder);
}

.wysiwyg h1,
.reader h1 {
  margin: 0 0 18px;
  font-size: 34px;
  line-height: 1.1;
}

.wysiwyg h2,
.reader h2 {
  margin: 28px 0 12px;
  font-size: 24px;
}

.wysiwyg h3,
.reader h3 {
  margin: 24px 0 10px;
  font-size: 19px;
}

.wysiwyg p,
.reader p {
  margin: 0 0 14px;
}

.wysiwyg blockquote,
.reader blockquote {
  margin: 18px 0;
  padding: 10px 14px;
  border-left: 4px solid var(--teal);
  background: var(--teal-soft);
  color: #1c4f4c;
}

.wysiwyg code,
.reader code {
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--surface-soft);
  font-family: Consolas, monospace;
  font-size: 0.93em;
}

.side-rail {
  display: grid;
  gap: 12px;
}

.side-panel {
  padding: 16px;
}

.side-panel h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.select {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  outline: none;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.76);
}

.metric small {
  color: var(--muted);
}

.metric strong {
  font-size: 24px;
  line-height: 1;
}

.share-box {
  display: grid;
  gap: 10px;
}

.share-url {
  min-height: 42px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.empty-state,
.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card,
.empty-card {
  width: min(520px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.login-card h1,
.empty-card h1 {
  margin: 0 0 10px;
  font-size: 32px;
}

.login-card p,
.empty-card p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.55;
}

.public-shell {
  min-height: 100vh;
  padding: 28px;
}

.public-page {
  max-width: 860px;
  margin: 0 auto;
}

.public-header {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.public-header p {
  margin: 8px 0 0;
  color: var(--muted);
}

.reader {
  padding: 28px;
}

.public-doc-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.public-doc {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 14px;
  z-index: 10;
}

.hidden {
  display: none !important;
}

@media (max-width: 1180px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    width: 100vw;
    height: auto;
    padding: 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workspace-nav {
    max-height: 320px;
  }

  .main {
    width: 100vw;
    padding: 22px 18px 32px;
  }

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

  .side-rail {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .brand,
  .topbar,
  .editor-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions,
  .doc-tools,
  .sidebar-actions,
  .mode-row {
    width: 100%;
  }

  .button,
  .segment,
  .segment button {
    flex: 1;
  }

  .icon-button {
    flex: 0 0 40px;
  }

  .main {
    padding: 18px 12px 28px;
  }

  .editor-area,
  .markdown-input,
  .wysiwyg {
    min-height: 58vh;
  }

  .markdown-input,
  .wysiwyg {
    padding: 18px 14px;
    font-size: 15px;
  }

  .side-rail,
  .metrics {
    grid-template-columns: 1fr;
  }

  .public-shell {
    padding: 16px 12px;
  }

  .reader {
    padding: 18px 14px;
  }
}
