:root {
  --bg-0: #101012;
  --bg-1: #17181a;
  --bg-2: #1f2023;
  --bg-3: #28292d;
  --bg-4: #323337;
  --border: #35363a;
  --border-soft: #2a2b2e;
  --text-primary: #edeeef;
  --text-secondary: #a5a7ad;
  --text-muted: #6c6e74;
  --accent: #c7a24a;
  --accent-dim: #8a7239;
  --accent-soft: rgba(199, 162, 74, 0.12);
  --danger: #c1584f;
  --success: #5fa87c;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-0);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

::selection { background: var(--accent-soft); }

/* Campi di testo/select standard in tutta l'app: grigio distinto dallo sfondo, angoli stondati */
input[type=text],
input[type=password],
input[type=datetime-local],
input[type=date],
select {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  color: var(--text-primary);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
}
input[type=text]:focus,
input[type=password]:focus,
input[type=datetime-local]:focus,
input[type=date]:focus,
select:focus { border-color: var(--accent-dim); }
input[type=text]::placeholder,
input[type=password]::placeholder { color: var(--text-muted); }
input[type=datetime-local]::-webkit-calendar-picker-indicator,
input[type=date]::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 10px; border: 2px solid var(--bg-0); }
::-webkit-scrollbar-thumb:hover { background: #45474c; }

/* ---------- Layout ---------- */

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100vh;
}

.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 26px 8px;
}

.brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(155deg, var(--bg-4), var(--bg-2));
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
  overflow: hidden;
  flex-shrink: 0;
}
.brand-mark img { width: 82%; height: 82%; object-fit: contain; }

.brand-name {
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: 0.2px;
  color: var(--text-primary);
  line-height: 1.2;
}
.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.nav-group { margin-bottom: 18px; }
.nav-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 0 10px 8px 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13.5px;
  transition: background .15s ease, color .15s ease;
  user-select: none;
}
.nav-item:hover { background: var(--bg-2); color: var(--text-primary); }
.nav-item.active {
  background: var(--bg-3);
  color: var(--text-primary);
  box-shadow: inset 2px 0 0 var(--accent);
}
.nav-item .icon { width: 17px; text-align: center; opacity: 0.85; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}
.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: var(--accent);
}
.user-meta { flex: 1; overflow: hidden; }
.user-name { font-size: 13px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); }
.icon-btn {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  border: none; background: transparent;
}
.icon-btn:hover { background: var(--bg-3); color: var(--text-primary); }

