/* ═══════════════════════════════════════════════════════════
   CSS Custom Properties — Light Theme (default)
   ═══════════════════════════════════════════════════════════ */
:root {
  --accent:          #0078d4;
  --accent-dark:     #005a9e;
  --accent-light:    #deecf9;
  --bg:              #f0f2f5;
  --surface:         #ffffff;
  --surface2:        #f8f8f8;
  --surface3:        #f0f0f0;
  --text:            #323130;
  --text-secondary:  #605e5c;
  --text-disabled:   #a19f9d;
  --border:          #e1dfdd;
  --shadow-sm:       0 1px 4px rgba(0,0,0,0.08);
  --shadow-md:       0 4px 16px rgba(0,0,0,0.12);
  --shadow-lg:       0 8px 32px rgba(0,0,0,0.16);
  --header-bg:       var(--accent);
  --header-text:     #ffffff;
  --radius-sm:       4px;
  --radius-md:       8px;
  --radius-lg:       12px;
  --radius-xl:       16px;
  --transition:      0.18s ease;
  --icon-size:        64px;
  --tile-w:           88px;
  --tile-letter-size: 26px;
  --font-scale:       1;
}

/* Dark Theme */
[data-theme="dark"] {
  --bg:              #1a1a1a;
  --surface:         #252525;
  --surface2:        #2e2e2e;
  --surface3:        #3a3a3a;
  --text:            #f3f2f1;
  --text-secondary:  #c8c6c4;
  --text-disabled:   #797775;
  --border:          #3a3a3a;
  --shadow-sm:       0 1px 4px rgba(0,0,0,0.3);
  --shadow-md:       0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg:       0 8px 32px rgba(0,0,0,0.5);
  --accent-light:    #003966;
  --header-bg:       #2e2e2e;
  --header-text:     #f3f2f1;
}

/* System preference dark mode */
@media (prefers-color-scheme: dark) {
  [data-theme="system"] {
    --bg:              #1a1a1a;
    --surface:         #252525;
    --surface2:        #2e2e2e;
    --surface3:        #3a3a3a;
    --text:            #f3f2f1;
    --text-secondary:  #c8c6c4;
    --text-disabled:   #797775;
    --border:          #3a3a3a;
    --shadow-sm:       0 1px 4px rgba(0,0,0,0.3);
    --shadow-md:       0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg:       0 8px 32px rgba(0,0,0,0.5);
    --accent-light:    #003966;
    --header-bg:       #2e2e2e;
    --header-text:     #f3f2f1;
  }
}

/* ═══════════════════════════════════════════════════════════
   Reset & Base
   ═══════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  width: 100%;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: calc(14px * var(--font-scale));
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════
   Login Screen
   ═══════════════════════════════════════════════════════════ */
.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0078d4 0%, #005a9e 100%);
  z-index: 9999;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  margin: 0 20px;
  box-sizing: border-box;
  text-align: center;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.login-icon {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.login-card h1 {
  font-size: calc(24px * var(--font-scale));
  font-weight: 600;
  color: var(--text);
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: calc(13px * var(--font-scale));
  margin-bottom: 4px;
  margin-top: 0;
}

.btn-ms {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  background: #ffffff;
  color: #323130;
  border: 1px solid #d2d0ce;
  border-radius: var(--radius-sm);
  font-size: calc(14px * var(--font-scale));
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow-sm);
}
.btn-ms:hover {
  background: #f8f8f8;
  box-shadow: var(--shadow-md);
}
.btn-ms:active { transform: scale(0.98); }

.config-warning {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #fde7e9;
  border: 1px solid #fca5a5;
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: left;
  font-size: calc(12px * var(--font-scale));
  color: #7f1d1d;
  line-height: 1.5;
  margin-top: 4px;
}
.config-warning svg { flex-shrink: 0; margin-top: 1px; }
.config-warning code {
  background: rgba(0,0,0,0.08);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: calc(11px * var(--font-scale));
}

.auth-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #fde7e9;
  border: 1px solid #fca5a5;
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: left;
  font-size: calc(12px * var(--font-scale));
  color: #7f1d1d;
  line-height: 1.5;
  margin-top: 8px;
  word-break: break-word;
}
.auth-error svg { flex-shrink: 0; margin-top: 1px; }

.auth-redirect-info {
  background: #f0f4ff;
  border: 1px solid #c7d2fe;
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: left;
  font-size: calc(12px * var(--font-scale));
  color: #1e1b4b;
  line-height: 1.6;
  margin-top: 12px;
  word-break: break-all;
}
.auth-redirect-info code {
  display: block;
  background: rgba(0,0,0,0.06);
  padding: 4px 6px;
  border-radius: 3px;
  font-size: calc(11px * var(--font-scale));
  margin: 4px 0;
}
.auth-redirect-info small {
  color: #4338ca;
}

.auth-lang-row {
  margin-top: 4px;
  display: flex;
  justify-content: center;
}

.auth-lang-select {
  appearance: none;
  background: transparent;
  border: none;
  outline: none;
  font-size: calc(11px * var(--font-scale));
  color: var(--text-secondary);
  opacity: 0.55;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: opacity 0.15s;
  text-align: center;
  text-align-last: center;
}

.auth-lang-select:hover,
.auth-lang-select:focus {
  opacity: 0.9;
}

.pin-auth-diagnostic {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: calc(11px * var(--font-scale));
  line-height: 1.5;
  text-align: left;
  word-break: break-all;
}
.pin-auth-local {
  background: #fff8e1;
  border: 1px solid #ffe082;
  color: #5d4037;
}
.pin-auth-entra {
  background: #f0f4ff;
  border: 1px solid #c7d2fe;
  color: #1e1b4b;
}
.pin-diag-uri { opacity: 0.8; }
.pin-diag-uri code {
  background: rgba(0,0,0,0.06);
  padding: 1px 3px;
  border-radius: 3px;
}

.settings-auth-info {
  font-size: calc(13px * var(--font-scale));
  color: var(--text-secondary);
  line-height: 1.5;
  padding: 2px 0;
}
.settings-auth-info strong { color: var(--text); }
.settings-auth-info em { font-style: normal; color: var(--text-secondary); }

.pin-overlay {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at top, rgba(0,120,212,0.16), transparent 40%),
    rgba(8,18,32, var(--pin-overlay-bg-opacity, 0.75));
  backdrop-filter: blur(14px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: max(24px, 6vh) 24px 24px;
  z-index: 10000;
  overflow-y: auto;
}

.pin-overlay--from-picker {
  background: linear-gradient(
    var(--picker-bg-angle, 135deg),
    var(--picker-bg-from, #0078d4) var(--picker-bg-from-pos, 0%),
    var(--picker-bg-to, #005a9e) var(--picker-bg-to-pos, 100%)
  );
  backdrop-filter: none;
}

.pin-card {
  width: min(100%, 420px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.35);
  padding: 16px 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: center;
}

.pin-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.pin-brand .login-icon {
  margin-bottom: 0;
  width: 36px;
  height: 36px;
}

.pin-brand .login-icon svg {
  width: 36px;
  height: 36px;
}

.pin-app-name {
  font-size: calc(18px * var(--font-scale));
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.pin-input {
  width: min(100%, 220px);
  height: 56px;
  margin: 0 auto;
  text-align: center;
  letter-spacing: 0.35em;
  font-size: calc(30px * var(--font-scale));
  font-weight: 700;
}

.pin-error {
  margin: 0;
  font-size: calc(13px * var(--font-scale));
  color: #c50f1f;
}

.pin-actions {
  justify-content: center;
  margin-top: 12px;
}

.pin-actions .btn {
  min-width: 96px;
}

.pin-skip-row {
  display: flex;
  justify-content: center;
  margin-top: 4px;
}

.pin-hint {
  margin: 0;
  white-space: pre-line;
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.pin-key {
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  border-radius: 16px;
  min-height: 54px;
  font-size: calc(22px * var(--font-scale));
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--transition), background var(--transition), border-color var(--transition);
}

.pin-key:hover {
  background: var(--surface3);
  border-color: var(--accent);
}

.pin-key:active {
  transform: scale(0.97);
}

.pin-key-secondary {
  font-size: calc(14px * var(--font-scale));
  font-weight: 600;
}

.pin-key-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-size: calc(16px * var(--font-scale));
}

.pin-key-primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

/* ═══════════════════════════════════════════════════════════
   App Shell
   ═══════════════════════════════════════════════════════════ */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;       /* fallback */
  height: 100dvh;      /* dynamic viewport height — accounts for mobile browser chrome */
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════
   Header
   ═══════════════════════════════════════════════════════════ */
.guest-save-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: #c42b1c;
  color: #fff;
  font-size: 0.85rem;
  flex-wrap: wrap;
}
.guest-save-banner span { flex: 1; min-width: 160px; }
.guest-save-banner.hidden { display: none; }

.cloud-sync-error-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 14px;
  background: #7a2d00;
  color: #fff;
  font-size: 0.84rem;
  flex-wrap: wrap;
}
.cloud-sync-error-banner.hidden { display: none; }
.cloud-sync-error-icon { flex-shrink: 0; margin-top: 2px; }
.cloud-sync-error-body { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 2px; }
.cloud-sync-error-detail { opacity: 0.82; font-size: 0.8rem; word-break: break-word; }
.cloud-sync-error-link { color: #ffd9b8; text-decoration: underline; white-space: nowrap; align-self: center; flex-shrink: 0; font-size: 0.84rem; }
.cloud-sync-error-link:hover { color: #fff; }
.cloud-sync-error-close {
  background: none; border: none; color: #fff; cursor: pointer;
  font-size: 1.3rem; padding: 0 2px; align-self: flex-start; opacity: 0.7;
  line-height: 1; flex-shrink: 0;
}
.cloud-sync-error-close:hover { opacity: 1; }

.cloud-sync-error-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  margin-bottom: 8px;
  border-radius: 6px;
  background: color-mix(in srgb, #d95000 18%, transparent);
  color: var(--text);
  font-size: 0.8rem;
}
.cloud-sync-error-indicator.hidden { display: none; }
.cloud-sync-error-indicator svg { flex-shrink: 0; color: #d95000; }
.cloud-sync-error-indicator-msg { opacity: 0.75; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px 4px 8px;
  min-height: 44px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0)),
    var(--header-bg);
  color: var(--header-text);
  flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(0,0,0,0.14);
  position: relative;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 24px;
  min-width: 0;
  flex: 1;
}

.header-app-icon {
  order: 2;
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 8px;
  margin-top: 2px;
  box-shadow: 0 8px 18px rgba(0,0,0,0.16);
}
.header-app-icon[src=""] { display: none; }

.header-app-name {
  order: 1;
  font-size: calc(22px * var(--font-scale));
  font-weight: 800;
  color: var(--header-text);
  letter-spacing: 0.005em;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  margin: 0 -4px;
  transition: background var(--transition), opacity var(--transition);
  text-align: left;
}
.header-app-name:hover { background: rgba(255,255,255,0.12); }

.header-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-height: 38px;
  margin-left: 2px;
}

