:root {
  color-scheme: light;
  --ink: #15131a;
  --ink-soft: #423d52;
  --ink-muted: #6c677a;
  --paper: #fff9f1;
  --paper-edge: #efe4d4;
  --sand: #f7efe5;
  --mist: #f3f5f9;
  --shadow: rgba(26, 20, 42, 0.12);
  --accent: #ff6b4a;
  --accent-deep: #e64a2c;
  --mint: #b8f2d3;
  --sky: #c6ddff;
  --plum: #2e233a;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 10% 10%, #fff4e0 0%, transparent 45%),
    radial-gradient(circle at 80% 20%, #e4f1ff 0%, transparent 50%),
    linear-gradient(180deg, #f6f2ea 0%, #f1f3f7 100%);
  min-height: 100vh;
}

.writer-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.writer-topbar {
  display: grid;
  grid-template-columns: 1.2fr 2fr 1.2fr;
  align-items: center;
  gap: 16px;
  padding: 18px 32px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(27, 20, 40, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #ffb199, #ff6b4a);
  display: grid;
  place-items: center;
  color: white;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.brand-text h1 {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: 22px;
  margin: 0;
}

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

.writer-search {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: white;
  border: 1px solid rgba(27, 20, 40, 0.08);
  align-items: center;
}

.writer-search input {
  border: none;
  outline: none;
  flex: 1;
  font-size: 14px;
  font-family: inherit;
}

.writer-search__hint {
  font-size: 12px;
  color: var(--ink-muted);
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn {
  border: none;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 12px 24px rgba(255, 107, 74, 0.22);
}

.btn-ghost {
  background: white;
  border: 1px solid rgba(27, 20, 40, 0.1);
}

.writer-body {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  padding: 24px 28px 32px;
}

.docs-sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 20px;
  height: fit-content;
}

.docs-nav {
  display: grid;
  gap: 18px;
}

.docs-compose {
  border: none;
  border-radius: 14px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #ff9068, #ff6b4a);
  color: white;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 14px 24px rgba(255, 107, 74, 0.25);
}

.docs-links {
  display: grid;
  gap: 6px;
}

.docs-link {
  text-decoration: none;
  color: var(--ink-soft);
  font-weight: 500;
  padding: 8px 10px;
  border-radius: 10px;
}

.docs-link.is-active,
.docs-link:hover {
  background: var(--mist);
  color: var(--ink);
}

.docs-storage {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-muted);
}

.docs-storage strong {
  color: var(--ink);
  font-size: 14px;
}

.docs-main {
  display: grid;
  gap: 18px;
}

.panel {
  background: rgba(255, 255, 255, 0.92);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: 0 18px 40px rgba(25, 22, 44, 0.08);
  border: 1px solid rgba(28, 22, 40, 0.06);
}

.panel h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-muted);
  margin: 0 0 16px;
}

.docs-section-header h2 {
  text-transform: none;
  letter-spacing: 0.02em;
  font-size: 16px;
  color: var(--ink);
  margin: 0;
}

.docs-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.docs-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.docs-back {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 999px;
}

.docs-templates {
  display: grid;
  gap: 16px;
}

.docs-template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 180px);
  justify-content: start;
  gap: 12px;
}

.docs-template-card {
  border: 1px solid rgba(27, 20, 40, 0.1);
  border-radius: var(--radius-md);
  background: white;
  padding: 0;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  appearance: none;
  color: inherit;
  display: grid;
  gap: 10px;
  justify-items: start;
  overflow: hidden;
}

.docs-template-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 20px rgba(30, 22, 44, 0.12);
}

.docs-template-card span {
  font-size: 12px;
  color: var(--ink-muted);
}

.docs-list {
  display: grid;
  gap: 14px;
}

.docs-list-actions {
  display: flex;
  gap: 8px;
}

.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.page-card {
  border: none;
  background: transparent;
  padding: 0;
  display: grid;
  gap: 10px;
  text-align: left;
  width: 100%;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  color: inherit;
}

