@font-face {
  font-family: 'MonoLisa';
  src: url('MonoLisa-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #070707;
  --radius: 3px;
  --font: 'MonoLisa', 'Courier New', monospace;
  --fg: #ffffff;
  --line: #2b2b2b;
  --line-hi: #6a6a6a;
  --muted: #6a6a6a;
  --panel: #0c0c0c;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] { display: none !important; }

html, body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  overflow-x: hidden;
}

#bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

#bg img,
#bg video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  /* dvh so mobile browser chrome does not push the hero off screen */
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#wrap {
  text-align: center;
  width: 600px;
  max-width: 95vw;
}

#dateline {
  font-size: 0.9rem;
  color: #cccccc;
  margin-bottom: 4px;
  letter-spacing: 1.5px;
  font-weight: 400;
  text-transform: uppercase;
}

#clock {
  font-size: 4rem;
  font-weight: 400;
  letter-spacing: 6px;
  margin-bottom: 8px;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}

#weather {
  font-size: 0.85rem;
  color: #b0b0b0;
  margin-bottom: 18px;
  font-weight: 400;
  letter-spacing: 0.5px;
  cursor: pointer;
}

#weather:hover { color: #ffffff; }

#bookmarks {
  /* flex, not grid: a last row that does not fill up gets centered */
  --cols: 3;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px;
  margin-top: 10px;
}

.bm {
  position: relative;
  /* -0.5px absorbs sub-pixel rounding, else the last tile of a row wraps */
  flex: 0 0 calc((100% - (var(--cols) - 1) * 2px) / var(--cols) - 0.5px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5px 2px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--fg);
  text-decoration: none;
  font-size: 0.7rem;
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
  cursor: pointer;
  min-width: 0;
}

.bm:hover {
  border-color: var(--line-hi);
  color: #cccccc;
}

.bm .chord {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 1px;
  color: #ffffff;
  letter-spacing: 0.5px;
  line-height: 1.1;
}

.bm .label {
  font-size: 0.5rem;
  color: var(--muted);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  letter-spacing: 0.2px;
  line-height: 1.1;
}

.bm .tick {
  position: absolute;
  top: 1px;
  right: 3px;
  font-size: 0.6rem;
  line-height: 1;
  color: #ffffff;
  opacity: 0;
}

body.select-mode .bm,
body.hide-mode .bm,
body.edit-mode .bm { cursor: crosshair; }

.bm.selected {
  border-color: #ffffff;
  background: #161616;
}

.bm.selected .tick { opacity: 1; }

/* dimmed and dashed while picking what to hide, so hidden ≠ visible */
.bm.hidden {
  opacity: 0.35;
  border-style: dashed;
}

.corner-bl,
.corner-br {
  position: fixed;
  bottom: 18px;
  display: flex;
  gap: 8px;
  z-index: 150;
}

.corner-bl { left: 18px; }
.corner-br { right: 18px; }

.corner-bl button,
.corner-br button {
  width: 32px;
  height: 32px;
  padding: 0;
  font-family: inherit;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid #333333;
  border-radius: var(--radius);
  color: #ffffff;
  opacity: 1;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

#addBtn {
  font-size: 20px;
  border-color: #555555;
}

.corner-bl button:not(:disabled):hover,
.corner-br button:not(:disabled):hover {
  border-color: #ffffff;
  background: #ffffff;
  color: #000000;
}

/* filled while the button's mode is on, so it is never a guess */
body.select-mode #delBtn,
body.hide-mode #eyeBtn,
body.edit-mode #editBtn {
  border-color: #ffffff;
  background: #ffffff;
  color: #000000;
}

.corner-bl button:disabled {
  opacity: 0.3;
  cursor: default;
}

#chordIndicator {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.8rem;
  color: #aaaaaa;
  min-height: 1em;
  font-weight: 400;
  letter-spacing: 3px;
  transition: color 0.1s ease;
}

#chordIndicator.nomatch {
  color: #8a3d3d;
}