/* ---------- Main ---------- */

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 26px;
  border-bottom: 1px solid var(--border-soft);
  flex-wrap: wrap;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-secondary);
  flex: 1;
  min-width: 200px;
  overflow-x: auto;
  white-space: nowrap;
}
.breadcrumb .crumb { cursor: pointer; padding: 3px 6px; border-radius: 5px; }
.breadcrumb .crumb:hover { background: var(--bg-2); color: var(--text-primary); }
.breadcrumb .crumb.current { color: var(--text-primary); font-weight: 600; }
.breadcrumb .sep { color: var(--text-muted); }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  min-width: 260px;
  transition: border-color .15s;
}
.search-box:focus-within { border-color: var(--accent-dim); }
.search-box input {
  background: transparent; border: none; outline: none;
  color: var(--text-primary); font-size: 13.5px; flex: 1;
}
.search-box input::placeholder { color: var(--text-muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-primary);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--bg-3); border-color: #45474c; }
.btn:active { transform: scale(0.98); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1408;
  font-weight: 600;
}
.btn.primary:hover { background: #d4ae54; }
.btn.danger { color: var(--danger); border-color: rgba(193,88,79,0.4); }
.btn.danger:hover { background: rgba(193,88,79,0.1); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--bg-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.small { padding: 5px 10px; font-size: 12px; }

.view-toggle { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.view-toggle button {
  border: none; background: var(--bg-2); color: var(--text-muted);
  width: 34px; height: 32px; cursor: pointer;
}
.view-toggle button.active { background: var(--bg-3); color: var(--accent); }

/* Toolbar delle azioni sui file: raggruppata e dimensionata per avere più peso visivo */
.toolbar-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 7px 9px;
}
.toolbar-divider { width: 1px; height: 28px; background: var(--border); }
.toolbar-group .view-toggle { border-radius: 8px; border-color: var(--border); }
.toolbar-group .view-toggle button { width: 42px; height: 42px; font-size: 16px; }
.toolbar-group .btn { padding: 11px 20px; font-size: 14px; border-radius: 8px; }

.content { flex: 1; overflow-y: auto; padding: 22px 26px 60px 26px; position: relative; }

/* Barra di stato del caricamento (indeterminata), sulla scala di grigi */
.top-loader {
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  overflow: hidden; z-index: 50; pointer-events: none;
  opacity: 0; transition: opacity .15s ease;
}
.top-loader.active { opacity: 1; }
.top-loader::before {
  content: ''; position: absolute; top: 0; left: -30%; width: 30%; height: 100%;
  background: linear-gradient(90deg, transparent, var(--text-muted), var(--accent), var(--text-muted), transparent);
  animation: top-loader-slide 1.1s ease-in-out infinite;
}
@keyframes top-loader-slide {
  0% { left: -30%; }
  100% { left: 100%; }
}

/* Barra contestuale per la selezione multipla dei file */
.selection-bar {
  display: none;
  align-items: center; justify-content: space-between;
  gap: 12px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 16px;
  position: sticky; top: 0; z-index: 40;
}
.selection-bar.active { display: flex; }
.selection-bar-info { font-size: 13px; color: var(--text-primary); }
.selection-bar-info span { font-weight: 700; color: var(--accent); }
.selection-bar-actions { display: flex; gap: 10px; }

/* Pannello di avanzamento upload, sulla scala di grigi */
.upload-panel {
  position: fixed; top: 84px; right: 24px; width: 300px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 14px 16px; box-shadow: var(--shadow-sm); z-index: 601;
  display: none;
}
.upload-panel.active { display: block; }
.upload-panel-row {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 10px; font-size: 12.5px; color: var(--text-secondary); gap: 10px;
}
.upload-panel-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-panel-percent { color: var(--text-primary); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.upload-progress-track { height: 6px; border-radius: 4px; background: var(--bg-4); overflow: hidden; }
.upload-progress-fill {
  height: 100%; width: 0%; border-radius: 4px;
  background: linear-gradient(90deg, var(--text-muted), var(--accent));
  transition: width .15s ease;
}

.section-title {
  font-size: 18px; font-weight: 600; margin: 0 0 4px 0;
}
.section-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 18px; }

/* ---------- File grid/list ---------- */

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 14px;
}

.file-card {
  background: var(--bg-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  cursor: pointer;
  position: relative;
  transition: border-color .15s, background .15s, transform .08s;
}
.file-card:hover { border-color: var(--border); background: var(--bg-2); }
.file-card.selected { border-color: var(--accent-dim); background: var(--accent-soft); }

.entry-select {
  display: flex; align-items: center; justify-content: center;
  background: rgba(16, 16, 18, 0.6); border-radius: 5px; padding: 3px;
  backdrop-filter: blur(2px); cursor: pointer;
}
.file-card .entry-select { position: absolute; top: 8px; left: 8px; z-index: 2; }
.entry-select input[type=checkbox] { width: 15px; height: 15px; margin: 0; cursor: pointer; accent-color: var(--accent); }

.file-thumb {
  width: 100%; height: 92px;
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  margin-bottom: 10px;
  font-size: 30px;
  color: var(--text-muted);
}
.file-thumb img, .file-thumb video { width: 100%; height: 100%; object-fit: cover; }

.file-name {
  font-size: 12.5px;
  color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-bottom: 3px;
}
.file-meta { font-size: 11px; color: var(--text-muted); }

.file-list { display: flex; flex-direction: column; border: 1px solid var(--border-soft); border-radius: var(--radius-md); overflow: hidden; }
.file-row {
  display: grid;
  grid-template-columns: 26px 1fr 90px 100px 140px auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  font-size: 13px;
}
.file-row .row-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .1s; }
.file-row:hover .row-actions { opacity: 1; }
.file-card .row-actions {
  position: absolute; top: 8px; right: 8px; display: flex; gap: 2px;
  opacity: 0; transition: opacity .1s; background: var(--bg-1); border-radius: var(--radius-sm);
}
.file-card:hover .row-actions { opacity: 1; }
.file-row:last-child { border-bottom: none; }
.file-row:hover { background: var(--bg-1); }
.file-row.selected { background: var(--accent-soft); }
.file-row .file-name-cell { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.file-row .file-name-cell span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .col-muted { color: var(--text-muted); font-size: 12px; }
.file-row .row-icon { color: var(--text-muted); width: 18px; text-align: center; }

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 70px 20px; color: var(--text-muted); text-align: center; gap: 8px;
}
.empty-state .big-icon { font-size: 40px; opacity: 0.6; margin-bottom: 6px; }

.dropzone-overlay {
  position: fixed; inset: 0; background: rgba(16,16,18,0.82);
  display: none; align-items: center; justify-content: center;
  z-index: 500; border: 2px dashed var(--accent-dim);
}
.dropzone-overlay.active { display: flex; }
.dropzone-overlay .msg { font-size: 20px; color: var(--text-primary); }

/* ---------- Anteprima file ---------- */

.preview-overlay {
  position: fixed; inset: 0; background: rgba(8, 8, 9, 0.92);
  display: none; flex-direction: column; z-index: 550;
  backdrop-filter: blur(4px);
}
.preview-overlay.active { display: flex; }
.preview-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; flex-shrink: 0;
}
.preview-title {
  color: var(--text-primary); font-size: 14px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 20px;
}
.preview-actions { display: flex; gap: 8px; flex-shrink: 0; }
.preview-actions .icon-btn {
  width: 36px; height: 36px; background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text-secondary); text-decoration: none; display: flex; align-items: center; justify-content: center;
}
.preview-actions .icon-btn:hover { background: var(--bg-3); color: var(--text-primary); }
.preview-body {
  flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  padding: 0 24px 24px 24px;
}
.preview-body img, .preview-body video {
  max-width: 100%; max-height: 100%; border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); object-fit: contain;
}
.preview-body audio { width: min(520px, 90vw); }
.preview-body iframe {
  width: min(900px, 92vw); height: 100%; border: 1px solid var(--border);
  border-radius: var(--radius-md); background: #fff;
}
.preview-body pre {
  width: min(820px, 92vw); height: 100%; overflow: auto; margin: 0;
  background: var(--bg-1); border: 1px solid var(--border-soft); border-radius: var(--radius-md);
  padding: 20px; color: var(--text-primary); font-size: 13px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
}
.preview-unavailable {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  color: var(--text-muted); text-align: center;
}
.preview-unavailable .big-icon { font-size: 46px; }

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(8,8,9,0.6);
  display: none; align-items: center; justify-content: center; z-index: 400;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 420px; max-width: calc(100vw - 40px);
  box-shadow: var(--shadow-lg);
  padding: 22px;
}
.modal h3 { margin: 0 0 16px 0; font-size: 16px; }
.modal .field { margin-bottom: 14px; }
.modal label { display: block; font-size: 12.5px; color: var(--text-secondary); margin-bottom: 6px; }
.modal .row { display: flex; gap: 10px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.checkbox-line { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }

.toast-stack { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 600; }
.toast {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 16px; font-size: 13px; box-shadow: var(--shadow-sm); max-width: 320px;
}
.toast.error { border-color: rgba(193,88,79,0.5); color: #f0a49d; }
.toast.success { border-color: rgba(95,168,124,0.4); color: #9fdcb8; }

/* ---------- Login ---------- */

.login-wrap {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 30% 20%, #1c1d20, var(--bg-0) 60%);
}
.login-card {
  width: 360px; background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 34px 30px; box-shadow: var(--shadow-lg);
}
.login-card .brand { justify-content: center; padding-bottom: 22px; }
.login-logo { display: block; width: 208px; height: auto; margin: 0 auto 20px auto; }
.login-card h1 { font-size: 17px; text-align: center; margin: 0 0 4px 0; }
.login-card .sub { text-align: center; color: var(--text-muted); font-size: 12.5px; margin-bottom: 22px; }
.login-card .field { margin-bottom: 14px; }
.login-card label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.login-card input { padding: 10px 12px; font-size: 14px; }
.login-card .btn.primary { width: 100%; justify-content: center; margin-top: 6px; padding: 11px; }
.login-error { color: #f0a49d; font-size: 12.5px; margin-top: 10px; text-align: center; min-height: 16px; }

/* ---------- Tables (admin/shares) ---------- */

table.data-table { width: 100%; border-collapse: collapse; }
table.data-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); padding: 10px 12px; border-bottom: 1px solid var(--border);
}
table.data-table td { padding: 11px 12px; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
table.data-table tr:last-child td { border-bottom: none; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px;
  background: var(--bg-3); color: var(--text-secondary); border: 1px solid var(--border);
}
.badge.admin { color: var(--accent); border-color: var(--accent-dim); }

.panel {
  background: var(--bg-1); border: 1px solid var(--border-soft); border-radius: var(--radius-lg);
  padding: 20px; margin-bottom: 20px;
}
.panel h2 { font-size: 14.5px; margin: 0 0 14px 0; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--text-secondary); margin-bottom: 6px; }

.settings-form-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.settings-form-row .field { flex: 1; min-width: 200px; margin-bottom: 0; }

.folder-perm-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.folder-perm-row input[type=text] { flex: 1; width: auto; padding: 7px 10px; font-size: 12.5px; }

/* Selettore ad albero delle cartelle (permessi collaboratore) */
.folder-tree {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 6px 4px;
  background: var(--bg-2);
}
.folder-tree-empty { padding: 14px; color: var(--text-muted); font-size: 12.5px; }
.folder-tree-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 6px 10px; border-radius: var(--radius-sm);
}
.folder-tree-row:hover { background: var(--bg-3); }
.folder-tree-row .checkbox-line { font-size: 13px; color: var(--text-primary); }
.folder-tree-row .folder-tree-icon { color: var(--text-muted); margin-right: 2px; }
.folder-tree-row .perm-write-inline {
  font-size: 11.5px; color: var(--text-muted); flex-shrink: 0;
  padding: 2px 8px; border-radius: 20px; border: 1px solid var(--border);
}
.folder-tree-row .perm-write-inline:has(input:checked) { color: var(--accent); border-color: var(--accent-dim); }

/* ---------- Appunti ---------- */

.notes-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }

.calendar-status { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.calendar-status-pill {
  font-size: 12px; color: var(--text-muted); background: var(--bg-1); border: 1px solid var(--border-soft);
  border-radius: 20px; padding: 6px 12px;
}
.calendar-status-pill.connected { color: var(--accent); border-color: var(--accent-dim); background: var(--accent-soft); }
.notes-search { flex: 1; min-width: 220px; max-width: 420px; }

.note-folders { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.note-folder-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 20px;
  padding: 7px 14px; font-size: 12.5px; color: var(--text-secondary); cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.note-folder-chip:hover { background: var(--bg-3); color: var(--text-primary); }
.note-folder-chip.active { background: var(--accent-soft); border-color: var(--accent-dim); color: var(--accent); }
.note-folder-count { color: var(--text-muted); font-size: 11px; }
.note-folder-chip.active .note-folder-count { color: var(--accent); opacity: .8; }
.note-folder-delete {
  color: var(--text-muted); opacity: 0; margin-left: 2px; padding: 0 2px; border-radius: 3px;
  transition: opacity .1s, color .15s;
}
.note-folder-chip:hover .note-folder-delete { opacity: 1; }
.note-folder-delete:hover { color: var(--danger); }
.note-folder-add { border-style: dashed; color: var(--text-muted); }
.note-folder-add:hover { color: var(--text-primary); }

.note-card-folder { font-size: 11px; color: var(--text-muted); margin-bottom: -2px; }

.note-editor-meta { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.note-editor-meta .note-title-input { margin-bottom: 0; flex: 1; }
.note-folder-select { width: auto; min-width: 180px; flex-shrink: 0; }

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.note-card {
  background: var(--bg-1); border: 1px solid var(--border-soft); border-radius: var(--radius-md);
  padding: 16px; cursor: pointer; transition: border-color .15s, background .15s;
  display: flex; flex-direction: column; gap: 8px; min-height: 110px;
}
.note-card:hover { border-color: var(--border); background: var(--bg-2); }
.note-card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.note-card-snippet {
  font-size: 12.5px; color: var(--text-secondary); flex: 1;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
}
.note-card-date { font-size: 11px; color: var(--text-muted); }

.note-editor { max-width: 820px; }
.note-editor-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.note-editor-actions { display: flex; gap: 10px; }
.note-title-input {
  font-size: 22px; font-weight: 700; background: transparent; border: none;
  padding: 6px 2px; margin-bottom: 12px; width: 100%;
}
.note-title-input:focus { border-color: transparent; }

.note-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 3px;
  background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  padding: 6px; border-bottom: none;
}
.note-toolbar-btn {
  min-width: 30px; height: 30px; padding: 0 8px;
  border: 1px solid transparent; background: transparent; border-radius: 5px;
  color: var(--text-secondary); font-size: 13px; cursor: pointer;
}
.note-toolbar-btn:hover { background: var(--bg-3); color: var(--text-primary); }
.note-toolbar-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }

.note-body {
  min-height: 400px; background: var(--bg-1); border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  padding: 20px; color: var(--text-primary); font-size: 14px; line-height: 1.7;
  outline: none;
}
.note-body:focus { border-color: var(--accent-dim); }
.note-body h2 { font-size: 19px; margin: 0 0 10px 0; }
.note-body h3 { font-size: 16px; margin: 0 0 8px 0; }
.note-body p { margin: 0 0 12px 0; }
.note-body ul, .note-body ol { margin: 0 0 12px 0; padding-left: 22px; }
.note-body li { margin-bottom: 4px; }
.note-body blockquote {
  margin: 0 0 12px 0; padding: 4px 14px; border-left: 3px solid var(--accent-dim);
  color: var(--text-secondary); font-style: italic;
}
.note-body a { color: var(--accent); text-decoration: underline; }
.note-body b, .note-body strong { font-weight: 700; }
.note-checklist-item {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 2px 0; padding: 2px 0;
}
.note-checklist-item input[type=checkbox] {
  margin-top: 4px; width: 17px; height: 17px; flex-shrink: 0;
  accent-color: var(--accent); cursor: pointer;
}
.note-checklist-text { flex: 1; outline: none; min-width: 1px; }

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

@media (max-width: 560px) {
  .topbar { padding: 12px 16px; }
  .content { padding: 16px 16px 60px 16px; }
  .search-box { min-width: 0; width: 100%; }
  #topbarActions { width: 100%; }
  .toolbar-group { width: 100%; justify-content: space-between; }
  .toolbar-group .btn { flex: 1; padding: 10px 12px; font-size: 13px; }
}