.page-cover {
  aspect-ratio: 3 / 4;
  border-radius: 16px;
  background: linear-gradient(160deg, var(--cover-1, #ffe6cf) 0%, var(--cover-2, #f8f5ff) 45%, var(--cover-3, #e7f2ff) 100%);
  border: 1px solid rgba(27, 20, 40, 0.08);
  box-shadow: 0 18px 30px rgba(22, 18, 40, 0.18);
  padding: 16px;
  display: grid;
  align-content: space-between;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.page-cover--template {
  width: 100%;
}

.page-cover--template .page-cover-title {
  font-size: 14px;
}

.page-cover--template .page-cover-meta {
  font-size: 10px;
}


.docs-template-card .page-cover {
  position: relative;
}

.docs-template-card .page-cover::after {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.docs-template-card .page-cover::before {
  background: rgba(27, 20, 40, 0.12);
}

.docs-template-card:hover .page-cover {
  transform: translateY(-3px);
}

.docs-template-card span {
  padding: 0 6px 10px;
}

.docs-template-card:nth-child(1) .page-cover {
  --cover-1: #ffe9d6;
  --cover-2: #f4f3ff;
  --cover-3: #e6f3ff;
}

.docs-template-card:nth-child(2) .page-cover {
  --cover-1: #f7efe1;
  --cover-2: #f6e4f1;
  --cover-3: #e7f4ff;
}

.docs-template-card:nth-child(3) .page-cover {
  --cover-1: #f0f5ff;
  --cover-2: #f9efe4;
  --cover-3: #e4f7ef;
}

.docs-template-card:nth-child(4) .page-cover {
  --cover-1: #f6e8ff;
  --cover-2: #f1f4ff;
  --cover-3: #e7f7ff;
}

.page-cover::after {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 12px;
  border: 1px solid rgba(27, 20, 40, 0.08);
  pointer-events: none;
}

.page-cover::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 12px;
  bottom: 12px;
  width: 4px;
  border-radius: 999px;
  background: rgba(27, 20, 40, 0.08);
  pointer-events: none;
}


.page-card.active .page-cover {
  box-shadow: 0 22px 40px rgba(255, 107, 74, 0.25);
  border-color: rgba(255, 107, 74, 0.4);
}

.page-cover-title {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: 16px;
  line-height: 1.2;
}

.page-cover-meta {
  font-size: 11px;
  color: var(--ink-muted);
}

.page-card:hover .page-cover {
  transform: translateY(-4px);
  box-shadow: 0 22px 36px rgba(22, 18, 40, 0.22);
}

.page-card strong {
  font-size: 14px;
}

.page-card span {
  font-size: 12px;
  color: var(--ink-muted);
}

.page-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.page-card__menu {
  border: 1px solid rgba(27, 20, 40, 0.12);
  background: white;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: grid;
  place-items: center;
  color: var(--ink-muted);
}

.page-card__menu:hover {
  color: var(--ink);
  background: var(--mist);
}

.page-card.is-favorite strong::after {
  content: " ★";
  color: var(--accent);
  font-size: 12px;
}

.editor-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at top, #f9f4ec 0%, #eef1f7 55%, #e7ecf3 100%);
  display: none;
  align-content: start;
  justify-items: center;
  padding: 32px 20px;
  z-index: 30;
  overflow: auto;
}

.editor-overlay[hidden] {
  display: none;
}

.writer-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 32, 0.55);
  z-index: 40;
}

.writer-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 41;
  padding: 20px;
}

.writer-modal[hidden],
.writer-modal-backdrop[hidden] {
  display: none;
}

.writer-modal__card {
  width: min(420px, 100%);
  background: white;
  border-radius: 16px;
  border: 1px solid rgba(28, 22, 40, 0.12);
  box-shadow: 0 24px 48px rgba(24, 20, 40, 0.2);
  padding: 20px;
  display: grid;
  gap: 12px;
}

.writer-modal__card h3 {
  margin: 0;
  font-size: 18px;
}

.writer-modal__message {
  margin: 0;
  color: var(--ink-muted);
  font-size: 14px;
}

.writer-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.writer-modal__danger {
  background: #ef4444;
  box-shadow: 0 12px 24px rgba(239, 68, 68, 0.25);
}

.writer-context {
  position: fixed;
  min-width: 200px;
  background: white;
  border-radius: 12px;
  border: 1px solid rgba(28, 22, 40, 0.12);
  box-shadow: 0 18px 36px rgba(24, 20, 40, 0.18);
  display: grid;
  z-index: 42;
  padding: 8px;
}