.header-info-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 1px;
  min-width: 0;
  padding: 2px 3px;
  border-radius: 10px;
  cursor: grab;
  transition: background var(--transition), transform var(--transition), opacity var(--transition);
}

.header-info-stack:hover {
  background: rgba(255,255,255,0.08);
}

.header-info-stack.dragging {
  opacity: 0.55;
}

.header-info-stack.drag-over {
  background: rgba(255,255,255,0.15);
  outline: 1px dashed rgba(255,255,255,0.4);
}

.header-meta-pill {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 18px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(255,255,255,0.82);
  font-size: calc(13px * var(--font-scale));
  font-weight: 500;
  letter-spacing: 0.01em;
  border: none;
  position: relative;
  white-space: nowrap;
}

/* Fixed-width time elements prevent layout shift as seconds tick */
#header-time, #header-item-time {
  font-variant-numeric: tabular-nums;
  min-width: 7.5em;
  text-align: right;
  justify-content: flex-end;
  display: inline-block;
}

.header-meta-link {
  appearance: none;
  cursor: pointer;
  font-family: inherit;
  transition: color var(--transition), opacity var(--transition);
}

.header-meta-link:hover:not(:disabled) {
  color: rgba(255,255,255,0.96);
}

.header-meta-link:disabled {
  opacity: 0.72;
  cursor: default;
}

.header-meta-link.is-fallback::after {
  content: "manual";
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  font-size: calc(9px * var(--font-scale));
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Unstacked individual header items */
.header-info-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 10px;
  background: transparent;
  color: rgba(255,255,255,0.88);
  font-size: calc(17px * var(--font-scale));
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  cursor: grab;
  border: none;
  font-family: inherit;
  transition: background var(--transition), opacity var(--transition);
}

.header-info-item:hover {
  background: rgba(255,255,255,0.08);
}

.header-info-item.dragging {
  opacity: 0.55;
}

.header-info-item.drag-over {
  background: rgba(255,255,255,0.15);
  outline: 1px dashed rgba(255,255,255,0.4);
}

.header-info-item.header-meta-link {
  cursor: pointer;
}

.header-info-item.header-meta-link:hover:not(:disabled) {
  color: rgba(255,255,255,0.96);
}

.header-info-item.header-meta-link:disabled {
  opacity: 0.72;
  cursor: default;
}

/* Hidden by ResizeObserver when header-meta is too narrow */
.header-info-item--narrow-hide {
  display: none !important;
}

/* Header drag-to-remove drop zone */
.header-drop-remove {
  position: fixed;
  left: 0;
  right: 0;
  height: 40px;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(196, 43, 28, 0.12);
  border-top: 2px dashed rgba(196, 43, 28, 0.45);
  border-bottom: 2px dashed rgba(196, 43, 28, 0.45);
  color: rgba(196, 43, 28, 0.8);
  font-size: calc(13px * var(--font-scale));
  font-weight: 600;
  letter-spacing: 0.01em;
  pointer-events: all;
  transition: background 0.15s, border-color 0.15s;
}

.header-drop-remove.drag-over {
  background: rgba(196, 43, 28, 0.28);
  border-color: rgba(196, 43, 28, 0.85);
  color: rgb(196, 43, 28);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 20px;
  background: rgba(255,255,255,0.15);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(11px * var(--font-scale));
  font-weight: 700;
  color: var(--header-text);
  text-transform: uppercase;
  flex-shrink: 0;
}

.user-display-name {
  font-size: calc(13px * var(--font-scale));
  font-weight: 500;
  color: var(--header-text);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--header-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  flex-shrink: 0;
}
.icon-btn:hover { background: rgba(255,255,255,0.2); }
.icon-btn:active { background: rgba(255,255,255,0.3); }

/* Dark-surface icon buttons (used inside modals, flyout) */
.icon-btn.dark-surface { color: var(--text-secondary); }
.icon-btn.dark-surface:hover { background: var(--surface3); color: var(--text); }

/* Icon buttons inside panel/modal/overlay headers — always use surface text color */
.modal-header .icon-btn,
.flyout-header .icon-btn,
.gist-pat-header .icon-btn,
.help-card-header .icon-btn {
  color: var(--text-secondary);
}
.modal-header .icon-btn:hover,
.flyout-header .icon-btn:hover,
.gist-pat-header .icon-btn:hover,
.help-card-header .icon-btn:hover {
  background: var(--surface3);
  color: var(--text);
}

/* ═══════════════════════════════════════════════════════════
   Main Content
   ═══════════════════════════════════════════════════════════ */
.app-main {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px calc(48px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  overscroll-behavior-y: contain;
}

.pull-refresh-indicator {
  --pull-progress: 0px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 0;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: calc(12px * var(--font-scale));
  font-weight: 600;
  opacity: 0;
  transform: translateY(-10px);
  transition: height 0.18s ease, opacity 0.18s ease, transform 0.18s ease;
}

body.is-pulling-refresh .pull-refresh-indicator,
.pull-refresh-indicator.ready,
.pull-refresh-indicator.active {
  height: calc(18px + var(--pull-progress));
  opacity: 1;
  transform: translateY(0);
}

.pull-refresh-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(0,120,212,0.16);
  transform: scale(0.9);
  transition: transform var(--transition), box-shadow var(--transition);
}

.pull-refresh-indicator.ready .pull-refresh-dot,
.pull-refresh-indicator.active .pull-refresh-dot {
  transform: scale(1.1);
}

/* ═══════════════════════════════════════════════════════════
   Groups
   ═══════════════════════════════════════════════════════════ */
.groups-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.group-section {
  background: color-mix(in srgb, var(--surface) var(--group-bg-opacity-pct, 100%), transparent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: box-shadow var(--transition);
  backdrop-filter: blur(var(--group-bg-blur, 0px));
  -webkit-backdrop-filter: blur(var(--group-bg-blur, 0px));
}
.group-section.drag-over {
  box-shadow: 0 0 0 2px var(--accent), var(--shadow-md);
}

.group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface2) var(--group-bg-opacity-pct, 100%), transparent);
  user-select: none;
}

.group-drag-handle {
  color: var(--text-disabled);
  cursor: grab;
  display: flex;
  align-items: center;
  padding: 2px;
  transition: color var(--transition);
}
.group-header:hover .group-drag-handle { color: var(--text-secondary); }

.group-name {
  font-size: calc(13px * var(--font-scale));
  font-weight: 600;
  color: var(--text);
  flex: 1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-size: calc(11px * var(--font-scale));
  color: var(--text-secondary);
}

.group-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
}
.group-header:hover .group-actions { opacity: 1; }

