/* ── Colour pickers (Settings note preview) ── */
.calendar-color-picker,
.theme-color-picker {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border: none;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  background: none;
  vertical-align: middle;
  margin-left: 6px;
  flex-shrink: 0;
  outline: none;
  /* overflow:hidden clips the browser's default square-cornered swatch frame to
     our circular shape on all platforms */
  overflow: hidden;
  /* Suppress any lingering focus ring — the box-shadow ring is the only border */
  -webkit-tap-highlight-color: transparent;
}

/* Suppress focus indicator; the box-shadow ring communicates the shape */
.calendar-color-picker:focus,
.theme-color-picker:focus {
  outline: none;
}

/* Calendar picker: smaller circle */
.calendar-color-picker {
  width: 20px;
  height: 20px;
  /* box-shadow ring is more reliable than pseudo-element borders across browsers */
  box-shadow: 0 0 0 1.5px var(--border);
}

/* Theme picker: slightly larger */
.theme-color-picker {
  width: 28px;
  height: 28px;
  box-shadow: 0 0 0 2px var(--border);
}

/* Chromium / Electron / Safari WebKit —————————————————————————————————————
   The swatch-wrapper defaults to padding:2px and has its own border, which
   produces a visible gap (inner ring) between the colour fill and the
   box-shadow outline ring.  Force it to fill the full input circle. */
.calendar-color-picker::-webkit-color-swatch-wrapper,
.theme-color-picker::-webkit-color-swatch-wrapper {
  padding: 0;
  border: none;
  border-radius: 50%;
  width: 100%;
  height: 100%;
}

.calendar-color-picker::-webkit-color-swatch,
.theme-color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
  /* Ensure the colour fill covers the full circle, no inner padding gap */
  width: 100%;
  height: 100%;
  min-height: unset;
}

/* Firefox ————————————————————————————————————————————————————————————————— */
.calendar-color-picker::-moz-color-swatch,
.theme-color-picker::-moz-color-swatch {
  border: none;
  border-radius: 50%;
}

.calendar-name-label {
  font-weight: 500;
}

.theme-label {
  font-weight: 500;
  min-width: 100px;
  display: inline-block;
}

.theme-reset-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 4px 12px;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  margin: 0;
}

.theme-reset-btn:hover {
  color: var(--text);
  background-color: var(--hover-overlay);
}
/* ── Text selection — themed to match accent ── */
::selection {
  background: var(--selection-bg);
  color: var(--selection-text);
}

/* ── Keyboard focus rings ─────────────────────────────────────────────────
   Visible only for keyboard navigation (:focus-visible) so mouse clicks
   stay un-ringed.  Covers the surfaces a keyboard user reaches most often:
   textareas, search inputs, toolbar buttons and sub-buttons.  Individual
   modules (editor.css, file-list.css) already opt out of the default
   :focus outline for the mouse case, so the ring below is the only one
   the user sees when tabbing in. */
textarea:focus-visible,
#searchBox:focus-visible,
#searchTasksBox:focus-visible,
#button-container button:focus-visible,
#tools-overflow-row button:focus-visible,
.sub-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Keyboard help overlay (triggered by `?`) ─────────────────────────────
   Modal-style backdrop + centred card.  Hidden by default via the `.hidden`
   class the JS adds on close. */
#help-overlay {
  position: fixed;
  inset: 0;
  background: var(--shadow);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gap);
  box-sizing: border-box;
}

#help-overlay.hidden {
  display: none;
}

#help-overlay-panel {
  background: var(--bg);
  color: var(--text);
  border-radius: 12px;
  padding: 18px 22px;
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 8px 32px var(--shadow);
  font-size: 14px;
}

#help-overlay-panel h2 {
  margin: 0.6em 0 0.4em;
  font-size: 1.05em;
}

#help-overlay-panel h2:first-child {
  margin-top: 0;
}

#help-overlay-panel table.help-shortcuts {
  border-collapse: collapse;
  width: 100%;
}

#help-overlay-panel table.help-shortcuts td {
  padding: 4px 8px;
  vertical-align: top;
}

#help-overlay-panel kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
  font-size: 0.9em;
  background: var(--surface);
  color: var(--text);
  white-space: nowrap;
}

#help-overlay-panel .help-syntax table {
  width: 100%;
  border-collapse: collapse;
}

#help-overlay-panel .help-syntax th,
#help-overlay-panel .help-syntax td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--surface);
  text-align: left;
}

#help-overlay-panel .help-hint {
  margin: 1em 0 0;
  font-size: 0.85em;
  color: var(--muted);
  text-align: center;
}

