:root {
  /* Hirui theme (default/fallback) */
  --void: #130a1f;
  --violet: #2d1444;
  --violet-soft: #3c1d5c;
  --magenta: #5c2a5e;
  --gold: #c9a227;
  --gold-bright: #e6c866;
  --star: #ede3f5;
  --star-dim: #b8a6cf;

  --violet-accent: #9b6bd4;
  --magenta-accent: #d17bc4;
  --rose-accent: #d98a6b;

  --panel: rgba(45, 20, 68, 0.28);
  --panel-border: rgba(201, 162, 39, 0.35);
  --danger: #d9666a;
  --accent-tint: rgba(230, 200, 102, 0.16);
  --on-accent: var(--void);
  --shadow: none;

  --font-display: 'Cinzel Decorative', Georgia, serif;
  --font-heading: 'Cinzel', Georgia, serif;
  --font-body: 'Cormorant Garamond', Georgia, serif;
  --font-mono: var(--font-heading);
}

[data-theme="kyne"] {
  --void: #0f151b;
  --violet: #161d25;
  --violet-soft: #1c2530;
  --magenta: #1c2530;
  --gold: #4d7ba8;
  --gold-bright: #6fa3d1;
  --star: #cdd6de;
  --star-dim: #7c8996;

  --violet-accent: #c98a4b;
  --magenta-accent: #4f9e73;
  --rose-accent: #b5544c;

  --panel: #161d25;
  --panel-border: #2a3542;
  --danger: #b5544c;
  --accent-tint: rgba(111, 163, 209, 0.12);
  --on-accent: #0f151b;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);

  --font-display: 'Rajdhani', sans-serif;
  --font-heading: 'Rajdhani', sans-serif;
  --font-body: 'Roboto', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

[data-theme="sven"] {
  --void: #2a0e1c;
  --violet: #5c1a3d;
  --violet-soft: #7a2650;
  --magenta: #8f2f5e;
  --gold: #d4a017;
  --gold-bright: #f5c94f;
  --star: #fff3e0;
  --star-dim: #e0b8c9;

  --violet-accent: #e0559b;
  --magenta-accent: #ff8fc4;
  --rose-accent: #ff6f91;

  --panel: rgba(122, 38, 80, 0.28);
  --panel-border: rgba(212, 160, 23, 0.4);
  --danger: #d63b52;
  --accent-tint: rgba(245, 201, 79, 0.16);
  --on-accent: var(--void);
  --shadow: 0 0 16px rgba(245, 201, 79, 0.18);

  --font-display: 'Playfair Display', Georgia, serif;
  --font-heading: 'Marcellus SC', Georgia, serif;
  --font-body: 'EB Garamond', Georgia, serif;
  --font-mono: var(--font-heading);
}

/* Liri — GTA IV pause-menu look: neutral matte black and gray, a bold
   condensed poster face, orange as the one hot color cutting through it. */
[data-theme="liri"] {
  --void: #0c0c0c;
  --violet: #1a1a1a;
  --violet-soft: #242424;
  --magenta: #2c2c2c;
  --gold: #cc6a1f;
  --gold-bright: #ff9736;
  --star: #e8e8e8;
  --star-dim: #8a8a8a;

  --violet-accent: #6b7480;
  --magenta-accent: #a13a2e;
  --rose-accent: #c9762e;

  --panel: rgba(255, 255, 255, 0.04);
  --panel-border: rgba(255, 255, 255, 0.12);
  --danger: #c0392b;
  --accent-tint: rgba(255, 151, 54, 0.16);
  --on-accent: var(--void);
  --shadow: none;

  --font-display: 'Bebas Neue', sans-serif;
  --font-heading: 'Oswald', sans-serif;
  --font-body: 'Roboto', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* Loydiie — rainbow neon theme: near-black glass, glowing multicolor
   accents, in place of Hirui's gothic dark or Kyne's cool tech look. */
[data-theme="loydiie"] {
  --void: #0a0014;
  --violet: #120022;
  --violet-soft: #1a0033;
  --magenta: #1a0033;
  --gold: #ff2ec4;
  --gold-bright: #00e5ff;
  --star: #f3f0ff;
  --star-dim: #9a86d6;

  --violet-accent: #b026ff;
  --magenta-accent: #ff2ec4;
  --rose-accent: #fff01f;

  --panel: rgba(24, 0, 46, 0.55);
  --panel-border: rgba(0, 229, 255, 0.35);
  --danger: #ff3860;
  --accent-tint: rgba(0, 229, 255, 0.16);
  --on-accent: #0a0014;
  --shadow: 0 0 10px rgba(255, 46, 196, 0.3), 0 0 26px rgba(0, 229, 255, 0.16);

  --font-display: 'Orbitron', sans-serif;
  --font-heading: 'Orbitron', sans-serif;
  --font-body: 'Rajdhani', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* Thanouf — cultist ritual theme: bleaker, blacker void than Hirui's gothic
   base, with a bruised amethyst glow standing in for gold, and blood/moss/
   bone tones for the note-tag colors instead of a warm palette. */
[data-theme="thanouf"] {
  --void: #050108;
  --violet: #150a24;
  --violet-soft: #200f36;
  --magenta: #240f1c;
  --gold: #6b21a8;
  --gold-bright: #b565f0;
  --star: #e6d9fb;
  --star-dim: #6d5a89;

  --violet-accent: #b8324a;
  --magenta-accent: #5a8f4f;
  --rose-accent: #c9a876;

  --panel: rgba(21, 10, 36, 0.45);
  --panel-border: rgba(181, 101, 240, 0.3);
  --danger: #b8324a;
  --accent-tint: rgba(181, 101, 240, 0.16);
  --on-accent: #f5eaff;
  --shadow: 0 0 20px rgba(107, 33, 168, 0.35);

  --font-display: 'Pirata One', 'Cinzel Decorative', Georgia, serif;
  --font-heading: 'Cinzel', Georgia, serif;
  --font-body: 'Cormorant Garamond', Georgia, serif;
  --font-mono: var(--font-heading);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.theme-variant {
  display: none;
}

[data-theme="hiru"] .theme-variant--hiru,
:root:not([data-theme]) .theme-variant--hiru {
  display: block;
}

[data-theme="kyne"] .theme-variant--kyne {
  display: block;
}

[data-theme="loydiie"] .theme-variant--loydiie {
  display: block;
}

[data-theme="sven"] .theme-variant--sven {
  display: block;
}

[data-theme="liri"] .theme-variant--liri {
  display: block;
}

[data-theme="thanouf"] .theme-variant--thanouf {
  display: block;
}

html, body {
  height: 100%;
}

/* Firefox: theme the scrollbars (the ::-webkit-scrollbar rules below are Chromium-only). */
html {
  scrollbar-color: var(--panel-border) transparent;
  scrollbar-width: thin;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 17px;
  color: var(--star);
  background: radial-gradient(ellipse at 50% -10%, var(--violet-soft) 0%, var(--void) 55%);
  /* No `background-attachment: fixed` here: body already has
     `overflow: hidden` below, so body itself never scrolls — there's
     nothing for "fixed" to hold still against. It was a no-op on desktop
     but a known trigger for repaint/ghosting glitches on mobile Chrome
     (worse layered under .panel's backdrop-filter blur), which is what
     the offset "double" panel in a phone screenshot turned out to be. */
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  transition: background 0.2s ease, color 0.2s ease;
}

#stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem 1rem 1rem;
}

.topbar__sigil {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
}

.topbar__title {
  position: relative;
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.3rem, 4.2vw, 2.1rem);
  letter-spacing: 0.06em;
  text-wrap: balance;
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 55%, #8a6a1a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.topbar__title span {
  -webkit-text-fill-color: initial;
  background: linear-gradient(180deg, var(--star) 0%, var(--star-dim) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.topbar__clock {
  position: absolute;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-heading);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--star-dim);
}

.topbar__user {
  position: absolute;
  left: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-heading);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--star-dim);
}