.group-action-btn {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
}
.group-action-btn:hover { background: var(--surface3); color: var(--text); }
.group-action-btn.danger:hover { background: #fde7e9; color: #c50f1f; }
.group-action-btn:disabled { opacity: .3; cursor: default; pointer-events: none; }

.confirm-delete-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: calc(12px * var(--font-scale));
  color: var(--text-secondary);
}
.confirm-delete-inline span { font-size: calc(12px * var(--font-scale)); }
.confirm-yes {
  padding: 2px 8px;
  background: #c50f1f;
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: calc(12px * var(--font-scale));
  cursor: pointer;
  font-weight: 500;
}
.confirm-no {
  padding: 2px 8px;
  background: var(--surface3);
  color: var(--text);
  border: none;
  border-radius: var(--radius-sm);
  font-size: calc(12px * var(--font-scale));
  cursor: pointer;
}

.btn-add-shortcut {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: calc(12px * var(--font-scale));
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition);
  white-space: nowrap;
  /* Override the fixed w/h from .group-action-btn so text fits */
  width: auto;
  height: auto;
  flex-shrink: 0;
}
.btn-add-shortcut:hover { background: var(--accent-dark); }

.group-shortcuts {
  display: grid;
  grid-template-columns: repeat(auto-fill, var(--tile-w, 88px));
  justify-content: center;
  gap: var(--tile-gap, 12px);
  padding: var(--tile-group-pad, 20px 16px);
  min-height: 60px;
  transition: background var(--transition);
}
.group-shortcuts.drag-target-empty {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  align-items: center;
  justify-content: center;
}

/* Hidden group state */
.group-section.group-hidden { display: none; }
.group-section.group-collapsed .group-shortcuts { display: none; }
.group-section.group-collapsed .group-header { border-bottom: none; }
.group-header { cursor: default; }
.group-header .group-name::after { content: ""; }
.group-section.group-collapsed .group-header .group-name::after {
  content: " ▸";
  font-size: calc(10px * var(--font-scale));
  opacity: 0.5;
  vertical-align: middle;
}

/* ── Group context menu ─────────────────────────────────── */
.group-ctx-menu {
  position: fixed;
  z-index: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 28px rgba(0,0,0,0.18);
  padding: 4px;
  min-width: 160px;
  animation: dropdownIn 0.12s ease;
}
.group-ctx-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: calc(13px * var(--font-scale));
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.group-ctx-item:hover { background: var(--surface3); }
.group-ctx-item.danger { color: #c50f1f; }
.group-ctx-item.danger:hover { background: #fde7e9; }
.group-ctx-item:disabled { opacity: .4; cursor: default; pointer-events: none; }
.group-ctx-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* ── Group header menu button ───────────────────────────── */
.group-menu-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: background var(--transition), color var(--transition), opacity var(--transition);
}
.group-header:hover .group-menu-btn,
.group-menu-btn:focus-visible { opacity: 1; }
.group-menu-btn:hover { background: var(--surface3); color: var(--text); }
@media (hover: none) { .group-menu-btn { opacity: 0.7; } }

/* ═══════════════════════════════════════════════════════════
   App Body Layout (sidebar + content)
   ═══════════════════════════════════════════════════════════ */
.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* ═══════════════════════════════════════════════════════════
   Left Navigation Sidebar (overlay drawer)
   ═══════════════════════════════════════════════════════════ */
.app-nav {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: 2px 0 12px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
  z-index: 200;
  transform: translateX(0);
}
.app-nav.collapsed { transform: translateX(-100%); }

/* Nav backdrop — shown when drawer is open */
.nav-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 199;
  cursor: pointer;
}

/* Resize handle hidden in overlay mode */
.nav-resize-handle { display: none; }

.nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.nav-title {
  font-size: calc(11px * var(--font-scale));
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  white-space: nowrap;
}

.nav-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.nav-user-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 8px 12px;
  border-bottom: 1px solid var(--border);
}
.nav-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #0078d4;
  color: #fff;
  font-size: calc(12px * var(--font-scale));
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
  overflow: hidden;
}
.nav-user-identity {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
  border-radius: 6px;
  padding: 2px 4px;
  margin: -2px -4px;
  transition: background var(--transition);
}
.nav-user-identity:hover { background: var(--hover); }
.nav-user-identity:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.nav-user-name {
  font-size: calc(13px * var(--font-scale));
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.inline-save-row { display: flex; gap: 8px; align-items: stretch; }
.inline-save-row .form-input { flex: 1; min-width: 0; }
.inline-save-row .btn { align-self: stretch; height: auto; }
.input-clear-wrap { position: relative; flex: 1; min-width: 0; }
.input-clear-wrap .form-input { width: 100%; padding-right: 28px; }
.input-clear-btn {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  background: none; border: none; padding: 2px; cursor: pointer; line-height: 1;
  color: var(--text-secondary); display: flex; align-items: center; justify-content: center;
  border-radius: 50%; transition: color var(--transition);
}
.input-clear-btn:hover { color: var(--text); }
.input-clear-btn.hidden { display: none; }
.nav-icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.nav-icon-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.nav-settings-row {
  display: flex;
  align-items: center;
}
.nav-settings-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  padding: 10px 12px 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: calc(11px * var(--font-scale));
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  font-family: inherit;
  transition: background var(--transition), color var(--transition);
}
.nav-settings-btn:hover {
  background: var(--surface3);
  color: var(--text);
}
.nav-settings-btn svg {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}
.nav-theme-btn {
  width: 28px;
  height: 28px;
  margin-right: 10px;
  flex-shrink: 0;
  color: var(--text-secondary);
}
.nav-theme-btn svg {
  width: 18px;
  height: 18px;
}
.nav-theme-pill {
  display: flex;
  margin: 6px 10px 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.nav-theme-pill[hidden] { display: none; }
.nav-theme-seg {
  flex: 1;
  padding: 5px 2px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: calc(10px * var(--font-scale));
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  font-family: inherit;
  white-space: nowrap;
}
.nav-theme-seg + .nav-theme-seg {
  border-left: 1px solid var(--border);
}
.nav-theme-seg:hover {
  background: var(--hover);
  color: var(--text);
}
.nav-theme-seg.active {
  background: var(--accent);
  color: #fff;
}

.nav-group-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.nav-group-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px 9px 10px;
  cursor: pointer;
  font-size: calc(13px * var(--font-scale));
  font-weight: 500;
  color: var(--text);
  border-left: 3px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  user-select: none;
  touch-action: none;
}
.nav-group-item:hover  { background: var(--surface3); }
.nav-group-item.drag-over {
  background: var(--accent-light);
  border-left-color: var(--accent);
  color: var(--accent);
}
.nav-group-item.dragging { opacity: 0.4; }

.nav-drag-handle {
  color: var(--text-disabled);
  display: flex;
  align-items: center;
  cursor: grab;
  flex-shrink: 0;
  padding: 2px;
  transition: color var(--transition);
  touch-action: none;
}
.nav-group-item:hover .nav-drag-handle { color: var(--text-secondary); }

.nav-group-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-toggle-btn {
  flex-shrink: 0;
  border: none;
  background: transparent;
  padding: 4px;
  margin-right: 6px;
  cursor: pointer;
  color: var(--header-text);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.nav-toggle-btn:hover { background: rgba(255,255,255,0.15); }

.nav-group-item.group-is-hidden { opacity: 0.6; }

.nav-hide-btn {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  padding: 0;
  opacity: 0;
  transition: opacity var(--transition), background var(--transition);
}
.nav-group-item:hover .nav-hide-btn          { opacity: 1; }
.nav-group-item.group-is-hidden .nav-hide-btn { opacity: 0.8; } /* always show when hidden */
.nav-hide-btn:hover { background: var(--surface3); }

/* Show-hidden toggle button in nav header */
.nav-show-hidden-btn.active {
  color: var(--accent);
  background: var(--accent-light);
}

/* ═══════════════════════════════════════════════════════════
   Checkbox
   ═══════════════════════════════════════════════════════════ */
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
}
.checkbox-input {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
  margin-top: 2px;
}
.checkbox-text {
  font-size: calc(13px * var(--font-scale));
  color: var(--text);
  line-height: 1.4;
}

/* ═══════════════════════════════════════════════════════════
   Shortcut Tiles
   ═══════════════════════════════════════════════════════════ */
.shortcut-tile {
  width: calc(var(--tile-w) - var(--tile-width-trim, 0px));
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--tile-inner-gap, 8px);
  cursor: pointer;
  border-radius: var(--radius-md);
  padding: var(--tile-pad, 8px 6px);
  transition: background var(--transition), transform var(--transition);
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: element;
}
.shortcut-tile:hover { background: var(--surface3); }
.shortcut-tile:active { transform: scale(0.96); }
.shortcut-tile.dragging { opacity: 0.4; }
.shortcut-tile.drag-over-left { box-shadow: -2px 0 0 0 var(--accent); }
.shortcut-tile.drag-over-right { box-shadow: 2px 0 0 0 var(--accent); }