/* ── Windows High-Contrast / forced-colors mode ───────────────────────────
   Some custom components (checkbox, focus ring, buttons) draw themselves
   with background-image or box-shadow, which forced-colors hides.  Ask the
   UA to re-apply system colours so the app stays usable. */
@media (forced-colors: active) {
  textarea:focus-visible,
  #searchBox:focus-visible,
  #searchTasksBox:focus-visible,
  #button-container button:focus-visible,
  #tools-overflow-row button:focus-visible,
  .sub-button:focus-visible {
    outline: 2px solid Highlight;
  }

  /* Our custom checkboxes use ::after for the tick.  Forced-colors replaces
     backgrounds with system colours and hides the box-shadow/background
     fills — ensure the tick border is still visible. */
  #preview input[type="checkbox"]:checked::after,
  #todoList input[type="checkbox"]:checked::after,
  #schedule-container .schedule-item input[type="checkbox"]:checked::after,
  #global-search-panel input[type="checkbox"]:checked::after {
    border-color: CanvasText;
  }

  /* Links keep their underline in forced colors so they remain identifiable */
  a, a:visited { text-decoration: underline; }
}

/* ── Missing / broken internal links in preview ── */
#preview a.internal-link-new {
  color: var(--link-missing);
  text-decoration-style: dashed;
  text-decoration-color: var(--link-missing);
}

/* ── Checkbox theming — override browser defaults ── */
input[type="checkbox"] {
  accent-color: var(--checkbox-accent, currentColor);
}

/* ── Custom checkbox base — all interactive contexts.
   Inherit font so em/lh units scale with surrounding text. ── */
#preview input[type="checkbox"],
#todoList input[type="checkbox"],
#schedule-container .schedule-item input[type="checkbox"],
#global-search-panel input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  border: 0.1em solid var(--checkbox-border);
  background: var(--checkbox-bg);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background-color 0.1s ease, border-color 0.1s ease;
}

/* Checked state — shared */
#preview input[type="checkbox"]:checked,
#todoList input[type="checkbox"]:checked,
#schedule-container .schedule-item input[type="checkbox"]:checked,
#global-search-panel input[type="checkbox"]:checked {
  background: var(--checkbox-checked-bg);
  border-color: var(--checkbox-checked-bg);
}

/* Checkmark — identical geometry across all contexts */
#preview input[type="checkbox"]:checked::after,
#todoList input[type="checkbox"]:checked::after,
#schedule-container .schedule-item input[type="checkbox"]:checked::after,
#global-search-panel input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 26%;
  top: 7%;
  width: 28%;
  height: 57%;
  border: solid var(--bg);
  border-width: 0 0.14em 0.14em 0;
  transform: rotate(45deg);
}

/* Focus ring — shared */
#preview input[type="checkbox"]:focus-visible,
#todoList input[type="checkbox"]:focus-visible,
#schedule-container .schedule-item input[type="checkbox"]:focus-visible,
#global-search-panel input[type="checkbox"]:focus-visible {
  outline: 0.15em solid var(--checkbox-checked-bg);
  outline-offset: 0.1em;
}

/* Preview & todo: 1em square, rounded, aligned to text baseline */
#preview input[type="checkbox"],
#todoList input[type="checkbox"] {
  width: 1em;
  height: 1em;
  border-radius: 0.2em;
  vertical-align: middle;
  align-self: flex-start;
}

/* Schedule: 1em square, same rounding as preview/todo checkboxes */
#schedule-container .schedule-item input[type="checkbox"] {
  width: 1em;
  height: 1em;
  border-radius: 0.2em;
}

/* Search panel: slightly smaller to sit inline with the compact search row */
#global-search-panel input[type="checkbox"] {
  width: 0.85em;
  height: 0.85em;
  border-radius: 0.2em;
  vertical-align: middle;
}

/* ── Bookmarklet drag links (Settings note preview) ── */
.bookmarklet-controls {
  padding: 8px 0 4px;
}

.bookmarklet-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.bookmarklet-btn {
  display: inline-block;
  padding: 8px 16px;
  background: none;
  border: 1.5px dashed var(--accent);
  border-radius: 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  cursor: grab;
  user-select: none;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  -webkit-user-drag: element;
}

.bookmarklet-btn:hover {
  background-color: var(--hover-overlay);
  color: var(--text);
  border-color: var(--text);
  text-decoration: none;
}

.bookmarklet-btn:active {
  cursor: grabbing;
}

.bookmarklet-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}