@media (max-width: 640px) {
  .topbar__user, .topbar__clock {
    position: static;
    transform: none;
  }

  /* Stack top-to-bottom (title, then account controls, then clock)
     instead of packing everything into one row and wrapping whatever
     doesn't fit. Wrapping alone wasn't enough: .topbar__user is a single
     flex item holding four controls (theme select, username, admin,
     sign out) with no wrap of its own, so on a narrow phone it — not its
     individual buttons — was the thing overflowing, spilling off both
     edges of the screen once centered. */
  .topbar {
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.9rem 0.75rem 0.6rem;
  }

  .topbar__user {
    flex-wrap: wrap;
    justify-content: center;
    order: 2;
  }

  /* The phone's own status bar already shows the time (see any phone
     screenshot of this page) — a second clock here is pure vertical
     chrome competing with the note for space, not information the app
     alone provides. */
  .topbar__clock {
    display: none;
  }
}

.divider {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0 1.25rem 0.75rem;
  color: var(--gold);
}

.divider .line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold) 50%, transparent);
  opacity: 0.55;
}

.divider .mark {
  font-size: 13px;
  opacity: 0.85;
  transform: rotate(45deg);
}

.layout {
  position: relative;
  z-index: 2;
  flex: 1;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1rem;
  padding: 0 1.25rem 1.25rem;
  min-height: 0;
}

.editor__back-mobile {
  display: none;
}

@media (max-width: 720px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }

  /* Phone-width only: show the note list OR the open note, never both
     stacked — avoids scrolling past the whole list to reach the editor. */
  .layout.layout--note-selected .sidebar {
    display: none;
  }

  .layout:not(.layout--note-selected) .editor {
    display: none;
  }

  .editor__back-mobile {
    display: inline-flex;
  }
}

.panel {
  position: relative;
  background: linear-gradient(160deg, rgba(92, 42, 94, 0.22), rgba(45, 20, 68, 0.22));
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow);
}

.panel::before, .panel::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1px solid var(--gold);
  opacity: 0.65;
  pointer-events: none;
}

.panel::before { top: -1px; left: -1px; border-right: none; border-bottom: none; }
.panel::after  { bottom: -1px; right: -1px; border-left: none; border-top: none; }

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.9rem;
  min-height: 0;
}

.sidebar__controls {
  display: flex;
  gap: 0.5rem;
}

#search-input {
  flex: 1;
  min-width: 0;
}

input, textarea {
  background: rgba(19, 10, 31, 0.55);
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  color: var(--star);
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 0.5rem 0.65rem;
  outline: none;
}

input::placeholder, textarea::placeholder {
  color: var(--star-dim);
  opacity: 0.8;
}

input:focus, textarea:focus {
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 2px var(--accent-tint);
}

.btn {
  display: inline-block;
  cursor: pointer;
  font-family: var(--font-heading);
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--on-accent);
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  padding: 0.55rem 1rem;
  border-radius: 2px;
  border: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.15s ease;
  box-shadow: 0 0 0 rgba(230, 200, 102, 0);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(230, 200, 102, 0.25);
}

.btn--ghost {
  background: transparent;
  color: var(--gold-bright);
  border: 1px solid var(--gold);
}

.btn--danger {
  color: var(--danger);
  border-color: var(--danger);
}

.btn--danger:hover {
  box-shadow: 0 6px 18px rgba(217, 102, 106, 0.25);
}

.tag-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  cursor: pointer;
  font-family: var(--font-heading);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.3rem 0.65rem;
  border-radius: 2px;
  border: 1px solid rgba(201, 162, 39, 0.4);
  background: transparent;
  color: var(--gold);
}

.chip--active {
  background: var(--accent-tint);
  color: var(--gold-bright);
  border-color: var(--gold-bright);
}

.note-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-right: 0.15rem;
}

.note-list__empty {
  color: var(--star-dim);
  text-align: center;
  padding: 2rem 0.5rem;
  font-style: italic;
}

.note-card {
  background: rgba(19, 10, 31, 0.5);
  border: 1px solid var(--panel-border);
  border-left: 3px solid var(--gold);
  border-radius: 3px;
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
}

.note-card:hover {
  transform: translateX(2px);
  box-shadow: 0 0 12px rgba(201, 162, 39, 0.25);
}

.note-card--active {
  box-shadow: 0 0 14px rgba(230, 200, 102, 0.35);
  border-color: var(--gold-bright);
}

.note-card--gold    { border-left-color: var(--gold-bright); }
.note-card--violet  { border-left-color: var(--violet-accent); }
.note-card--magenta { border-left-color: var(--magenta-accent); }
.note-card--rose    { border-left-color: var(--rose-accent); }
.note-card--star    { border-left-color: var(--star); }

.note-card__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.note-card__title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-card__pin {
  background: none;
  border: none;
  color: var(--gold-bright);
  padding: 0;
  font-size: 1rem;
  cursor: pointer;
}

.note-card__snippet {
  color: var(--star-dim);
  font-size: 0.9rem;
  margin: 0.35rem 0;
}

.note-card__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-heading);
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--star-dim);
}

.note-card__delete {
  background: none;
  border: none;
  color: var(--star-dim);
  padding: 0;
  cursor: pointer;
  font-family: var(--font-body);
}

.note-card__delete:hover {
  color: var(--danger);
}

.editor {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 1.25rem;
}

@media (max-width: 720px) {
  /* Every rem of padding here is a rem the textarea below the toolbars
     doesn't get, and on a phone — especially with the keyboard up — that
     trade isn't worth it. */
  .editor {
    padding: 0.75rem;
  }
}

.editor__empty {
  margin: auto;
  color: var(--star-dim);
  font-family: var(--font-heading);
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.editor__form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
  height: 100%;
}

.editor__title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--panel-border);
  border-radius: 0;
  color: var(--gold-bright);
  padding: 0.25rem 0.1rem 0.5rem;
}

.editor__toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.color-picker {
  display: flex;
  gap: 0.4rem;
}

.swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  padding: 0;
  border: 1px solid rgba(237, 227, 245, 0.4);
  cursor: pointer;
}

.swatch--active {
  box-shadow: 0 0 0 2px var(--star), 0 0 8px currentColor;
}

.swatch--gold    { background: var(--gold-bright); }
.swatch--violet  { background: var(--violet-accent); }
.swatch--magenta { background: var(--magenta-accent); }
.swatch--rose    { background: var(--rose-accent); }
.swatch--star    { background: var(--star); }

.swatch--custom {
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
  color: var(--void);
  font-size: 11px;
  line-height: 16px;
  text-align: center;
}