.writer-context[hidden] {
  display: none;
}

.writer-context__item {
  border: none;
  background: transparent;
  padding: 8px 10px;
  text-align: left;
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}

.writer-context__item:hover {
  background: var(--mist);
}

.writer-context__item.is-danger {
  color: #b91c1c;
}

.writer-context__divider {
  height: 1px;
  background: rgba(27, 20, 40, 0.08);
  margin: 4px 0;
}

.editor-layout {
  width: min(100%, 1280px);
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
}

.editor-sidebar {
  align-self: start;
  position: sticky;
  top: 24px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-md);
  border: 1px solid rgba(28, 22, 40, 0.08);
  box-shadow: 0 12px 24px rgba(30, 22, 44, 0.08);
  padding: 14px;
  display: grid;
  gap: 12px;
}

.editor-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 13px;
}

.editor-sidebar__list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 220px);
  overflow: auto;
  padding-right: 4px;
}

.editor-page-item {
  border: 1px solid rgba(27, 20, 40, 0.08);
  border-radius: 12px;
  padding: 10px 10px;
  background: white;
  display: grid;
  gap: 6px;
  cursor: pointer;
}

.editor-page-item.is-dragging {
  opacity: 0.6;
}

.editor-page-item.is-drop-before {
  box-shadow: inset 0 2px 0 var(--accent);
}

.editor-page-item.is-drop-after {
  box-shadow: inset 0 -2px 0 var(--accent);
}

.editor-page-item.is-active {
  border-color: rgba(255, 107, 74, 0.45);
  box-shadow: 0 10px 20px rgba(255, 107, 74, 0.18);
}

.editor-page-item__title {
  font-size: 13px;
  font-weight: 600;
}

.editor-page-item__meta {
  font-size: 11px;
  color: var(--ink-muted);
}

.editor-page-item__actions {
  display: flex;
  gap: 6px;
}

.editor-page-item__action {
  border: 1px solid rgba(27, 20, 40, 0.1);
  background: #f7f5ff;
  color: var(--ink);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
}

.editor-stage {
  width: 100%;
  display: grid;
  gap: 16px;
  padding-bottom: 40px;
}

.editor-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(28, 22, 40, 0.08);
  box-shadow: 0 12px 24px rgba(30, 22, 44, 0.08);
}

.editor-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.editor-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
}

.editor-actions {
  display: flex;
  gap: 8px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(28, 22, 40, 0.08);
  box-shadow: 0 12px 24px rgba(30, 22, 44, 0.08);
}

.tool-group {
  display: inline-flex;
  gap: 8px;
  padding-right: 10px;
  border-right: 1px solid rgba(27, 20, 40, 0.08);
}

.tool-group:last-child {
  border-right: none;
  padding-right: 0;
}

.tool-btn {
  border: 1px solid rgba(27, 20, 40, 0.1);
  background: white;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
}

.tool-btn.active {
  background: var(--plum);
  color: white;
}

.writer-status {
  margin-left: auto;
  font-size: 12px;
  color: var(--ink-muted);
}

.writer-status[data-tone="success"] {
  color: #15803d;
}

.writer-status[data-tone="error"] {
  color: #b91c1c;
}

.writer-status[data-tone="muted"] {
  color: var(--ink-muted);
}

.paper {
  background: var(--paper);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  min-height: 60vh;
  border: 1px solid var(--paper-edge);
  box-shadow: inset 0 0 0 8px rgba(255, 255, 255, 0.35),
    0 30px 60px rgba(28, 22, 40, 0.18);
  position: relative;
  overflow: hidden;
}

.writer-page {
  display: grid;
  grid-template-rows: auto 1fr;
  height: var(--page-height, 1123px);
}

.editor-pages {
  display: grid;
  gap: 24px;
}

.page-canvas {
  max-width: 794px;
  width: min(100%, 794px);
  margin: 0 auto;
  min-height: 0;
  height: var(--page-height, 1123px);
  background: #fffdf9;
  box-shadow: 0 24px 60px rgba(23, 20, 40, 0.18);
}

.page-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--ink-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 6px auto 0;
}

.page-divider::before,
.page-divider::after {
  content: "";
  height: 1px;
  background: rgba(28, 22, 40, 0.12);
  flex: 1;
}

