/* =====================================================================
   Liquid Glass layer
   Loaded after styles.css. Surfaces are very clear (they let the soft
   wallpaper show through) while text keeps strong contrast.
   --glass-t (0–1) comes from Settings → Glass clarity: higher = clearer.
   ===================================================================== */

[hidden] { display: none !important; }

:root {
  --clarity: var(--glass-t, .7);
  --opacity-cut: calc(1 - var(--clarity));
}

/* ---------- Palette per theme and tint ---------- */
:root body {
  --wall-base: #eef0f5;
  --orb-a: #ffc6ae; --orb-b: #bfd2ff; --orb-c: #ffd3ea; --orb-d: #bdeee0;
  --g-rgb: 255, 255, 255;
  --g-alpha: calc(.10 + .44 * var(--opacity-cut));
  --g-alpha-card: calc(.18 + .44 * var(--opacity-cut));
  --g-alpha-strong: calc(.46 + .36 * var(--opacity-cut));
  --g-alpha-control: calc(.22 + .40 * var(--opacity-cut));
  --g-blur: calc(18px + 16px * var(--opacity-cut));
  --g-edge: rgba(255, 255, 255, .72);
  --g-edge-soft: rgba(255, 255, 255, .38);
  --g-sheen: linear-gradient(150deg, rgba(255, 255, 255, .55) 0%, rgba(255, 255, 255, .12) 34%, rgba(255, 255, 255, 0) 58%, rgba(255, 255, 255, .16) 100%);
  --g-shadow: inset 0 1px 1px rgba(255, 255, 255, .9), inset 0 -1px 1px rgba(255, 255, 255, .3), 0 10px 30px rgba(52, 40, 70, .10), 0 1px 3px rgba(52, 40, 70, .06);
  --g-shadow-lift: inset 0 1px 1px rgba(255, 255, 255, .95), inset 0 -1px 1px rgba(255, 255, 255, .35), 0 18px 44px rgba(52, 40, 70, .16), 0 2px 6px rgba(52, 40, 70, .08);
  --g-text-shadow: 0 1px 0 rgba(255, 255, 255, .35);
  --ink: #1d1b19;
  --text-secondary: #4b4741;
  --muted: #625d56;
  --line: rgba(60, 50, 40, .12);
  --surface: rgba(255, 255, 255, .35);
  --paper-rgb: 255, 255, 255;
  --accent: #d9694a;
  --accent-ink: #fff;
  --accent-soft: rgba(217, 105, 74, .14);
  --danger: #c4442f;
  --success: #2f8a5b;
  --theme-color: #eef0f5;
  color: var(--ink);
  background: var(--wall-base);
}
:root body[data-tint="pearl"] {
  --wall-base: #f6efe4;
  --orb-a: #ffd3a1; --orb-b: #f2c0c6; --orb-c: #fff0bf; --orb-d: #dccdfb;
  --accent: #a8683a; --accent-soft: rgba(168, 104, 58, .15);
  --theme-color: #f6efe4;
}
:root body[data-tint="graphite"] {
  --wall-base: #e7ebf1;
  --orb-a: #b3c4dc; --orb-b: #bfe0e3; --orb-c: #d4cdea; --orb-d: #f0d3c4;
  --accent: #4f6684; --accent-soft: rgba(79, 102, 132, .15);
  --theme-color: #e7ebf1;
}
:root body[data-theme="dark"] {
  --wall-base: #0b0c12;
  --orb-a: #a04a36; --orb-b: #3149a8; --orb-c: #6d3596; --orb-d: #1d7f70;
  --g-rgb: 28, 30, 38;
  --g-alpha: calc(.16 + .46 * var(--opacity-cut));
  --g-alpha-card: calc(.24 + .44 * var(--opacity-cut));
  --g-alpha-strong: calc(.52 + .34 * var(--opacity-cut));
  --g-alpha-control: calc(.26 + .40 * var(--opacity-cut));
  --g-edge: rgba(255, 255, 255, .20);
  --g-edge-soft: rgba(255, 255, 255, .10);
  --g-sheen: linear-gradient(150deg, rgba(255, 255, 255, .16) 0%, rgba(255, 255, 255, .04) 34%, rgba(255, 255, 255, 0) 58%, rgba(255, 255, 255, .06) 100%);
  --g-shadow: inset 0 1px 0 rgba(255, 255, 255, .20), inset 0 -1px 0 rgba(255, 255, 255, .05), 0 12px 34px rgba(0, 0, 0, .38), 0 1px 3px rgba(0, 0, 0, .3);
  --g-shadow-lift: inset 0 1px 0 rgba(255, 255, 255, .24), inset 0 -1px 0 rgba(255, 255, 255, .06), 0 20px 48px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .35);
  --g-text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
  --ink: #f7f4ef;
  --text-secondary: #d5d0c8;
  --muted: #b9b3aa;
  --line: rgba(255, 255, 255, .12);
  --surface: rgba(28, 30, 38, .45);
  --paper-rgb: 28, 30, 38;
  --accent: #f0e6b0;
  --accent-ink: #17181b;
  --accent-soft: rgba(240, 230, 176, .16);
  --danger: #ff8a75;
  --success: #7fd6a4;
  --theme-color: #0b0c12;
}
:root body[data-theme="dark"][data-tint="pearl"] {
  --wall-base: #120e0a;
  --orb-a: #a85f22; --orb-b: #8c2f45; --orb-c: #b38a2e; --orb-d: #563d8c;
  --g-rgb: 36, 30, 26;
  --accent: #f2cf98; --accent-soft: rgba(242, 207, 152, .16);
  --theme-color: #120e0a;
}
:root body[data-theme="dark"][data-tint="graphite"] {
  --wall-base: #0a0c10;
  --orb-a: #2c4f86; --orb-b: #1f6f74; --orb-c: #4c3f86; --orb-d: #7c4f30;
  --g-rgb: 24, 27, 33;
  --accent: #c9d6e6; --accent-soft: rgba(201, 214, 230, .16);
  --theme-color: #0a0c10;
}

/* ---------- Wallpaper behind the glass ---------- */
.wallpaper { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: var(--wall-base); pointer-events: none; }
.wallpaper .orb { position: absolute; display: block; width: 62vmax; height: 62vmax; border-radius: 50%; filter: blur(70px); opacity: .85; will-change: transform; }
body[data-theme="dark"] .wallpaper .orb { opacity: .34; filter: blur(90px) saturate(.85); }
.orb-a { background: var(--orb-a); top: -22vmax; left: -18vmax; animation: drift-a 38s ease-in-out infinite alternate; }
.orb-b { background: var(--orb-b); top: -10vmax; right: -26vmax; animation: drift-b 44s ease-in-out infinite alternate; }
.orb-c { background: var(--orb-c); bottom: -30vmax; left: 4vmax; animation: drift-c 50s ease-in-out infinite alternate; }
.orb-d { background: var(--orb-d); bottom: -24vmax; right: -12vmax; animation: drift-a 46s ease-in-out infinite alternate-reverse; }
@keyframes drift-a { to { transform: translate(8vmax, 6vmax) scale(1.08); } }
@keyframes drift-b { to { transform: translate(-7vmax, 9vmax) scale(.94); } }
@keyframes drift-c { to { transform: translate(10vmax, -6vmax) scale(1.06); } }
@media (prefers-reduced-motion: reduce) { .wallpaper .orb { animation: none; } }