.colorpicker {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.colorpicker__wheel-wrap,
.colorpicker__bar-wrap {
  position: relative;
}

.colorpicker__wheel {
  border-radius: 50%;
  cursor: crosshair;
  display: block;
  touch-action: none;
}

.colorpicker__thumb {
  position: absolute;
  top: 0;
  left: 0;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.colorpicker__bar {
  border-radius: 4px;
  cursor: pointer;
  display: block;
  touch-action: none;
}

.colorpicker__bar-thumb {
  position: absolute;
  top: 0;
  left: -3px;
  right: -3px;
  height: 4px;
  border: 2px solid #fff;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  transform: translateY(-50%);
}

.colorpicker__preview {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  flex-shrink: 0;
}

.colorpicker__fields {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.colorpicker__field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-family: var(--font-heading);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--star-dim);
}

.colorpicker__field input {
  width: 70px;
}

.colorpicker__field--hex input {
  width: 100px;
  text-transform: none;
}

.editor__tags {
  flex: 1;
  min-width: 120px;
  /* Anything below 16px makes iOS/Android auto-zoom the whole page on
     focus, forcing a manual pinch back out — this field was the one
     writing-flow input still under that threshold. */
  font-size: 1rem;
}

.save-status {
  font-family: var(--font-heading);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--star-dim);
  font-style: italic;
  min-width: 70px;
}

.editor__presence {
  font-size: 0.75rem;
  color: var(--gold-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.editor__preview {
  margin-left: auto;
}

.editor__shared-banner {
  font-family: var(--font-heading);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--star-dim);
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  padding: 0.35rem 0.6rem;
  margin-bottom: 0.5rem;
}

.editor__share-hint {
  font-size: 0.75rem;
  color: var(--star-dim);
  margin: 0;
}

.editor__share-link {
  flex: 1;
  min-width: 160px;
  font-size: 1rem; /* same auto-zoom-on-focus reason as .editor__tags above */
}

.editor__attachments {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 140px;
  overflow-y: auto;
  flex-shrink: 0;
}

.editor__attachments-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.editor__attachments-title {
  font-family: var(--font-heading);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--star-dim);
  margin-right: auto;
}

.attachment-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.attachment-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  padding: 0.2rem 0;
}

.attachment-row__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--gold-bright);
  text-decoration: none;
}

.attachment-row__name:hover {
  text-decoration: underline;
}

.attachment-row__size {
  color: var(--star-dim);
  font-size: 0.75rem;
  white-space: nowrap;
}

.attachment-row__remove {
  background: none;
  border: none;
  color: var(--star-dim);
  cursor: pointer;
  padding: 0 0.2rem;
  font-size: 0.9rem;
}

.attachment-row__remove:hover {
  color: var(--danger);
}

.editor__content {
  flex: 1;
  resize: none;
  font-size: 1.05rem;
  line-height: 1.6;
  min-height: 200px;
}

.editor__field-wrap {
  position: relative;
}

.editor__field-wrap--grow {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Other people's live cursor position, overlaid on top of the plain
   textarea/input — a native <textarea> can't host DOM children inside its
   text, so this is positioned via a hidden "mirror" element that copies the
   field's exact text layout and reports where that offset lands on screen. */
.remote-cursor {
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  pointer-events: none;
  transition: top 0.1s linear, left 0.1s linear;
}

.remote-cursor__flag {
  position: absolute;
  top: -1.1em;
  left: 0;
  font-family: var(--font-heading);
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
  padding: 0.05em 0.35em;
  border-radius: 2px;
  color: var(--void);
  transform: translateX(-2px);
}

.editor__format-toolbar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.editor__format-toolbar .btn {
  padding: 0.35rem 0.6rem;
  min-width: 2rem;
}

.editor__md-preview-toggle {
  margin-left: auto;
}

@media (max-width: 720px) {
  /* .editor__toolbar and .editor__format-toolbar carry ~15 controls
     between them (color swatches, tags, share/delete, bold/italic/
     heading/lists/link, font & size pickers, checklist, preview). Left to
     wrap, that's 4-5 stacked rows of chrome standing between "open a note"
     and "see the textarea" — on a phone, with the on-screen keyboard then
     eating another third of the viewport, there's barely a line of the
     actual note left to type into. Scroll them horizontally instead:
     everything stays reachable, but the content field claims the vertical
     space right under the title.
     This has to come after the base rules above (not in the earlier
     phone-breakpoint block near .layout) — same selector, same
     specificity, so source order alone decides the winner, and a rule
     placed before flex-wrap: wrap loses to it even inside a matching
     media query. */
  .editor__toolbar,
  .editor__format-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.3rem;
  }

  .editor__toolbar > *,
  .editor__format-toolbar > * {
    flex-shrink: 0;
  }

  .editor__md-preview-toggle {
    margin-left: 0;
  }
}

.editor__content-preview {
  flex: 1;
  min-height: 200px;
  overflow-y: auto;
  padding: 0.6rem 0.1rem;
  line-height: 1.6;
}

.editor__content-preview h1,
.editor__content-preview h2,
.editor__content-preview h3 {
  font-family: var(--font-heading);
  color: var(--gold-bright);
  margin: 0.6em 0 0.3em;
}

.editor__content-preview p {
  margin: 0 0 0.75em;
}

.editor__content-preview ul,
.editor__content-preview ol {
  margin: 0 0 0.75em;
  padding-left: 1.4em;
}

.editor__content-preview li {
  margin: 0.2em 0;
}

.editor__content-preview li > ul,
.editor__content-preview li > ol {
  margin: 0.2em 0;
}

.editor__content-preview li.task-list-item {
  list-style: none;
}

.editor__content-preview li.task-list-item input[type="checkbox"] {
  margin-right: 0.4em;
}

.editor__content-preview code {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 2px;
  padding: 0.1em 0.3em;
  font-family: var(--font-mono, monospace);
}

.editor__content-preview pre code {
  display: block;
  padding: 0.6em;
  overflow-x: auto;
}

.editor__content-preview blockquote {
  border-left: 2px solid var(--panel-border);
  margin: 0 0 0.75em;
  padding-left: 0.75em;
  color: var(--star-dim);
}

.editor__content-preview a {
  color: var(--gold-bright);
}

.editor__content-checklist {
  flex: 1;
  min-height: 200px;
  overflow-y: auto;
  padding: 0.6rem 0.1rem;
}

.checklist {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.checklist__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.15);
}

.checklist__checkbox-wrap {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* The visible checkbox stays small (matches the text); the label's
     padding pads out the *tappable* area without changing how it looks.
     Kept modest (not the full ~44px target) so the padded hit area of one
     row doesn't bleed into its neighbor across the list's 0.35rem gap. */
  padding: 0.5rem;
  margin: -0.5rem;
  cursor: pointer;
}

.checklist__checkbox {
  flex: none;
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--gold-bright);
}

.checklist__text,
.checklist__text-input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--star);
}

.checklist__text {
  word-break: break-word;
}

.checklist__item--checked .checklist__text {
  color: var(--star-dim);
  text-decoration: line-through;
}

.checklist__text-input {
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  padding: 0.4rem 0;
}

.checklist__text-input:focus {
  outline: none;
  border-bottom-color: var(--gold-bright);
}

.checklist__remove {
  flex: none;
  background: none;
  border: none;
  color: var(--star-dim);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.55rem;
  margin: -0.2rem -0.3rem -0.2rem 0;
  min-width: 2.2rem;
  min-height: 2.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.checklist__remove:hover {
  color: var(--danger);
}

.checklist__empty {
  color: var(--star-dim);
  font-style: italic;
  padding: 0.5rem;
}

.checklist__add-row {
  margin-top: 0.5rem;
}

.checklist__add-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px dashed var(--panel-border);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  color: var(--star);
  font-family: var(--font-body);
  font-size: 1rem; /* was 0.95rem — too close to the 16px auto-zoom floor */
}