.shortcut-icon {
  width: var(--icon-size);
  height: var(--icon-size);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  flex-shrink: 0;
  position: relative;
  transition: box-shadow var(--transition);
}
.shortcut-tile:hover .shortcut-icon { box-shadow: 0 4px 14px rgba(0,0,0,0.25); }

.shortcut-icon img {
  width: var(--tile-icon-fill, 84%);
  height: var(--tile-icon-fill, 84%);
  object-fit: contain;
  display: block;
  border-radius: var(--radius-md);
}

.shortcut-icon .letter-fallback {
  font-size: var(--tile-letter-size);
  font-weight: 700;
  color: var(--default-icon-text-color);
  text-transform: uppercase;
  line-height: 1;
}

.shortcut-icon .text-icon,
.shortcut-icon-preview .text-icon,
.search-result-icon .text-icon {
  font-weight: 700;
  text-transform: uppercase;
  line-height: 1;
}

.shortcut-icon .text-icon {
  font-size: calc(var(--icon-size) * 0.3);
}

.shortcut-name {
  font-size: calc(12px * var(--font-scale));
  font-weight: 500;
  text-align: center;
  width: calc(var(--tile-w) - var(--tile-width-trim, 0px) - 4px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  line-height: 1.3;
}

/* Tile action overlay */
.tile-actions {
  position: absolute;
  top: 4px;
  right: 2px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--transition);
  z-index: 10;
}
.tile-hide-container {
  position: absolute;
  top: 4px;
  left: 2px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--transition);
  z-index: 10;
}
.shortcut-tile:hover .tile-actions,
.shortcut-tile:hover .tile-hide-container { opacity: 1; }

.tile-action-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition), background var(--transition);
}
.tile-action-btn:hover { transform: scale(1.15); }
.tile-refresh-btn { background: #107c10; color: white; }
.tile-edit-btn { background: #0078d4; color: white; }
.tile-delete-btn { background: #c50f1f; color: white; }

/* ═══════════════════════════════════════════════════════════
   Add Group Row
   ═══════════════════════════════════════════════════════════ */
.add-group-row {
  margin-top: 24px;
  display: flex;
  justify-content: center;
}

.btn-add-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md);
  font-size: calc(13px * var(--font-scale));
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.btn-add-group:hover {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
}

/* ═══════════════════════════════════════════════════════════
   Settings Flyout
   ═══════════════════════════════════════════════════════════ */
.flyout-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 500;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.2s ease;
}

.settings-flyout {
  position: fixed;
  top: 0;
  right: -420px;
  width: 380px;
  height: 100vh;       /* fallback */
  height: 100dvh;      /* accounts for mobile browser chrome */
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  z-index: 600;
  display: flex;
  flex-direction: column;
  transition: right 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.settings-flyout.open { right: 0; }

.flyout-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.flyout-header h2 {
  font-size: calc(17px * var(--font-scale));
  font-weight: 600;
  color: var(--text);
}

.flyout-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

/* Cross-navigation link between Settings and Account Settings drawers */
.flyout-crossnav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 20px;
  background: var(--surface2, rgba(0,0,0,.03));
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--accent);
  font-size: calc(13px * var(--font-scale));
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
}
.flyout-crossnav-btn:hover { background: var(--surface3); }
.flyout-crossnav-chevron { margin-left: auto; opacity: .6; }

/* Guest create-profile prompt in Account Settings */
.as-guest-section {
  background: var(--surface2, rgba(0,0,0,.03));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.flyout-footer {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.settings-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.settings-section:last-child { border-bottom: none; }

/* Top-level collapsible sections (Appearance, Behavior) */
details.settings-section {
  padding: 0;
  display: block;
}
.settings-section-content {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.settings-top-collapsible > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  user-select: none;
  border-bottom: 1px solid transparent;
}
.settings-top-collapsible > summary::-webkit-details-marker { display: none; }
.settings-top-collapsible > summary::after {
  content: "›";
  font-size: calc(16px * var(--font-scale));
  color: var(--text-secondary);
  transform: rotate(0deg);
  transition: transform 0.2s;
  display: inline-block;
  flex-shrink: 0;
}
.settings-top-collapsible[open] > summary {
  border-bottom-color: var(--border);
}
.settings-top-collapsible[open] > summary::after {
  transform: rotate(90deg);
}

/* Collapsible danger subsection (Clear local data) */
.settings-danger-group {
  border: 1px solid rgba(196, 43, 28, 0.35);
  border-radius: 8px;
  overflow: hidden;
}
.settings-danger-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: calc(13px * var(--font-scale));
  font-weight: 500;
  color: #c42b1c;
  cursor: pointer;
  user-select: none;
  list-style: none;
  background: rgba(196, 43, 28, 0.06);
}
.settings-danger-summary::-webkit-details-marker { display: none; }
.settings-danger-summary::after {
  content: "›";
  font-size: calc(16px * var(--font-scale));
  color: #c42b1c;
  opacity: 0.6;
  transform: rotate(0deg);
  transition: transform 0.2s;
  display: inline-block;
}
.settings-danger-group[open] > .settings-danger-summary::after {
  transform: rotate(90deg);
}
.settings-danger-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid rgba(196, 43, 28, 0.25);
}
.danger-warning-box {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: rgba(196, 43, 28, 0.07);
  border: 1px solid rgba(196, 43, 28, 0.2);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: calc(13px * var(--font-scale));
  color: #c42b1c;
  line-height: 1.4;
}
.danger-warning-box svg { flex-shrink: 0; margin-top: 1px; }

/* Clear data confirmation overlay */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 18, 32, 0.65);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20000;
}
.confirm-overlay.hidden { display: none; }
.confirm-card {
  width: min(100%, 400px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  padding: 28px 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.confirm-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(196, 43, 28, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}
.confirm-title {
  font-size: calc(18px * var(--font-scale));
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.confirm-body {
  font-size: calc(14px * var(--font-scale));
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
}
.confirm-body--secondary {
  font-size: calc(13px * var(--font-scale));
}
.confirm-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  width: 100%;
  justify-content: center;
}
.confirm-actions .btn {
  flex: 1;
  max-width: 180px;
  justify-content: center;
}

/* Collapsible color subsection */
.settings-color-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.settings-color-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: calc(13px * var(--font-scale));
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  list-style: none;
  background: var(--surface-2, var(--surface));
}
.settings-color-summary::-webkit-details-marker { display: none; }
.settings-color-summary::after {
  content: "›";
  font-size: calc(16px * var(--font-scale));
  color: var(--text-secondary);
  transform: rotate(0deg);
  transition: transform 0.2s;
  display: inline-block;
}
.settings-color-group[open] > .settings-color-summary::after {
  transform: rotate(90deg);
}
.settings-color-group-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 12px;
  border-top: 1px solid var(--border);
}
.color-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#header-gradient-controls,
#bg-gradient-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#bg-image-settings.gradient-mode .bg-image-controls { display: none !important; }

.settings-section-title {
  font-size: calc(14px * var(--font-scale));
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--section-title-color, var(--accent));
  margin-bottom: 0;
}

/* ═══════════════════════════════════════════════════════════
   Modals
   ═══════════════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 700;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.15s ease;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 800;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modalIn 0.18s ease;
}

@keyframes modalIn {
  from { transform: translate(-50%, -50%) scale(0.95); opacity: 0; }
  to   { transform: translate(-50%, -50%) scale(1);    opacity: 1; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h2 { font-size: calc(16px * var(--font-scale)); font-weight: 600; }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════
   Shortcut Preview (inside modal)
   ═══════════════════════════════════════════════════════════ */
.shortcut-preview-row {
  display: flex;
  justify-content: center;
  padding: 8px 0 4px;
}

.shortcut-preview-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.shortcut-icon-preview {
  width: 72px;
  height: 72px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  background: #0078d4;
}
.shortcut-icon-preview img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}
.shortcut-icon-preview .letter-fallback {
  font-size: calc(30px * var(--font-scale));
  font-weight: 700;
  color: white;
  text-transform: uppercase;
}

.shortcut-icon-preview .text-icon {
  font-size: calc(28px * var(--font-scale));
}

.shortcut-preview-name {
  font-size: calc(12px * var(--font-scale));
  font-weight: 500;
  color: var(--text-secondary);
  max-width: 88px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════
   Forms
   ═══════════════════════════════════════════════════════════ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: calc(13px * var(--font-scale));
  font-weight: 500;
  color: var(--text);
}

.label-hint {
  font-weight: 400;
  color: var(--text-secondary);
  font-size: calc(12px * var(--font-scale));
}

