:root {
  --bg: #fff;
  --surface: #fff;
  --surface-2: #f1f3f4;
  --text: #202124;
  --muted: #5f6368;
  --border: #e0e0e0;
  --border-strong: #d0d0d0;
  --hover: rgba(60,64,67,.08);
  --active: #feefc3;
  --active-ink: #3c4043;
  --shadow-1: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
  --shadow-2: 0 1px 2px rgba(60,64,67,.3), 0 2px 6px 2px rgba(60,64,67,.15);
  --yellow: #fbbc04;
  --focus: #1a73e8;
  --sidebar: 280px;
  --topbar: 64px;
  font-family: "Google Sans", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

:root[data-theme="dark"] {
  --bg: #202124;
  --surface: #202124;
  --surface-2: #303134;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --border: #5f6368;
  --border-strong: #6f7378;
  --hover: rgba(232,234,237,.08);
  --active: #41331c;
  --active-ink: #e8eaed;
  --shadow-1: 0 1px 2px rgba(0,0,0,.55), 0 1px 4px rgba(0,0,0,.35);
  --shadow-2: 0 3px 8px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
button, input, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
svg { width: 24px; height: 24px; fill: currentColor; display: block; }
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.is-hidden { display: none !important; }
.noscript { padding: 16px; color: #b3261e; text-align: center; }

/* Login */
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #f8f9fa; }
:root[data-theme="dark"] .login-view { background: #171717; }
.login-card {
  width: 100%; max-width: 448px; min-height: 500px; padding: 48px 40px 36px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  text-align: center;
}
.login-brand { width: 58px; height: 58px; border-radius: 13px; background: var(--yellow); color: #fff; display: grid; place-items: center; margin: 0 auto 18px; box-shadow: 0 2px 5px rgba(0,0,0,.16); }
.login-brand svg { width: 38px; height: 38px; }
.login-card h1 { margin: 0; font-size: 28px; line-height: 1.3; font-weight: 500; }
.login-subtitle { margin: 8px 0 34px; font-size: 16px; color: var(--muted); }
.login-card form { text-align: left; }
.field { display: block; position: relative; margin: 0 0 18px; }
.field span { display: block; margin: 0 0 7px 2px; font-size: 13px; color: var(--muted); }
.field input { width: 100%; height: 54px; border: 1px solid var(--border-strong); border-radius: 4px; padding: 0 14px; background: transparent; outline: none; font-size: 16px; }
.field input:focus { border: 2px solid var(--focus); padding: 0 13px; }
.primary-button { width: 100%; height: 44px; margin-top: 8px; border: 0; border-radius: 4px; background: #1a73e8; color: white; font-weight: 500; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.primary-button:hover { background: #1765cc; }
.primary-button:disabled { opacity: .65; cursor: wait; }
.form-error { min-height: 20px; margin: -4px 0 8px; color: #d93025; font-size: 13px; }
.private-caption { margin: 44px 0 0; color: var(--muted); font-size: 12px; }

/* Header */
.topbar { height: var(--topbar); position: fixed; z-index: 30; inset: 0 0 auto 0; display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
.icon-button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; display: inline-grid; place-items: center; padding: 0; cursor: pointer; color: var(--muted); flex: 0 0 auto; }
.icon-button:hover { background: var(--hover); color: var(--text); }
.icon-button:focus-visible, .text-button:focus-visible, .nav-item:focus-visible, .avatar-button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.icon-button[aria-pressed="true"] { color: var(--text); background: var(--hover); }
.brand { width: 188px; display: flex; align-items: center; gap: 9px; color: var(--muted); text-decoration: none; font-size: 22px; line-height: 44px; }
.brand-mark { width: 40px; height: 40px; border-radius: 8px; display: grid; place-items: center; color: var(--yellow); }
.brand-mark svg { width: 32px; height: 32px; }
.search { height: 48px; max-width: 720px; flex: 1 1 720px; display: flex; align-items: center; background: var(--surface-2); border-radius: 8px; padding: 0 4px; }
.search:focus-within { background: var(--surface); box-shadow: var(--shadow-1); }
.search input { width: 100%; height: 100%; border: 0; outline: 0; background: transparent; padding: 0 8px; font-size: 16px; }
.search input::placeholder { color: var(--muted); }
.top-actions { margin-left: auto; display: flex; align-items: center; }
.avatar-button { width: 34px; height: 34px; margin: 0 5px 0 8px; border: 0; border-radius: 50%; background: #7e57c2; color: white; font-weight: 600; cursor: pointer; }
.profile-menu { position: fixed; z-index: 60; top: 58px; right: 12px; width: 280px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-2); padding: 16px; }
.profile-row { display: flex; gap: 12px; align-items: center; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.profile-row div { display: flex; flex-direction: column; gap: 4px; }
.profile-row small { color: var(--muted); }
.avatar-large { width: 44px; height: 44px; border-radius: 50%; background: #7e57c2; color: #fff; display: grid; place-items: center; font-size: 18px; }
.profile-menu button { width: 100%; min-height: 44px; margin-top: 8px; border: 0; background: transparent; border-radius: 6px; display: flex; align-items: center; gap: 12px; cursor: pointer; }
.profile-menu button:hover { background: var(--hover); }

/* Sidebar */
.sidebar { position: fixed; z-index: 25; top: var(--topbar); bottom: 0; left: 0; width: var(--sidebar); background: var(--surface); padding: 8px 0; overflow-y: auto; transition: width .18s ease, transform .18s ease; display: flex; flex-direction: column; }
.nav-item { width: calc(100% - 8px); min-height: 48px; border: 0; background: transparent; border-radius: 0 24px 24px 0; display: flex; align-items: center; gap: 28px; padding: 0 20px; cursor: pointer; color: var(--text); text-align: left; }
.nav-item svg { flex: 0 0 24px; color: var(--muted); }
.nav-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover { background: var(--hover); }
.nav-item.is-active { background: var(--active); color: var(--active-ink); font-weight: 500; }
.nav-item.is-active svg { color: var(--active-ink); }
.sidebar-footer { margin: auto 24px 8px; color: var(--muted); font-size: 11px; }
body.sidebar-collapsed .sidebar { width: 80px; }
body.sidebar-collapsed .nav-item { width: 72px; gap: 0; border-radius: 0 24px 24px 0; }
body.sidebar-collapsed .nav-item span, body.sidebar-collapsed .sidebar-footer { display: none; }
body.sidebar-collapsed .main-content { margin-left: 80px; }
.sidebar-backdrop { position: fixed; z-index: 24; inset: var(--topbar) 0 0; background: rgba(0,0,0,.32); }

/* Main content */
.main-content { min-height: 100vh; margin-left: var(--sidebar); padding: calc(var(--topbar) + 24px) 32px 48px; transition: margin-left .18s ease; }
.composer { width: min(600px, 100%); margin: 0 auto 34px; border-radius: 8px; background: var(--surface); box-shadow: var(--shadow-1); overflow: hidden; }
.composer-collapsed { height: 46px; display: flex; align-items: center; padding: 0 4px 0 16px; }
.composer-collapsed > button:first-child { flex: 1; height: 100%; border: 0; background: transparent; color: var(--muted); font-size: 16px; font-weight: 500; text-align: left; cursor: text; }
.composer-expanded { padding: 8px 8px 4px 16px; }
.composer-title-row { display: flex; align-items: center; }
.composer-title-row input, .composer textarea, .dialog-title, .note-dialog textarea { width: 100%; border: 0; outline: 0; background: transparent; resize: none; }
.composer-title-row input { height: 44px; font-size: 16px; font-weight: 500; }
.composer textarea { min-height: 54px; padding: 10px 36px 10px 0; line-height: 1.5; }
.composer-footer, .dialog-footer { min-height: 44px; display: flex; align-items: center; justify-content: space-between; }
.composer-tools { display: flex; align-items: center; }
.composer-tools .icon-button, .dialog-footer .icon-button { width: 38px; height: 38px; }
.composer-tools svg, .dialog-footer svg { width: 20px; height: 20px; }
.text-button { min-width: 72px; min-height: 38px; border: 0; border-radius: 4px; background: transparent; padding: 0 14px; font-weight: 500; cursor: pointer; }
.text-button:hover { background: var(--hover); }
.content-header { max-width: 1160px; margin: 0 auto 10px; display: flex; justify-content: space-between; align-items: baseline; }
.content-header h1 { margin: 0; color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; }
.content-header span { color: var(--muted); font-size: 12px; }
.note-section { max-width: 1160px; margin: 0 auto 28px; }
.note-section h2 { margin: 0 0 10px; color: var(--muted); font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; }
.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; align-items: start; }
body.list-layout .notes-grid { display: flex; flex-direction: column; align-items: center; gap: 12px; }
body.list-layout .note-card { width: min(600px, 100%); }
.note-card { position: relative; min-height: 104px; border: 1px solid var(--border-strong); border-radius: 8px; padding: 14px 14px 48px; overflow: hidden; cursor: default; background: var(--note-bg, var(--surface)); transition: box-shadow .12s ease; }
.note-card:hover, .note-card:focus-within { box-shadow: var(--shadow-2); }
.note-card[data-color="coral"] { --note-bg: #f28b82; --note-ink: #202124; }
.note-card[data-color="peach"] { --note-bg: #fbbc04; --note-ink: #202124; }
.note-card[data-color="sand"] { --note-bg: #fff475; --note-ink: #202124; }
.note-card[data-color="yellow"] { --note-bg: #fff475; --note-ink: #202124; }
.note-card[data-color="mint"] { --note-bg: #ccff90; --note-ink: #202124; }
.note-card[data-color="sage"] { --note-bg: #a7ffeb; --note-ink: #202124; }
.note-card[data-color="fog"] { --note-bg: #cbf0f8; --note-ink: #202124; }
.note-card[data-color="storm"] { --note-bg: #aecbfa; --note-ink: #202124; }
.note-card[data-color="dusk"] { --note-bg: #d7aefb; --note-ink: #202124; }
.note-card[data-color="blossom"] { --note-bg: #fdcfe8; --note-ink: #202124; }
.note-card[data-color="clay"] { --note-bg: #e6c9a8; --note-ink: #202124; }
.note-card[data-color="chalk"] { --note-bg: #e8eaed; --note-ink: #202124; }
:root[data-theme="dark"] .note-card[data-color]:not([data-color="default"]) { color: var(--note-ink); border-color: transparent; }
.note-title { margin: 0 34px 10px 0; font-size: 16px; line-height: 1.35; font-weight: 600; overflow-wrap: anywhere; white-space: pre-wrap; }
.note-content { margin: 0 0 10px; line-height: 1.45; overflow-wrap: anywhere; white-space: pre-wrap; max-height: 280px; overflow: hidden; }
.pin-button { position: absolute; top: 5px; right: 5px; opacity: 0; }
.note-card:hover .pin-button, .pin-button[aria-pressed="true"], .note-card:focus-within .pin-button { opacity: 1; }
.note-actions { position: absolute; inset: auto 5px 4px; display: flex; align-items: center; opacity: 0; }
.note-card:hover .note-actions, .note-card:focus-within .note-actions { opacity: 1; }
.note-actions .icon-button { width: 36px; height: 36px; color: currentColor; opacity: .72; }
.note-actions svg { width: 18px; height: 18px; }
.note-actions .restore-button { margin-left: auto; }
.note-labels { display: flex; gap: 5px; flex-wrap: wrap; margin: 10px 0 0; }
.note-label { max-width: 100%; border-radius: 12px; background: rgba(60,64,67,.12); padding: 4px 8px; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-reminder { display: inline-flex; align-items: center; gap: 5px; margin: 8px 0 0; border-radius: 12px; background: rgba(60,64,67,.12); padding: 4px 8px; font-size: 11px; }
.note-reminder svg { width: 14px; height: 14px; }
.checklist-view { display: grid; gap: 7px; margin: 4px 0 8px; }
.checklist-line { display: flex; gap: 8px; align-items: flex-start; line-height: 1.35; }
.checklist-line svg { width: 16px; height: 16px; flex: 0 0 16px; margin-top: 1px; }
.checklist-line.is-checked span { text-decoration: line-through; opacity: .55; }
.empty-state { min-height: 360px; display: grid; place-content: center; justify-items: center; color: var(--muted); }
.empty-state svg { width: 92px; height: 92px; margin-bottom: 18px; opacity: .58; }
.empty-state p { font-size: 17px; }
.trash-toolbar { min-height: 44px; margin: -12px auto 20px; max-width: 720px; display: flex; justify-content: center; align-items: center; gap: 14px; color: var(--muted); }
.trash-toolbar button { border: 0; background: transparent; color: #1a73e8; font-weight: 500; cursor: pointer; min-height: 40px; }

/* Editors and menus */
dialog { color: var(--text); background: var(--surface); border: 0; padding: 0; box-shadow: var(--shadow-2); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.note-dialog { width: min(600px, calc(100vw - 32px)); border-radius: 8px; }
.note-dialog form { padding: 14px 16px 6px; }
.dialog-title { height: 46px; font-size: 20px; font-weight: 500; }
.note-dialog textarea { min-height: 100px; line-height: 1.5; font-size: 15px; }
.editor-meta { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 14px; display: grid; gap: 14px; }
.editor-meta > label { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.editor-meta input[type="datetime-local"] { min-height: 40px; border: 1px solid var(--border); border-radius: 4px; background: transparent; padding: 6px 8px; }
.editor-meta fieldset { border: 0; margin: 0; padding: 0; }
.editor-meta legend { color: var(--muted); margin-bottom: 8px; }
.label-options { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.label-choice { display: inline-flex; align-items: center; gap: 6px; }
.color-options, .color-menu { display: flex; flex-wrap: wrap; gap: 7px; }
.color-swatch { width: 30px; height: 30px; border: 2px solid transparent; border-radius: 50%; background: var(--swatch); cursor: pointer; box-shadow: inset 0 0 0 1px rgba(60,64,67,.22); }
.color-swatch:hover, .color-swatch.is-selected { border-color: var(--text); }
.color-swatch[data-color="default"] { --swatch: var(--surface); }
.color-swatch[data-color="coral"] { --swatch: #f28b82; }
.color-swatch[data-color="peach"] { --swatch: #fbbc04; }
.color-swatch[data-color="sand"], .color-swatch[data-color="yellow"] { --swatch: #fff475; }
.color-swatch[data-color="mint"] { --swatch: #ccff90; }
.color-swatch[data-color="sage"] { --swatch: #a7ffeb; }
.color-swatch[data-color="fog"] { --swatch: #cbf0f8; }
.color-swatch[data-color="storm"] { --swatch: #aecbfa; }
.color-swatch[data-color="dusk"] { --swatch: #d7aefb; }
.color-swatch[data-color="blossom"] { --swatch: #fdcfe8; }
.color-swatch[data-color="clay"] { --swatch: #e6c9a8; }
.color-swatch[data-color="chalk"] { --swatch: #e8eaed; }
.floating-menu { position: fixed; z-index: 90; left: 50%; bottom: 28px; transform: translateX(-50%); width: 220px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow-2); }
#composer[data-color="coral"], #editor-dialog[data-color="coral"] { background: #f28b82; color: #202124; }
#composer[data-color="peach"], #editor-dialog[data-color="peach"] { background: #fbbc04; color: #202124; }
#composer[data-color="sand"], #composer[data-color="yellow"], #editor-dialog[data-color="sand"], #editor-dialog[data-color="yellow"] { background: #fff475; color: #202124; }
#composer[data-color="mint"], #editor-dialog[data-color="mint"] { background: #ccff90; color: #202124; }
#composer[data-color="sage"], #editor-dialog[data-color="sage"] { background: #a7ffeb; color: #202124; }
#composer[data-color="fog"], #editor-dialog[data-color="fog"] { background: #cbf0f8; color: #202124; }
#composer[data-color="storm"], #editor-dialog[data-color="storm"] { background: #aecbfa; color: #202124; }
#composer[data-color="dusk"], #editor-dialog[data-color="dusk"] { background: #d7aefb; color: #202124; }
#composer[data-color="blossom"], #editor-dialog[data-color="blossom"] { background: #fdcfe8; color: #202124; }
#composer[data-color="clay"], #editor-dialog[data-color="clay"] { background: #e6c9a8; color: #202124; }
#composer[data-color="chalk"], #editor-dialog[data-color="chalk"] { background: #e8eaed; color: #202124; }
.unchecked-box { width: 16px; height: 16px; flex: 0 0 16px; line-height: 14px; font-size: 19px; }
.muted { color: var(--muted); }
.checklist-editor { display: grid; gap: 4px; margin: 4px 0 8px; }
.checklist-edit-row { display: flex; align-items: center; gap: 6px; min-height: 36px; }
.checklist-edit-row input[type="checkbox"] { width: 18px; height: 18px; }
.checklist-edit-row input[type="text"] { flex: 1; height: 34px; border: 0; border-bottom: 1px solid transparent; outline: none; background: transparent; }
.checklist-edit-row input[type="text"]:focus { border-bottom-color: var(--border-strong); }
.checklist-edit-row .icon-button { width: 34px; height: 34px; }
.checklist-edit-row .icon-button svg { width: 18px; height: 18px; }
.add-check-item { width: fit-content; min-height: 36px; border: 0; background: transparent; color: var(--muted); display: flex; align-items: center; gap: 8px; cursor: pointer; }
.add-check-item svg { width: 18px; height: 18px; }
.labels-dialog { width: min(420px, calc(100vw - 32px)); max-height: min(600px, calc(100vh - 48px)); border-radius: 4px; padding: 16px 0 8px; }
.labels-dialog h2 { margin: 0 20px 14px; font-size: 18px; font-weight: 500; }
.labels-dialog > form { display: flex; align-items: center; padding: 0 10px 8px; }
.labels-dialog > form input { flex: 1; height: 42px; border: 0; outline: 0; background: transparent; }
#labels-list { max-height: 370px; overflow-y: auto; padding: 0 10px; }
.label-edit-row { display: flex; align-items: center; gap: 4px; }
.label-edit-row input { flex: 1; min-width: 0; height: 42px; border: 0; border-bottom: 1px solid transparent; outline: 0; background: transparent; }
.label-edit-row input:focus { border-bottom-color: var(--border-strong); }
.label-edit-row .icon-button { width: 40px; height: 40px; }
.label-edit-row .icon-button svg { width: 19px; height: 19px; }
.labels-footer { margin-top: 8px; border-top: 1px solid var(--border); padding: 8px 12px 0; display: flex; justify-content: flex-end; }
.toast { position: fixed; z-index: 120; left: 24px; bottom: 24px; min-width: 260px; max-width: min(440px, calc(100vw - 48px)); min-height: 48px; padding: 14px 18px; border-radius: 4px; background: #323232; color: white; box-shadow: var(--shadow-2); }

@media (max-width: 900px) {
  .brand { width: auto; }
  .brand > span:last-child { display: none; }
  .main-content, body.sidebar-collapsed .main-content { margin-left: 0; padding-left: 20px; padding-right: 20px; }
  .sidebar, body.sidebar-collapsed .sidebar { width: 280px; transform: translateX(-100%); box-shadow: var(--shadow-2); }
  body.mobile-sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-collapsed .nav-item { width: calc(100% - 8px); gap: 28px; }
  body.sidebar-collapsed .nav-item span, body.sidebar-collapsed .sidebar-footer { display: initial; }
}

@media (max-width: 640px) {
  :root { --topbar: 56px; }
  .topbar { padding: 4px 6px; gap: 2px; }
  .topbar .icon-button { width: 42px; height: 42px; }
  .brand { margin-right: 2px; }
  .brand-mark { width: 34px; }
  .search { flex: 1; min-width: 0; background: transparent; }
  .search > .icon-button { display: none; }
  .search input { font-size: 15px; padding: 0 6px; }
  #refresh-button { display: none; }
  #layout-button { display: none; }
  .avatar-button { margin-left: 0; }
  .main-content { padding: calc(var(--topbar) + 14px) 12px 32px; }
  .composer { margin-bottom: 24px; }
  .content-header { padding: 0 2px; }
  .notes-grid { grid-template-columns: 1fr; gap: 10px; }
  .note-section { margin-bottom: 20px; }
  .note-actions, .pin-button { opacity: 1; }
  .note-card { padding-bottom: 46px; }
  .trash-toolbar { align-items: flex-start; flex-direction: column; gap: 0; padding: 0 8px; }
  .login-view { padding: 0; background: var(--surface); align-items: start; }
  .login-card { min-height: 100vh; max-width: none; padding: 64px 28px 30px; border: 0; border-radius: 0; }
  .toast { left: 12px; right: 12px; bottom: 12px; min-width: 0; max-width: none; }
}

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