.checklist__add-input:focus {
  outline: none;
  border-color: var(--gold-bright);
  border-style: solid;
}

@media (max-width: 480px) {
  /* Roomier rows and bigger tap targets once a mouse pointer is no longer
     the assumption — thumbs need more room than a cursor does. */
  .checklist {
    gap: 0.55rem;
  }

  .checklist__item {
    padding: 0.5rem 0.6rem;
  }

  .checklist__checkbox {
    width: 1.3rem;
    height: 1.3rem;
  }

  .checklist__remove {
    font-size: 1.05rem;
  }

  .checklist__add-input {
    padding: 0.6rem 0.7rem;
  }
}

/* Fixed, sanitizer-safe formatting classes the toolbar inserts — never raw
   inline `style`, since CSS values inside a style attribute aren't reliably
   vetted for injection by the sanitizer even though the markup itself is. */
.md-size-sm  { font-size: 0.8em; }
.md-size-lg  { font-size: 1.3em; }
.md-size-xl  { font-size: 1.8em; }
.md-font-serif   { font-family: Georgia, 'Times New Roman', serif; }
.md-font-sans    { font-family: Arial, Helvetica, sans-serif; }
.md-font-mono    { font-family: 'JetBrains Mono', monospace; }
.md-font-cursive { font-family: 'Brush Script MT', cursive; }

/* Theme switcher — a dropdown so more themes can be added without crowding the UI */
.theme-select {
  cursor: pointer;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: rgba(19, 10, 31, 0.4);
  color: var(--star-dim);
  font-family: var(--font-heading);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.3rem 1.6rem 0.3rem 0.7rem;
  outline: none;
  transition: border-color 0.15s ease, color 0.15s ease;
}

@media (max-width: 720px) {
  /* This select is used both as the small decorative theme picker and as
     the font/size pickers inside the format toolbar — its 0.65rem
     (~11px) is well under the 16px floor that keeps iOS/Android from
     auto-zooming the page on focus. Scoped to mobile rather than changed
     globally so the compact pill look in the topbar is untouched on
     desktop, where nothing auto-zooms anyway. */
  .theme-select {
    font-size: 1rem;
  }
}

.theme-select:hover,
.theme-select:focus {
  border-color: var(--gold-bright);
  color: var(--gold-bright);
}

.theme-select option {
  background: var(--void);
  color: var(--star);
  text-transform: none;
  letter-spacing: 0;
}

.auth-theme-switch {
  display: flex;
  justify-content: center;
  margin-bottom: 1.25rem;
}

/* Auth screen */
.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  padding: 2.25rem 2rem 2rem;
  text-align: center;
  background: linear-gradient(160deg, rgba(92, 42, 94, 0.3), rgba(45, 20, 68, 0.3));
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow);
}

.auth-card::before, .auth-card::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 1px solid var(--gold);
  opacity: 0.7;
}

.auth-card::before { top: -1px; left: -1px; border-right: none; border-bottom: none; }
.auth-card::after  { bottom: -1px; right: -1px; border-left: none; border-top: none; }

.auth-sigil {
  width: 72px;
  height: 72px;
  margin: 0 auto 1.25rem;
}

.auth-title {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.3rem, 8vw, 2rem);
  text-wrap: balance;
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 55%, #8a6a1a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.auth-subtitle {
  margin: 0 0 1.5rem;
  font-family: var(--font-heading);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--star-dim);
}

.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.auth-tab {
  flex: 1;
  cursor: pointer;
  background: transparent;
  border: 1px solid rgba(201, 162, 39, 0.3);
  color: var(--star-dim);
  font-family: var(--font-heading);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.55rem 0.5rem;
  border-radius: 2px;
}

.auth-tab--active {
  color: var(--gold-bright);
  border-color: var(--gold-bright);
  background: var(--accent-tint);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.auth-form input {
  text-align: center;
}

.auth-form .btn {
  margin-top: 0.25rem;
}

.auth-error {
  min-height: 1.1rem;
  font-family: var(--font-heading);
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  color: var(--danger);
}

.app-root {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.toast-stack {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 100;
}

.toast {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  background: rgba(19, 10, 31, 0.92);
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  padding: 0.6rem 0.9rem;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s, transform 0.3s;
}

.toast--in {
  opacity: 1;
  transform: translateY(0);
}

.toast--error {
  border-color: var(--danger);
  color: #f0a3a6;
}

.toast--info {
  border-color: var(--gold);
  color: var(--gold-bright);
}

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-thumb {
  background: var(--panel-border);
  border-radius: 4px;
}

/* Admin panel */
.admin-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(8, 4, 14, 0.55);
  backdrop-filter: blur(2px);
}

.admin-modal {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.5rem;
  background: linear-gradient(160deg, rgba(92, 42, 94, 0.35), rgba(19, 10, 31, 0.92));
}

.admin-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.admin-modal__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--gold-bright);
}

.admin-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.admin-field {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-heading);
  font-size: 0.85rem;
}

.admin-field__label {
  color: var(--star-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.7rem;
}

.admin-field__value {
  color: var(--star);
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--panel-border);
}

.admin-form h3 {
  margin: 0 0 0.15rem;
  font-family: var(--font-heading);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--star-dim);
}

.admin-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}

.admin-row--split {
  justify-content: space-between;
}

.admin-import-label {
  cursor: pointer;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.admin-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.6rem 0.3rem;
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  background: rgba(19, 10, 31, 0.4);
}

.admin-stat__value {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--gold-bright);
}

.admin-stat__label {
  font-family: var(--font-heading);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--star-dim);
}

.admin-trash-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 220px;
  overflow-y: auto;
}

.admin-trash-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-rows: auto auto;
  gap: 0.25rem 0.6rem;
  align-items: center;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  background: rgba(19, 10, 31, 0.4);
}

.admin-trash-row__title {
  grid-column: 1 / -1;
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--star);
}

.admin-trash-row__meta {
  font-size: 0.7rem;
  color: var(--star-dim);
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 180px;
  overflow-y: auto;
}

.admin-list-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  background: rgba(19, 10, 31, 0.4);
}

.admin-list-row__actions {
  display: flex;
  gap: 0.4rem;
  margin-left: auto;
}

.admin-list-row__title {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--star);
}

.admin-list-row__meta {
  font-size: 0.7rem;
  color: var(--star-dim);
  white-space: nowrap;
}

[data-theme="kyne"] .admin-overlay {
  background: rgba(22, 35, 47, 0.35);
}

[data-theme="kyne"] .admin-modal {
  background: var(--panel);
  border-radius: 12px;
}

[data-theme="kyne"] .admin-modal::before,
[data-theme="kyne"] .admin-modal::after {
  content: none;
}

[data-theme="kyne"] .admin-stat,
[data-theme="kyne"] .admin-trash-row,
[data-theme="kyne"] .admin-list-row {
  background: var(--violet-soft);
  border-color: var(--panel-border);
  border-radius: 8px;
}

[data-theme="kyne"] .admin-field__label,
[data-theme="kyne"] .admin-form h3,
[data-theme="kyne"] .admin-stat__label {
  text-transform: none;
  letter-spacing: 0;
}

/* ============================================================
   Kyne theme overrides — clean light "tech dashboard" look,
   in place of Hirui's gold/violet celestial styling.
   ============================================================ */

[data-theme="kyne"] body {
  background: var(--void);
}

[data-theme="kyne"] .topbar__title,
[data-theme="kyne"] .auth-title {
  background: none;
  -webkit-text-fill-color: initial;
  color: var(--star);
  letter-spacing: 0;
}