.required { color: #c50f1f; }

.field-error-msg { color: #c42b1c; font-size: 0.8rem; margin-top: 4px; }
.field-error-msg.hidden { display: none; }
.input--error { border-color: #c42b1c !important; }

.font-scale-reset-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-left: 6px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  vertical-align: middle;
  transition: background var(--transition), color var(--transition);
}
.font-scale-reset-btn:hover { background: var(--surface3); color: var(--text); }

.form-input, .form-select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: calc(13px * var(--font-scale));
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-input:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}
.form-input::placeholder { color: var(--text-disabled); }

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%23605e5c' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

/* Segmented control */
.segmented-control {
  display: flex;
  background: var(--surface3);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.seg-btn {
  flex: 1;
  padding: 5px 8px;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--text-secondary);
  font-size: calc(13px * var(--font-scale));
  font-family: inherit;
  cursor: pointer;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.seg-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* Radio group */
.radio-group {
  display: flex;
  gap: 20px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: calc(13px * var(--font-scale));
  color: var(--text);
  cursor: pointer;
}
.radio-label input[type="radio"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════
   Color Row (swatches + custom picker)
   ═══════════════════════════════════════════════════════════ */
.color-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition);
  position: relative;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.swatch-light { box-shadow: inset 0 0 0 1px rgba(0,0,0,.18); }
.color-swatch.swatch-none {
  background: var(--surface2);
  box-shadow: inset 0 0 0 1px var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}
.color-swatch.swatch-transparent {
  background: repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 0 0 / 10px 10px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.15);
}
.color-swatch.selected {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text);
}

.color-custom {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  box-shadow: 0 0 0 1.5px var(--border);
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
  cursor: pointer;
  overflow: hidden;
  position: relative;
  transition: transform var(--transition);
}
.color-custom:hover { transform: scale(1.15); }
.color-custom input[type="color"] {
  position: absolute;
  inset: -4px;
  opacity: 0;
  cursor: pointer;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
}

/* Dark-overrides divider inside gradient controls (not theme-filtered by JS) */
.settings-theme-divider-dark {
  border-top: 1px dashed var(--border);
  padding-top: 8px;
}
.settings-theme-label-dark {
  font-size: 0.78em;
  opacity: 0.6;
  margin-left: 4px;
  font-style: italic;
}

/* Full-width native color picker for gradient settings */
.color-input-full {
  width: 100%;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════
   Brightness slider
   ═══════════════════════════════════════════════════════════ */
.brightness-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}
.brightness-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  cursor: grab;
  touch-action: none;
}
.brightness-slider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  cursor: grab;
}
.brightness-slider:active::-webkit-slider-thumb { cursor: grabbing; }
.brightness-slider:active::-moz-range-thumb     { cursor: grabbing; }

/* ═══════════════════════════════════════════════════════════
   Buttons
   ═══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: calc(13px * var(--font-scale));
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
  border: 1px solid transparent;
  line-height: 1;
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface3); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-secondary:hover { background: var(--surface3); border-color: var(--accent); color: var(--accent); }

.btn-danger {
  background: #c50f1f;
  color: #fff;
  border-color: #c50f1f;
}
.btn-danger:hover { background: #a80000; border-color: #a80000; }

.btn-success {
  background: #107c10;
  color: #fff;
  border-color: #107c10;
}
.btn-success:hover { background: #0b5e0b; border-color: #0b5e0b; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row--equal .btn { flex: 1; justify-content: center; min-width: 0; }

.form-hint {
  font-size: calc(12px * var(--font-scale));
  color: var(--text-secondary);
}

@media (max-width: 860px) {
  .app-header {
    min-height: 46px;
    padding-top: 5px;
    padding-bottom: 5px;
  }

  .header-app-name {
    font-size: calc(19px * var(--font-scale));
  }

  .header-meta {
    gap: 8px;
  }

  .header-info-stack {
    min-width: 0;
    padding: 2px 4px;
  }

  .user-badge {
    display: none;
  }

  .header-meta-pill {
    font-size: calc(10px * var(--font-scale));
    padding: 0;
  }
}

/* ─── Import Modal ─────────────────────────────────────── */
.modal-wide { max-width: 560px; }

/* ─── Merge Defaults Modal ──────────────────────────────── */
.merge-defaults-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.merge-defaults-group-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: calc(11px * var(--font-scale));
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  padding: 10px 0 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
  cursor: pointer;
}
.merge-defaults-group-label:first-child { padding-top: 0; }
.merge-defaults-group-cb { flex-shrink: 0; }

.merge-defaults-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}
.merge-defaults-item:hover { background: var(--surface2); }

.merge-defaults-item .merge-item-name {
  flex: 1;
  font-size: calc(13px * var(--font-scale));
  color: var(--text);
}