:root body, :root body .app-shell, :root body .main-panel { background: transparent; }
:root body { color: var(--ink); }
html { background: var(--wall-base, #eef0f5); }

/* ---------- The glass material ---------- */
:root body .sidebar,
:root body .note-card,
:root body .note-management,
:root body .calendar-view,
:root body .calendar-day,
:root body .mobile-nav,
:root body .small-dialog,
:root body .editor-dialog,
:root body .toast,
:root body .empty-state .empty-art,
:root body .appearance-preview,
:root body .search-row input {
  background-color: rgba(var(--g-rgb), var(--g-alpha));
  background-image: var(--g-sheen);
  border: 1px solid var(--g-edge);
  box-shadow: var(--g-shadow);
  -webkit-backdrop-filter: blur(var(--g-blur)) saturate(1.9);
  backdrop-filter: blur(var(--g-blur)) saturate(1.9);
  color: var(--ink);
}
:root body .note-card,
:root body .calendar-day,
:root body .appearance-preview { background-color: rgba(var(--g-rgb), var(--g-alpha-card)); }
:root body .small-dialog,
:root body .editor-dialog { background-color: rgba(var(--g-rgb), var(--g-alpha-strong)); box-shadow: var(--g-shadow-lift); }

/* Controls: buttons, selects and inputs share a lighter glass pill. */
:root body .icon-button,
:root body .share-button,
:root body .management-button,
:root body .card-tool,
:root body .text-button,
:root body .attach-top-button,
:root body .delete-note-button,
:root body .format-toolbar button,
:root body .format-toolbar select,
:root body .text-color-control,
:root body .select-field,
:root body .editor-meta input,
:root body .editor-meta select,
:root body .theme-options button,
:root body .calendar-step,
:root body .calendar-cell,
:root body .mobile-nav-item,
:root body .secondary-button,
:root body .settings-row-button,
:root body .space-chip,
:root body .language-option,
:root body .space-option {
  background-color: rgba(var(--g-rgb), var(--g-alpha-control));
  background-image: var(--g-sheen);
  border: 1px solid var(--g-edge-soft);
  box-shadow: inset 0 1px 0 var(--g-edge), 0 2px 8px rgba(0, 0, 0, .05);
  color: var(--ink);
  -webkit-backdrop-filter: blur(14px) saturate(1.6);
  backdrop-filter: blur(14px) saturate(1.6);
}
:root body .icon-button:hover,
:root body .share-button:hover,
:root body .management-button:hover,
:root body .card-tool:hover,
:root body .secondary-button:hover,
:root body .settings-row-button:hover,
:root body .space-chip:hover,
:root body .language-option:hover,
:root body .space-option:hover,
:root body .calendar-cell:hover { border-color: var(--g-edge); background-color: rgba(var(--g-rgb), calc(var(--g-alpha-control) + .12)); }
:root body .select-field:focus,
:root body .search-row input:focus,
:root body .editor-meta input:focus,
:root body .editor-meta select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 1px; }
:root body .select-field::placeholder,
:root body .search-row input::placeholder { color: var(--muted); }

/* Tinted glass for the main actions. */
:root body .primary-button,
:root body .done-button,
:root body .new-note,
:root body .mobile-new-note {
  background-color: color-mix(in srgb, var(--accent) 88%, transparent);
  background-image: linear-gradient(160deg, rgba(255, 255, 255, .38), rgba(255, 255, 255, 0) 55%);
  color: var(--accent-ink);
  border: 1px solid color-mix(in srgb, var(--accent) 60%, white 40%);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, .55), 0 8px 22px color-mix(in srgb, var(--accent) 32%, transparent);
  text-shadow: none;
}
:root body .primary-button:hover,
:root body .done-button:hover,
:root body .new-note:hover { background-color: var(--accent); }
:root body .primary-button:disabled,
:root body .secondary-button:disabled { opacity: .55; cursor: default; }

/* Text: keep it crisp on top of the clear glass. */
:root body .welcome-row h1,
:root body .card-title,
:root body .dialog-heading h2,
:root body .brand,
:root body .breadcrumb strong,
:root body .calendar-heading h2,
:root body .calendar-day h3 { color: var(--ink); text-shadow: var(--g-text-shadow); }
:root body .card-preview,
:root body .subhead,
:root body .card-date,
:root body .card-footer,
:root body .side-label,
:root body .field-label,
:root body .auth-copy,
:root body .management-hint,
:root body .sidebar-bottom small,
:root body .breadcrumb,
:root body .message-body,
:root body #message-body,
:root body .calendar-note span,
:root body .calendar-empty,
:root body .empty-state p,
:root body .save-status { color: var(--text-secondary); }
:root body .eyebrow { display: block; color: var(--accent-text, var(--accent)); font-weight: 600; font-size: 11px; line-height: 1.7; letter-spacing: .08em; margin-bottom: 4px; }
:root:lang(th) body .eyebrow { letter-spacing: .01em; text-transform: none; }
:root body .field-label span { color: var(--muted); }
:root body .field-label span[data-i18n] { float: none; color: inherit; }
:root body .nav-item,
:root body .collection-item,
:root body .add-collection,
:root body .auth-switch,
:root body .settings-trigger,
:root body .breadcrumb b { color: var(--text-secondary); }
:root body .nav-item svg,
:root body .settings-trigger svg { stroke: currentColor; }

/* ---------- Layout surfaces ---------- */
@media (min-width: 761px) {
  :root body .sidebar {
    position: sticky; top: 12px; align-self: flex-start;
    height: calc(100vh - 24px); margin: 12px 0 12px 12px;
    border-radius: 26px; overflow: auto;
  }
}
:root body .topbar { border-bottom: 0; background: transparent; }
:root body .nav-item.active,
:root body .collection-item.active {
  background-color: rgba(var(--g-rgb), calc(var(--g-alpha-control) + .14));
  background-image: var(--g-sheen);
  box-shadow: inset 0 1px 0 var(--g-edge), 0 2px 8px rgba(0, 0, 0, .06);
  color: var(--ink);
  border-radius: 14px;
}
:root body[data-nav="pill"] .nav-item.active,
:root body[data-nav="pill"] .collection-item.active { background-color: var(--accent); color: var(--accent-ink); border-radius: 99px; }
:root body .nav-item .count { background: rgba(var(--g-rgb), .55); color: var(--ink); border-radius: 99px; padding: 1px 7px; }
:root body .note-card { border-radius: 22px; }
:root body .note-card:hover { box-shadow: var(--g-shadow-lift); transform: translateY(-2px); }
:root body .note-card.selected { outline: 2px solid var(--accent); outline-offset: 1px; }
:root body .note-card:nth-child(n) { background-color: rgba(var(--g-rgb), var(--g-alpha-card)); }
:root body .card-image { border-radius: 14px; }
:root body .note-management { border-radius: 18px; }
:root body .toast { background-color: rgba(28, 28, 34, .72); color: #fff; border-color: rgba(255, 255, 255, .22); border-radius: 16px; padding: 11px 16px; font-size: 13px; max-width: calc(100vw - 32px); text-align: center; z-index: 50; }
:root body .search-row input { border-radius: 16px; padding: 12px 15px; font-size: 14px; }
:root body .empty-state h2 { color: var(--ink); }

/* Dialogs */
:root body .small-dialog,
:root body .editor-dialog { border-radius: 28px; }
:root body .small-dialog::backdrop,
:root body .editor-dialog::backdrop { background: rgba(20, 16, 28, .18); -webkit-backdrop-filter: blur(6px) saturate(1.2); backdrop-filter: blur(6px) saturate(1.2); }
:root body[data-theme="dark"] .small-dialog::backdrop,
:root body[data-theme="dark"] .editor-dialog::backdrop { background: rgba(0, 0, 0, .42); }
:root body .editor-toolbar,
:root body .format-toolbar,
:root body .format-sidebar { background: transparent; border-color: var(--line); }
@media (max-width: 760px) {
  :root body .format-sidebar {
    background-color: rgba(var(--g-rgb), calc(var(--g-alpha-strong) - .08));
    -webkit-backdrop-filter: blur(var(--g-blur)) saturate(1.8);
    backdrop-filter: blur(var(--g-blur)) saturate(1.8);
  }
  :root body .small-dialog,
  :root body .editor-dialog { border-radius: 26px; }
}
:root body .body-input,
:root body .body-input h1 { color: var(--ink); }
:root body .preview-text { background: transparent; color: var(--ink); }

/* Mobile bottom navigation: a floating glass capsule. */
:root body .mobile-nav { border-radius: 26px; }
:root body .mobile-nav-item { border-radius: 18px; }
:root body .mobile-nav-item.active { background-color: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); color: var(--ink); }

