:root {
  --bg: #f4efe6;
  --bg-soft: rgba(255, 255, 255, 0.72);
  --surface: rgba(255, 251, 246, 0.88);
  --surface-strong: #fffdf9;
  --line: rgba(73, 52, 35, 0.14);
  --text: #1d1a17;
  --muted: #6b6258;
  --accent: #b85c38;
  --accent-deep: #8d3f22;
  --accent-soft: #f6d8bf;
  --success: #235b42;
  --danger: #922f2f;
  --shadow: 0 24px 80px rgba(54, 38, 23, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --font-sans: "Avenir Next", "PingFang SC", "Noto Sans SC", sans-serif;
  --font-serif: "Iowan Old Style", "Songti SC", serif;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(184, 92, 56, 0.18), transparent 28%),
    linear-gradient(180deg, #f8f4ec 0%, #efe7db 100%);
  min-height: 100vh;
}

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

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

.page-bg {
  position: fixed;
  inset: auto;
  pointer-events: none;
  z-index: 0;
}

.page-bg-one {
  top: -8rem;
  right: -5rem;
  width: 22rem;
  height: 22rem;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(184, 92, 56, 0.24), rgba(184, 92, 56, 0));
}

.page-bg-two {
  bottom: -10rem;
  left: -8rem;
  width: 26rem;
  height: 26rem;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(35, 91, 66, 0.18), rgba(35, 91, 66, 0));
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1rem 0 2.5rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.2rem;
  margin: 0.75rem 0 1.5rem;
  background: rgba(255, 251, 246, 0.72);
  border: 1px solid var(--line);
  backdrop-filter: blur(24px);
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand strong {
  display: block;
  font-size: 1rem;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.7rem;
  height: 2.7rem;
  border-radius: 1rem;
  background: linear-gradient(135deg, var(--accent), #df946a);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.topnav a {
  padding: 0.72rem 1rem;
  border-radius: 999px;
  color: var(--muted);
}

.topnav a.is-active,
.topnav a:hover {
  background: rgba(184, 92, 56, 0.12);
  color: var(--accent-deep);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.user-badge,
.meta-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  background: rgba(35, 91, 66, 0.08);
  color: var(--success);
}

.auth-main,
.dashboard-main,
.editor-main,
.settings-main {
  display: grid;
  gap: 1.4rem;
}

.auth-main {
  grid-template-columns: 1.08fr 0.92fr;
  align-items: stretch;
  min-height: calc(100vh - 10rem);
}

.auth-panel,
.hero-card,
.stat-card,
.sidebar-card,
.content-card,
.settings-card {
  background: var(--surface);
  border: 1px solid rgba(73, 52, 35, 0.1);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.auth-panel,
.hero-card,
.sidebar-card,
.content-card,
.settings-card {
  padding: 1.6rem;
}

.auth-copy-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3rem;
  background:
    linear-gradient(145deg, rgba(255, 248, 241, 0.92), rgba(245, 231, 216, 0.78)),
    linear-gradient(45deg, rgba(184, 92, 56, 0.08), transparent);
}

.auth-form-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2.5rem;
}

.eyebrow {
  margin: 0 0 0.6rem;
  color: var(--accent-deep);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 700;
}

h1 {
  font-size: clamp(2.1rem, 4vw, 3.6rem);
  line-height: 1.08;
}

h2 {
  font-size: 1.35rem;
}

.lead {
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.75;
  max-width: 60ch;
}

.feature-list,
.metrics-grid,
.document-list,
.stack-form,
.category-list {
  display: grid;
  gap: 0.9rem;
}

.feature-list {
  padding-left: 1.2rem;
  color: var(--muted);
}

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

.metrics-grid article,
.stat-card {
  padding: 1rem 1.1rem;
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  border: 1px solid rgba(73, 52, 35, 0.08);
}

.metrics-grid strong,
.stat-card strong {
  display: block;
  font-size: 1.3rem;
  margin-bottom: 0.35rem;
}

.metrics-grid span,
.stat-card span,
.document-meta,
.helper-text,
.form-footnote,
.footer,
.empty-state {
  color: var(--muted);
}

.flash {
  padding: 0.95rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 0.4rem;
}

.flash-error {
  background: rgba(146, 47, 47, 0.1);
  border: 1px solid rgba(146, 47, 47, 0.15);
  color: var(--danger);
}