.merge-defaults-item .merge-item-url {
  font-size: calc(11px * var(--font-scale));
  color: var(--text-secondary);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.gist-pat-info-panel {
  background: var(--hover-bg, rgba(0,0,0,0.04));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: calc(13px * var(--font-scale));
  line-height: 1.55;
  margin-top: 4px;
}
.gist-pat-info-panel p { margin: 0 0 8px; }
.gist-pat-info-panel p:last-child { margin-bottom: 0; }
.gist-pat-info-panel code {
  background: var(--surface-raised, rgba(0,0,0,0.06));
  border-radius: 3px;
  padding: 1px 5px;
  font-family: monospace;
  font-size: calc(12px * var(--font-scale));
}

/* ─── Revision Picker ──────────────────────────────────── */
.revision-picker-modal {
  display: flex;
  flex-direction: column;
  height: 70vh;
}
.revision-picker-modal .modal-body { padding: 0; flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.revision-panes { display: flex; flex: 1; overflow: hidden; min-height: 0; }
.rev-list-item:hover { background: var(--hover-bg, rgba(0,0,0,0.05)); }

.import-instructions {
  margin: 0 0 16px;
  font-size: calc(13px * var(--font-scale));
  color: var(--text-secondary);
  line-height: 1.5;
}

.import-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  color: var(--text-secondary);
  text-align: center;
  user-select: none;
}
.import-dropzone:hover,
.import-dropzone.drag-active {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}
.dropzone-label { font-size: calc(14px * var(--font-scale)); font-weight: 500; }
.dropzone-link  { color: var(--accent); text-decoration: underline; }
.dropzone-hint  { font-size: calc(12px * var(--font-scale)); color: var(--text-disabled); }

.import-preview { margin-top: 20px; }
.import-preview-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.import-file-name  { font-size: calc(13px * var(--font-scale)); font-weight: 600; color: var(--text); }
.import-count-badge {
  font-size: calc(11px * var(--font-scale));
  font-weight: 600;
  background: var(--accent-light);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 99px;
}

.import-options { margin-bottom: 16px; }

.import-preview-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.import-folder-name {
  font-size: calc(12px * var(--font-scale));
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.import-folder-count {
  font-size: calc(11px * var(--font-scale));
  font-weight: 400;
  background: var(--surface3);
  color: var(--text-secondary);
  padding: 1px 6px;
  border-radius: 99px;
  text-transform: none;
  letter-spacing: 0;
}
.import-folder-links {
  list-style: none;
  margin: 0;
  padding: 0 0 0 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.import-folder-links li {
  font-size: calc(12px * var(--font-scale));
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.import-more { color: var(--text-disabled); font-style: italic; }
.import-truncate-note {
  font-size: calc(12px * var(--font-scale));
  color: var(--text-disabled);
  text-align: center;
  margin: 4px 0 0;
}

/* ── Checkbox import tree ───────────────────────────────── */
.import-tree {
  font-size: calc(13px * var(--font-scale));
  max-height: 420px;
  overflow-y: auto;
  margin-top: 8px;
}
.import-tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px 3px 0;
  border-radius: 4px;
  cursor: default;
  user-select: none;
}
.import-tree-row:hover { background: var(--hover-bg, rgba(0,0,0,.04)); }
.import-tree-select-all { margin-bottom: 4px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.import-tree-toggle {
  width: 16px;
  flex-shrink: 0;
  text-align: center;
  cursor: pointer;
  font-size: calc(10px * var(--font-scale));
  color: var(--text-secondary);
}
.import-tree-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.import-tree-folder-name { font-weight: 600; }
.import-tree-url {
  font-size: calc(11px * var(--font-scale));
  color: var(--text-disabled);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
  flex-shrink: 0;
}
.import-tree-children.import-tree-collapsed { display: none; }

/* ═══════════════════════════════════════════════════════════
   Search Popup
   ═══════════════════════════════════════════════════════════ */
.search-popup {
  position: fixed;
  width: 340px;
  max-height: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 28px rgba(0,0,0,0.18);
  z-index: 400;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: dropdownIn 0.15s ease;
}
@keyframes dropdownIn {
  from { transform: translateY(-6px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.search-popup-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 8px 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 6px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.search-icon-inline { color: var(--text-secondary); flex-shrink: 0; }

.search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: calc(13px * var(--font-scale));
  color: var(--text);
  padding: 7px 0;
  outline: none;
  font-family: inherit;
}
.search-input::placeholder { color: var(--text-disabled); }

.search-clear-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  line-height: 1;
}
.search-clear-btn:hover { background: var(--surface3); color: var(--text); }

.search-show-hidden-btn.active {
  color: var(--accent);
  background: var(--accent-light);
}
.search-show-hidden-btn.active:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.search-results {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  min-height: 48px;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  cursor: pointer;
  transition: background var(--transition);
}
.search-result-item:hover { background: var(--surface3); }

.search-result-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  font-size: calc(14px * var(--font-scale));
  font-weight: 700;
  color: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.search-result-icon img { width: 18px; height: 18px; object-fit: contain; }

.search-result-info { flex: 1; overflow: hidden; }
.search-result-name {
  font-size: calc(13px * var(--font-scale));
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-group {
  font-size: calc(11px * var(--font-scale));
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-empty, .search-no-results {
  padding: 20px 14px;
  font-size: calc(13px * var(--font-scale));
  color: var(--text-secondary);
  text-align: center;
}

/* ═══════════════════════════════════════════════════════════
   Touch devices: long-press to reveal tile actions
   ═══════════════════════════════════════════════════════════ */
@media (hover: none) {
  /* Suppress hover-triggered tile actions on touch devices */
  .shortcut-tile:hover .tile-actions        { opacity: 0; }
  .shortcut-tile:hover .tile-hide-container { opacity: 0; }
  /* Show tile actions only when long-press activates them */
  .shortcut-tile.show-actions .tile-actions        { opacity: 1; }
  .shortcut-tile.show-actions .tile-hide-container { opacity: 1; }
}

.frame-warning {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 24px;
  text-align: center;
  font-size: calc(13px * var(--font-scale));
  color: var(--text-secondary);
  animation: fadeIn 0.3s ease;
}
.frame-warning p { margin: 0; }
.btn-sm { padding: 4px 12px; font-size: calc(12px * var(--font-scale)); }

/* ═══════════════════════════════════════════════════════════
   Custom Language Selector (Flag Support)
   ═══════════════════════════════════════════════════════════ */
.custom-select-container {
  position: relative;
  width: 100%;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: calc(13px * var(--font-scale));
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  user-select: none;
}
.custom-select-trigger:hover { border-color: var(--accent); }
.custom-select-trigger.open {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.custom-select-trigger::after {
  content: "";
  margin-left: auto;
  width: 12px;
  height: 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%23605e5c' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  transition: transform var(--transition);
}
.custom-select-trigger.open::after { transform: rotate(180deg); }

.custom-options {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-top: none;
  border-bottom-left-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 1000;
  max-height: 240px;
  overflow-y: auto;
  display: none;
}
.custom-options.open { display: block; }

.custom-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: calc(13px * var(--font-scale));
  color: var(--text);
  transition: background var(--transition);
}
.custom-option:hover { background: var(--surface3); }
.custom-option.selected { background: var(--accent-light); color: var(--accent); font-weight: 600; }

.flag-icon {
  width: 20px;
  height: 14px;
  object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  flex-shrink: 0;
}

/* Auth version (minimal, center-aligned) */
.auth-lang-row .custom-select-container {
  width: auto;
  min-width: 140px;
}
.auth-lang-row .custom-select-trigger {
  background: transparent;
  border-color: transparent;
  opacity: 0.65;
  height: 28px;
  font-size: calc(12px * var(--font-scale));
  color: var(--text-secondary);
  justify-content: center;
}
.auth-lang-row .custom-select-trigger:hover { opacity: 1; color: var(--text); }
.auth-lang-row .custom-select-trigger::after { margin-left: 4px; }
.auth-lang-row .custom-options {
  left: 50%;
  transform: translateX(-50%);
  width: 160px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-top: 4px;
}

/* ═══════════════════════════════════════════════════════════
   Scrollbar styling
   ═══════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-disabled); }

/* ═══════════════════════════════════════════════════════════
   Floating Frame
   ═══════════════════════════════════════════════════════════ */
.floating-frame {
  position: fixed;
  top: 5%;
  left: 5%;
  width: 90%;
  height: 90%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 300px;
  min-height: 200px;
}

.floating-frame-header {
  height: 40px;
  background: var(--surface-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 8px 0 16px;
  cursor: move;
  user-select: none;
  flex-shrink: 0;
}

.floating-frame-title {
  flex: 1;
  font-size: calc(13px * var(--font-scale));
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 12px;
}

.floating-frame-body {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.floating-frame-content {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

.floating-frame-blocked {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: calc(14px * var(--font-scale));
  text-align: center;
  padding: 24px;
}
.floating-frame-blocked p {
  margin: 0;
}
.floating-frame-blocked.hidden {
  display: none;
}
.floating-frame-open-btn {
  margin-top: 4px;
  padding: 8px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: calc(13px * var(--font-scale));
  cursor: pointer;
  transition: opacity var(--transition);
}
.floating-frame-open-btn:hover {
  opacity: 0.85;
}

.floating-frame-newtab {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition);
  color: var(--text-muted);
  margin-right: 4px;
}
.floating-frame-newtab:hover {
  background: var(--surface-hover, rgba(0,0,0,0.08));
  color: var(--text);
}

.floating-frame-resizer {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, var(--border) 50%);
  z-index: 10;
}

.floating-frame-close {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition);
  color: var(--text-muted);
}
.floating-frame-close:hover {
  background: rgba(232, 17, 35, 0.1);
  color: #e81123;
}

[data-theme='dark'] .floating-frame-content {
  background: #1e1e1e;
}

/* ═══════════════════════════════════════════════════════════
   Profile Picker
   ═══════════════════════════════════════════════════════════ */

.profile-picker-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(var(--picker-bg-angle, 135deg), var(--picker-bg-from, #0078d4) var(--picker-bg-from-pos, 0%), var(--picker-bg-to, #005a9e) var(--picker-bg-to-pos, 100%));
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
}

.profile-picker-screen.hidden { display: none; }

/* Picker background image (when APP_CONFIG.profilePicker.bgImage is set) */
.profile-picker-screen.has-picker-bg-image,
#pin-overlay.pin-overlay--from-picker.has-picker-bg-image {
  background: transparent;
}

.profile-picker-screen.has-picker-bg-image::before,
#pin-overlay.pin-overlay--from-picker.has-picker-bg-image::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--picker-bg-image);
  background-size: cover;
  background-position: center;
  filter: blur(var(--picker-bg-blur, 0px));
  transform: scale(1.1);
  z-index: 0;
}

.profile-picker-screen.has-picker-bg-image::after,
#pin-overlay.pin-overlay--from-picker.has-picker-bg-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, var(--picker-bg-darken-value, 0));
  z-index: 0;
}

.profile-picker-screen.has-picker-bg-image .profile-picker-inner {
  position: relative;
  z-index: 1;
}

#pin-overlay.pin-overlay--from-picker.has-picker-bg-image {
  backdrop-filter: none;
  overflow: hidden;
}

#pin-overlay.pin-overlay--from-picker.has-picker-bg-image .pin-card {
  position: relative;
  z-index: 1;
}

.profile-picker-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 600px;
}

.picker-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

.profile-picker-icon { margin-bottom: 0; }

.profile-picker-title {
  color: var(--picker-title-color, #fff);
  font-size: 1.8rem;
  font-weight: 700;
  margin: 0;
  text-align: center;
}

.profile-picker-subtitle {
  color: var(--picker-subtitle-color, rgba(255,255,255,0.8));
  font-size: 1rem;
  margin: 0 0 28px 0;
  text-align: center;
}

.profile-picker-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  width: 100%;
  max-width: 560px;
}

.profile-picker-grid .profile-card {
  width: 156px;
  flex-shrink: 0;
}

.profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 22px 12px 18px;
  background: var(--picker-card-bg, #fff);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  outline: none;
  user-select: none;
}

.profile-card:hover,
.profile-card:focus {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  border-color: rgba(0,120,212,0.5);
}

.profile-card--add {
  background: rgba(255,255,255,0.15);
  border: 2px dashed rgba(255,255,255,0.5);
  color: #fff;
}
.profile-card--add:hover,
.profile-card--add:focus {
  background: rgba(255,255,255,0.25);
  border-color: rgba(255,255,255,0.8);
  transform: translateY(-3px);
}

.profile-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

.profile-avatar--add {
  background: rgba(255,255,255,0.2);
  font-size: 3.3rem;
}

.profile-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.profile-card-name {
  font-size: 1.3rem;
  font-weight: 900;
  /* font-family: "Nunito", "Varela Round", "Quicksand", system-ui, sans-serif; */
  color: var(--picker-card-text, #1a1a1a);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

/* Guest card name is longer — allow it to wrap */
.profile-card--guest .profile-card-name {
  white-space: normal;
  word-break: break-word;
  line-height: 1.3;
}

.profile-card--add .profile-card-name {
  color: rgba(255,255,255,0.9);
}

/* Guest card — slightly muted background to distinguish from user profiles */
.profile-card--guest {
  background: rgba(255,255,255,0.55);
}
.profile-card--guest:hover,
.profile-card--guest:focus {
  background: rgba(255,255,255,0.72);
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.14);
}
.profile-avatar--guest {
  background: #888;
}

.profile-card-last-used {
  font-size: 0.72rem;
  color: var(--picker-card-subtext, #666);
  text-align: center;
}

/* Create profile form */
.create-profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 20px;
  background: #999;
  transition: background 0.2s;
}

.create-profile-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}

.create-profile-btn-row {
  display: flex;
  gap: 10px;
  width: 100%;
}

.create-profile-btn-row .btn {
  flex: 1;
}

.create-profile-name-input {
  text-align: center;
  font-size: 1rem;
  border-radius: 8px;
  width: 100%;
}

/* Profile picker — dropdown mode (5–8 profiles) */
.profile-picker-dropdown-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}

.profile-picker-select {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1.5px solid rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  appearance: auto;
}

.profile-picker-select option {
  background: #1a1a2e;
  color: #fff;
}

/* "Continue without a profile" ghost link */
.profile-picker-guest-btn {
  margin-top: 12px;
  color: rgba(255,255,255,0.7);
  font-size: 1rem;
}

.profile-picker-guest-btn:hover {
  color: #fff;
  text-decoration: underline;
}

/* ═══════════════════════════════════════════════════════════
   Toast notification
   ═══════════════════════════════════════════════════════════ */

.dashboard-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1a1a1a;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.875rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 99999;
  white-space: nowrap;
}