/* Calendar */
:root body .calendar-cell.selected { background-color: var(--accent); color: var(--accent-ink); border-color: transparent; }
:root body .calendar-cell i { background: var(--accent); color: var(--accent-ink); }
:root body .calendar-cell.selected i { background: var(--accent-ink); color: var(--accent-on-ink, var(--accent)); }
:root body .calendar-note { background: rgba(var(--g-rgb), var(--g-alpha-control)); border: 1px solid var(--g-edge-soft); border-radius: 14px; color: var(--ink); }

/* Card and editor tools keep their danger colour */
:root body .card-delete,
:root body .permanent-delete,
:root body .delete-note-button,
:root body .danger-action,
:root body .danger-link { color: var(--danger); }

/* ---------- New components ---------- */
.space-chip { display: flex; align-items: center; gap: 8px; width: 100%; margin: -18px 0 16px; padding: 9px 12px; border-radius: 14px; font: inherit; font-size: 12px; text-align: left; cursor: pointer; }
.space-chip svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.space-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.crumb-space { border: 0; background: none; padding: 4px 8px; margin: -4px -8px; border-radius: 10px; color: inherit; font: inherit; cursor: pointer; }
.crumb-space:hover { background: rgba(var(--g-rgb), var(--g-alpha-control)); color: var(--ink); }
.collections-label { display: flex; align-items: center; justify-content: space-between; }
.side-manage { border: 0; background: none; padding: 2px 6px; color: var(--accent-text, var(--accent)); font: inherit; font-size: 11px; font-weight: 600; cursor: pointer; border-radius: 8px; }
.side-manage:hover { background: var(--accent-soft); }
.new-note b { font-weight: inherit; }