.flash-notice {
  background: rgba(35, 91, 66, 0.1);
  border: 1px solid rgba(35, 91, 66, 0.14);
  color: var(--success);
}

.stack-form label,
.stack-form .form-row {
  display: grid;
  gap: 0.55rem;
}

.stack-form span {
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border-radius: 1rem;
  border: 1px solid rgba(73, 52, 35, 0.12);
  background: rgba(255, 255, 255, 0.82);
  padding: 0.95rem 1rem;
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

textarea {
  resize: vertical;
  min-height: 22rem;
  line-height: 1.7;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(184, 92, 56, 0.5);
  box-shadow: 0 0 0 4px rgba(184, 92, 56, 0.12);
}

.primary-button,
.secondary-button,
.ghost-button,
.text-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.primary-button,
.secondary-button,
.ghost-button {
  padding: 0.85rem 1.2rem;
  border-radius: 999px;
  font-weight: 700;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), #d28761);
  color: #fff;
  box-shadow: 0 18px 36px rgba(184, 92, 56, 0.22);
}

.secondary-button {
  background: rgba(184, 92, 56, 0.1);
  color: var(--accent-deep);
}

.ghost-button {
  background: rgba(255, 255, 255, 0.75);
  color: var(--text);
  border: 1px solid rgba(73, 52, 35, 0.1);
}

.text-link {
  color: var(--accent-deep);
  font-weight: 700;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.text-link:hover {
  transform: translateY(-1px);
}

.hero-card,
.editor-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.hero-card {
  background:
    linear-gradient(135deg, rgba(255, 251, 246, 0.86), rgba(255, 240, 226, 0.68)),
    linear-gradient(30deg, rgba(184, 92, 56, 0.14), transparent);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.dashboard-grid,
.editor-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 1rem;
}

.editor-grid {
  grid-template-columns: minmax(0, 1.05fr) minmax(300px, 0.95fr);
}

.section-heading,
.form-actions,
.inline-form,
.document-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
}

.section-heading {
  margin-bottom: 1rem;
}

.inline-form input {
  flex: 1;
}

.category-list {
  margin-top: 1rem;
}

.category-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.8rem 0.95rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.6);
  color: var(--muted);
  border: 1px solid rgba(73, 52, 35, 0.08);
}

.category-pill span {
  color: var(--accent-deep);
  font-weight: 700;
}

.category-pill.is-selected,
.category-pill:hover {
  background: rgba(184, 92, 56, 0.12);
  color: var(--accent-deep);
}

.document-row {
  padding: 1rem 1.1rem;
  border: 1px solid rgba(73, 52, 35, 0.08);
  border-radius: 1.2rem;
  background: rgba(255, 255, 255, 0.65);
}

.document-title {
  display: inline-block;
  margin-bottom: 0.35rem;
  font-weight: 700;
  font-size: 1.05rem;
}

.document-title:hover {
  color: var(--accent-deep);
}

.empty-box {
  display: grid;
  gap: 0.9rem;
  place-items: start;
  min-height: 240px;
  align-content: center;
}

.editor-panel,
.preview-panel,
.settings-card {
  min-height: 520px;
}

.two-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.markdown-body {
  color: var(--text);
  line-height: 1.8;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin-top: 1.6rem;
  margin-bottom: 0.75rem;
  font-family: var(--font-serif);
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body pre {
  margin: 0 0 1rem;
}

.markdown-body blockquote {
  padding: 0.1rem 0 0.1rem 1rem;
  border-left: 4px solid rgba(184, 92, 56, 0.32);
  color: var(--muted);
}

.markdown-body code,
.markdown-body pre {
  font-family: "SFMono-Regular", "Menlo", monospace;
}

.markdown-body pre {
  padding: 1rem;
  overflow: auto;
  border-radius: 1rem;
  background: #281f19;
  color: #fef3e9;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid rgba(73, 52, 35, 0.1);
  padding: 0.7rem;
  text-align: left;
}

.narrow-form {
  max-width: 520px;
}

.footer {
  padding: 1.4rem 0 0.2rem;
  text-align: center;
  font-size: 0.92rem;
}

@media (max-width: 980px) {
  .auth-main,
  .dashboard-grid,
  .editor-grid,
  .stats-grid,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .hero-card,
  .editor-hero,
  .section-heading,
  .document-row,
  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .topnav,
  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .auth-copy-panel,
  .auth-form-panel {
    padding: 1.6rem;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 1rem, 1180px);
  }

  .topbar {
    border-radius: 1.6rem;
  }

  .topnav {
    flex-wrap: wrap;
  }

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

  h1 {
    font-size: 2rem;
  }

  .auth-main {
    min-height: auto;
  }
}

