:root {
  color-scheme: light;
  --ink: #24231f;
  --muted: #79766d;
  --line: #e6e2d8;
  --panel: #ffffff;
  --canvas: #f2f0ea;
  --accent: #d29d27;
  --accent-soft: #f7df91;
  --shadow: 0 18px 50px rgba(49, 44, 31, .10);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  height: 76px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid rgba(36,35,31,.08);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 13px;
  display: grid; place-items: center;
  background: #25241f; color: #f5d672; font-size: 18px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.1);
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; letter-spacing: .02em; }
.brand small { color: var(--muted); margin-top: 3px; font-size: 11px; }
.top-actions { display: flex; gap: 10px; }
.ghost-btn, .primary-btn {
  border-radius: 12px; padding: 10px 17px; border: 1px solid #ddd9cf;
  background: #fff; color: var(--ink); font-weight: 650; font-size: 14px;
}
.primary-btn { border-color: #24231f; background: #24231f; color: #fff; }
.primary-btn:hover { transform: translateY(-1px); box-shadow: 0 7px 16px rgba(0,0,0,.16); }

.workspace { display: grid; grid-template-columns: 430px minmax(0, 1fr); min-height: calc(100vh - 76px); }
.editor-panel {
  background: var(--panel); border-right: 1px solid rgba(36,35,31,.09);
  padding: 34px 30px 50px; overflow: auto;
}
.panel-section { padding: 24px 0; border-bottom: 1px solid #ece9e1; }
.intro-section { padding-top: 4px; }
.intro-section .eyebrow { color: #a47d1c; font-size: 10px; font-weight: 800; letter-spacing: .17em; }
.intro-section h1 { font-size: 27px; line-height: 1.34; letter-spacing: -.035em; margin: 12px 0 10px; }
.intro-section p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.8; }
.section-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-title-row label, .end-copy-settings > label { font-weight: 750; font-size: 14px; }
.section-title-row span { color: var(--muted); font-size: 12px; }
#contentInput {
  width: 100%; min-height: 320px; resize: vertical; border: 1px solid #dedbd2;
  border-radius: 15px; padding: 17px; outline: none; background: #fbfaf7;
  line-height: 1.75; font-size: 14px; color: #34322d;
  transition: border .2s, box-shadow .2s;
}
#contentInput:focus, input:focus, select:focus, .end-copy-settings textarea:focus {
  border-color: #c99b2e; box-shadow: 0 0 0 3px rgba(210,157,39,.12);
}
.helper-row { display: flex; gap: 15px; margin-top: 10px; font-size: 11px; color: #918e85; }
.helper-row b { color: #a57b17; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px 14px; }
.settings-grid label > span { display: block; font-size: 12px; color: #77736b; margin-bottom: 7px; }
.settings-grid select, .settings-grid input {
  width: 100%; height: 42px; border: 1px solid #dedbd2; border-radius: 10px;
  padding: 0 11px; background: #fff; outline: none; font-size: 13px; color: var(--ink);
}
.toggles { display: grid; gap: 16px; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.toggle-row input { display: none; }
.toggle-row i { width: 39px; height: 22px; border-radius: 20px; background: #d8d6d0; position: relative; transition: .2s; }
.toggle-row i::after { content: ""; width: 18px; height: 18px; background: white; border-radius: 50%; position: absolute; left: 2px; top: 2px; box-shadow: 0 1px 4px rgba(0,0,0,.2); transition: .2s; }
.toggle-row input:checked + i { background: #d1a02d; }
.toggle-row input:checked + i::after { transform: translateX(17px); }
.end-copy-settings { border-bottom: 0; }
.end-copy-settings textarea {
  margin-top: 10px; width: 100%; resize: vertical; border: 1px solid #dedbd2; border-radius: 11px;
  padding: 12px; outline: none; line-height: 1.6; font-size: 13px;
}

.preview-panel { padding: 25px 30px 70px; min-width: 0; }
.preview-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.preview-toolbar strong { font-size: 15px; }
.preview-toolbar span { margin-left: 8px; font-size: 12px; color: var(--muted); }
.view-switch { padding: 3px; border: 1px solid #dedbd2; border-radius: 10px; background: rgba(255,255,255,.75); }
.view-switch button { border: 0; background: transparent; padding: 6px 10px; font-size: 11px; color: #7d796f; border-radius: 7px; }
.view-switch button.active { background: #fff; color: #24231f; box-shadow: 0 2px 7px rgba(42,39,31,.08); }
.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 24px; align-items: start; }
.preview-grid.large { grid-template-columns: repeat(auto-fill, minmax(410px, 1fr)); }
.card-wrap { min-width: 0; }
.card-meta { display: flex; justify-content: space-between; margin: 0 2px 8px; font-size: 11px; color: #8c887f; }
.card-stage { aspect-ratio: 3 / 4; width: 100%; position: relative; overflow: hidden; border-radius: 3px; box-shadow: var(--shadow); background: #fff; container-type: inline-size; }
.note-card {
  --card-bg: #fffdf8; --card-ink: #26251f; --card-muted: #89847a; --card-line: #e8e2d5; --card-accent: #d3a128; --card-highlight: #f5dd82;
  position: absolute; inset: 0; width: 100%; height: 100%; padding: 7.5% 7.2% 6%;
  background: var(--card-bg); color: var(--card-ink); overflow: hidden;
}
.note-card.theme-journal { --card-bg: #efe8dc; --card-ink: #2f302a; --card-muted: #77766e; --card-line: #d8cdbd; --card-accent: #8c7859; --card-highlight: #cfbf96; }
.note-card.theme-mono { --card-bg: #f5f5f2; --card-ink: #1d1d1b; --card-muted: #777; --card-line: #d7d7d2; --card-accent: #1d1d1b; --card-highlight: #d8d8d3; }
.card-head { display: flex; justify-content: space-between; align-items: center; color: var(--card-accent); font-weight: 650; font-size: 2.42cqw; }
.card-head .back { display: flex; align-items: center; gap: .35em; }
.card-head .back::before { content: "‹"; font-size: 1.7em; line-height: .6; }
.card-head .dots { letter-spacing: .12em; }
.card-date { margin-top: 5.5%; color: var(--card-muted); font-size: 1.86cqw; }
.cover-inner { height: calc(100% - 12%); display: flex; flex-direction: column; justify-content: center; }
.cover-kicker { display: inline-flex; align-self: flex-start; border: 1px solid var(--card-line); border-radius: 99px; padding: .55em .85em; color: var(--card-muted); font-size: 1.77cqw; letter-spacing: .08em; }
.cover-title { font-size: 6.12cqw; line-height: 1.28; letter-spacing: -.055em; margin: 7% 0 5%; font-weight: 820; }
.cover-line { height: 7px; width: 32%; background: var(--card-highlight); border-radius: 4px; transform: rotate(-1deg); }
.cover-subtitle { margin-top: 8%; font-size: 2.74cqw; line-height: 1.7; color: var(--card-muted); }
.body-content { padding-top: 6%; }
.body-content h2 { font-size: calc(4.75cqw * var(--body-scale, 1)); line-height: 1.28; letter-spacing: -.04em; margin: 0 0 6%; }
.body-content p, .body-content li, .body-content blockquote { font-size: calc(3.86cqw * var(--body-scale, 1)); line-height: 1.72; }
.body-content p { margin: 0 0 4.2%; }
.body-content ul { list-style: none; padding: 0; margin: 0 0 4%; }
.body-content li { position: relative; padding-left: 1.3em; margin-bottom: 2.5%; }
.body-content li::before { content: "✓"; position: absolute; left: 0; color: var(--card-accent); font-weight: 800; }
.body-content blockquote { margin: 2% 0 5%; padding: 4% 5%; border-left: 3px solid var(--card-accent); background: color-mix(in srgb, var(--card-highlight) 23%, transparent); border-radius: 0 8px 8px 0; }
.hl { background: linear-gradient(transparent 58%, var(--card-highlight) 58%, var(--card-highlight) 92%, transparent 92%); font-weight: 720; }
.card-foot { position: absolute; left: 7.2%; right: 7.2%; bottom: 4.7%; display: flex; justify-content: space-between; align-items: center; padding-top: 3%; border-top: 1px solid var(--card-line); color: var(--card-muted); font-size: 1.77cqw; }
.end-inner { height: 82%; display: flex; flex-direction: column; justify-content: center; text-align: center; align-items: center; }
.end-symbol { width: 16%; aspect-ratio: 1; border: 1px solid var(--card-line); border-radius: 50%; display: grid; place-items: center; color: var(--card-accent); font-size: 5.31cqw; }
.end-copy { white-space: pre-line; font-weight: 760; font-size: 4.35cqw; line-height: 1.55; margin: 8% 0 4%; }
.end-note { color: var(--card-muted); font-size: 2.25cqw; }
.empty-state { min-height: 62vh; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #8b887e; text-align: center; }
.empty-state.hidden { display: none; }
.empty-paper { width: 74px; height: 96px; background: #fff; border-radius: 5px; box-shadow: 0 13px 30px rgba(56,51,39,.1); padding: 25px 15px; transform: rotate(-3deg); }
.empty-paper span { display: block; height: 4px; border-radius: 4px; background: #e0ddd5; margin-bottom: 10px; }
.empty-paper span:nth-child(2) { width: 75%; background: #ead98d; }
.empty-state h2 { color: #545148; font-size: 16px; margin: 24px 0 7px; }
.empty-state p { margin: 0; font-size: 12px; }
.toast { position: fixed; bottom: 28px; left: 50%; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: #25241f; color: #fff; padding: 11px 17px; border-radius: 10px; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.2); transition: .25s; z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .editor-panel { border-right: 0; border-bottom: 1px solid #ddd; }
  .preview-panel { padding: 24px 18px 60px; }
  .preview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .topbar { padding: 0 16px; }
  .brand small { display: none; }
}
@media (max-width: 560px) {
  .topbar { height: 66px; }
  .ghost-btn { display: none; }
  .workspace { min-height: calc(100vh - 66px); }
  .editor-panel { padding: 26px 18px; }
  .preview-grid, .preview-grid.large { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr 1fr; }
}
@media(max-width:560px){.topbar{height:auto;min-height:104px;flex-wrap:wrap;gap:10px;padding:12px 16px}.top-actions{width:100%;justify-content:space-between;gap:6px}.top-actions .ghost-btn{display:inline-flex;align-items:center;padding:9px 10px;font-size:12px}.top-actions .primary-btn{padding:9px 10px;font-size:12px}.workspace{min-height:calc(100vh - 104px)}}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important}}