.page-add-below {
  margin: 10px auto 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px dashed rgba(28, 22, 40, 0.2);
  background: white;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink);
  font-family: inherit;
  box-shadow: 0 10px 20px rgba(30, 22, 44, 0.08);
}

.page-add-below:hover {
  border-color: rgba(255, 107, 74, 0.4);
  color: var(--accent-deep);
}

.page-next {
  margin: 20px auto 0;
  max-width: 860px;
  width: min(100%, 860px);
  text-align: center;
}

.page-next__cover {
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  background: #fffdf9;
  border: 1px solid var(--paper-edge);
  box-shadow: 0 24px 60px rgba(23, 20, 40, 0.18);
  display: grid;
  gap: 6px;
  min-height: 75vh;
  align-content: start;
  text-align: left;
  position: relative;
  overflow: hidden;
  width: 100%;
  cursor: text;
}

.page-next__cover::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(transparent 95%, rgba(24, 20, 36, 0.08) 100%);
  background-size: 100% 32px;
  opacity: 0.35;
  pointer-events: none;
}

.page-next__title {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: 28px;
}

.page-next__meta {
  font-size: 13px;
  color: var(--ink-muted);
}


.page-next__open {
  margin-top: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(27, 20, 40, 0.12);
  background: white;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.page-canvas::before {
  opacity: 0;
}

.writer-shell.is-editor-open {
  height: 100vh;
  overflow: hidden;
}

.writer-shell.is-editor-open .editor-overlay {
  display: grid;
}

.writer-shell.is-editor-open .writer-body,
.writer-shell.is-editor-open .writer-topbar {
  filter: blur(8px);
  pointer-events: none;
}

.paper::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(transparent 95%, rgba(24, 20, 36, 0.08) 100%);
  background-size: 100% 32px;
  opacity: 0.35;
  pointer-events: none;
}

.paper-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

.paper-title {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: 28px;
  margin: 0;
}

.paper-title-input {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: 28px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--ink);
  padding: 0;
  width: 100%;
}

.paper-title-input::placeholder {
  color: rgba(108, 103, 122, 0.7);
}

.writer-page.page-has-content .paper-title-input::placeholder {
  opacity: 0;
}

.paper-title-ghost {
  font-size: 16px;
  color: rgba(108, 103, 122, 0.55);
  margin-top: 6px;
  letter-spacing: 0.02em;
}

.writer-page.page-has-content .paper-title-ghost {
  opacity: 0;
  height: 0;
  margin: 0;
  overflow: hidden;
}

.paper-meta {
  font-size: 12px;
  color: var(--ink-muted);
}

.editor {
  min-height: 0;
  height: 100%;
  overflow: hidden;
  outline: none;
  font-size: 17px;
  line-height: 1.8;
  font-family: "Fraunces", "Times New Roman", serif;
  position: relative;
  z-index: 1;
  white-space: pre-wrap;
  word-break: break-word;
}

.editor:focus {
  outline: none;
}

.editor.is-empty::before {
  content: attr(data-placeholder);
  color: var(--ink-muted);
  pointer-events: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 0;
  opacity: 0.5;
}

.editor > * {
  position: relative;
  z-index: 1;
}

.fade-in {
  animation: fadeUp 0.6s ease forwards;
  opacity: 0;
  transform: translateY(10px);
}

.stagger-1 {
  animation-delay: 0.1s;
}

.stagger-2 {
  animation-delay: 0.2s;
}

.stagger-3 {
  animation-delay: 0.3s;
}

.stagger-4 {
  animation-delay: 0.4s;
}

.stagger-5 {
  animation-delay: 0.5s;
}

@keyframes fadeUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1200px) {
  .writer-body {
    grid-template-columns: 200px 1fr;
  }

}

@media (max-width: 900px) {
  .writer-topbar {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .writer-body {
    grid-template-columns: 1fr;
  }

  .docs-sidebar {
    position: static;
  }

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

  .editor-sidebar {
    position: static;
  }

}

@media (max-width: 600px) {
  .writer-topbar {
    padding: 16px 20px;
  }

  .writer-body {
    padding: 20px;
  }

  .paper {
    min-height: 60vh;
  }

  .editor-stage {
    width: 100%;
  }

  .page-canvas {
    padding: 22px 18px;
  }
}