[data-theme="kyne"] .topbar__title span {
  background: none;
  -webkit-text-fill-color: initial;
  color: var(--gold-bright);
}

[data-theme="kyne"] .topbar__clock,
[data-theme="kyne"] .save-status {
  font-family: var(--font-mono);
}

[data-theme="kyne"] .divider {
  display: none;
}

[data-theme="kyne"] .layout {
  margin-top: 1rem;
}

[data-theme="kyne"] .panel,
[data-theme="kyne"] .auth-card {
  background: var(--panel);
  backdrop-filter: none;
  border-radius: 12px;
}

[data-theme="kyne"] .panel::before,
[data-theme="kyne"] .panel::after,
[data-theme="kyne"] .auth-card::before,
[data-theme="kyne"] .auth-card::after {
  content: none;
}

[data-theme="kyne"] input,
[data-theme="kyne"] textarea {
  background: var(--violet-soft);
  color: var(--star);
}

[data-theme="kyne"] .btn {
  background: var(--gold-bright);
  border-radius: 8px;
  box-shadow: none;
}

[data-theme="kyne"] .btn:hover {
  background: var(--gold);
  transform: none;
  box-shadow: none;
}

[data-theme="kyne"] .btn--ghost {
  background: transparent;
  color: var(--star);
  border-color: var(--panel-border);
}

[data-theme="kyne"] .btn--ghost:hover {
  background: var(--violet-soft);
}

[data-theme="kyne"] .btn--danger {
  color: var(--danger);
  border-color: var(--danger);
}

[data-theme="kyne"] .chip {
  border-color: var(--panel-border);
  border-radius: 8px;
}

[data-theme="kyne"] .note-card {
  background: var(--panel);
  box-shadow: var(--shadow);
  border-radius: 8px;
}

[data-theme="kyne"] .note-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(111, 163, 209, 0.18);
}

[data-theme="kyne"] .note-card--active {
  box-shadow: 0 0 0 2px rgba(111, 163, 209, 0.3);
}

[data-theme="kyne"] .note-card__pin {
  color: var(--violet-accent);
}

[data-theme="kyne"] .swatch {
  border-color: rgba(205, 214, 222, 0.15);
}

[data-theme="kyne"] .auth-tab {
  border-color: var(--panel-border);
}

[data-theme="kyne"] .toast {
  background: var(--violet-soft);
  color: var(--star);
  box-shadow: var(--shadow);
}

[data-theme="kyne"] .toast--error {
  color: var(--danger);
}

[data-theme="kyne"] .toast--info {
  color: var(--gold);
}

[data-theme="kyne"] .topbar__clock,
[data-theme="kyne"] .topbar__user,
[data-theme="kyne"] .btn,
[data-theme="kyne"] .chip,
[data-theme="kyne"] .note-card__title,
[data-theme="kyne"] .note-card__meta,
[data-theme="kyne"] .editor__empty,
[data-theme="kyne"] .save-status,
[data-theme="kyne"] .auth-tab,
[data-theme="kyne"] .auth-subtitle,
[data-theme="kyne"] .theme-select {
  text-transform: none;
  letter-spacing: 0;
}

[data-theme="kyne"] .theme-select {
  border-radius: 8px;
}

/* ============================================================
   Loydiie theme overrides — rainbow neon look: near-black glass
   panels, glowing multicolor borders and text, a pulsing ring
   sigil. Electric counterpoint to Hirui's gothic dark and Kyne's
   cool tech style.
   ============================================================ */

[data-theme="loydiie"] body {
  background:
    radial-gradient(ellipse at 15% 0%, rgba(176, 38, 255, 0.25) 0%, transparent 45%),
    radial-gradient(ellipse at 85% 15%, rgba(0, 229, 255, 0.2) 0%, transparent 45%),
    radial-gradient(ellipse at 50% 100%, rgba(255, 46, 196, 0.18) 0%, transparent 55%),
    var(--void);
}

@keyframes loydiie-rainbow-shift {
  to { background-position: 300% center; }
}

[data-theme="loydiie"] .topbar__title,
[data-theme="loydiie"] .topbar__title span,
[data-theme="loydiie"] .auth-title {
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, #00e5ff, #b026ff, #ff2ec4, #fff01f, #39ff14, #00e5ff);
  background-size: 300% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: loydiie-rainbow-shift 7s linear infinite;
}

[data-theme="loydiie"] .topbar__title span {
  animation-delay: -3.5s;
}

@media (prefers-reduced-motion: reduce) {
  [data-theme="loydiie"] .topbar__title,
  [data-theme="loydiie"] .topbar__title span,
  [data-theme="loydiie"] .auth-title {
    animation: none;
  }
}

[data-theme="loydiie"] .topbar__clock,
[data-theme="loydiie"] .save-status {
  font-family: var(--font-mono);
}

[data-theme="loydiie"] .divider {
  display: none;
}

[data-theme="loydiie"] .layout {
  margin-top: 1rem;
}

[data-theme="loydiie"] .panel,
[data-theme="loydiie"] .auth-card,
[data-theme="loydiie"] .admin-modal {
  background: var(--panel);
  backdrop-filter: blur(10px);
  border-radius: 14px;
  border-width: 1px;
  box-shadow: var(--shadow);
}

[data-theme="loydiie"] .panel::before,
[data-theme="loydiie"] .panel::after,
[data-theme="loydiie"] .auth-card::before,
[data-theme="loydiie"] .auth-card::after {
  content: none;
}

[data-theme="loydiie"] input,
[data-theme="loydiie"] textarea {
  background: rgba(10, 0, 20, 0.6);
  border-radius: 8px;
  border-color: var(--panel-border);
}

[data-theme="loydiie"] input:focus,
[data-theme="loydiie"] textarea:focus {
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 2px var(--accent-tint), 0 0 14px rgba(0, 229, 255, 0.35);
}

[data-theme="loydiie"] .btn {
  background: linear-gradient(135deg, var(--gold-bright), var(--violet-accent) 50%, var(--gold));
  border-radius: 8px;
  color: var(--on-accent);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.3), 0 0 10px rgba(255, 46, 196, 0.2);
}

[data-theme="loydiie"] .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.55), 0 0 20px rgba(255, 46, 196, 0.4);
}

[data-theme="loydiie"] .btn--ghost {
  background: transparent;
  color: var(--gold-bright);
  border-color: var(--gold-bright);
  box-shadow: none;
}

[data-theme="loydiie"] .btn--ghost:hover {
  background: var(--accent-tint);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.4);
}

[data-theme="loydiie"] .btn--danger {
  color: var(--danger);
  border-color: var(--danger);
}

[data-theme="loydiie"] .btn--danger:hover {
  box-shadow: 0 0 12px rgba(255, 56, 96, 0.5);
}

[data-theme="loydiie"] .chip {
  border-radius: 999px;
  border-color: var(--panel-border);
  color: var(--gold-bright);
}

[data-theme="loydiie"] .chip--active {
  background: var(--accent-tint);
  color: var(--gold-bright);
  border-color: var(--gold-bright);
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.4);
}

[data-theme="loydiie"] .note-card {
  background: var(--panel);
  border-radius: 10px;
  border-left-width: 3px;
  box-shadow: none;
}

[data-theme="loydiie"] .note-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 16px currentColor;
}

[data-theme="loydiie"] .note-card--active {
  box-shadow: 0 0 0 1px var(--gold-bright), 0 0 16px rgba(0, 229, 255, 0.45);
}