.dashboard-toast.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ═══════════════════════════════════════════════════════════
   Undo-hide banner (top-center, non-modal)
   ═══════════════════════════════════════════════════════════ */

.undo-hide-banner {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 99998;
  white-space: nowrap;
}

.undo-hide-banner.banner-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.undo-hide-banner .undo-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 13px;
  font-size: 0.875rem;
  cursor: pointer;
  font-weight: 500;
  flex-shrink: 0;
}

.undo-hide-banner .undo-btn:hover {
  background: var(--accent-dark);
}

/* Cloud sync provider buttons in settings */
.cloud-provider-btns-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cloud-provider-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  justify-content: flex-start;
}

/* Cloud sync PAT / disconnect sections */
#cloud-gist-pat-group { margin-top: 8px; }
#cloud-disconnect-group { margin-top: 8px; }

/* Data modal textarea */
#data-modal-textarea {
  height: auto;
  font-family: monospace;
  font-size: calc(11px * var(--font-scale));
  resize: vertical;
  white-space: pre;
  overflow: auto;
  line-height: 1.4;
}

/* Hidden file inputs (programmatically triggered) */
#restore-file-input,
#import-file-input { display: none; }

/* Icon preview image — hidden until a valid URL is resolved */
#icon-preview-img { display: none; }

/* Import flat-name row — hidden until "flat" import mode is selected */
#import-flat-name-wrap { display: none; }

/* Cloud sync status paragraph spacing */
#cloud-sync-status-text { margin-bottom: 8px; }

/* Import scope chooser spacing inside data modal */
#data-modal-import-scope { margin-bottom: 12px; }

/* Import scope chooser inside data modal */
.import-scope-heading {
  font-size: calc(13px * var(--font-scale));
  font-weight: 600;
  margin-bottom: 8px;
}
#data-modal-import-scope .checkbox-label:first-of-type { margin-bottom: 6px; }

/* ═══════════════════════════════════════════════════════════
   Segmented control — wrap variant (for 5+ options)
   ═══════════════════════════════════════════════════════════ */
.segmented-control--wrap {
  flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════════
   GitHub PAT Overlay
   ═══════════════════════════════════════════════════════════ */
.gist-pat-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 48px;
}
.gist-pat-overlay.hidden { display: none; }
.gist-pat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(480px, calc(100vw - 32px));
  overflow: hidden;
}
.gist-pat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.gist-pat-header h3 {
  font-size: calc(15px * var(--font-scale));
  font-weight: 600;
  margin: 0;
}
.gist-pat-body {
  padding: 16px 20px;
}
.gist-pat-input-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.gist-pat-input {
  flex: 1;
  min-width: 0;
  font-family: monospace;
  font-size: calc(13px * var(--font-scale));
  height: 42px;
}
.gist-pat-paste-btn {
  flex-shrink: 0;
}
.gist-pat-header-btns {
  display: flex;
  gap: 4px;
  align-items: center;
}

.flyout-header-btns {
  display: flex;
  gap: 4px;
  align-items: center;
}

/* ═══════════════════════════════════════════════════════════
   Help Overlay
   ═══════════════════════════════════════════════════════════ */
.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 2100;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.help-overlay.hidden { display: none; }

.help-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 75%;
  max-width: 900px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.help-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.help-card-header h2 {
  font-size: calc(17px * var(--font-scale));
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.help-card-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
}

/* ── Markdown rendering ─────────────────────────────────── */
.markdown-body { font-size: calc(14px * var(--font-scale)); line-height: 1.7; color: var(--text); }
.markdown-body h1 { font-size: calc(22px * var(--font-scale)); font-weight: 700; margin: 0 0 16px; color: var(--text); }
.markdown-body h2 { font-size: calc(17px * var(--font-scale)); font-weight: 600; margin: 28px 0 10px; color: var(--text); border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.markdown-body h3 { font-size: calc(14px * var(--font-scale)); font-weight: 600; margin: 20px 0 8px; color: var(--text); }
.markdown-body p  { margin: 0 0 10px; }
.markdown-body ul, .markdown-body ol { margin: 0 0 10px; padding-left: 22px; }
.markdown-body li { margin-bottom: 4px; }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.markdown-body code {
  background: var(--surface2);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: monospace;
  font-size: calc(12px * var(--font-scale));
}
.markdown-body pre {
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 12px 16px;
  overflow-x: auto;
  margin: 0 0 12px;
}
.markdown-body pre code { background: none; padding: 0; }
.markdown-body a { color: var(--accent); text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; }
.markdown-body strong { font-weight: 600; }
.markdown-body em { font-style: italic; }
.markdown-body table { width: 100%; border-collapse: collapse; margin: 0 0 12px; font-size: calc(13px * var(--font-scale)); }
.markdown-body th { background: var(--surface2); font-weight: 600; text-align: left; padding: 7px 12px; border: 1px solid var(--border); }
.markdown-body td { padding: 6px 12px; border: 1px solid var(--border); }
.markdown-body tr:nth-child(even) td { background: var(--surface2); }

@media (max-width: 600px) {
  .help-card { width: 96%; }
}
#gist-pat-error {
  margin: 0 20px 8px;
}
.gist-pat-footer {
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
}
.gist-pat-footer .btn {
  display: flex;
  flex: 1;
  justify-content: center;
}

/* ═══════════════════════════════════════════════════════════
   Map Prompt Popup
   ═══════════════════════════════════════════════════════════ */
.map-prompt-popup {
  position: fixed;
  z-index: 1500;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 160px;
}
.map-prompt-popup.hidden { display: none; }
.map-prompt-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  font-size: calc(14px * var(--font-scale));
  text-align: left;
  cursor: pointer;
  color: var(--text);
  transition: background var(--transition);
}
.map-prompt-item:hover { background: var(--hover); }

/* ═══════════════════════════════════════════════════════════
   Hidden shortcut tiles
   ═══════════════════════════════════════════════════════════ */