.settings-row-button { display: flex; align-items: center; gap: 11px; width: 100%; padding: 11px 13px; border-radius: 14px; font: inherit; text-align: left; cursor: pointer; }
.settings-row-button svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.settings-row-button span { display: flex; flex-direction: column; min-width: 0; }
.settings-row-button b { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-row-button small { font-size: 11px; color: var(--text-secondary); }

.secondary-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 42px; padding: 10px 16px; border-radius: 14px; font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; }
.secondary-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.link-button { align-self: flex-start; border: 0; background: none; padding: 4px 0; color: var(--accent-text, var(--accent)); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.link-button:hover { text-decoration: underline; }
:root body .primary-button.message-action,
:root body .secondary-button.message-action { width: 100%; min-height: 48px; border-radius: 16px; font-size: 14px; font-weight: 600; }
.secondary-button.message-action { margin-top: 10px; }
.forgot-password { align-self: flex-end; margin-top: 8px; }

.form-status { min-height: 0; margin: 10px 0 0; font-size: 12px; line-height: 1.6; color: var(--danger); }
.form-status:empty { display: none; }
.form-status[data-tone="info"] { color: var(--text-secondary); }
.form-status[data-tone="success"] { color: var(--success); }
:root body .auth-error { min-height: 0; }

.dialog-icon { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 0 14px; border-radius: 18px; color: var(--accent-text, var(--accent)); background-color: var(--accent-soft); box-shadow: inset 0 1px 0 var(--g-edge); }
.dialog-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.dialog-icon.success { color: var(--success); background-color: color-mix(in srgb, var(--success) 16%, transparent); }
.dialog-icon.warning { color: var(--danger); background-color: color-mix(in srgb, var(--danger) 14%, transparent); }
.hint-list, .rule-list { margin: 4px 0 6px; padding: 0; list-style: none; display: grid; gap: 7px; }
.hint-list li, .rule-list li { position: relative; padding-left: 22px; font-size: 12px; line-height: 1.55; color: var(--text-secondary); }
.hint-list li::before { content: ''; position: absolute; left: 6px; top: .6em; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.rule-list li::before { content: ''; position: absolute; left: 2px; top: .25em; width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--muted); box-sizing: border-box; }
.rule-list li.ok { color: var(--success); }
.rule-list li.ok::before { border-color: var(--success); background: var(--success) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 12 4 4 8-8'/%3E%3C/svg%3E") center / 10px no-repeat; }
.strength { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin: 10px 0 4px; }
.strength i { height: 5px; border-radius: 9px; background: rgba(var(--g-rgb), .6); box-shadow: inset 0 0 0 1px var(--line); }
.strength[data-score="1"] i:nth-child(-n+1) { background: var(--danger); }
.strength[data-score="2"] i:nth-child(-n+2) { background: #e0a43a; }
.strength[data-score="3"] i:nth-child(-n+3) { background: #6aa84f; }
.strength[data-score="4"] i:nth-child(-n+4) { background: var(--success); }
.strength-label { font-size: 11px; color: var(--text-secondary); }
.spinner { width: 34px; height: 34px; margin: 18px auto 8px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }

/* Auth dialog views */
.auth-dialog form { display: contents; }
.auth-dialog .auth-view,
#reset-dialog .auth-view { display: none; flex-direction: column; }
.auth-dialog[data-view="login"] .auth-login-view,
.auth-dialog[data-view="register"] .auth-login-view,
.auth-dialog[data-view="forgot"] .auth-forgot-view,
.auth-dialog[data-view="sent"] .auth-sent-view,
#reset-dialog[data-view="checking"] .reset-checking-view,
#reset-dialog[data-view="form"] .reset-form-view,
#reset-dialog[data-view="expired"] .reset-expired-view { display: flex; }
.auth-dialog .auth-name { display: none; }
.auth-dialog.register .auth-name { display: block; }
.auth-dialog.register .forgot-password { display: none; }
.auth-view .auth-switch { align-self: center; }
.auth-sent-view .auth-switch + .auth-switch { margin-top: 4px; }

/* Language picker */
.language-options { display: grid; gap: 10px; margin: 6px 0 8px; }
.language-option { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 18px; font: inherit; text-align: left; cursor: pointer; }
.language-option span:last-child { display: flex; flex-direction: column; }
.language-option b { font-size: 16px; font-weight: 600; }
.language-option small { font-size: 12px; color: var(--text-secondary); }
.language-flag { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-text, var(--accent)); font-size: 20px; font-weight: 700; flex: none; }
:root body .language-option.selected { border-color: var(--accent); box-shadow: inset 0 1px 0 var(--g-edge), 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent); }

/* Spaces */
.space-list { display: grid; gap: 8px; }
.space-option { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 12px 14px; border-radius: 16px; font: inherit; text-align: left; cursor: pointer; }
.space-option span { display: flex; flex-direction: column; min-width: 0; }
.space-option b { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.space-option small { font-size: 11px; color: var(--text-secondary); }
.space-option em { font-style: normal; font-size: 11px; font-weight: 600; color: var(--accent-text, var(--accent)); flex: none; }
:root body .space-option.selected { border-color: var(--accent); cursor: default; }
.inline-field { display: flex; gap: 8px; }
.inline-field .select-field { flex: 1; min-width: 0; }
.inline-field .select-field:disabled { opacity: .7; }
.member-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.member-list li { display: flex; align-items: center; gap: 10px; }
.member-list .avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent-text, var(--accent)); font-weight: 700; font-size: 13px; }
.member-list span:nth-child(2) { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.member-list b { font-size: 13px; font-weight: 600; }
.member-list small { font-size: 11px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; }
.member-list em { font-style: normal; font-size: 11px; color: var(--text-secondary); }
.dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.danger-link { color: var(--danger); }

/* Collections manager */
.collection-manager { margin: 14px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.collection-manager li { display: grid; grid-template-columns: 9px minmax(0, 1fr) auto auto; align-items: center; gap: 8px; }
.collection-manager li.collection-empty { display: block; text-align: center; }
.collection-manager .danger-link { align-self: center; padding: 4px 2px; }
.collection-manager .select-field { flex: 1; min-width: 0; }
.collection-manager .secondary-button { min-height: 38px; padding: 8px 12px; }
.collection-manager .collection-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.collection-empty { justify-content: center; color: var(--text-secondary); font-size: 13px; padding: 12px 0; }

/* Dialog details */
:root body .small-dialog { max-height: min(90dvh, 780px); overflow: auto; }
:root body .small-dialog .select-field { min-height: 44px; border-radius: 13px; font-size: 14px; padding: 10px 13px; color: var(--ink); }
:root body .small-dialog .field-label { font-size: 12px; font-weight: 600; }
:root body .message-body { white-space: pre-line; overflow-wrap: anywhere; }
:root body .dialog-heading .icon-button { width: 36px; height: 36px; border-radius: 50%; font-size: 20px; display: grid; place-items: center; padding: 0; }
.password-toggle svg { stroke: var(--text-secondary); }

/* Editor title placeholder follows the chosen language */
:root body .body-input h1:empty::before { content: var(--title-placeholder, 'ตั้งชื่อโน้ต'); color: var(--muted); }
:root body .body-input:empty::before { color: var(--muted); }

/* Lighter, flatter rendering for people who reduce transparency, and where backdrop-filter is unavailable */
@media (prefers-reduced-transparency: reduce) {
  :root body { --g-alpha: .86; --g-alpha-card: .9; --g-alpha-strong: .95; --g-alpha-control: .8; }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root body { --g-alpha: .86; --g-alpha-card: .9; --g-alpha-strong: .95; --g-alpha-control: .8; }
}

dialog:focus, dialog:focus-visible { outline: none; }

/* =====================================================================
   Round 4: no accidental zoom, calendar events, folder menu,
   visibility toggle, menu styles and extra tints
   ===================================================================== */

/* Stop double-tap zoom everywhere; inputs at 16px+ so iOS never zooms on focus. */
html, body { touch-action: manipulation; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
button, a, input, select, textarea, label, [contenteditable] { touch-action: manipulation; }
@media (max-width: 760px) {
  :root body input, :root body select, :root body textarea, :root body .select-field,
  :root body .format-toolbar select, :root body .editor-meta input, :root body .editor-meta select,
  :root body .search-row input { font-size: 16px; }
  :root body .format-toolbar select { max-width: 150px; }
  :root body .format-toolbar #inline-size { max-width: 88px; }
}

/* ---------- Calendar ---------- */
:root body .calendar-heading { flex-wrap: wrap; gap: 10px; justify-content: center; }
.calendar-pickers { display: flex; gap: 8px; }
:root body .calendar-select {
  appearance: none; -webkit-appearance: none; border-radius: 14px; padding: 9px 30px 9px 14px; min-height: 42px;
  font: inherit; font-size: 17px; font-weight: 600; color: var(--ink); cursor: pointer;
  background: rgba(var(--g-rgb), var(--g-alpha-control)) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") right 10px center / 14px no-repeat;
  border: 1px solid var(--g-edge-soft); box-shadow: inset 0 1px 0 var(--g-edge);
}
.calendar-today { border: 0; background: none; color: var(--accent-text, var(--accent)); font: inherit; font-size: 13px; font-weight: 600; padding: 6px 10px; border-radius: 12px; cursor: pointer; }
.calendar-today:hover { background: var(--accent-soft); }
:root body .calendar-grid { background-color: rgba(var(--g-rgb), var(--g-alpha-card)); background-image: var(--g-sheen); border: 1px solid var(--g-edge); border-radius: 22px; box-shadow: var(--g-shadow); -webkit-backdrop-filter: blur(var(--g-blur)) saturate(1.9); backdrop-filter: blur(var(--g-blur)) saturate(1.9); }
:root body .calendar-cell { display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; border-radius: 14px; }
:root body .calendar-cell em { font-style: normal; font-size: 15px; line-height: 1; letter-spacing: -2px; align-self: flex-end; }
:root body .calendar-cell.is-today span { color: var(--accent-text, var(--accent)); font-weight: 700; }
:root body .calendar-cell.is-today { border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
:root body .calendar-cell.selected span { color: var(--accent-ink); }
:root body .calendar-cell.has-notes::after { display: none; }
@media (max-width: 760px) { :root body .calendar-cell em { font-size: 12px; } :root body .calendar-select { font-size: 16px; } }
:root body .calendar-day { border-radius: 22px; padding: 18px; }
:root body .calendar-day h3 { color: var(--ink); font-size: 16px; font-weight: 600; margin: 0 0 10px; }
.upcoming-title { margin-top: 22px !important; padding-top: 16px; border-top: 1px solid var(--line); }
.event-list { display: grid; gap: 8px; }
.event-row { display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px 12px; border-radius: 16px; text-align: left; font: inherit; cursor: pointer; color: var(--ink);
  background-color: rgba(var(--g-rgb), var(--g-alpha-control)); background-image: var(--g-sheen); border: 1px solid var(--g-edge-soft); box-shadow: inset 0 1px 0 var(--g-edge); }
.event-row:hover { border-color: var(--g-edge); }
.event-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: var(--accent-soft); font-size: 18px; flex: none; }
.event-text { display: flex; flex-direction: column; min-width: 0; }
.event-text strong { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-text small { font-size: 12px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-text .lock { font-style: normal; font-size: 11px; }
:root body .calendar-add-button { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 46px; margin-top: 12px; border-radius: 16px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  background-color: color-mix(in srgb, var(--accent) 88%, transparent); background-image: linear-gradient(160deg, rgba(255, 255, 255, .38), rgba(255, 255, 255, 0) 55%); color: var(--accent-ink); border: 1px solid color-mix(in srgb, var(--accent) 60%, white 40%); box-shadow: inset 0 1px 1px rgba(255, 255, 255, .55), 0 8px 22px color-mix(in srgb, var(--accent) 30%, transparent); }
:root body .calendar-add-button span { display: inline; }

/* Event dialog */
.kind-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.kind-options button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; border-radius: 16px; font: inherit; cursor: pointer; color: var(--ink);
  background-color: rgba(var(--g-rgb), var(--g-alpha-control)); border: 1px solid var(--g-edge-soft); box-shadow: inset 0 1px 0 var(--g-edge); }
.kind-options button span { font-size: 22px; line-height: 1; }
.kind-options button small { font-size: 11px; color: var(--text-secondary); }
.kind-options button.selected { border-color: var(--accent); box-shadow: inset 0 1px 0 var(--g-edge), 0 0 0 2px color-mix(in srgb, var(--accent) 40%, transparent); }
.switch-row { display: flex; align-items: center; gap: 10px; margin: 14px 0 2px; font-size: 14px; color: var(--ink); cursor: pointer; }
.switch-row input { width: 20px; height: 20px; accent-color: var(--accent); }
:root body textarea.select-field { resize: vertical; min-height: 80px; line-height: 1.6; font-family: inherit; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 16px; background: rgba(var(--g-rgb), var(--g-alpha-control)); border: 1px solid var(--g-edge-soft); }
.segmented button { min-height: 38px; border: 0; border-radius: 12px; background: transparent; color: var(--text-secondary); font: inherit; font-size: 13px; cursor: pointer; }
.segmented button.selected { background: rgba(var(--g-rgb), .92); color: var(--ink); font-weight: 600; box-shadow: 0 2px 8px rgba(0, 0, 0, .1); }
body[data-theme="dark"] .segmented button.selected { background: rgba(255, 255, 255, .16); }
.segmented button:disabled { opacity: .55; cursor: not-allowed; }
.event-delete { align-self: center; margin-top: 10px; }

/* ---------- Collections as a folder ---------- */
.folder-toggle { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 2px 0; color: inherit; font: inherit; cursor: pointer; }
.folder-toggle svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.folder-toggle i { font-style: normal; font-size: 10px; transition: transform .2s; }
.sidebar.folder-closed .folder-toggle i { transform: rotate(-90deg); }
.sidebar.folder-closed .collection-list, .sidebar.folder-closed .add-collection { display: none; }
:root body .sidebar .collection-list { max-height: 38vh; overflow-y: auto; scrollbar-width: thin; }
:root body .mobile-folder { display: inline-flex; align-items: center; gap: 6px; max-width: 180px; }
:root body .mobile-folder span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:root body .mobile-folder i { font-style: normal; font-size: 10px; opacity: .7; }
.folder-list { display: grid; gap: 6px; max-height: 55vh; overflow-y: auto; }
.folder-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 14px; border-radius: 16px; font: inherit; font-size: 15px; text-align: left; cursor: pointer; color: var(--ink);
  background-color: rgba(var(--g-rgb), var(--g-alpha-control)); border: 1px solid var(--g-edge-soft); box-shadow: inset 0 1px 0 var(--g-edge); }
.folder-row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-row em { font-style: normal; font-size: 12px; color: var(--text-secondary); background: rgba(var(--g-rgb), .6); padding: 2px 9px; border-radius: 99px; }
.folder-row .collection-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.folder-row .folder-all { font-style: normal; width: 10px; text-align: center; color: var(--accent-text, var(--accent)); }
.folder-row.selected { border-color: var(--accent); box-shadow: inset 0 1px 0 var(--g-edge), 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.folder-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }

/* ---------- Note visibility ---------- */
:root body .visibility-toggle { min-height: 36px; padding: 6px 12px; border-radius: 99px; font: inherit; font-size: 13px; cursor: pointer; color: var(--ink);
  background-color: rgba(var(--g-rgb), var(--g-alpha-control)); border: 1px solid var(--g-edge-soft); box-shadow: inset 0 1px 0 var(--g-edge); white-space: nowrap; }
:root body .visibility-toggle.is-private { background-color: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 55%, transparent); color: var(--ink); font-weight: 600; }
:root body .visibility-toggle:disabled { opacity: .6; cursor: not-allowed; }
:root body .editor-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.card-lock { font-style: normal; font-size: .8em; }

/* ---------- Menu style: make both options clearly different, on desktop and phone ---------- */
:root body[data-nav="soft"] .nav-item.active,
:root body[data-nav="soft"] .collection-item.active,
:root body[data-nav="soft"] .mobile-nav-item.active,
:root body[data-nav="soft"] .mobile-folder.active {
  background-color: rgba(var(--g-rgb), calc(var(--g-alpha-control) + .3)); background-image: var(--g-sheen);
  border: 1px solid var(--g-edge); color: var(--accent-text, var(--accent)); font-weight: 600; border-radius: 16px;
  box-shadow: inset 0 1px 0 var(--g-edge), 0 4px 14px rgba(0, 0, 0, .08);
}
:root body[data-nav="pill"] .nav-item.active,
:root body[data-nav="pill"] .collection-item.active,
:root body[data-nav="pill"] .mobile-nav-item.active,
:root body[data-nav="pill"] .mobile-folder.active {
  background-color: var(--accent); background-image: linear-gradient(160deg, rgba(255, 255, 255, .3), rgba(255, 255, 255, 0) 60%);
  border: 1px solid transparent; color: var(--accent-ink); font-weight: 600; border-radius: 999px;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 35%, transparent);
}
:root body[data-nav] .nav-item.active svg, :root body[data-nav] .mobile-nav-item.active svg { stroke: currentColor; }
.nav-options button { flex-direction: column; gap: 8px; padding: 12px 6px !important; }
.nav-sample { display: flex; gap: 4px; align-items: center; }
.nav-sample i, .nav-sample b { display: block; height: 14px; }
.nav-sample i { width: 34px; }
.nav-sample b { width: 18px; border-radius: 99px; background: var(--line); }
.nav-sample.soft i { border-radius: 6px; background: rgba(var(--g-rgb), .9); border: 1px solid var(--g-edge); box-shadow: inset 0 0 0 1px var(--accent-soft); }
.nav-sample.pill i { border-radius: 99px; background: var(--accent); }
.settings-hint { margin: 6px 0 0; font-size: 11px; line-height: 1.6; color: var(--text-secondary); }

/* ---------- Tint picker ---------- */
:root body .tint-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
:root body .tint-options button { flex-direction: column; gap: 6px; padding: 10px 4px; font-size: 11px; }
:root body .tint-swatch { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .12); }
.crystal-swatch { background: linear-gradient(135deg, #ffc6ae, #bfd2ff 55%, #bdeee0); }
.pearl-swatch { background: linear-gradient(135deg, #ffd3a1, #f2c0c6 55%, #fff0bf); }
.graphite-swatch { background: linear-gradient(135deg, #b3c4dc, #bfe0e3 55%, #4f6684); }
.lavender-swatch { background: linear-gradient(135deg, #E0E0F3 45%, #FADCDC 55%); }
.lime-swatch { background: linear-gradient(135deg, #000 45%, #d4e157 55%); }
.rose-swatch { background: linear-gradient(135deg, #000 45%, #EEA0AA 55%); }
.olive-swatch { background: linear-gradient(135deg, #3E2A09 45%, #CDDC39 55%); }

/* ---------- New tints (each has a light and a dark version) ---------- */
:root body[data-tint="lavender"] { --wall-base: #E0E0F3; --orb-a: #FADCDC; --orb-b: #cbcbf0; --orb-c: #f6d2e4; --orb-d: #d6e2f7; --accent: #9a5b86; --accent-soft: rgba(154, 91, 134, .14); --theme-color: #E0E0F3; }
:root body[data-theme="dark"][data-tint="lavender"] { --wall-base: #14131f; --orb-a: #8a6a96; --orb-b: #4c4c8f; --orb-c: #9a5f72; --orb-d: #3f4f7a; --g-rgb: 30, 28, 44; --accent: #FADCDC; --accent-ink: #2a1f2b; --accent-soft: rgba(250, 220, 220, .15); --theme-color: #14131f; }
:root body[data-tint="lime"] { --wall-base: #f2f6dc; --orb-a: #e6ee9c; --orb-b: #c5e1a5; --orb-c: #fff59d; --orb-d: #d7ecc0; --accent: #5f6d0b; --accent-soft: rgba(95, 109, 11, .14); --theme-color: #f2f6dc; }
:root body[data-theme="dark"][data-tint="lime"] { --wall-base: #000000; --orb-a: #d4e157; --orb-b: #6f8a1c; --orb-c: #2e3d06; --orb-d: #9ab83a; --g-rgb: 14, 16, 8; --accent: #d4e157; --accent-ink: #101300; --accent-soft: rgba(212, 225, 87, .16); --theme-color: #000000; }
:root body[data-tint="rose"] { --wall-base: #fbeef0; --orb-a: #f6c1c9; --orb-b: #fadadd; --orb-c: #e9cdf0; --orb-d: #ffe0cf; --accent: #b14d5d; --accent-soft: rgba(177, 77, 93, .13); --theme-color: #fbeef0; }
:root body[data-theme="dark"][data-tint="rose"] { --wall-base: #000000; --orb-a: #EEA0AA; --orb-b: #8c3f55; --orb-c: #4a1f33; --orb-d: #b86a8a; --g-rgb: 18, 10, 13; --accent: #EEA0AA; --accent-ink: #26090f; --accent-soft: rgba(238, 160, 170, .16); --theme-color: #000000; }
:root body[data-tint="olive"] { --wall-base: #f3f6d2; --orb-a: #CDDC39; --orb-b: #e9ef9f; --orb-c: #d9c08f; --orb-d: #f1e3bb; --accent: #3E2A09; --accent-ink: #f3f6d2; --accent-soft: rgba(62, 42, 9, .12); --ink: #2b1e07; --text-secondary: #4f4220; --theme-color: #f3f6d2; }
:root body[data-theme="dark"][data-tint="olive"] { --wall-base: #2a1c05; --orb-a: #CDDC39; --orb-b: #6b4a14; --orb-c: #8a6d1f; --orb-d: #3E2A09; --g-rgb: 52, 36, 9; --accent: #CDDC39; --accent-ink: #3E2A09; --accent-soft: rgba(205, 220, 57, .16); --ink: #f7f5e6; --text-secondary: #ddd8b8; --theme-color: #2a1c05; }
body[data-theme="dark"][data-tint="lime"] .wallpaper .orb,
body[data-theme="dark"][data-tint="rose"] .wallpaper .orb { opacity: .26; }
body[data-theme="dark"][data-tint="olive"] .wallpaper .orb { opacity: .3; }

/* Event reminder cards on the notes page */
.event-banners { display: grid; gap: 10px; margin: 0 0 18px; }
.event-banner { display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 8px; border-radius: 20px;
  background-color: rgba(var(--g-rgb), var(--g-alpha-card)); background-image: var(--g-sheen); border: 1px solid var(--g-edge); box-shadow: var(--g-shadow);
  -webkit-backdrop-filter: blur(var(--g-blur)) saturate(1.9); backdrop-filter: blur(var(--g-blur)) saturate(1.9); }
.event-banner.is-today { border-color: color-mix(in srgb, var(--accent) 60%, transparent); background-image: linear-gradient(120deg, var(--accent-soft), transparent 70%), var(--g-sheen); }
.event-banner-open { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; padding: 6px; border: 0; background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.event-banner .event-icon { width: 42px; height: 42px; font-size: 21px; border-radius: 14px; }
.event-banner .event-text strong { font-size: 15px; }
.event-banner-close { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(var(--g-rgb), .5); color: var(--text-secondary); font-size: 18px; line-height: 1; cursor: pointer; }
.event-banner-close:hover { color: var(--ink); background: rgba(var(--g-rgb), .8); }

/* Locked notes */
#lock-dialog .auth-view { display: none; flex-direction: column; }
#lock-dialog[data-mode="set"] .lock-set-view, #lock-dialog[data-mode="manage"] .lock-manage-view { display: flex; }
.lock-warning { margin: 0 0 4px; padding: 10px 12px; border-radius: 14px; font-size: 12px; line-height: 1.6; color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent); }
.lock-hint-shown { margin: 0 0 4px; font-size: 13px; color: var(--accent-text, var(--accent)); font-weight: 600; }
.lock-hint-shown:empty { display: none; }
.lock-remove { align-self: center; margin-top: 12px; }
:root body .card-preview.is-locked { font-style: italic; color: var(--muted); }

/* Account, consent and storage */
.consent-row { display: flex; align-items: flex-start; gap: 10px; margin: 14px 0 0; font-size: 13px; line-height: 1.55; color: var(--text-secondary); cursor: pointer; }
.consent-row input { flex: none; width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); }
.consent-row a { color: var(--accent-text, var(--accent)); font-weight: 600; }
.auth-dialog .consent-row.auth-name { display: none; }
.auth-dialog.register .consent-row.auth-name { display: flex; }
.settings-section { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; padding-top: 6px; border-top: 1px solid var(--line); }
:root body a.settings-row-button { text-decoration: none; }
.account-delete { align-self: flex-start; margin-top: 4px; }
:root body .danger-button { background-color: color-mix(in srgb, var(--danger) 90%, transparent); border-color: color-mix(in srgb, var(--danger) 60%, white 40%); color: #fff; box-shadow: inset 0 1px 1px rgba(255, 255, 255, .45), 0 8px 22px color-mix(in srgb, var(--danger) 30%, transparent); }
.storage-meter { display: grid; gap: 6px; }
.storage-bar { height: 8px; border-radius: 99px; background: rgba(var(--g-rgb), .6); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.storage-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .3s; }
.storage-bar i.warn { background: var(--danger); }
.storage-meter small { font-size: 12px; color: var(--text-secondary); }

/* =====================================================================
   Dark mode, redesigned: clear "liquid" glass over a dark base.
   The panels are almost fully transparent and neutral (they no longer tint
   everything muddy); depth comes from blur, bright rim light and a soft
   inner sheen. The base stays dark so white text always reads clearly,
   and the tint colours appear as defined glows that move behind the glass.
   ===================================================================== */
:root body[data-theme="dark"] {
  --g-rgb: 18, 18, 22;
  --g-alpha: calc(.05 + .30 * var(--opacity-cut));
  --g-alpha-card: calc(.07 + .30 * var(--opacity-cut));
  --g-alpha-strong: calc(.34 + .36 * var(--opacity-cut));
  --g-alpha-control: calc(.06 + .24 * var(--opacity-cut));
  --g-blur: calc(22px + 14px * var(--opacity-cut));
  --g-edge: rgba(255, 255, 255, .26);
  --g-edge-soft: rgba(255, 255, 255, .14);
  --g-sheen: linear-gradient(155deg, rgba(255, 255, 255, .16) 0%, rgba(255, 255, 255, .05) 22%, rgba(255, 255, 255, 0) 46%, rgba(255, 255, 255, 0) 72%, rgba(255, 255, 255, .06) 100%);
  --g-shadow: inset 0 1px 0 rgba(255, 255, 255, .34), inset 1px 0 0 rgba(255, 255, 255, .08), inset 0 -1px 0 rgba(255, 255, 255, .06), 0 18px 40px rgba(0, 0, 0, .45);
  --g-shadow-lift: inset 0 1px 0 rgba(255, 255, 255, .4), inset 1px 0 0 rgba(255, 255, 255, .1), inset 0 -1px 0 rgba(255, 255, 255, .08), 0 26px 60px rgba(0, 0, 0, .6);
  --g-text-shadow: 0 1px 2px rgba(0, 0, 0, .55);
  --ink: #ffffff;
  --text-secondary: rgba(255, 255, 255, .80);
  --muted: rgba(255, 255, 255, .62);
  --line: rgba(255, 255, 255, .12);
}
/* Glass filter for dark: keep colours lively behind, lift brightness a touch so the glass reads as glass. */
:root body[data-theme="dark"] .sidebar,
:root body[data-theme="dark"] .note-card,
:root body[data-theme="dark"] .note-management,
:root body[data-theme="dark"] .calendar-grid,
:root body[data-theme="dark"] .calendar-day,
:root body[data-theme="dark"] .mobile-nav,
:root body[data-theme="dark"] .small-dialog,
:root body[data-theme="dark"] .editor-dialog,
:root body[data-theme="dark"] .event-banner,
:root body[data-theme="dark"] .appearance-preview,
:root body[data-theme="dark"] .search-row input {
  -webkit-backdrop-filter: blur(var(--g-blur)) saturate(1.8) brightness(1.08);
  backdrop-filter: blur(var(--g-blur)) saturate(1.8) brightness(1.08);
}
:root body[data-theme="dark"] .card-preview,
:root body[data-theme="dark"] .card-title,
:root body[data-theme="dark"] .welcome-row h1,
:root body[data-theme="dark"] .subhead,
:root body[data-theme="dark"] .event-text strong,
:root body[data-theme="dark"] .body-input { text-shadow: var(--g-text-shadow); }
:root body[data-theme="dark"] .note-card:hover { background-color: rgba(var(--g-rgb), calc(var(--g-alpha-card) + .06)); }
:root body[data-theme="dark"] .toast { background-color: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .3); -webkit-backdrop-filter: blur(20px) saturate(1.8); backdrop-filter: blur(20px) saturate(1.8); }
:root body[data-theme="dark"] .small-dialog::backdrop,
:root body[data-theme="dark"] .editor-dialog::backdrop { background: rgba(0, 0, 0, .35); }

/* Dark wallpaper: defined glows instead of a muddy wash. */
body[data-theme="dark"] .wallpaper .orb { opacity: .55; filter: blur(64px); width: 46vmax; height: 46vmax; }
body[data-theme="dark"] .wallpaper::after { content: ''; position: absolute; inset: 0; background: radial-gradient(120% 90% at 50% 45%, transparent 35%, rgba(0, 0, 0, .55) 100%); }
body[data-theme="dark"] .orb-a { top: -12vmax; left: -14vmax; }
body[data-theme="dark"] .orb-b { top: 18vh; right: -18vmax; width: 38vmax; height: 38vmax; }
body[data-theme="dark"] .orb-c { bottom: -16vmax; left: 10vw; width: 40vmax; height: 40vmax; }
body[data-theme="dark"] .orb-d { bottom: 22vh; right: 18vw; width: 22vmax; height: 22vmax; opacity: .45; }

/* The three dark pairings picked earlier — same colours, cleaner glass. */
:root body[data-theme="dark"][data-tint="lime"] { --wall-base: #000000; --orb-a: #d4e157; --orb-b: #8bc34a; --orb-c: #c0ca33; --orb-d: #f0f4c3; --accent: #d4e157; --accent-ink: #0d1000; --accent-soft: rgba(212, 225, 87, .18); --theme-color: #000000; }
:root body[data-theme="dark"][data-tint="rose"] { --wall-base: #000000; --orb-a: #EEA0AA; --orb-b: #c2185b; --orb-c: #f8bbd0; --orb-d: #ff8a80; --accent: #EEA0AA; --accent-ink: #26090f; --accent-soft: rgba(238, 160, 170, .18); --theme-color: #000000; }
:root body[data-theme="dark"][data-tint="olive"] { --wall-base: #3E2A09; --orb-a: #CDDC39; --orb-b: #f9a825; --orb-c: #827717; --orb-d: #fff59d; --accent: #CDDC39; --accent-ink: #2a1c05; --accent-soft: rgba(205, 220, 57, .18); --theme-color: #3E2A09; }
body[data-theme="dark"][data-tint="lime"] .wallpaper .orb,
body[data-theme="dark"][data-tint="rose"] .wallpaper .orb { opacity: .42; }
body[data-theme="dark"][data-tint="lime"] .orb-d,
body[data-theme="dark"][data-tint="rose"] .orb-d { opacity: .3; }
body[data-theme="dark"][data-tint="olive"] .wallpaper .orb { opacity: .36; }
body[data-theme="dark"][data-tint="olive"] .wallpaper::after { background: radial-gradient(120% 90% at 50% 45%, transparent 35%, rgba(20, 12, 2, .6) 100%); }
/* Accent buttons in dark: tinted glass with the accent as a bright fill so text stays crisp. */
:root body[data-theme="dark"] .primary-button,
:root body[data-theme="dark"] .done-button,
:root body[data-theme="dark"] .new-note,
:root body[data-theme="dark"] .mobile-new-note,
:root body[data-theme="dark"] .calendar-add-button {
  background-color: color-mix(in srgb, var(--accent) 92%, transparent);
  background-image: linear-gradient(165deg, rgba(255, 255, 255, .45), rgba(255, 255, 255, .06) 45%, rgba(255, 255, 255, 0) 60%);
  border: 1px solid rgba(255, 255, 255, .45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 10px 28px color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--accent-ink);
}

/* Dark tuning: keep the base truly dark; glows are small accents near the edges. */
body[data-theme="dark"] .wallpaper .orb { filter: blur(80px); width: 34vmax; height: 34vmax; opacity: .3; }
body[data-theme="dark"] .orb-a { top: -14vmax; left: -12vmax; }
body[data-theme="dark"] .orb-b { top: 30vh; right: -16vmax; width: 28vmax; height: 28vmax; }
body[data-theme="dark"] .orb-c { bottom: -14vmax; left: -6vmax; width: 30vmax; height: 30vmax; }
body[data-theme="dark"] .orb-d { bottom: 8vh; right: -4vmax; width: 16vmax; height: 16vmax; opacity: .22; }
body[data-theme="dark"][data-tint="lime"] .wallpaper .orb,
body[data-theme="dark"][data-tint="rose"] .wallpaper .orb { opacity: .26; }
body[data-theme="dark"][data-tint="olive"] .wallpaper .orb { opacity: .2; }
body[data-theme="dark"] .wallpaper::after { background: radial-gradient(110% 80% at 50% 40%, transparent 30%, rgba(0, 0, 0, .5) 100%); }
:root body[data-theme="dark"] .sidebar,
:root body[data-theme="dark"] .note-card,
:root body[data-theme="dark"] .note-management,
:root body[data-theme="dark"] .calendar-grid,
:root body[data-theme="dark"] .calendar-day,
:root body[data-theme="dark"] .mobile-nav,
:root body[data-theme="dark"] .small-dialog,
:root body[data-theme="dark"] .editor-dialog,
:root body[data-theme="dark"] .event-banner,
:root body[data-theme="dark"] .appearance-preview,
:root body[data-theme="dark"] .search-row input {
  -webkit-backdrop-filter: blur(var(--g-blur)) saturate(1.3) brightness(1.05);
  backdrop-filter: blur(var(--g-blur)) saturate(1.3) brightness(1.05);
}

/* Offline */
.offline-banner { margin: 0 0 14px; padding: 10px 14px; border-radius: 16px; font-size: 13px; line-height: 1.5; color: var(--ink);
  background-color: color-mix(in srgb, #e0a43a 22%, rgba(var(--g-rgb), var(--g-alpha-card))); border: 1px solid color-mix(in srgb, #e0a43a 55%, transparent);
  -webkit-backdrop-filter: blur(var(--g-blur)) saturate(1.6); backdrop-filter: blur(var(--g-blur)) saturate(1.6); }
.offline-banner::before { content: '⚡ '; }
.editor-dialog.read-only .format-sidebar,
.editor-dialog.read-only .attach-top-button,
.editor-dialog.read-only .delete-note-button { display: none !important; }
body.is-offline .card-tool:not(.card-select) { display: none; }

/* Settings: make the chosen tint and menu style unmistakable (the glass control styles hid the old ring). */
:root body .theme-options button { position: relative; transition: border-color .15s, box-shadow .15s, background-color .15s; }
:root body .theme-options button.selected {
  border: 2px solid var(--accent);
  background-color: color-mix(in srgb, var(--accent) 16%, rgba(var(--g-rgb), .92));
  box-shadow: inset 0 1px 0 var(--g-edge), 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent), 0 6px 16px rgba(0, 0, 0, .08);
  font-weight: 700;
  color: var(--ink);
}
:root body .theme-options button.selected::after {
  content: '✓'; position: absolute; top: 6px; right: 6px; display: grid; place-items: center;
  width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  font-size: 12px; font-weight: 700; line-height: 1; box-shadow: 0 2px 6px rgba(0, 0, 0, .18);
}
:root body .theme-options button:not(.selected) { opacity: .82; }
:root body .theme-options button:not(.selected):hover { opacity: 1; }
:root body .tint-options button.selected .tint-swatch { box-shadow: 0 0 0 2px var(--accent-ink, #fff), 0 0 0 4px var(--accent); }

/* Unsaved drafts banner */
.draft-banner { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; padding: 10px 10px 10px 14px; border-radius: 16px; font-size: 13px; line-height: 1.5; color: var(--ink);
  background-color: color-mix(in srgb, var(--accent) 14%, rgba(var(--g-rgb), var(--g-alpha-card))); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  -webkit-backdrop-filter: blur(var(--g-blur)) saturate(1.6); backdrop-filter: blur(var(--g-blur)) saturate(1.6); }
.draft-banner span { flex: 1; min-width: 0; }
.draft-banner .secondary-button { flex: none; min-height: 36px; padding: 6px 12px; }
.conflict-third { align-self: center; margin-top: 10px; }
#lock-strength { margin-top: 10px; }

/* "Note text size" also scales the Settings preview and the note cards, so the choice is visible right away. */
:root body .appearance-preview .preview-text { font-size: var(--note-font-size, 17px); }
:root body .appearance-preview strong { font-size: calc(var(--note-font-size, 17px) + 2px); }
:root body .card-preview { font-size: calc(var(--note-font-size, 17px) * .76); line-height: 1.6; }
:root body .card-title { font-size: var(--note-font-size, 17px); }

/* Sharing: access banner, invite access picker, member controls */
.access-banner { margin: 0 0 14px; padding: 10px 14px; border-radius: 16px; font-size: 13px; line-height: 1.5; color: var(--ink);
  background-color: color-mix(in srgb, var(--accent) 12%, rgba(var(--g-rgb), var(--g-alpha-card))); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  -webkit-backdrop-filter: blur(var(--g-blur)) saturate(1.6); backdrop-filter: blur(var(--g-blur)) saturate(1.6); }
.access-options { display: grid; gap: 8px; margin: 4px 0 6px; }
.access-option { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; font: inherit; text-align: left; cursor: pointer; color: var(--ink);
  background-color: rgba(var(--g-rgb), var(--g-alpha-control)); border: 1px solid var(--g-edge-soft); box-shadow: inset 0 1px 0 var(--g-edge); position: relative; }
.access-option > span:last-child { display: flex; flex-direction: column; }
.access-option b { font-size: 14px; font-weight: 600; }
.access-option small { font-size: 12px; color: var(--text-secondary); }
.access-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--accent-soft); font-size: 18px; flex: none; }
.access-option.selected { border: 2px solid var(--accent); background-color: color-mix(in srgb, var(--accent) 14%, rgba(var(--g-rgb), .92)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.access-option.selected::after { content: '✓'; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; }
.member-list .member-access { width: auto; min-height: 34px !important; padding: 4px 8px !important; font-size: 12px !important; flex: none; }
.member-list li { flex-wrap: wrap; }

/* Read-only space: hide everything that would change it */
body.space-readonly #new-note, body.space-readonly #new-note-top, body.space-readonly #mobile-new-note, body.space-readonly #empty-create,
body.space-readonly .card-delete, body.space-readonly #delete-selected, body.space-readonly #select-mode, body.space-readonly #select-all,
body.space-readonly #add-collection, body.space-readonly #manage-collections, body.space-readonly #folder-add, body.space-readonly #folder-manage,
body.space-readonly #calendar-add, body.space-readonly #share-space, body.space-readonly #draft-banner { display: none !important; }

/* Comments */
.comments { margin: 28px 0 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.comments h3 { margin: 0 0 10px; font-size: 15px; font-weight: 600; color: var(--ink); }
.comments h3 em { font-style: normal; color: var(--text-secondary); font-weight: 400; }
.comment-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; }
.comment { padding: 10px 12px; border-radius: 14px; background: rgba(var(--g-rgb), var(--g-alpha-control)); border: 1px solid var(--g-edge-soft); }
.comment-head { display: flex; align-items: baseline; gap: 8px; }
.comment-head b { font-size: 13px; }
.comment-head small { font-size: 11px; color: var(--text-secondary); flex: 1; }
.comment-head .link-button { padding: 0; font-size: 11px; }
.comment p { margin: 4px 0 0; font-size: 14px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); }
.comment-empty { font-size: 13px; color: var(--text-secondary); }
.comment-form { display: flex; gap: 8px; align-items: flex-end; }
.comment-form textarea { flex: 1; min-height: 44px !important; resize: vertical; }
.card-comments { font-style: normal; }
.access-option { padding-right: 46px; }
body.space-readonly #note-management:not(.trash-view) { display: none !important; }