[data-theme="loydiie"] .note-card--gold    { color: var(--gold-bright); }
[data-theme="loydiie"] .note-card--violet  { color: var(--violet-accent); }
[data-theme="loydiie"] .note-card--magenta { color: var(--magenta-accent); }
[data-theme="loydiie"] .note-card--rose    { color: var(--rose-accent); }
[data-theme="loydiie"] .note-card--star    { color: #39ff14; border-left-color: #39ff14; }

[data-theme="loydiie"] .note-card__pin {
  color: var(--rose-accent);
}

[data-theme="loydiie"] .swatch {
  border-color: rgba(243, 240, 255, 0.25);
}

[data-theme="loydiie"] .swatch--star { background: #39ff14; }

[data-theme="loydiie"] .swatch--active {
  box-shadow: 0 0 0 2px var(--void), 0 0 10px currentColor;
}

[data-theme="loydiie"] .auth-tab {
  border-color: var(--panel-border);
  border-radius: 8px;
}

[data-theme="loydiie"] .auth-tab--active {
  background: var(--accent-tint);
  border-color: var(--gold-bright);
  color: var(--gold-bright);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.35);
}

[data-theme="loydiie"] .theme-select {
  border-radius: 8px;
}

[data-theme="loydiie"] .toast {
  background: rgba(18, 0, 34, 0.92);
  color: var(--star);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

[data-theme="loydiie"] .toast--error {
  color: #ff8fa8;
  border-color: var(--danger);
  box-shadow: 0 0 12px rgba(255, 56, 96, 0.4);
}

[data-theme="loydiie"] .toast--info {
  color: var(--gold-bright);
  border-color: var(--gold-bright);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.35);
}

[data-theme="loydiie"] .admin-overlay {
  background: rgba(5, 0, 12, 0.7);
}

[data-theme="loydiie"] .admin-modal::before,
[data-theme="loydiie"] .admin-modal::after {
  content: none;
}

[data-theme="loydiie"] .admin-modal__title {
  background: linear-gradient(90deg, #00e5ff, #b026ff, #ff2ec4);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

[data-theme="loydiie"] .admin-stat,
[data-theme="loydiie"] .admin-trash-row,
[data-theme="loydiie"] .admin-list-row {
  background: rgba(10, 0, 20, 0.55);
  border-color: var(--panel-border);
  border-radius: 8px;
}

[data-theme="loydiie"] .admin-stat__value {
  color: var(--gold-bright);
  text-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
}

[data-theme="loydiie"] .topbar__clock,
[data-theme="loydiie"] .topbar__user,
[data-theme="loydiie"] .btn,
[data-theme="loydiie"] .chip,
[data-theme="loydiie"] .note-card__title,
[data-theme="loydiie"] .note-card__meta,
[data-theme="loydiie"] .editor__empty,
[data-theme="loydiie"] .save-status,
[data-theme="loydiie"] .auth-tab,
[data-theme="loydiie"] .auth-subtitle,
[data-theme="loydiie"] .theme-select,
[data-theme="loydiie"] .admin-field__label,
[data-theme="loydiie"] .admin-form h3,
[data-theme="loydiie"] .admin-stat__label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ============================================================
   Sven theme overrides — a pink-and-gilt court look. Keeps
   Hirui's structure (sigil corner brackets, divider, serif
   elegance) and repaints it: a rose/gold crest gradient on the
   title, warmer panel and card tints, a gilded glow on hover.
   ============================================================ */

[data-theme="sven"] .topbar__title,
[data-theme="sven"] .auth-title {
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--rose-accent) 55%, var(--gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

[data-theme="sven"] .panel,
[data-theme="sven"] .auth-card {
  background: linear-gradient(160deg, rgba(143, 47, 94, 0.32), rgba(42, 14, 28, 0.32));
}

[data-theme="sven"] input,
[data-theme="sven"] textarea {
  background: rgba(30, 8, 20, 0.55);
}

[data-theme="sven"] .note-card {
  background: rgba(30, 8, 20, 0.5);
}

[data-theme="sven"] .btn:hover {
  box-shadow: 0 6px 20px rgba(245, 201, 79, 0.35), 0 0 14px rgba(224, 85, 155, 0.3);
}

/* ============================================================
   Liri theme overrides — the GTA IV pause menu, not a Hirui
   repaint: flat matte black, sharp square edges, no blur, no
   glow, no starfield, no sigil. Orange is the only color that
   ever lights up — everything else is black, white or gray.
   ============================================================ */

[data-theme="liri"] #stars {
  display: none;
}

[data-theme="liri"] body {
  background: var(--void);
}

[data-theme="liri"] .divider {
  display: none;
}

[data-theme="liri"] .layout {
  margin-top: 1.25rem;
}

[data-theme="liri"] .topbar__title,
[data-theme="liri"] .auth-title {
  font-family: var(--font-display);
  letter-spacing: 0.1em;
  background: none;
  -webkit-text-fill-color: initial;
  color: var(--star);
}

[data-theme="liri"] .topbar__title span {
  background: none;
  -webkit-text-fill-color: initial;
  color: var(--gold-bright);
}

[data-theme="liri"] .panel,
[data-theme="liri"] .auth-card {
  background: var(--panel);
  backdrop-filter: none;
  border-radius: 0;
  border: none;
  box-shadow: none;
}

[data-theme="liri"] .panel::before,
[data-theme="liri"] .panel::after,
[data-theme="liri"] .auth-card::before,
[data-theme="liri"] .auth-card::after {
  content: none;
}

[data-theme="liri"] input,
[data-theme="liri"] textarea {
  background: rgba(0, 0, 0, 0.5);
  border: none;
  border-bottom: 1px solid var(--panel-border);
  border-radius: 0;
}

[data-theme="liri"] input:focus,
[data-theme="liri"] textarea:focus {
  border-bottom-color: var(--gold-bright);
  box-shadow: none;
}

[data-theme="liri"] .btn {
  background: transparent;
  border: 1px solid var(--star-dim);
  border-radius: 0;
  color: var(--star);
  box-shadow: none;
}

[data-theme="liri"] .btn:hover {
  background: var(--gold-bright);
  border-color: var(--gold-bright);
  color: var(--void);
  transform: none;
  box-shadow: none;
}

[data-theme="liri"] .btn--ghost {
  background: transparent;
  color: var(--star-dim);
  border-color: var(--panel-border);
}

[data-theme="liri"] .btn--danger {
  color: var(--danger);
  border-color: var(--danger);
}

[data-theme="liri"] .btn--danger:hover {
  background: var(--danger);
  color: var(--star);
}

[data-theme="liri"] .chip {
  border-radius: 0;
  border-color: var(--panel-border);
  color: var(--star-dim);
}

[data-theme="liri"] .chip--active {
  background: var(--gold-bright);
  color: var(--void);
  border-color: var(--gold-bright);
}

[data-theme="liri"] .note-card {
  background: rgba(0, 0, 0, 0.35);
  border: none;
  border-bottom: 1px solid var(--panel-border);
  border-left: 3px solid var(--gold);
  border-radius: 0;
}

[data-theme="liri"] .note-card:hover {
  transform: none;
  background: rgba(255, 151, 54, 0.08);
  box-shadow: none;
}

[data-theme="liri"] .note-card--active {
  box-shadow: inset 3px 0 0 var(--gold-bright);
  border-color: var(--panel-border);
}

[data-theme="liri"] .note-card__pin {
  color: var(--gold-bright);
}

[data-theme="liri"] .swatch {
  border-radius: 2px;
  border-color: var(--panel-border);
}

[data-theme="liri"] .swatch--active {
  box-shadow: 0 0 0 2px var(--star);
}

[data-theme="liri"] .auth-tab {
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
}

[data-theme="liri"] .auth-tab--active {
  background: transparent;
  border-bottom-color: var(--gold-bright);
  color: var(--gold-bright);
}

[data-theme="liri"] .theme-select {
  border-radius: 0;
}

[data-theme="liri"] .toast {
  background: var(--void);
  border-radius: 0;
  box-shadow: none;
}

[data-theme="liri"] .admin-overlay {
  background: rgba(0, 0, 0, 0.75);
}

[data-theme="liri"] .admin-modal {
  border-radius: 0;
}

[data-theme="liri"] .admin-modal::before,
[data-theme="liri"] .admin-modal::after {
  content: none;
}

[data-theme="liri"] .admin-list-row,
[data-theme="liri"] .admin-trash-row,
[data-theme="liri"] .admin-stat {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 0;
}


/* ==========================================================================
   Calendar
   Built only on the theme variables (--gold-bright, --panel-border, --star,
   --accent-tint, ...) and the shared .panel/.btn/.chip/.swatch classes, so
   every theme restyles it without needing calendar-specific overrides.
   ========================================================================== */

.ev--gold    { --ev: var(--gold-bright); }
.ev--violet  { --ev: var(--violet-accent); }
.ev--magenta { --ev: var(--magenta-accent); }
.ev--rose    { --ev: var(--rose-accent); }
.ev--star    { --ev: var(--star); }
/* .ev--custom gets --ev from an inline style (a validated #rrggbb). */

/* Plain buttons used as clickable cells/rows: strip the browser chrome. */
.cal-ev, .cal-block, .cal-more, .cal-day__num, .cal-grid__dayhead,
.mini-cal__day, .upcoming__ev, .cal-agenda__ev {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  text-align: left;
  cursor: pointer;
}

.cal-layout {
  grid-template-columns: 290px minmax(0, 1fr);
}

.cal-layout .sidebar {
  overflow-y: auto;
}

.side-heading {
  margin: 0.25rem 0 0;
  font-family: var(--font-heading);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--star-dim);
}

.calendar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
  min-width: 0;
  padding: 1rem;
}