/* Refined compact visual tune */
:root {
  --shadow: 0 14px 38px rgba(54, 38, 23, 0.1);
  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius-md: 12px;
}

html {
  font-size: 15px;
}

.page-shell {
  width: min(1060px, calc(100% - 1.5rem));
  padding: 0.65rem 0 1.7rem;
}

.topbar {
  padding: 0.68rem 0.95rem;
  margin: 0.35rem 0 1rem;
}

.brand-mark {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 0.78rem;
  font-size: 0.9rem;
}

.topnav a {
  padding: 0.5rem 0.75rem;
  font-size: 0.94rem;
}

.auth-main,
.dashboard-main,
.editor-main,
.settings-main {
  gap: 0.9rem;
}

.auth-panel,
.hero-card,
.sidebar-card,
.content-card,
.settings-card {
  padding: 1.2rem;
}

.auth-copy-panel {
  padding: 2rem;
}

.auth-form-panel {
  padding: 1.8rem;
}

h1 {
  font-size: clamp(1.7rem, 3.5vw, 2.7rem);
  line-height: 1.15;
}

h2 {
  font-size: 1.16rem;
}

.lead {
  font-size: 0.95rem;
  line-height: 1.65;
}

.eyebrow {
  margin-bottom: 0.45rem;
  font-size: 0.74rem;
}

.stats-grid,
.dashboard-grid,
.editor-grid {
  gap: 0.85rem;
}

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

.stat-card,
.metrics-grid article {
  padding: 0.8rem 0.92rem;
}

.stat-card strong,
.metrics-grid strong {
  font-size: 1.14rem;
}

input,
select,
textarea {
  border-radius: 0.82rem;
  padding: 0.72rem 0.84rem;
}

textarea {
  min-height: 17rem;
}

.primary-button,
.secondary-button,
.ghost-button {
  padding: 0.62rem 0.95rem;
  font-size: 0.92rem;
}

.document-row {
  padding: 0.74rem 0.86rem;
  border-radius: 0.95rem;
}

.document-title {
  font-size: 0.98rem;
  margin-bottom: 0.24rem;
}

.document-meta,
.helper-text,
.form-footnote,
.footer {
  font-size: 0.88rem;
}

.footer {
  padding-top: 0.9rem;
}

.editor-panel,
.preview-panel,
.settings-card {
  min-height: 420px;
}

.share-card {
  border: 1px solid rgba(73, 52, 35, 0.12);
  background:
    linear-gradient(145deg, rgba(255, 252, 247, 0.9), rgba(250, 241, 230, 0.78)),
    linear-gradient(30deg, rgba(35, 91, 66, 0.07), transparent 45%);
}

.share-info {
  display: grid;
  gap: 0.68rem;
  margin-bottom: 0.7rem;
}

.share-actions,
.share-create {
  display: flex;
  gap: 0.62rem;
  align-items: center;
  flex-wrap: wrap;
}

.share-actions .inline-form,
.share-create.inline-form {
  margin-left: auto;
  width: auto;
}

.share-view-card {
  max-width: 920px;
  margin: 0 auto;
}

html.modal-open,
html.modal-open body {
  overflow: hidden;
}

.share-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.share-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(25, 21, 18, 0.42);
  backdrop-filter: blur(10px);
}

.share-modal-card {
  position: relative;
  z-index: 1;
  width: min(92vw, 520px);
  margin: min(10vh, 5rem) auto 0;
  padding: 1.25rem;
  border-radius: 20px;
  border: 1px solid rgba(73, 52, 35, 0.12);
  background: linear-gradient(160deg, rgba(255, 252, 248, 0.96), rgba(244, 236, 225, 0.9));
  box-shadow: 0 30px 80px rgba(34, 24, 16, 0.22);
}

.share-modal-heading {
  align-items: flex-start;
}