#searchInput {
  position: relative;
  z-index: 1;
  margin-top: 14px;
  text-align: center;
  color: #ffffff;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
  font-weight: 400;
  cursor: text;
  outline: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 14px;
  background: transparent;
  max-width: 100%;
  line-height: 1.5;
  min-height: 1.9em;
  transform-origin: center center;
  will-change: transform;
  transition: border-color 0.15s ease,
              transform 0.42s cubic-bezier(0.16, 0.9, 0.24, 1.02);
}

#searchInput:focus {
  border-color: #ffffff;
}

#searchInput:empty::before {
  content: 'search  ·  press / or enter';
  color: #565656;
  pointer-events: none;
}

/* transform/filter only: nothing behind the search may reflow */
#wrap > *:not(#searchInput) {
  transition: filter 0.5s ease-out,
              transform 0.5s cubic-bezier(0.15, 0.85, 0.25, 1),
              opacity 0.5s ease-out;
}

body.search-focused #wrap > *:not(#searchInput) {
  filter: blur(10px);
  transform: scale(1.45);
  opacity: 0.3;
}

body.search-focused #searchInput {
  z-index: 200;
  transform: translate(var(--dx, 0px), var(--dy, 0px)) scale(1.15);
  background: var(--bg);
  border-color: #ffffff;
  box-shadow: 0 12px 48px #000000;
  animation: search-warp 0.42s cubic-bezier(0.2, 0.8, 0.3, 1);
}