/* ---- toolbar + "you are here" banner ---- */

.cal-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.cal-nav, .cal-views {
  display: flex;
  gap: 0.35rem;
}

.cal-title {
  flex: 1;
  min-width: 12rem;
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gold-bright);
}

.cal-here {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.2rem 0.75rem;
  padding: 0.45rem 0.75rem;
  border-left: 3px solid var(--gold-bright);
  background: var(--accent-tint);
  font-size: 0.8rem;
  color: var(--star);
}

.cal-here__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 0 var(--danger);
  animation: cal-pulse 2s ease-out infinite;
}

.cal-here__label {
  font-family: var(--font-heading);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold-bright);
}

.cal-here__rel {
  color: var(--star-dim);
  font-style: italic;
}

.cal-here .btn {
  padding: 0.25rem 0.6rem;
  margin-left: auto;
}

@keyframes cal-pulse {
  70%  { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .cal-here__dot { animation: none; }
}

.cal-day__here {
  font-family: var(--font-heading);
  font-size: 0.55rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  background: var(--gold-bright);
  color: var(--on-accent);
}

.cal-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

/* ---- event chips (month cells, all-day rows) ---- */

.cal-ev {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  min-width: 0;
  padding: 0.1rem 0.35rem;
  border-left: 3px solid var(--ev, var(--gold-bright));
  border-radius: 2px;
  background: color-mix(in srgb, var(--ev, var(--gold-bright)) 18%, transparent);
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--star);
}

.cal-ev:hover, .cal-block:hover, .upcoming__ev:hover, .cal-agenda__ev:hover {
  background: color-mix(in srgb, var(--ev, var(--gold-bright)) 34%, transparent);
}

.cal-ev--allday {
  background: color-mix(in srgb, var(--ev, var(--gold-bright)) 42%, transparent);
}

.cal-ev__time {
  flex: none;
  color: var(--star-dim);
  font-size: 0.68rem;
}

.cal-ev__title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-ev__badge {
  flex: none;
  color: var(--ev, var(--gold-bright));
  font-size: 0.7rem;
  margin-left: 0.25rem;
}

/* ---- month ---- */

.cal-month {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 34rem;
}

.cal-month__head,
.cal-month__grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.cal-month__dow {
  padding: 0.3rem 0.4rem;
  font-family: var(--font-heading);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--star-dim);
}

.cal-month__grid {
  flex: 1;
  grid-template-rows: repeat(6, minmax(6rem, 1fr));
  border-top: 1px solid var(--panel-border);
  border-left: 1px solid var(--panel-border);
}

.cal-day {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
  padding: 0.25rem;
  overflow: hidden;
  cursor: pointer;
  border-right: 1px solid var(--panel-border);
  border-bottom: 1px solid var(--panel-border);
}

.cal-day:hover {
  background: var(--accent-tint);
}

.cal-day--other .cal-day__top,
.cal-day--other .cal-day__events {
  opacity: 0.45;
}

.cal-day--today {
  background: var(--accent-tint);
  box-shadow: inset 0 0 0 2px var(--gold-bright);
}

.cal-day--anchor:not(.cal-day--today) {
  box-shadow: inset 0 0 0 1px var(--star-dim);
}

.cal-day__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.3rem;
}

.cal-day__num {
  min-width: 1.6rem;
  height: 1.6rem;
  line-height: 1.6rem;
  text-align: center;
  border-radius: 50%;
  font-family: var(--font-heading);
  font-size: 0.8rem;
}

.cal-day__num:hover {
  background: var(--accent-tint);
}

.cal-day--today .cal-day__num {
  background: var(--gold-bright);
  color: var(--on-accent);
  font-weight: 700;
}

.cal-day__events {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.cal-more {
  font-size: 0.7rem;
  color: var(--star-dim);
  padding: 0 0.35rem;
}

.cal-more:hover {
  color: var(--gold-bright);
}

/* ---- week / day time grid ---- */

.cal-grid {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.cal-grid__head,
.cal-allday,
.cal-grid__body {
  display: grid;
  grid-template-columns: 3.4rem repeat(var(--cols), minmax(0, 1fr));
}

/* Leave room for the scrollbar the time grid below has. */
.cal-grid__head,
.cal-allday {
  padding-right: 8px;
}

.cal-grid__dayhead {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0.35rem 0.2rem;
  border-left: 1px solid var(--panel-border);
}

.cal-grid__dayhead:disabled {
  cursor: default;
}

.cal-grid__dow {
  font-family: var(--font-heading);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--star-dim);
}

.cal-grid__dom {
  font-family: var(--font-heading);
  font-size: 1.15rem;
}

.cal-grid__dayhead--today .cal-grid__dom {
  color: var(--gold-bright);
  font-weight: 700;
}

.cal-allday {
  border-top: 1px solid var(--panel-border);
  border-bottom: 1px solid var(--panel-border);
}

.cal-gutter {
  font-size: 0.62rem;
  color: var(--star-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.3rem 0.4rem 0 0;
  text-align: right;
}

.cal-allday__cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 1.9rem;
  padding: 0.2rem 0.15rem;
  border-left: 1px solid var(--panel-border);
  cursor: pointer;
}

.cal-grid__scroll {
  flex: 1;
  min-height: 16rem;
  overflow-y: auto;
}

.cal-grid__body {
  position: relative;
}

.cal-hour {
  position: relative;
  border-top: 1px solid var(--panel-border);
  box-sizing: border-box;
}

.cal-hour span {
  position: absolute;
  top: -0.55em;
  right: 0.4rem;
  font-size: 0.62rem;
  color: var(--star-dim);
}

.cal-hour:first-child { border-top-color: transparent; }
.cal-hour:first-child span { top: 0; }

.cal-col {
  position: relative;
  cursor: pointer;
  border-left: 1px solid var(--panel-border);
  /* one faint line per hour; 52px must match HOUR_H in components/calendar.js */
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 51px,
    var(--panel-border) 51px,
    var(--panel-border) 52px
  );
}