.share-close {
  min-width: 4.5rem;
}

.share-modal-actions {
  align-items: center;
}

.share-result {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(73, 52, 35, 0.1);
}

.share-result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.share-create-trigger {
  display: inline-flex;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.hero-card,
.content-card,
.sidebar-card,
.auth-panel,
.settings-card {
  position: relative;
  overflow: hidden;
}

.hero-card::after,
.content-card::after,
.sidebar-card::after,
.auth-panel::after,
.settings-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(29, 26, 23, 0.035) 0.45px, transparent 0.45px);
  background-size: 6px 6px;
  opacity: 0.32;
}

.document-row {
  border-color: rgba(73, 52, 35, 0.1);
}

.document-row:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(54, 38, 23, 0.08);
}

.primary-button {
  background: linear-gradient(145deg, #b05836, #c26f4f);
}

.secondary-button {
  border: 1px solid rgba(141, 63, 34, 0.18);
}

.topbar {
  background:
    linear-gradient(145deg, rgba(255, 252, 248, 0.82), rgba(246, 237, 226, 0.74)),
    rgba(255, 251, 246, 0.72);
}

.editor-main .editor-grid {
  align-items: start;
}

.editor-main textarea {
  letter-spacing: 0.01em;
}

.preview-panel {
  display: flex;
  flex-direction: column;
}

.preview-body {
  flex: 1 1 auto;
  min-height: 0;
}

.preview-body {
  padding: 0.1rem 0;
  overflow: auto;
}

.share-countdown-card {
  margin-bottom: 1rem;
  padding: 0.95rem 1rem;
  border-radius: 14px;
  background: rgba(35, 91, 66, 0.08);
  border: 1px solid rgba(35, 91, 66, 0.12);
}

.share-countdown-card strong {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.92rem;
}

.share-countdown-text {
  margin: 0;
  color: var(--success);
  font-weight: 600;
}

.share-countdown-text.is-permanent {
  color: var(--accent-deep);
}

html.editor-focus body {
  background: linear-gradient(180deg, #f5eee3 0%, #e9decd 100%);
}

html.editor-focus .topbar,
html.editor-focus .footer,
html.editor-focus .editor-hero,
html.editor-focus .share-card {
  display: none;
}

html.editor-focus .page-shell {
  width: min(100% - 1rem, 1200px);
  padding-top: 0.5rem;
}

html.editor-focus .editor-main {
  gap: 0.85rem;
}

html.editor-focus .editor-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: stretch;
}

html.editor-focus .editor-panel,
html.editor-focus .preview-panel {
  min-height: calc(100vh - 1.5rem);
}

html.editor-focus .editor-panel .section-heading,
html.editor-focus .preview-panel .section-heading,
html.editor-focus .editor-panel .stack-form > label:not(:last-of-type),
html.editor-focus .editor-panel .form-row,
html.editor-focus .editor-panel .helper-text {
  display: none;
}

html.editor-focus .editor-panel .stack-form {
  display: flex;
  flex-direction: column;
  height: 100%;
}

html.editor-focus .editor-panel .stack-form > label:last-of-type {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

html.editor-focus .editor-panel .stack-form > label:last-of-type span {
  margin-bottom: 0.55rem;
}

html.editor-focus .editor-panel textarea {
  min-height: 0;
  height: 100%;
  flex: 1 1 auto;
}

html.editor-focus .editor-panel .form-actions {
  margin-top: 0.8rem;
  justify-content: flex-start;
}

html.editor-focus .preview-panel {
  display: flex;
  flex-direction: column;
}

html.editor-focus .preview-body {
  height: 100%;
}

@media (max-width: 980px) {
  .page-shell {
    width: min(100% - 1rem, 1060px);
  }

  .auth-copy-panel,
  .auth-form-panel {
    padding: 1.2rem;
  }

  .share-actions .inline-form,
  .share-create.inline-form {
    margin-left: 0;
    width: 100%;
  }

  .share-actions form,
  .share-actions select,
  .share-create select,
  .share-actions button,
  .share-create button {
    width: 100%;
  }

  .share-modal-card {
    width: min(100% - 1rem, 520px);
    margin-top: 1rem;
  }

  .share-result-meta {
    flex-direction: column;
    align-items: stretch;
  }

  .row-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}