.shortcut-tile.tile-is-hidden {
  opacity: 0.45;
  position: relative;
}
.shortcut-tile.tile-is-hidden .shortcut-icon::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 4px,
    rgba(0,0,0,0.15) 4px,
    rgba(0,0,0,0.15) 5px
  );
  pointer-events: none;
}
.shortcut-tile.tile-is-hidden .shortcut-name::after {
  content: ' 🚫';
  font-size: 0.7em;
}
.tile-hide-btn { background: #8764b8; color: white; }

/* Search result hidden badge */
.search-result-hidden { opacity: 0.75; }
.search-hidden-badge {
  font-size: 0.75em;
  color: var(--text-secondary);
  font-weight: normal;
}

/* Search result meta line (line 2: group + optional match annotation) */
.search-result-meta {
  font-size: calc(11px * var(--font-scale));
  color: var(--text-secondary);
  display: flex;
  align-items: baseline;
  white-space: nowrap;
  overflow: hidden;
  min-width: 0;
}
.srm-group { flex-shrink: 0; }
.srm-sep   { flex-shrink: 0; padding: 0 6px; }
.srm-label { flex-shrink: 0; font-weight: 500; }
.srm-value { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
mark.search-match {
  background: transparent;
  color: var(--accent);
  font-weight: 700;
}

/* Tag chip input widget */
.tag-chip-wrap {
  position: relative;
}
.tag-chip-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: text;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.tag-chip-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: calc(11px * var(--font-scale));
  font-weight: 500;
  padding: 2px 6px 2px 8px;
  border-radius: 99px;
  white-space: nowrap;
  user-select: none;
}
.tag-chip-remove {
  border: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  font-size: calc(14px * var(--font-scale));
  display: flex;
  align-items: center;
  opacity: 0.7;
}
.tag-chip-remove:hover { opacity: 1; }
.tag-chip-textinput {
  flex: 1;
  min-width: 80px;
  border: none;
  outline: none;
  background: transparent;
  font-size: calc(13px * var(--font-scale));
  color: var(--text);
  font-family: inherit;
  padding: 2px 0;
}
.tag-chip-textinput::placeholder { color: var(--text-disabled); }
.tag-autocomplete {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  z-index: 20;
  overflow: hidden;
}
.tag-autocomplete.hidden { display: none; }
.tag-ac-item {
  padding: 7px 12px;
  font-size: calc(13px * var(--font-scale));
  cursor: pointer;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tag-ac-item:hover { background: var(--surface3); }

/* Color row hex text fallback input */
.color-hex-input {
  width: 72px;
  height: 26px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: calc(12px * var(--font-scale));
  font-family: monospace;
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.color-hex-input:focus { border-color: var(--accent); }

/* ── Custom Tooltip ─────────────────────────────────────────── */
#tooltip-popup {
  position: fixed;
  z-index: 99999;
  pointer-events: none;
  background: rgba(32, 31, 30, 0.92);
  color: #fff;
  font-size: calc(12px * var(--font-scale));
  line-height: 1.3;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.1s ease, transform 0.1s ease;
}
#tooltip-popup.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ═══════════════════════════════════════════════════════════
   Avatar Picker
   ═══════════════════════════════════════════════════════════ */

/* Nav sidebar image avatar */
#nav-user-avatar img.nav-avatar-img,
.profile-avatar img.profile-avatar-img,
.profile-avatar img.nav-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

/* Account Settings avatar row */
.avatar-current-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Preset grid */
.avatar-preset-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 4px 0;
  min-height: 60px;
}
.avatar-preset-cell {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
  outline: none;
}
.avatar-preset-cell:hover,
.avatar-preset-cell:focus {
  transform: scale(1.06);
}
.avatar-preset-cell.selected {
  border-color: var(--accent);
}
.avatar-preset-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

/* Tab panels */
.avatar-tab-panel {
  padding-top: 14px;
}

/* Crop stage */
.avatar-crop-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.avatar-crop-stage {
  position: relative;
  width: 256px;
  height: 256px;
  border-radius: 50%;
  overflow: hidden;
  touch-action: none;
  flex-shrink: 0;
}
#avatar-crop-canvas {
  cursor: grab;
  touch-action: none;
  user-select: none;
  display: block;
}
#avatar-crop-canvas:active {
  cursor: grabbing;
}
.avatar-crop-circle-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

/* Zoom controls */
.avatar-zoom-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  width: 256px;
}
.avatar-zoom-slider {
  flex: 1;
}
.avatar-zoom-btn {
  width: 32px;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
}

/* Crop preview */
.avatar-crop-preview-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.avatar-crop-preview {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: block;
  flex-shrink: 0;
}
.avatar-url-fallback-preview {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

/* Modal max-width */
#avatar-picker-modal {
  max-width: 480px;
}

/* Initials tab */
.avatar-initials-preview-wrap {
  display: flex;
  justify-content: center;
  padding: 8px 0 16px;
}
.avatar-initials-preview-circle {
  width: 80px !important;
  height: 80px !important;
  font-size: 2rem !important;
  transition: background 0.15s, color 0.15s;
}
.avatar-color-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.avatar-color-input {
  width: 44px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  cursor: pointer;
  background: none;
  flex-shrink: 0;
}
.avatar-color-input:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ═══════════════════════════════════════════════════════════
   QR Relay Modal
   ═══════════════════════════════════════════════════════════ */
.qr-relay-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.qr-relay-modal.hidden { display: none; }

.qr-relay-card {
  background: var(--surface, #fff);
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0,0,0,.22);
  width: 100%;
  max-width: 320px;
  overflow: hidden;
}

.qr-relay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 0;
}

.qr-relay-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: var(--text, #111);
}

.qr-relay-body {
  padding: 14px 20px 8px;
  text-align: center;
}

#qr-relay-canvas {
  display: inline-block;
  background: #fff;
  padding: 10px;
  border-radius: 8px;
  line-height: 0;
  margin-bottom: 12px;
}

#qr-relay-canvas img,
#qr-relay-canvas canvas {
  display: block;
}

.qr-relay-hint {
  font-size: .82rem;
  color: var(--text-muted, #666);
  margin: 0 0 8px;
  line-height: 1.45;
}

.qr-relay-status {
  font-size: .82rem;
  color: var(--text-muted, #888);
  margin: 0;
  min-height: 1.3em;
}


.qr-relay-footer {
  padding: 10px 16px 16px;
  display: flex;
  justify-content: flex-end;
}

/* Countdown timer inside QR modal */
.qr-relay-timer {
  font-size: 1.15rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary, #555);
  margin: 6px 0 0;
  letter-spacing: .03em;
  transition: color .2s;
}
.qr-relay-timer--expired {
  color: #d32f2f;
}

/* QR button (hidden by default; revealed by probe) */
.qr-btn {
  flex-shrink: 0;
  color: var(--text-muted, #666);
}
.qr-btn.hidden { display: none; }

/* QR buttons inside inline-save-row — match form-input height (36px), keep square */
.inline-save-row .qr-btn {
  height: auto;
  width: 36px;
  align-self: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
}
.inline-save-row .qr-btn:hover {
  background: var(--surface3);
  color: var(--text);
}

/* QR button inside gist-pat-input-row — match pat input height (42px) */
.gist-pat-input-row .qr-btn {
  height: 42px;
  width: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
}
.gist-pat-input-row .qr-btn:hover {
  background: var(--surface3);
  color: var(--text);
}


/* ═══════════════════════════════════════════════════════════
   Background Image Layers
   ═══════════════════════════════════════════════════════════ */

#bg-image-layer {
  position: fixed;
  inset: -5%;
  background-image: var(--bg-image, none);
  background-size: cover;
  background-position: top center;
  filter: blur(var(--bg-blur, 0px));
  pointer-events: none;
  z-index: -1;
  will-change: filter;
}

#bg-darken-layer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, var(--bg-darken, 0));
  pointer-events: none;
  z-index: -1;
}

/* When a bg image is active, make page/content-area backgrounds transparent
   so the fixed image layers show through the gaps between tiles. */
html.has-bg-image,
html.has-bg-image body,
html.has-bg-image .app-main {
  background: transparent;
}


/* ═══════════════════════════════════════════════════════════
   Background Image Settings UI
   ═══════════════════════════════════════════════════════════ */

.bg-image-preview {
  width: 100%;
  height: 160px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background-size: cover;
  background-position: top center;
}
.bg-image-preview.empty {
  background-color: var(--surface2);
}

.bg-image-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bg-image-url-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
.bg-url-input-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}
.bg-url-input-wrap .form-input {
  width: 100%;
  padding-right: 30px;
}
.bg-url-clear-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: var(--text-secondary);
  color: var(--surface1);
  cursor: pointer;
  padding: 0;
  opacity: 0.7;
  transition: opacity .15s;
}
.bg-url-clear-btn:hover { opacity: 1; }
.bg-url-clear-btn.hidden { display: none; }

/* Background image crop modal */
.bg-crop-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
}
.bg-crop-modal.hidden { display: none; }
.bg-crop-card {
  background: var(--surface1);
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0,0,0,.35);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.bg-crop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.bg-crop-title {
  font-size: calc(15px * var(--font-scale));
  font-weight: 600;
  margin: 0;
}
.bg-crop-container {
  aspect-ratio: 4/3;
  flex: none;
  width: 100%;
  overflow: hidden;
  position: relative;
  cursor: grab;
  user-select: none;
  background: #000;
}
.bg-crop-container:active { cursor: grabbing; }
.bg-crop-container img {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: 0 0;
  pointer-events: none;
}
.bg-crop-hint {
  text-align: center;
  font-size: calc(12px * var(--font-scale));
  color: var(--text-secondary);
  padding: 8px 16px 4px;
  flex-shrink: 0;
}
.bg-crop-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 10px 16px 14px;
  flex-shrink: 0;
}

.settings-subsection-label {
  font-size: calc(11px * var(--font-scale));
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin: 4px 0 0;
}

.settings-subsection-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 8px 0;
}