.cal-col--today {
  background-color: var(--accent-tint);
}

.cal-block {
  position: absolute;
  z-index: 1;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0.15rem 0.35rem;
  border: 1px solid color-mix(in srgb, var(--ev, var(--gold-bright)) 55%, transparent);
  border-left: 3px solid var(--ev, var(--gold-bright));
  border-radius: 3px;
  background: color-mix(in srgb, var(--ev, var(--gold-bright)) 30%, var(--void));
  font-size: 0.72rem;
  line-height: 1.3;
  color: var(--star);
}

.cal-block__time {
  color: var(--star-dim);
  font-size: 0.64rem;
  white-space: nowrap;
}

.cal-block__title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-block__loc {
  color: var(--star-dim);
  font-size: 0.66rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The current-time line: "you are here" in the time grid. */
.cal-now {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 3;
  height: 0;
  border-top: 2px solid var(--danger);
  pointer-events: none;
}

.cal-now::before {
  content: '';
  position: absolute;
  left: -5px;
  top: -6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
}

.cal-now__label {
  position: absolute;
  right: 2px;
  top: -0.85rem;
  padding: 0 0.3rem;
  border-radius: 3px;
  background: var(--danger);
  color: #fff;
  font-size: 0.6rem;
  line-height: 1.2;
}

/* ---- agenda ---- */

.cal-agenda {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.cal-agenda__day {
  border-left: 2px solid var(--panel-border);
  padding-left: 0.75rem;
}

.cal-agenda__day--today {
  border-left-color: var(--gold-bright);
  background: var(--accent-tint);
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

.cal-agenda__header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.3rem;
  font-family: var(--font-heading);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--gold-bright);
}

.cal-agenda__ev {
  display: flex;
  gap: 0.9rem;
  width: 100%;
  padding: 0.4rem 0.6rem;
  margin-bottom: 3px;
  border-left: 3px solid var(--ev, var(--gold-bright));
  border-radius: 2px;
  background: color-mix(in srgb, var(--ev, var(--gold-bright)) 14%, transparent);
}

.cal-agenda__when {
  flex: none;
  width: 9.5rem;
  font-size: 0.8rem;
  color: var(--star-dim);
}

.cal-agenda__what {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.cal-agenda__loc {
  font-size: 0.75rem;
  color: var(--star-dim);
}

.cal-agenda__live {
  margin-left: 0.5rem;
  padding: 0 0.35rem;
  border-radius: 3px;
  background: var(--danger);
  color: #fff;
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.cal-agenda__empty,
.cal-agenda__none {
  color: var(--star-dim);
  font-style: italic;
  font-size: 0.85rem;
}

.cal-agenda__none {
  text-align: center;
  padding: 2rem 0;
}

/* ---- sidebar: mini calendar + upcoming ---- */

.mini-cal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.mini-cal__header .btn {
  padding: 0.2rem 0.6rem;
}

.mini-cal__title {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--gold-bright);
}

.mini-cal__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}

.mini-cal__dow {
  font-size: 0.65rem;
  color: var(--star-dim);
  padding-bottom: 0.15rem;
}

.mini-cal__day {
  aspect-ratio: 1;
  text-align: center;
  border-radius: 50%;
  font-size: 0.75rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mini-cal__day:hover { background: var(--accent-tint); }
.mini-cal__day--other { opacity: 0.4; }
.mini-cal__day--inweek { background: var(--accent-tint); border-radius: 4px; }
.mini-cal__day--anchor { outline: 1px solid var(--star-dim); }

.mini-cal__day--today {
  background: var(--gold-bright);
  color: var(--on-accent);
  font-weight: 700;
}

.upcoming {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.upcoming__day {
  margin-top: 0.4rem;
  font-family: var(--font-heading);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
}

.upcoming__ev {
  display: grid;
  grid-template-columns: 3.4rem 1fr;
  gap: 0.1rem 0.5rem;
  padding: 0.3rem 0.5rem;
  border-left: 3px solid var(--ev, var(--gold-bright));
  border-radius: 2px;
  background: color-mix(in srgb, var(--ev, var(--gold-bright)) 12%, transparent);
  font-size: 0.8rem;
}

.upcoming__time { color: var(--star-dim); font-size: 0.72rem; }
.upcoming__title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upcoming__by { grid-column: 2; color: var(--star-dim); font-size: 0.7rem; }

.upcoming__empty {
  color: var(--star-dim);
  font-style: italic;
  font-size: 0.8rem;
  padding: 0.5rem 0;
}

/* ---- event form ---- */

.event-modal {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 520px;
}

.event-modal.panel::before { top: 0; left: 0; }
.event-modal.panel::after { bottom: 0; right: 0; }

.event-modal input,
.event-modal textarea {
  color-scheme: dark;
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.6rem;
}

.event-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.event-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.event-check input {
  width: auto;
}

.event-when {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.event-when__row {
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 0.5rem;
  align-items: center;
}

.event-when__label {
  font-family: var(--font-heading);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--star-dim);
}

.event-description {
  resize: vertical;
  font-family: var(--font-body);
}

.event-color {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ---- phone ---- */

@media (max-width: 720px) {
  .layout.cal-layout {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }

  .cal-layout .calendar {
    flex: none;
    min-height: 75vh;
    padding: 0.6rem;
  }

  .cal-layout .sidebar {
    flex: none;
    order: 2;
    overflow-y: visible;
  }

  .cal-title {
    order: 3;
    flex-basis: 100%;
    font-size: 1.1rem;
  }

  .cal-views {
    margin-left: auto;
  }

  .cal-grid {
    min-width: 38rem;
  }

  /* Month fits the phone width: compact chips, no times, no "you are here"
     tag (the filled date circle already marks today). */
  .cal-month {
    min-width: 0;
  }

  .cal-month__grid {
    grid-template-rows: repeat(6, minmax(4.5rem, 1fr));
  }

  .cal-day {
    padding: 0.15rem;
  }

  .cal-day .cal-ev__time,
  .cal-day .cal-day__here {
    display: none;
  }

  .cal-ev {
    padding: 0 0.2rem;
    font-size: 0.62rem;
  }

  .cal-agenda__ev {
    flex-direction: column;
    gap: 0.15rem;
  }

  .cal-agenda__when {
    width: auto;
  }

  .event-when__row {
    grid-template-columns: 3.5rem 1fr;
  }

  .event-when__row input[type="time"] {
    grid-column: 2;
  }
}

/* ---- calendar import ---- */

.import-summary ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.import-summary__note {
  color: var(--star-dim);
  font-size: 0.75rem;
}

.import-summary__total {
  padding-top: 0.5rem;
  border-top: 1px solid var(--panel-border);
  color: var(--gold-bright);
}
