@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Libre+Baskerville:wght@400;700&display=swap');

:root {
  color-scheme: light;
  --sidebar: #203941;
  --sidebar-text: #f3f5f3;
  --sidebar-muted: #a9bec0;
  --sidebar-line: #3d5960;
  --canvas: #f4f7f6;
  --topbar: #f7f9f8;
  --text: #20333a;
  --muted: #788b90;
  --line: #dce5e5;
  --accent: #c88253;
  --button-hover: #e7efee;
  --serif: 'Libre Baskerville', Georgia, serif;
  --sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--canvas); color: var(--text); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.app { display: flex; width: 100%; min-height: 100vh; min-height: 100dvh; }

.sidebar { width: 272px; flex: 0 0 272px; min-height: 100vh; min-height: 100dvh; background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; z-index: 20; }
.sidebar-head { height: 84px; padding: 0 27px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 21px; font-weight: 700; letter-spacing: -.07em; line-height: 1; white-space: nowrap; }
.brand-mark { display: inline-block; width: 16px; height: 24px; border-left: 4px solid var(--sidebar-text); border-top: 4px solid var(--sidebar-text); border-radius: 1px 0 0; transform: translateY(2px); }
.brand-dot { color: var(--accent); }
.sidebar-close { display: none !important; color: var(--sidebar-muted) !important; }
.sidebar-section { padding: 54px 14px 24px; flex: 1; overflow-y: auto; }
.section-title { padding: 0 14px 17px; color: var(--sidebar-muted); font-size: 11px; line-height: 1; font-weight: 700; letter-spacing: .16em; }
.new-button { width: 100%; min-height: 45px; padding: 0 13px; display: flex; gap: 10px; align-items: center; border: 1px solid var(--sidebar-line); border-radius: 8px; color: var(--sidebar-text); background: #2a4850; text-align: left; font-size: 13px; font-weight: 600; transition: background .18s, border-color .18s; }
.new-button:hover { background: #365760; border-color: #698186; }
.new-plus { font-size: 23px; font-weight: 400; line-height: 1; transform: translateY(-1px); }
.new-shortcut { margin-left: auto; color: #9db4b8; font-size: 11px; font-weight: 500; }
.draft-list { display: flex; flex-direction: column; gap: 3px; margin-top: 24px; }
.draft-item { position: relative; display: block; width: 100%; padding: 13px 13px 12px 16px; border: 0; border-radius: 7px; color: #c1d1d2; background: transparent; text-align: left; transition: background .18s, color .18s; }
.draft-item:hover { background: #2b4850; color: #fff; }
.draft-item.active { color: #fff; background: #34535b; }
.draft-item.active::before { content: ''; position: absolute; left: 0; top: 11px; bottom: 11px; width: 3px; background: var(--accent); border-radius: 2px; }
.draft-item-title { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; font-weight: 600; }
.draft-item-meta { display: block; margin-top: 5px; color: #9fb7bb; font-size: 11px; line-height: 1.4; }
.sidebar-foot { display: flex; align-items: center; gap: 10px; padding: 20px 27px 27px; border-top: 1px solid var(--sidebar-line); color: var(--sidebar-muted); font-size: 11px; }
.local-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }

.main { position: relative; min-width: 0; flex: 1; display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; background: var(--canvas); }
.topbar { height: 75px; min-height: 75px; padding: 0 35px; border-bottom: 1px solid var(--line); background: var(--topbar); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topbar-left, .topbar-actions { min-width: 0; display: flex; align-items: center; gap: 16px; }
.topbar-left { color: var(--muted); font-size: 13px; }
.topbar-location { font-weight: 600; }
.topbar-slash { color: #aab9ba; }
.topbar-document { display: block; max-width: min(20vw, 240px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 600; }
.topbar-divider { width: 1px; height: 20px; background: var(--line); }
.save-status { min-width: 49px; text-align: right; color: var(--muted); font-size: 12px; white-space: nowrap; }
.save-status.error { color: #a4453c; }
.icon-button, .action-button { display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--text); }
.icon-button { width: 34px; height: 34px; border-radius: 6px; padding: 7px; }
.icon-button:hover, .action-button:hover { background: var(--button-hover); }
.icon-button svg, .action-button svg, .leave-focus svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.action-button { min-height: 36px; gap: 8px; padding: 0 9px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.focus-button { border: 1px solid var(--line); background: transparent; padding: 0 11px; }
.focus-button:hover { border-color: #bbcacb; }
.menu-button { display: none; }

.editor-wrap { width: 100%; flex: 1; }
.editor-content { width: min(100% - 72px, 750px); min-height: 100%; margin: 0 auto; padding: clamp(65px, 10vh, 116px) 0 45px; display: flex; flex-direction: column; }
.document-kicker { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .16em; }
.kicker-line { width: 23px; height: 2px; background: var(--accent); }
.draft-title { width: 100%; border: 0; outline: none; padding: 0 0 20px; background: transparent; color: var(--text); font-family: var(--serif); font-size: clamp(36px, 4vw, 54px); line-height: 1.25; font-weight: 700; letter-spacing: -.06em; }
.draft-title::placeholder { color: #99a9aa; opacity: 1; }
.draft-title:focus-visible, .draft-body:focus-visible { outline: none; }
.draft-body { width: 100%; flex: 1; min-height: max(400px, 50vh); resize: none; overflow: hidden; border: 0; outline: none; padding: 10px 0 0; background: transparent; color: var(--text); font-family: var(--serif); font-size: 18px; line-height: 2.05; letter-spacing: -.015em; }
.draft-body::placeholder { color: #a3b1b1; opacity: 1; }
.statusbar { position: sticky; bottom: 0; min-height: 56px; padding: 0 35px; border-top: 1px solid var(--line); background: var(--topbar); display: flex; justify-content: space-between; align-items: center; gap: 18px; color: var(--muted); font-size: 11px; }
.statusbar-left, .statusbar-right { display: flex; align-items: center; gap: 10px; }
.status-pip { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.status-separator { color: #b3c0c1; }
.text-button { border: 0; background: none; color: var(--muted); font-size: 11px; padding: 8px 0 8px 13px; }
.text-button:hover { color: #a4453c; text-decoration: underline; }
.leave-focus { display: none; }
.scrim { display: none; }

.focus .sidebar, .focus .topbar, .focus .statusbar { display: none; }
.focus .editor-content { width: min(100% - 72px, 720px); padding-top: clamp(75px, 15vh, 160px); }
.focus .document-kicker { opacity: .7; }
.focus .leave-focus { position: fixed; top: 19px; right: 21px; display: inline-flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--canvas); color: var(--muted); font-size: 12px; opacity: .35; transition: opacity .2s; }
.focus .leave-focus:hover, .focus .leave-focus:focus-visible { opacity: 1; }

.confirm-dialog { width: min(400px, calc(100vw - 32px)); padding: 26px; border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 22px 70px #0b242b35; background: var(--topbar); color: var(--text); }
.confirm-dialog::backdrop { background: #071b1fa8; }
.confirm-dialog h2 { margin: 0 0 10px; font-family: var(--serif); font-size: 22px; }
.confirm-dialog p { margin: 0 0 26px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; }
.dialog-actions button { border-radius: 6px; padding: 9px 13px; font-size: 13px; font-weight: 600; }
.dialog-cancel { border: 1px solid var(--line); background: transparent; color: var(--text); }
.dialog-delete { border: 1px solid #a94a40; background: #a94a40; color: white; }

body.dark { color-scheme: dark; --sidebar: #14272d; --sidebar-text: #ecf1ef; --sidebar-muted: #93aaad; --sidebar-line: #315056; --canvas: #1b2b30; --topbar: #1b2d32; --text: #e8eeec; --muted: #a0b4b6; --line: #34484d; --accent: #dfa473; --button-hover: #294148; }
body.dark .new-button { background: #254047; }
body.dark .new-button:hover { background: #35545b; }
body.dark .draft-item.active { background: #29464e; }
body.dark .draft-title::placeholder, body.dark .draft-body::placeholder { color: #759095; }

@media (max-width: 800px) {
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; transform: translateX(-100%); transition: transform .25s ease; box-shadow: 15px 0 50px #0b242b22; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close, .menu-button { display: inline-flex !important; }
  .scrim:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 10; background: #071b1f77; }
  .topbar { padding: 0 20px; }
  .topbar-left, .topbar-actions { gap: 9px; }
  .topbar-divider { display: none; }
  .topbar-document { max-width: 22vw; }
  .statusbar { padding: 0 22px; }
  .statusbar-right .hint { display: none; }
}
@media (max-width: 560px) {
  .topbar { height: 63px; min-height: 63px; padding: 0 14px; }
  .topbar-location, .topbar-slash, .topbar-document, .save-status, .action-button span { display: none; }
  .topbar-actions { gap: 3px; }
  .action-button { padding: 0 8px; }
  .focus-button { padding: 0 8px; }
  .editor-content { width: min(100% - 42px, 750px); padding-top: 52px; }
  .draft-title { font-size: clamp(34px, 8vw, 44px); }
  .draft-body { font-size: 17px; line-height: 1.95; }
  .statusbar { min-height: 48px; padding: 0 20px; }
  .statusbar-right { display: none; }
  .focus .editor-content { width: min(100% - 42px, 720px); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; } }