@keyframes search-warp {
  0% {
    transform: translate(0, 0) scale(1);
    filter: blur(0);
  }
  30% {
    transform: translate(calc(var(--dx, 0px) * 0.35), calc(var(--dy, 0px) * 0.35)) scale(0.97, 1.12);
    filter: blur(0);
  }
  100% {
    transform: translate(var(--dx, 0px), var(--dy, 0px)) scale(1.15);
    filter: blur(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  body.search-focused #searchInput { animation: none; }
  body.search-focused #wrap > *:not(#searchInput) { transform: none; }
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  z-index: 400;
}

.panel {
  width: 400px;
  max-width: 92vw;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid #333333;
  border-radius: var(--radius);
  padding: 18px;
  text-align: left;
  color: #dddddd;
  font-size: 0.75rem;
}

.panel h3 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.panel h3 .esc {
  font-size: 0.62rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: #5a5a5a;
}

.panel .field {
  margin-bottom: 16px;
}

.panel .group {
  margin: 20px 0 10px;
  padding-top: 14px;
  border-top: 1px solid #232323;
  color: #5a5a5a;
  font-size: 0.62rem;
  letter-spacing: 1.4px;
  text-transform: uppercase;
}

/* the first group is a label, not a divider — no rule under the title */
.panel h3 + .group {
  margin-top: 2px;
  padding-top: 0;
  border-top: none;
}

.panel .field:last-of-type {
  margin-bottom: 0;
}

.panel label {
  display: block;
  margin-bottom: 6px;
  color: #8a8a8a;
  font-size: 0.7rem;
  letter-spacing: 0.4px;
}

.panel input,
.panel select,
.panel textarea {
  display: block;
  width: 100%;
  padding: 7px 9px;
  font-family: inherit;
  font-size: 0.78rem;
  color: #ffffff;
  background: #050505;
  border: 1px solid #333333;
  border-radius: var(--radius);
  outline: none;
}

.panel input:focus,
.panel select:focus,
.panel textarea:focus {
  border-color: #ffffff;
}

/* inline, so the box sits beside its own label instead of above it */
.panel input[type="checkbox"] {
  display: inline-block;
  width: 14px;
  height: 14px;
  padding: 0;
  margin: 0 7px 0 0;
  vertical-align: -2px;
  accent-color: #ffffff;
}

.panel input[type="range"] {
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  accent-color: #ffffff;
  cursor: pointer;
}

.panel input[type="file"] {
  padding: 5px;
  cursor: pointer;
  font-size: 0.68rem;
}

.panel input[type="file"]::file-selector-button {
  margin-right: 8px;
  padding: 5px 10px;
  font-family: inherit;
  font-size: 0.68rem;
  color: #dddddd;
  background: #151515;
  border: 1px solid #333333;
  border-radius: var(--radius);
  cursor: pointer;
}

.panel textarea {
  resize: vertical;
  line-height: 1.4;
}

.panel code { color: #ffffff; }

.panel .inline {
  display: flex;
  gap: 6px;
}

/* font and background side by side, each half the panel: a control on top and
   its two buttons below, so the buttons come out half the width of the column
   they act on */
.panel .cols {
  display: flex;
  gap: 6px;
}

.panel .col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.panel .col > * { margin-bottom: 0; }

.panel .col .row { margin-top: 0; }

/* a value the user cannot type into — reads as an input, but the upload and
   remove buttons below are the only things that change it */
.panel .box {
  display: block;
  width: 100%;
  padding: 7px 9px;
  font-size: 0.78rem;
  color: #9a9a9a;
  background: #050505;
  border: 1px solid #333333;
  border-radius: var(--radius);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* the label that opens the hidden font picker is a button, so it has to behave
   like one: the whole box is the hit area, and the focus ring shows on it */
.panel label.btn {
  display: block;
  text-align: center;
  cursor: pointer;
}

.panel label.btn:focus-within {
  border-color: #ffffff;
}

/* a file input driven from a label: clipped rather than display:none, because
   a display:none input's label no longer opens the picker everywhere */
.panel input.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
}

.panel .inline input { flex: 1 1 auto; width: auto; }
.panel .inline button { flex: 0 0 auto; }

.panel .row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.panel .row button,
.panel .row .btn { flex: 1; }

.panel button.wide,
.panel .btn.wide { display: block; width: 100%; }

.panel button,
.panel .btn {
  padding: 7px 12px;
  font-family: inherit;
  font-size: 0.72rem;
  color: #dddddd;
  background: transparent;
  border: 1px solid #333333;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

/* link styled as a panel button (the extension downloads) */
.panel .btn {
  text-align: center;
  text-decoration: none;
}

/* dismiss the extension buttons, and the small way back in the title */
.panel .x {
  flex: 0 0 auto;
  padding: 0 6px;
  color: #6a6a6a;
}

/* the labels are long; they wrap to three lines at the normal size */
#extRow .btn { font-size: 0.62rem; }

.panel h3 button {
  padding: 1px 7px;
  font-size: 0.72rem;
  line-height: 1.4;
  letter-spacing: 0;
}

.panel button:hover,
.panel .btn:hover {
  border-color: #ffffff;
  background: #ffffff;
  color: #000000;
}

#locState { cursor: help; }

#locValue {
  transition: filter 0.18s ease;
  user-select: none;
  letter-spacing: 1px;
}

#locState.masked #locValue {
  filter: blur(var(--blur, 5px));
}

/* the blurred token is only obvious as a choice if something explains it */
#locState:not(.masked) .cap {
  display: none;
}

.panel .hint {
  margin: 6px 0 0;
  color: #6a6a6a;
  font-size: 0.68rem;
}

.panel .err {
  color: #ff7777;
  margin-top: 10px;
  font-size: 0.7rem;
}

.panel .hint.ok { color: #8aff8a; }
.panel .hint.bad { color: #ff7777; }

#warn {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 9px 16px;
  background: #101010;
  border-bottom: 1px solid #2b2b2b;
  color: #cccccc;
  font-size: 0.72rem;
  letter-spacing: 0.3px;
  z-index: 300;
}

#warn button {
  flex: 0 0 auto;
  padding: 2px 9px;
  font-family: inherit;
  font-size: 0.72rem;
  color: #dddddd;
  background: transparent;
  border: 1px solid #333333;
  border-radius: var(--radius);
  cursor: pointer;
}

#warn button:hover {
  background: #ffffff;
  border-color: #ffffff;
  color: #000000;
}

