/* ---------- Theme tokens ---------- */
:root {
  --bg: #fbfaf7;
  --panel: #f3f1ec;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #6b7078;
  --line: #e2dfd7;
  --accent: #2f6f5e;
  --accent-soft: #e3efe9;
  --danger: #b4372f;
  --selected: #eaf2ee;
  --shadow: 0 6px 24px rgba(20, 20, 20, .12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17191c; --panel: #1e2125; --surface: #1a1c1f; --text: #e6e6e3; --muted: #9aa0a6;
    --line: #2c3035; --accent: #6cc3a6; --accent-soft: #23352f; --danger: #ef7d74;
    --selected: #232a28; --shadow: 0 6px 24px rgba(0, 0, 0, .5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17191c; --panel: #1e2125; --surface: #1a1c1f; --text: #e6e6e3; --muted: #9aa0a6;
  --line: #2c3035; --accent: #6cc3a6; --accent-soft: #23352f; --danger: #ef7d74;
  --selected: #232a28; --shadow: 0 6px 24px rgba(0, 0, 0, .5); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; background: var(--accent);
  display: inline-block; position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; left: 5px; right: 5px; top: 7px; height: 2px;
  background: var(--surface); box-shadow: 0 4px 0 var(--surface), 0 8px 0 var(--surface);
}
.brand-name { font-weight: 600; letter-spacing: .2px; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 220px 320px 1fr; height: 100vh; height: 100dvh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 10px; overflow-y: auto; }
.sidebar-head { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.views { display: flex; flex-direction: column; gap: 2px; }
.nav-item { text-align: left; padding: 7px 10px; border-radius: 7px; }
.nav-item:hover { background: var(--line); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tags-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 10px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.tag-list { list-style: none; margin: 0; padding: 0; flex: 1; }
.tag-list li { display: flex; align-items: center; gap: 4px; }
.tag-list .nav-item { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-list .tag-edit { flex: 1; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.tag-list .tag-del { color: var(--danger); padding: 4px 8px; }
.sidebar-foot { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px 10px 4px; border-top: 1px solid var(--line); }
.link-btn { color: var(--accent); font-size: 13px; text-decoration: none; padding: 2px 0; }
.link-btn:hover { text-decoration: underline; }
.danger { color: var(--danger) !important; }

.list-pane { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.list-head { display: flex; align-items: center; gap: 6px; padding: 10px; border-bottom: 1px solid var(--line); }
.search-wrap { flex: 1; }
#search { width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); outline: none; }
#search:focus { border-color: var(--accent); }
.icon-btn { width: 34px; height: 34px; border-radius: 8px; font-size: 18px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--line); }
#menuBtn { display: none; }
.list-title { padding: 10px 14px 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.trash-bar { padding: 0 14px 6px; }
.note-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.note-item { padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; position: relative; }
.note-item:hover { background: var(--panel); }
.note-item.selected { background: var(--selected); box-shadow: inset 3px 0 0 var(--accent); }
.note-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 18px; }
.note-snippet { color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.note-meta { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.pin-dot { position: absolute; right: 12px; top: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
/* Pinned notes: grip handle for drag to reorder */
.note-item.pinned { padding-right: 40px; }
.grip { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 28px; height: 40px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; color: var(--accent); cursor: grab; touch-action: none; opacity: .75; }
.grip svg { fill: currentColor; }
.grip:hover { opacity: 1; background: var(--line); }
.is-dragging, .is-dragging * { cursor: grabbing !important; user-select: none; }
.note-item.dragging { opacity: .45; }
.note-item.drop-before { box-shadow: inset 0 3px 0 var(--accent); }
.note-item.drop-after { box-shadow: inset 0 -3px 0 var(--accent); }
mark { background: var(--accent-soft); color: inherit; border-radius: 2px; }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; }

.editor-pane { display: flex; flex-direction: column; min-width: 0; position: relative; background: var(--surface); }
.editor-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); min-height: 51px; }
.back-btn { display: none; font-size: 26px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 2px; flex: 1; }
.tool { padding: 5px 10px; border-radius: 7px; font-size: 13.5px; color: var(--muted); }
.tool:hover { background: var(--panel); color: var(--text); }
.tool.on { color: var(--accent); background: var(--accent-soft); }
.save-state { font-size: 12px; color: var(--muted); white-space: nowrap; }

.history-bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--accent-soft); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
#historyRange { flex: 1; min-width: 140px; accent-color: var(--accent); }
#historyLabel { font-size: 13px; color: var(--muted); min-width: 150px; }

.editor-body { flex: 1; position: relative; overflow: hidden; }
#editor { width: 100%; height: 100%; border: 0; outline: none; resize: none; padding: 22px max(22px, calc((100% - 760px) / 2)); background: transparent; font-size: 16px; line-height: 1.6; }
#editor.readonly { color: var(--muted); }
#editor { position: relative; z-index: 1; }
#editor.over-link { cursor: pointer; }
/* Sits behind the editor, same size and text, so web addresses get underlined */
.link-layer { position: absolute; top: 0; left: 0; overflow: hidden; white-space: pre-wrap; overflow-wrap: break-word; word-wrap: break-word; color: transparent; pointer-events: none; z-index: 0; }
.link-layer a { color: transparent; text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 1.5px; text-underline-offset: 2px; }
.link-layer.ctrl a { background: var(--accent-soft); border-radius: 2px; }
.preview { position: absolute; inset: 0; overflow-y: auto; background: var(--surface); z-index: 1; padding: 22px max(22px, calc((100% - 760px) / 2)); line-height: 1.65; }
.preview h1, .preview h2, .preview h3 { line-height: 1.25; }
.preview code { font-family: var(--mono); background: var(--panel); padding: 1px 5px; border-radius: 4px; font-size: .92em; }
.preview pre { background: var(--panel); padding: 12px; border-radius: 8px; overflow-x: auto; }
.preview pre code { background: none; padding: 0; }
.preview blockquote { margin: 0; padding-left: 14px; border-left: 3px solid var(--line); color: var(--muted); }
.preview a { color: var(--accent); }
.preview img { max-width: 100%; }
.preview table { border-collapse: collapse; }
.preview td, .preview th { border: 1px solid var(--line); padding: 4px 8px; }
.no-note { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); background: var(--surface); }

.tag-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px max(14px, calc((100% - 760px) / 2)); border-top: 1px solid var(--line); }
.tag-chips { display: contents; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; }
.chip button { width: 18px; height: 18px; border-radius: 50%; color: var(--muted); line-height: 1; }
.chip button:hover { background: var(--line); color: var(--text); }
#tagInput { flex: 1; min-width: 120px; border: 0; outline: none; background: transparent; padding: 4px 2px; font-size: 13.5px; }

.info-panel { position: absolute; right: 12px; top: 56px; width: 260px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 14px 16px; font-size: 13.5px; z-index: 5; }
.info-panel dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; }
.info-panel dt { color: var(--muted); }
.info-panel dd { margin: 0; text-align: right; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 8px; font-size: 14px; box-shadow: var(--shadow); z-index: 50; display: flex; gap: 14px; align-items: center; }
.toast button { color: var(--accent-soft); font-weight: 600; }
.scrim { display: none; }

/* ---------- Auth pages ---------- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.auth-card h1 { font-size: 22px; margin: 10px 0 18px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card label { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; color: var(--muted); }
.auth-card input { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); outline: none; }
.auth-card input:focus { border-color: var(--accent); }
.auth-card label.remember { flex-direction: row; align-items: center; gap: 8px; color: var(--text); cursor: pointer; }
.auth-card label.remember input { width: 16px; height: 16px; padding: 0; accent-color: var(--accent); }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; padding-right: 44px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 32px; border-radius: 6px; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; }
.pw-toggle:hover { color: var(--text); background: var(--panel); }
.pw-toggle .eye-closed { display: none; }
.pw-toggle.showing .eye-open { display: none; }
.pw-toggle.showing .eye-closed { display: inline; }
.btn-primary { background: var(--accent); color: #fff; padding: 10px; border-radius: 8px; font-weight: 600; margin-top: 4px; }
:root[data-theme="dark"] .btn-primary { color: #102019; }
.auth-error { background: #fbe9e7; color: #8a2a23; padding: 9px 12px; border-radius: 8px; font-size: 14px; }
.auth-hint { font-size: 14px; color: var(--muted); margin: -6px 0 16px; }
.auth-notice { background: var(--accent-soft); color: var(--text); padding: 10px 12px; border-radius: 8px; font-size: 14px; line-height: 1.5; }
.auth-forgot { align-self: flex-end; margin-top: -6px; font-size: 13px; color: var(--accent); }
.auth-switch { font-size: 14px; color: var(--muted); margin: 18px 0 0; }
.auth-switch a { color: var(--accent); }

/* ---------- Narrow screens ---------- */
@media (max-width: 1000px) {
  .app { grid-template-columns: 300px 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 250px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .app.menu-open .sidebar { transform: none; box-shadow: var(--shadow); }
  .app.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 15; }
  #menuBtn { display: inline-flex; }
}
@media (max-width: 680px) {
  .app { grid-template-columns: 1fr; }
  .app[data-view="list"] .editor-pane { display: none; }
  .app[data-view="editor"] .list-pane { display: none; }
  .back-btn { display: inline-flex; }
  .tool { padding: 5px 7px; }
  .info-panel { left: 12px; width: auto; }
}

/* ---------- Links between notes ---------- */
.link-layer a.note-link { text-decoration-color: var(--accent); }
.link-layer a.note-link.missing { text-decoration-style: dotted; text-decoration-color: var(--muted); }
.preview a.note-link { text-decoration: none; border-bottom: 1.5px solid var(--accent); }
.preview a.note-link.missing { color: var(--muted); border-bottom-style: dotted; }
.note-suggest { position: absolute; z-index: 4; min-width: 200px; max-width: 320px; max-height: 260px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 4px; font-size: 14px; }
.suggest-item { padding: 7px 10px; border-radius: 7px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest-item:hover { background: var(--panel); }
.suggest-item.active { background: var(--accent-soft); color: var(--accent); }

/* ---------- Images in notes ---------- */
.image-tray { display: flex; gap: 8px; overflow-x: auto; padding: 8px max(14px, calc((100% - 760px) / 2)); border-top: 1px solid var(--line); }
.image-tray a { flex: 0 0 auto; display: block; height: 64px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); background: var(--panel); }
.image-tray a:hover { border-color: var(--accent); }
.image-tray img { height: 100%; width: auto; max-width: 160px; object-fit: cover; display: block; }
.editor-body.drop-target { outline: 2px dashed var(--accent); outline-offset: -8px; background: var(--accent-soft); }
.preview img { border-radius: 6px; }
/* Keep the columns inside the window so the strip and tags stay on screen */
.app > * { min-height: 0; }
.editor-body { min-height: 0; }

/* ---------- Icon buttons with hover labels ---------- */
.icon-tool, .icon-btn { position: relative; }
.icon-tool { width: 36px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.icon-tool svg, .icon-btn svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-tool svg .dot { fill: currentColor; stroke: none; }
#pinBtn.on svg .fillable { fill: currentColor; }
.icon-tool.danger:hover { background: rgba(180, 55, 47, .1); }

/* Label bubble under the button */
[data-tip]::after {
  content: attr(data-tip); position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); font-size: 12px; font-weight: 500; line-height: 1;
  padding: 6px 8px; border-radius: 6px; white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .12s ease .25s; z-index: 30;
}
@media (hover: hover) { [data-tip]:hover::after { opacity: 1; } }
[data-tip]:focus-visible::after { opacity: 1; transition-delay: 0s; }
/* Keep the first and last labels from running off the edge */
.toolbar > [data-tip]:first-child::after, .list-head > [data-tip]:first-child::after { left: 0; transform: none; }
.list-head > #newBtn::after { left: auto; right: 0; transform: none; }

/* ---------- Sponsor spots (named to dodge ad blockers) ---------- */
.spot { position: relative; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.spot a { display: flex; width: 100%; height: 100%; align-items: center; justify-content: center; }
.spot img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.spot-square { width: 196px; height: 196px; margin: 12px auto 4px; }
.spot-banner { width: 300px; max-width: calc(100% - 20px); height: 100px; margin: 10px auto; }
.spot-tag { position: absolute; top: 4px; right: 4px; font-size: 10px; line-height: 1; letter-spacing: .3px; padding: 3px 5px; border-radius: 4px; background: rgba(0, 0, 0, .55); color: #fff; pointer-events: none; }
.list-pane > .spot-banner { border-top: 1px solid var(--line); }
.spot-empty { color: var(--muted); font-size: 13px; }

/* ---------- Ad dashboard ---------- */
.admin-body { min-height: 100vh; }
.admin-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.admin-head .auth-brand { margin: 0; }
.admin-main { max-width: 860px; margin: 0 auto; padding: 24px 16px 60px; }
.admin-main h1 { font-size: 24px; margin: 0 0 6px; }
.admin-intro { color: var(--muted); margin: 0 0 18px; }
.admin-main > .auth-notice, .admin-main > .auth-error { margin: 0 0 18px; }
.admin-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin-bottom: 20px; }
.admin-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.admin-card-head h2 { font-size: 17px; margin: 0; }
.status { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.status.live { background: var(--accent-soft); color: var(--accent); }
.status.off { background: var(--panel); color: var(--muted); }
.admin-card-body { display: grid; grid-template-columns: 320px 1fr; gap: 24px; align-items: start; }
.admin-preview .preview-frame { margin: 0 0 10px; }
.admin-hint { font-size: 12.5px; color: var(--muted); margin: 0 0 12px; line-height: 1.45; }
.admin-stats { display: flex; gap: 8px; margin: 0; }
.admin-stats div { flex: 1; background: var(--panel); border-radius: 8px; padding: 8px 10px; }
.admin-stats dt { font-size: 11.5px; color: var(--muted); }
.admin-stats dd { margin: 2px 0 0; font-size: 17px; font-weight: 600; }
.admin-form { display: flex; flex-direction: column; gap: 14px; }
.admin-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; color: var(--muted); }
.admin-form input[type=text], .admin-form input[type=url], .cloud-setup input[type=password] { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); outline: none; }
.admin-form input[type=text]:focus, .admin-form input[type=url]:focus, .cloud-setup input[type=password]:focus { border-color: var(--accent); }
.admin-form input[type=file] { font-size: 13.5px; color: var(--text); }
.admin-form label.remember { flex-direction: row; align-items: center; gap: 8px; color: var(--text); cursor: pointer; }
.admin-form label.remember input { width: 16px; height: 16px; accent-color: var(--accent); }
.admin-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.admin-actions .btn-primary { padding: 9px 22px; margin: 0; }
.btn-plain { padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line); font-size: 14px; }
.btn-plain:hover { background: var(--panel); }
@media (max-width: 720px) {
  .admin-card-body { grid-template-columns: 1fr; }
  .admin-preview .spot-banner { max-width: 100%; }
}

