:root {
  font-family: "Aptos", "Segoe UI", sans-serif;
  color: #20252d;
  background: #f7f7f5;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #20252d;
  --muted: #747a82;
  --line: #dedfdf;
  --blue: #2f6fb2;
  --blue-soft: #eaf1fa;
  --paper: #fff;
  --sidebar-width: 312px;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
button, input, select { font: inherit; }
button { color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.svg-sprite { position: fixed; width: 0; height: 0; overflow: hidden; pointer-events: none; }
[hidden] { display: none !important; }

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 18% 18%, rgba(47, 111, 178, .10), transparent 34%),
    linear-gradient(145deg, #f4f6f8, #fbfbfa 58%, #eef2f6);
}

.auth-loading { display: grid; justify-items: center; color: #69717a; }
.auth-loading p { margin: 15px 0 0; font-size: 13px; }

.login-card {
  width: min(100%, 390px);
  padding: 34px;
  border: 1px solid #d8dcdf;
  border-radius: 14px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 22px 70px rgba(31, 42, 54, .15);
}

.login-brand {
  color: var(--blue);
  font: 700 22px/1 Georgia, "Times New Roman", serif;
}

.login-card h1 {
  margin: 25px 0 8px;
  color: #1f232a;
  font: 700 34px/1.15 Georgia, "Times New Roman", serif;
  letter-spacing: -.7px;
}

.login-card > p { margin: 0 0 24px; color: #6d747b; font-size: 13.5px; line-height: 1.5; }
.login-card label { display: block; margin: 15px 0 7px; color: #394049; font-size: 12.5px; font-weight: 650; }
.login-card input {
  width: 100%;
  height: 45px;
  padding: 0 12px;
  border: 1px solid #cfd4d8;
  border-radius: 7px;
  outline: 0;
  color: #20252d;
  background: white;
}
.login-card input:focus { border-color: #6f9bc6; box-shadow: 0 0 0 3px rgba(47, 111, 178, .12); }
.login-card .login-error { margin: 13px 0 0; color: #a33a37; font-size: 12.5px; }
.login-button {
  width: 100%;
  height: 45px;
  margin-top: 21px;
  border: 0;
  border-radius: 7px;
  color: white;
  background: linear-gradient(135deg, #3679bd, #2864a6);
  box-shadow: 0 5px 14px rgba(39, 101, 168, .20);
  cursor: pointer;
  font-weight: 700;
}
.login-button:hover { background: linear-gradient(135deg, #397fc4, #2868ad); }
.login-button:disabled { opacity: .65; cursor: wait; }

.app-shell {
  min-height: 100%;
  background: var(--paper);
  overflow: hidden;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  background: linear-gradient(105deg, #fbfbfa 0%, #f7f7f6 100%);
  border: 1px solid #d9d9d7;
  border-radius: 0 10px 10px 0;
  box-shadow: 9px 0 23px rgba(31, 38, 46, .13);
  transform: translateX(-100%);
  transition: transform 180ms ease;
}

.sidebar.is-open { transform: translateX(0); }

.sidebar-resizer {
  position: fixed;
  z-index: 24;
  inset: 0 auto 0 calc(var(--sidebar-width) - 3px);
  width: 7px;
  cursor: col-resize;
  touch-action: none;
}

.sidebar-resizer::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 3px;
  width: 1px;
  background: transparent;
  transition: background 120ms ease, box-shadow 120ms ease;
}

.sidebar-resizer:hover::after,
.sidebar-resizer.active::after {
  background: #6e99c3;
  box-shadow: 0 0 0 2px rgba(47, 111, 178, .11);
}

.sidebar:not(.is-open) + .sidebar-resizer { display: none; }
body.is-resizing { cursor: col-resize; user-select: none; }

.brand-row {
  height: 79px;
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  padding: 0 20px;
}

.brand {
  padding-left: 24px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 29px;
  font-weight: 700;
  letter-spacing: -.7px;
}

.icon-button,
.menu-button,
.tool-button,
.row-menu-button,
.trash-actions button,
.search-box button {
  display: inline-grid;
  place-items: center;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 7px;
  color: #596068;
}

.icon-button:hover { background: #ececea; }
.icon-button:disabled { opacity: .35; cursor: default; }

.new-note {
  height: 46px;
  margin: 4px 23px 16px;
  padding: 0 15px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 0;
  border-radius: 7px;
  color: white;
  background: linear-gradient(135deg, #3679bd, #2864a6);
  box-shadow: 0 4px 10px rgba(39, 101, 168, .18);
  cursor: pointer;
  font-weight: 650;
  letter-spacing: .1px;
}

.new-note:hover { background: linear-gradient(135deg, #397fc4, #2868ad); }
.new-note kbd { margin-left: auto; opacity: 0; font: 11px/1 "Aptos", sans-serif; }
.new-note:hover kbd { opacity: .7; }

.search-box {
  height: 44px;
  margin: 0 23px 20px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  border: 1px solid #d7d8d7;
  border-radius: 7px;
  color: #858a8f;
  background: rgba(255,255,255,.7);
  box-shadow: 0 1px 2px rgba(0,0,0,.02);
}

.search-box:focus-within { border-color: #83a9d1; box-shadow: 0 0 0 3px rgba(47,111,178,.1); }
.search-box input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--ink); }
.search-box input::placeholder { color: #8c9197; }
.search-box kbd { padding: 3px 5px; border: 1px solid #e0e0dd; border-radius: 4px; color: #a0a3a7; font-size: 10px; }
.search-box button { padding: 2px; color: #858a8f; }

.list-heading { padding: 0 22px 9px; color: #72777e; font-size: 11px; font-weight: 700; letter-spacing: .25px; }
.note-list { min-height: 0; flex: 1; padding: 0 12px 10px; overflow-y: auto; scrollbar-width: thin; }
.note-row {
  position: relative;
  min-height: 56px;
  display: grid;
  grid-template-columns: 30px 1fr 30px;
  align-items: center;
  padding: 5px 7px 5px 14px;
  border-radius: 6px;
  cursor: pointer;
  outline: none;
}
.note-row:hover { background: #f0f1f1; }
.note-row.selected { background: #e7eef7; }
.note-row.selected::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; border-radius: 3px 0 0 3px; background: var(--blue); }
.note-row:focus-visible { box-shadow: inset 0 0 0 2px #79a5d3; }
.note-row > svg { width: 19px; height: 19px; align-self: start; margin-top: 8px; color: #777d83; stroke-width: 1.6; }
.note-meta { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.note-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; font-weight: 600; }
.note-meta span { color: #777d84; font-size: 11.5px; }
.row-menu-button { width: 30px; height: 30px; border-radius: 5px; color: #555d65; }
.row-menu-button:hover { background: rgba(255,255,255,.7); }
.row-menu-wrap { position: relative; }
.row-popover { position: absolute; z-index: 5; top: 28px; right: 0; width: 145px; padding: 5px; border: 1px solid #dcdddc; border-radius: 7px; background: white; box-shadow: 0 8px 24px rgba(35,40,45,.14); }
.row-popover button { width: 100%; padding: 8px; display: flex; align-items: center; gap: 7px; border: 0; border-radius: 5px; background: none; color: #a33a37; cursor: pointer; font-size: 12px; }
.row-popover button:hover { background: #fff0ef; }
.trash-actions { display: flex; margin-left: -26px; }
.trash-actions button { width: 29px; height: 29px; border-radius: 5px; color: #636a71; }
.trash-actions button:hover { background: white; color: var(--blue); }

.list-empty { display: flex; flex-direction: column; align-items: center; gap: 9px; padding: 48px 25px; text-align: center; color: #8b9095; font-size: 12.5px; }
.trash-row { height: 81px; flex: 0 0 auto; padding: 0 28px 0 30px; display: grid; grid-template-columns: 29px 1fr auto; align-items: center; border: 0; border-top: 1px solid #e0e0df; background: rgba(249,249,248,.85); cursor: pointer; font-size: 13px; text-align: left; }
.trash-row:hover, .trash-row.active { background: #eeeeec; }
.trash-row b { color: #7e8388; font-size: 12px; font-weight: 500; }

.workspace { min-height: 100vh; margin-left: var(--sidebar-width); transition: margin-left 180ms ease; background: #fff; }
.workspace.sidebar-closed { margin-left: 0; }
.workspace-topbar { height: 78px; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; }
.menu-button { width: 40px; height: 38px; border: 1px solid #dedfdf; border-radius: 7px; color: #545b62; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.menu-button:hover { background: #f5f5f3; }
.topbar-actions { position: relative; display: flex; align-items: center; gap: 13px; }
.presence-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: min(42vw, 260px);
  padding: 6px 9px;
  border: 1px solid #e4c985;
  border-radius: 999px;
  color: #765816;
  background: #fff9e8;
  font-size: 11.5px;
  white-space: nowrap;
}
.presence-status > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.presence-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: #d79818; box-shadow: 0 0 0 3px rgba(215, 152, 24, .14); }
.top-popover { position: absolute; z-index: 10; top: 42px; right: 0; width: 150px; padding: 5px; border: 1px solid #dcdddc; border-radius: 7px; background: white; box-shadow: 0 8px 24px rgba(35,40,45,.14); }
.top-popover button { width: 100%; padding: 8px; display: flex; align-items: center; gap: 7px; border: 0; border-radius: 5px; background: none; color: #a33a37; cursor: pointer; font-size: 12px; }
.top-popover button:hover { background: #fff0ef; }
.top-popover svg { width: 16px; height: 16px; }
.save-status { min-width: 72px; display: flex; align-items: center; justify-content: flex-end; gap: 8px; color: #74787c; font-size: 11.5px; }
.save-status.saved svg { width: 18px; height: 18px; padding: 2px; border: 1px solid #8c9297; border-radius: 50%; }
.save-status.saving { color: #5e7891; }
.save-status.error { color: #a33a37; }

.editor-page { width: auto; max-width: 1120px; margin: 0; padding: 0 48px 80px 42px; }
.title-input { width: 100%; margin: 2px 0 16px; padding: 0; border: 0; outline: 0; background: transparent; color: #1f232a; font-family: Georgia, "Times New Roman", serif; font-size: clamp(33px, 4vw, 43px); font-weight: 700; line-height: 1.18; letter-spacing: -1.2px; }
.title-input::placeholder { color: #a5a6a7; }

.toolbar { height: 48px; display: flex; align-items: center; gap: 3px; border-bottom: 1px solid #dedfde; color: #444a50; }
.tool-button { width: 39px; height: 36px; border-radius: 5px; }
.tool-button:hover { background: #f0f1ef; color: #1f5f9f; }
.tool-button:focus-visible { outline: 2px solid #77a6d5; outline-offset: -2px; }
.tool-divider { height: 24px; width: 1px; margin: 0 6px; background: #e1e2e0; }
.heading-select { position: relative; width: 63px; height: 36px; display: flex; align-items: center; }
.heading-select select { width: 100%; height: 100%; padding: 0 25px 0 6px; appearance: none; border: 0; outline: 0; background: transparent; color: #464c52; cursor: pointer; }
.heading-select svg { position: absolute; right: 5px; pointer-events: none; }

.editor { min-height: 520px; padding-top: 17px; outline: 0; color: #252a31; font-size: 14px; line-height: 1.48; caret-color: var(--blue); }
.editor:empty::before { content: attr(data-placeholder); color: #a1a4a7; pointer-events: none; }
.editor h1, .editor h2, .editor h3 { color: #23282e; letter-spacing: -.2px; }
.editor h1 { margin: 19px 0 10px; font-family: Georgia, serif; font-size: 29px; }
.editor h2 { margin: 0 0 8px; padding-top: 0; font-size: 19px; line-height: 1.35; }
.editor h2:not(:first-child) { margin-top: 21px; padding-top: 16px; border-top: 1px solid #e2e2e0; }
.editor h3 { margin: 16px 0 7px; font-size: 16px; }
.editor p { margin: 0 0 10px; }
.editor ul, .editor ol { margin: 8px 0 14px; padding-left: 25px; }
.editor li { margin: 5px 0; padding-left: 2px; }
.editor a { color: #276aaa; text-decoration-color: #8bb1d7; text-underline-offset: 2px; }
.editor img { display: block; max-width: 100%; max-height: 430px; margin: 16px 0; border: 1px solid #d8d8d5; border-radius: 7px; object-fit: contain; }
.editor .checklist { margin: 8px 0 14px; padding: 0; list-style: none; }
.editor .checklist li { position: relative; min-height: 27px; margin: 0; padding: 0 0 0 25px; list-style: none; }
.editor .checklist li::before { content: ""; position: absolute; top: 2px; left: 0; width: 15px; height: 15px; border: 1px solid #a8acaf; background: white; cursor: pointer; user-select: none; }
.editor .checklist li[data-checked="true"]::before { content: "✓"; display: grid; place-items: center; border-color: var(--blue); color: white; background: var(--blue); font-size: 10px; line-height: 1; }
.editor .checklist li[data-checked="true"] { color: #80858a; text-decoration: line-through; }

.empty-workspace { min-height: calc(100vh - 78px); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px; text-align: center; }
.empty-icon, .modal-icon { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 14px; color: var(--blue); background: #edf3f9; }
.empty-workspace h1 { margin: 17px 0 7px; font-family: Georgia, serif; font-size: 28px; }
.empty-workspace p { margin: 0 0 20px; color: #767c82; }
.empty-workspace button, .button-primary { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border: 0; border-radius: 7px; color: white; background: var(--blue); cursor: pointer; }
.empty-icon svg, .modal-icon svg { width: 25px; height: 25px; }

.modal-layer { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(29,33,38,.26); backdrop-filter: blur(2px); }
.modal { width: min(100%, 410px); padding: 25px; border: 1px solid #d9dad8; border-radius: 12px; background: #fff; box-shadow: 0 22px 70px rgba(23,27,31,.22); animation: modal-in 150ms ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(5px) scale(.99); } }
.modal-icon { width: 43px; height: 43px; border-radius: 11px; }
.modal-icon.danger { color: #a33a37; background: #fbeeed; }
.modal h2 { margin: 16px 0 7px; font-family: Georgia, serif; font-size: 23px; }
.modal p { margin: 0; color: #6e747a; font-size: 13.5px; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 23px; }
.button-secondary, .button-danger, .button-primary { padding: 9px 14px; border-radius: 6px; cursor: pointer; }
.button-secondary { border: 1px solid #d8d9d7; background: white; }
.button-danger { border: 0; color: white; background: #a84642; }
.storage-stat { margin-top: 18px; padding: 12px 14px; display: flex; justify-content: space-between; border-radius: 7px; background: #f5f5f3; font-size: 13px; }

.loading-screen { min-height: 100%; display: grid; place-content: center; justify-items: center; color: #777d82; }
.loading-screen p { font-size: 13px; }
.loading-mark { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 14px; color: white; background: var(--blue); font: 700 29px Georgia, serif; box-shadow: 0 8px 25px rgba(47,111,178,.2); }
.mobile-scrim { display: none; }

@media (min-width: 760px) {
  .sidebar { transform: translateX(0); }
  .sidebar:not(.is-open) { transform: translateX(-100%); }
}

@media (max-width: 900px) {
  .title-input { font-size: 36px; }
}

@media (max-width: 759px) {
  .sidebar { width: min(88vw, 312px); border-radius: 0 10px 10px 0; }
  .sidebar-resizer { display: none; }
  .workspace, .workspace.sidebar-closed { margin-left: 0; }
  .mobile-scrim.visible { display: block; position: fixed; z-index: 19; inset: 0; width: 100%; border: 0; background: rgba(26,30,34,.25); backdrop-filter: blur(1px); }
  .workspace-topbar { height: 66px; padding: 0 14px; }
  .topbar-actions { gap: 8px; }
  .presence-status { max-width: 44vw; padding: 6px 8px; }
  .editor-page { width: auto; max-width: none; padding: 0 15px 45px; }
  .title-input { margin-top: 2px; font-size: clamp(30px, 9vw, 38px); }
  .toolbar { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
  .toolbar::-webkit-scrollbar { display: none; }
  .tool-button { flex: 0 0 38px; }
  .tool-divider { flex: 0 0 1px; }
  .heading-select { flex: 0 0 63px; }
  .editor { min-height: 460px; font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