/* "visible buttons": white text and borders become the inverse of the
   wallpaper under them. Must sit on .hero as a whole — .hero is its own
   stacking context, so anything inside it blends against the hero instead. */
body.bg-contrast .hero,
body.bg-contrast .corner-bl,
body.bg-contrast .corner-br,
body.bg-contrast #chordIndicator {
  mix-blend-mode: difference;
}

body.bg-contrast #dateline,
body.bg-contrast #clock,
body.bg-contrast #weather,
body.bg-contrast #searchInput,
body.bg-contrast #searchInput:empty::before,
body.bg-contrast .bm,
body.bg-contrast .bm .chord,
body.bg-contrast .bm .label,
body.bg-contrast .bm .tick,
body.bg-contrast .corner-bl button,
body.bg-contrast .corner-br button {
  color: #ffffff;
  border-color: #ffffff;
}

.zen-current-workspace-indicator {
  display: none !important;
}

/* buttons and tiles: no 300ms double-tap zoom delay, no tap highlight flash */
button,
.btn,
.bm,
#weather,
#locState {
  touch-action: manipulation;
}

/* ---------- phones ---------- */
@media (max-width: 640px) {
  #wrap {
    width: 100%;
    padding: 0 14px;
  }

  /* 4rem + 6px tracking overflows a 360px screen; 13vw keeps 8 digits inside */
  #clock {
    font-size: clamp(2.2rem, 13vw, 3.4rem);
    letter-spacing: 3px;
  }

  #dateline {
    font-size: 0.72rem;
    letter-spacing: 1px;
  }

  #weather {
    font-size: 0.75rem;
    line-height: 1.5;
  }

  /* 16px is the floor: anything smaller makes iOS zoom the page on focus */
  #searchInput,
  .panel input,
  .panel select,
  .panel textarea {
    font-size: 1rem;
  }

  #searchInput {
    padding: 9px 12px;
  }

  /* no hardware keyboard to press "/" on */
  #searchInput:empty::before {
    content: 'search';
  }

  /* the flight to centre is desktop theatre — on a phone it just fights the
     keyboard and pushes the box off screen. Blur the rest, leave it in place. */
  body.search-focused #searchInput {
    transform: none;
    animation: none;
  }

  body.search-focused #wrap > *:not(#searchInput) {
    transform: none;
    filter: blur(8px);
    opacity: 0.25;
  }

  /* fingers, not cursors */
  .corner-bl,
  .corner-br {
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    gap: 6px;
  }

  .corner-bl { left: 10px; }
  .corner-br { right: 10px; }

  .corner-bl button,
  .corner-br button {
    width: 44px;
    height: 44px;
    font-size: 22px;
  }

  #addBtn { font-size: 24px; }

  #chordIndicator {
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }

  .bm {
    padding: 8px 3px;
  }

  .bm .chord { font-size: 1rem; }

  .bm .label { font-size: 0.62rem; }

  /* the last row would otherwise sit under the corners */
  #bookmarks { margin-bottom: 44px; }

  .panel {
    width: 100%;
    max-width: 94vw;
    max-height: 88dvh;
    padding: 14px;
  }

  .panel input[type="checkbox"] {
    width: 22px;
    height: 22px;
  }

  /* no escape key on a phone — the header × is the only way out */
  .panel h3 .esc { display: none; }
  .panel h3 button {
    padding: 4px 11px;
    font-size: 1rem;
  }

  .panel button,
  .panel .btn {
    padding: 10px 12px;
    font-size: 0.82rem;
  }

  .panel .inline button { padding: 10px 14px; }

  /* the warning bar's text and two buttons do not fit on one line */
  #warn {
    flex-wrap: wrap;
    gap: 8px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px;
    font-size: 0.7rem;
  }

  #warnText { flex: 1 1 100%; }
}