/* ---------- Admin dashboard: tabs, overview, users ---------- */
.admin-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 6px 0 20px; }
.admin-tabs a { padding: 9px 16px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.admin-tabs a:hover { color: var(--text); }
.admin-tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.stat span { font-size: 12px; color: var(--muted); }
.stat strong { font-size: 22px; line-height: 1.2; }
.stat em { font-style: normal; font-size: 12px; color: var(--muted); }
.inline-form { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.inline-form .admin-hint { margin: 0; }
.inline-form .btn-primary { margin: 0; padding: 9px 18px; }
.user-filter { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); outline: none; width: 220px; max-width: 100%; }
.user-filter:focus { border-color: var(--accent); }
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.user-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.user-table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.user-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.user-table tr:last-child td { border-bottom: 0; }
.user-table .num { text-align: right; }
.user-table .email-cell { white-space: normal; word-break: break-all; min-width: 160px; }
.badge { display: inline-block; margin-left: 6px; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.muted { color: var(--muted); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.btn-small { font-size: 12.5px; padding: 5px 9px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); white-space: nowrap; }
.btn-small:hover { background: var(--panel); }
.btn-small.danger:hover { background: rgba(180, 55, 47, .1); }
.actions-col { text-align: right; }
@media (max-width: 820px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-grid .stat:last-child { grid-column: span 2; }
}

/* ---------- Help & FAQ page ---------- */
.help-main { max-width: 780px; }
.help-search { width: 100%; padding: 11px 14px; font-size: 15px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); outline: none; margin: 4px 0 14px; }
.help-search:focus { border-color: var(--accent); }
.help-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 26px; }
.help-nav a { font-size: 13px; padding: 5px 11px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--text); text-decoration: none; }
.help-nav a:hover { border-color: var(--accent); color: var(--accent); }
.help-section { margin-bottom: 30px; scroll-margin-top: 16px; }
.help-section h2 { font-size: 18px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.help-section.owner { border-top: 1px dashed var(--line); padding-top: 22px; }
.help-section details { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; scroll-margin-top: 16px; }
.help-section summary { cursor: pointer; padding: 13px 44px 13px 16px; font-weight: 600; list-style: none; position: relative; }
.help-section summary::-webkit-details-marker { display: none; }
.help-section summary::after { content: ""; position: absolute; right: 18px; top: 50%; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: translateY(-70%) rotate(45deg); transition: transform .15s; }
.help-section details[open] summary::after { transform: translateY(-30%) rotate(-135deg); }
.help-section summary:hover { color: var(--accent); }
.help-section details[open] summary { border-bottom: 1px solid var(--line); }
.answer { padding: 4px 16px 6px; line-height: 1.6; }
.answer p { margin: 10px 0; }
.answer code, .help-table code { font-family: var(--mono); font-size: .9em; background: var(--panel); padding: 1px 5px; border-radius: 4px; }
kbd { font-family: var(--font); font-size: 12px; font-weight: 600; padding: 1px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); white-space: nowrap; }
.ico { display: inline-flex; vertical-align: -3px; padding: 2px; border-radius: 5px; background: var(--panel); color: var(--text); }
.ico svg { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.ico svg .dot, .ico-fill svg { fill: currentColor; }
.ico-fill svg { stroke: none; color: var(--accent); }
.help-table { width: 100%; border-collapse: collapse; margin: 8px 0 10px; font-size: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.help-table th { text-align: left; font-size: 12px; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--line); }
.help-table td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.help-table tr:last-child td { border-bottom: 0; }
.help-table.keys td:first-child { white-space: nowrap; width: 1%; }
.help-foot { color: var(--muted); font-size: 14px; margin-top: 10px; }
.auth-help { margin: 8px 0 0; font-size: 13px; }
.auth-help a { color: var(--muted); }
@media (max-width: 560px) { .help-table.keys td:first-child { white-space: normal; } }

/* ---------- Count of highlighted text ---------- */
.sel-count { font-size: 12px; color: var(--accent); background: var(--accent-soft); padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.sel-count strong { font-weight: 700; }
@media (max-width: 680px) { .sel-words { display: none; } }
.sel-demo { display: inline-block; vertical-align: 1px; }
.badge-warn { background: rgba(214, 140, 30, .16); color: #a35f00; }
:root[data-theme="dark"] .badge-warn { color: #f0b45c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge-warn { color: #f0b45c; } }
.spam-tip { margin: 12px 0 14px; padding: 10px 12px 10px 14px; border-left: 4px solid #d68c1e; background: rgba(214, 140, 30, .12); border-radius: 6px; font-size: 14px; line-height: 1.5; color: var(--text); }
.spam-tip strong:first-child { display: block; margin-bottom: 2px; }

/* ---------- Account preferences: text size and font in notes ---------- */
body.text-large #editor, body.text-large .preview { font-size: 18px; }
body.text-larger #editor, body.text-larger .preview { font-size: 21px; }
body.font-typewriter #editor, body.font-typewriter .preview { font-family: "Courier New", Courier, ui-monospace, monospace; }
body.font-typewriter .preview h1, body.font-typewriter .preview h2, body.font-typewriter .preview h3 { font-family: var(--font); }

/* ---------- Account page ---------- */
.account-main { max-width: 720px; }
.acct-stats { grid-template-columns: repeat(3, 1fr); }
.acct-stats .small-strong { font-size: 18px; }
.acct-current { margin: 0 0 14px; }
.acct-form { max-width: 420px; }
.pending-box { margin: 0 0 16px; }
.pending-box form.inline { display: inline; }
.pending-box .link-btn { margin-left: 4px; }
.acct-prefs { display: flex; flex-direction: column; gap: 16px; }
.acct-prefs fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.acct-prefs legend { font-size: 13.5px; color: var(--muted); margin-bottom: 6px; padding: 0; width: 100%; }
.choice { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; font-size: 14px; background: var(--bg); }
.choice:hover { border-color: var(--accent); }
.choice input { accent-color: var(--accent); margin: 0; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.font-sample-typewriter { font-family: "Courier New", Courier, ui-monospace, monospace; }
.btn-link { display: inline-block; text-decoration: none; color: var(--text); }
.danger-card { border-color: rgba(180, 55, 47, .35); }
.danger-card h2 { color: var(--danger); }
.delete-box summary { cursor: pointer; color: var(--danger); font-weight: 600; font-size: 14px; margin: 4px 0 12px; }
.btn-danger { background: var(--danger); color: #fff; padding: 9px 16px; border-radius: 8px; font-weight: 600; }
.btn-danger:hover { filter: brightness(1.08); }
@media (max-width: 560px) { .acct-stats { grid-template-columns: 1fr 1fr; } .acct-stats .stat:first-child { grid-column: span 2; } .acct-stats .stat:last-child { grid-column: auto; } }

/* ---------- Backups (Account page and Admin dashboard) ---------- */
.backup-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin: 14px 0 6px; }
.backup-actions .inline-form { justify-content: flex-start; gap: 10px; }
.backup-auto { font-size: 14px; color: var(--muted); display: inline-flex; align-items: center; gap: 7px; }
.backup-auto strong { color: var(--text); }
.dot-status { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot-status.on { background: #2f9e6a; }
.btn-link-plain { background: none; border: 0; padding: 4px 2px; color: var(--accent); font: inherit; font-size: 14px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.muted-text { color: var(--muted); }
.backup-list, .cloud-list { list-style: none; margin: 12px 0 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.backup-list li, .cloud-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; }
.backup-list li + li, .cloud-row + .cloud-row { border-top: 1px solid var(--line); }
.backup-info, .cloud-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.backup-info strong { font-size: 15px; }
.backup-meta { font-size: 13px; color: var(--muted); }
.backup-clouds { font-size: 12.5px; color: #2f9e6a; }
.backup-clouds::before { content: "\2713  "; }
.cloud-error { font-size: 13px; color: var(--danger); }
.acct-sub { font-size: 15px; margin: 22px 0 0; }
.cloud-row .inline-form { flex: none; }
.cloud-logo { flex: none; width: 34px; height: 34px; border-radius: 8px; background: var(--panel) center / 20px 20px no-repeat; border: 1px solid var(--line); }
.cloud-gdrive { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%2334a853' d='M8 3h8l7 12h-8z' opacity='.9'/%3E%3Cpath fill='%23fbbc04' d='M8 3 1 15l4 7 7-12z'/%3E%3Cpath fill='%234285f4' d='M5 22h14l4-7H9z'/%3E%3C/svg%3E"); }
.cloud-dropbox { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%230061fe'%3E%3Cpath d='m7 3-5 3.2 5 3.2 5-3.2zm10 0-5 3.2 5 3.2 5-3.2zM2 12.6l5 3.2 5-3.2-5-3.2zm15-3.2-5 3.2 5 3.2 5-3.2zM7 17l5 3.2 5-3.2-5-3.2z'/%3E%3C/svg%3E"); }
.setup-steps { margin: 8px 0 0; padding-left: 20px; font-size: 14px; line-height: 1.6; }
.setup-steps li { margin-bottom: 6px; }
.copy-field { display: flex; gap: 8px; align-items: stretch; margin: 6px 0 12px; }
.copy-field code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); font-size: 13px; }
.copy-field button { flex: none; }
.cloud-setup + .cloud-setup { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 18px; }
.ready-tag { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; margin-left: 8px; vertical-align: 2px; }
.ready-tag.yes { background: rgba(47, 158, 106, .15); color: #2f9e6a; }
.ready-tag.no { background: var(--panel); color: var(--muted); border: 1px solid var(--line); }
@media (max-width: 560px) {
  .backup-list li, .cloud-row { flex-wrap: wrap; }
  .backup-list li .btn-link { margin-left: auto; }
  .cloud-row .inline-form { width: 100%; justify-content: flex-end; }
}
.setup-box { margin-top: 14px; }
.setup-box > summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 14px; }
.setup-box code { font-size: 12.5px; }
.cloud-setup .admin-form { margin-top: 12px; }
.backup-when { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.backup-when .badge { margin-left: 0; }

/* ---------- Contact support and the Messages tab ---------- */
.btn-link-primary { display: inline-block; text-decoration: none; }
.contact-form textarea { width: 100%; box-sizing: border-box; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); resize: vertical; min-height: 160px; line-height: 1.5; outline: none; }
.contact-form textarea:focus { border-color: var(--accent); }
.contact-label { font-size: 13.5px; color: var(--muted); margin-bottom: -10px; }
.contact-label em { font-style: normal; opacity: .8; }
.contact-count { font-size: 12.5px; color: var(--muted); text-align: right; margin-top: -10px; min-height: 1em; }
.contact-shot { display: flex; flex-direction: column; gap: 6px; }
.contact-shot .contact-label { margin-bottom: 0; }
.contact-shot .admin-hint { margin: 0; }
.contact-shot input[type=file] { font-size: 13.5px; }
.shot-preview { display: flex; align-items: flex-start; gap: 10px; }
.shot-preview img { max-width: 220px; max-height: 140px; border: 1px solid var(--line); border-radius: 8px; object-fit: contain; background: var(--panel); }
.contact-alt { margin-top: 14px; }
.contact-done .admin-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.help-contact { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.help-contact span { flex: 1 1 260px; color: var(--muted); }
.auth-support { margin-top: 4px; color: var(--muted); }
.tab-count { display: inline-block; min-width: 18px; padding: 1px 6px; margin-left: 4px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 700; text-align: center; line-height: 1.5; vertical-align: 1px; }
:root[data-theme="dark"] .tab-count { color: #10201b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tab-count { color: #10201b; } }
.msg-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.msg { border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.msg.is-new { border-color: var(--accent); }
.msg > summary { list-style: none; cursor: pointer; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.msg > summary::-webkit-details-marker { display: none; }
.msg-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 14px; }
.msg-top .badge { margin-left: 0; }
.msg-topic { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); }
.msg-problem { color: var(--danger); }
.msg-from { font-weight: 600; word-break: break-all; }
.msg-when { color: var(--muted); font-size: 13px; margin-left: auto; }
.msg-preview { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.msg.is-new .msg-preview { color: var(--text); }
.msg[open] .msg-preview { display: none; }
.msg-body { padding: 0 16px 16px; }
.msg-text { white-space: normal; line-height: 1.6; font-size: 15px; padding: 12px 14px; border-radius: 8px; background: var(--panel); word-wrap: break-word; }
.msg-shot img { display: block; margin-top: 12px; max-width: 100%; max-height: 360px; border: 1px solid var(--line); border-radius: 8px; }
.msg-meta { font-size: 13px; color: var(--muted); margin: 10px 0; }
.msg-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.msg-actions form { display: flex; align-items: center; gap: 10px; margin: 0; }
.msg-delete { color: var(--danger); }
@media (max-width: 560px) { .msg-when { margin-left: 0; width: 100%; } }
.admin-intro a:not([class]), .contact-alt a, .help-contact a:not([class]) { color: var(--accent); }
.admin-tabs { overflow-x: auto; scrollbar-width: none; }
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tabs a { white-space: nowrap; }
@media (max-width: 560px) { .admin-tabs a { padding: 9px 11px; } }
