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

/* The hidden attribute must win over display rules on .row, .field-group, etc. */
[hidden] {
  display: none !important;
}

:root {
  --bg: #0f0f14;
  --surface: #1a1a24;
  --surface-raised: #22222f;
  --border: #2e2e40;
  --text: #e8e8f0;
  --text-muted: #8888aa;
  --yellow: #f0c040;
  --yellow-dim: #c09828;
  --purple: #9060d8;
  --purple-bright: #b080f8;
  --purple-dim: #5a3a9a;
  --radius: 8px;
}

[data-theme="light"] {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-raised: #f5f5fa;
  --border: #d0d0e0;
  --text: #1a1a2c;
  --text-muted: #5a5a7a;
  --yellow: #c07000;
  --yellow-dim: #9a5800;
  --purple: #6030b8;
  --purple-bright: #5020a0;
  --purple-dim: #d8d0f0;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "header header"
    "nav    main"
    "footer footer";
}

/* ── Header ── */
header {
  grid-area: header;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

header .logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--yellow);
  letter-spacing: -0.5px;
  text-decoration: none;
}

header .logo span {
  color: var(--purple-bright);
}

/* ── Sidebar nav ── */
nav {
  grid-area: nav;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

nav .nav-section {
  padding: 0.25rem 1rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--purple-bright);
  margin-top: 1rem;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

nav .nav-section::before {
  content: '▶';
  font-size: 0.55rem;
  transition: transform 0.18s;
  display: inline-block;
}

nav .nav-section.open::before {
  transform: rotate(90deg);
}

nav a {
  display: block;
  padding: 0.55rem 1rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

nav a:hover {
  color: var(--text);
  background: var(--surface-raised);
}

nav a.active {
  color: var(--yellow);
  border-left-color: var(--yellow);
  background: var(--surface-raised);
}

/* ── Main content ── */
main {
  grid-area: main;
  padding: 2rem 2.5rem;
  max-width: 960px;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--yellow);
  margin-bottom: 0.5rem;
}

h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--purple-bright);
  margin-bottom: 1rem;
  margin-top: 2rem;
}

p {
  line-height: 1.65;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* ── Cards (used on index) ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.2s, transform 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.card:hover {
  border-color: var(--purple);
  transform: translateY(-2px);
}

.card .card-title {
  font-weight: 600;
  color: var(--yellow);
  font-size: 0.95rem;
}

.card .card-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Calculator widgets ── */
.calc-card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin-top: 1.5rem;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
}

label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

input[type="date"],
input[type="number"],
input[type="text"],
select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  padding: 0.55rem 0.75rem;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
  -moz-appearance: textfield;
}

input[type="date"]:focus,
input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
  border-color: var(--purple);
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.row .field-group {
  flex: 1;
}

.row .field-group.narrow {
  flex: 0 0 90px;
}

/* ── Toggle pill ── */
.toggle-group {
  display: flex;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.toggle-group input[type="radio"] {
  display: none;
}

.toggle-group label {
  flex: 1;
  text-align: center;
  padding: 0.55rem 1rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
  background: transparent;
  border: none;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}

.toggle-group input[type="radio"]:checked + label {
  background: var(--purple-dim);
  color: var(--text);
}

/* ── Primary button (yellow) ── */
.bright-btn {
  background: var(--yellow);
  color: #1a1400;
  border: none;
  border-radius: var(--radius);
  padding: 0.65rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s;
}

.bright-btn:hover {
  background: var(--yellow-dim);
}

.bright-btn:active {
  transform: scale(0.97);
}

/* ── Result box ── */
.result {
  margin-top: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--purple-dim);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  display: none;
}

.result.visible {
  display: block;
}


.result-date {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--yellow);
}

.result-detail {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

/* ── Copy button (used on countdown clock, markdown sanitiser) ── */
.copy-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  transition: border-color 0.15s, color 0.15s;
}

.copy-btn:hover {
  border-color: var(--purple);
  color: var(--text);
}

.copy-btn.copied {
  border-color: var(--yellow);
  color: var(--yellow);
}

/* ── Timezone filterable select (used on timezone calculator, countdown clock) ── */
.tz-filter {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  color: var(--text);
  font-size: 0.9rem;
  padding: 0.45rem 0.75rem;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}

.tz-filter:focus {
  border-color: var(--purple);
}

.tz-filter:focus + select {
  border-color: var(--purple);
}

.tz-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  padding: 0.45rem 0.75rem;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
  overflow-y: auto;
}

.tz-select:focus {
  border-color: var(--purple);
}

.tz-select optgroup {
  color: var(--purple-bright);
  font-size: 0.75rem;
  font-weight: 700;
  font-style: normal;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tz-select option {
  color: var(--text);
  padding: 0.15rem 0;
}

.tz-select option:checked {
  background: var(--purple-dim);
}

/* ── Time selects (used on timezone calculator, countdown clock) ── */
.time-selects {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.time-selects select {
  width: auto;
  flex: 1;
}

.time-colon {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* ── Footer ── */
footer {
  grid-area: footer;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── Hamburger button (hidden on desktop) ── */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.25rem;
  margin-left: auto;
  opacity: 0.75;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.theme-toggle:hover { opacity: 1; }

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Responsive ── */
@media (max-width: 640px) {
  body {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto;
    grid-template-areas:
      "header"
      "nav"
      "main"
      "footer";
  }

  .hamburger {
    display: flex;
  }

  nav {
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 0;
    gap: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
  }

  nav.open {
    max-height: min(75vh, 40rem);
    padding: 0.5rem 0;
    overflow-y: auto;
  }

  nav a {
    border-left: 3px solid transparent;
  }

  main {
    padding: 1.25rem 1rem;
  }
}

/* ═══════════════════════════════════════════════
   TIMEZONE CALCULATOR
   ═══════════════════════════════════════════════ */

.arrow-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 0.5rem 0;
}

.arrow-row hr {
  flex: 1;
  border: none;
  border-top: 1px solid var(--border);
}

.swap-btn {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}

.swap-btn:hover {
  border-color: var(--purple);
  color: var(--purple-bright);
}

.datetime-row {
  display: flex;
  gap: 0.75rem;
}

.datetime-row .field-group:first-child {
  flex: 1.5;
}

.datetime-row .field-group:last-child {
  flex: 1;
}

.result-time {
  font-size: 2rem;
  font-weight: 700;
  color: var(--yellow);
  letter-spacing: -0.5px;
}

.result-weekdate {
  font-size: 1rem;
  color: var(--text);
  margin-top: 0.15rem;
}

.result-meta {
  display: flex;
  gap: 1.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.result-meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.result-meta-item .meta-label {
  font-size: 0.72rem;
}

.result-meta-item .meta-value {
  font-size: 0.9rem;
  color: var(--text);
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.result-header .toggle-group label {
  padding: 0.25rem 0.65rem;
  font-size: 0.78rem;
}

/* ═══════════════════════════════════════════════
   COUNTDOWN CLOCK
   ═══════════════════════════════════════════════ */

.countdown-display {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 1.5rem 0 0.5rem;
}

.countdown-unit {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 1.25rem;
  min-width: 80px;
  flex: 1;
}

.countdown-unit.hidden {
  display: none;
}

.countdown-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--yellow);
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
  line-height: 1;
}

.countdown-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

#countdown-display[data-theme="light"] .countdown-unit {
  background: #ffffff;
  border-color: #e2e2e2;
}

#countdown-display[data-theme="light"] .countdown-value {
  color: #7c3aed;
}

#countdown-display[data-theme="light"] .countdown-label {
  color: #888888;
}

.expired-msg {
  display: none;
  color: var(--purple-bright);
  font-size: 1rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
}

.expired-msg.visible {
  display: block;
}

.unit-toggles {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.unit-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  user-select: none;
}

.unit-toggle input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--purple);
  cursor: pointer;
}

.unit-toggle input[type="checkbox"]:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.unit-toggle span {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.unit-toggle input:disabled + span {
  opacity: 0.35;
}

.embed-section {
  margin-top: 1.75rem;
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}

.embed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

textarea.embed-code {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 0.72rem;
  line-height: 1.5;
  padding: 0.75rem;
  resize: vertical;
  height: 280px;
  max-height: 280px;
  overflow-y: auto;
  outline: none;
}

.embed-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* ═══════════════════════════════════════════════
   MARKDOWN SANITISER
   ═══════════════════════════════════════════════ */

.tool-panel {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tool-panel + .tool-panel {
  margin-top: 1.25rem;
}

.tool-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tool-stats {
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.7;
}

textarea.tool-input,
.tool-output {
  width: 100%;
  height: 280px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: "SF Mono", "Fira Code", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.8rem;
  line-height: 1.65;
  padding: 0.75rem;
  resize: none;
  outline: none;
  transition: border-color 0.15s;
}

textarea.tool-input:focus {
  border-color: var(--purple);
}

.tool-output {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  color: var(--text);
}

.clear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.5rem;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.clear-btn:hover { opacity: 1; }

/* ═══════════════════════════════════════════════
   IMAGE CROPPER
   ═══════════════════════════════════════════════ */

#upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--surface);
}

#upload-zone:hover,
#upload-zone.drag-over {
  border-color: var(--purple);
  background: var(--surface-raised);
}

#upload-zone .upload-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.6;
}

#upload-zone .upload-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}

#upload-zone .upload-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
}

#file-input { display: none; }

#editor { display: none; flex-direction: column; gap: 1.25rem; }
#editor.visible { display: flex; }

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


.ratio-group {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.ratio-group input[type="radio"] { display: none; }

.ratio-group label {
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  user-select: none;
  border-right: 1px solid var(--border);
}

.ratio-group label:last-of-type { border-right: none; }

.ratio-group input[type="radio"]:checked + label {
  background: var(--purple-dim);
  color: var(--text);
}

.toolbar-spacer { flex: 1; }

.change-btn {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.change-btn:hover { border-color: var(--purple); color: var(--text); }

.crop-wrap {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  max-height: 520px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.crop-wrap img { display: block; max-width: 100%; max-height: 520px; }

.export-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 1.25rem;
  align-items: end;
}

.export-panel .field-group { margin-bottom: 0; }

.size-row { display: flex; align-items: center; gap: 0.5rem; }

.size-row input[type="number"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  padding: 0.5rem 0.65rem;
  width: 90px;
  outline: none;
  transition: border-color 0.15s;
}

.size-row input[type="number"]:focus { border-color: var(--purple); }

.size-x { color: var(--text-muted); font-size: 0.85rem; font-weight: 600; }

.format-quality { display: flex; flex-direction: column; gap: 1rem; }

.export-panel .toggle-group {
  background: var(--bg);
}

.export-panel .toggle-group label {
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  border-right: 1px solid var(--border);
  border-bottom: none;
  text-transform: none;
  letter-spacing: 0;
}

.export-panel .toggle-group label:last-of-type { border-right: none; }

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

input[type="range"] {
  flex: 1;
  accent-color: var(--purple-bright);
  height: 4px;
  cursor: pointer;
}

.quality-field { display: none; }
.quality-field.visible { display: flex; flex-direction: column; gap: 0.35rem; }

.dl-wrap { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }

.tint-colour-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 2.25rem;
  height: 2.25rem;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
  flex-shrink: 0;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: calc(var(--radius) - 2px); }
input[type="color"]::-moz-color-swatch { border: none; border-radius: calc(var(--radius) - 2px); }

.tint-colour-row input[type="text"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono, monospace);
  font-size: 0.88rem;
  padding: 0.45rem 0.6rem;
  width: 6.5rem;
  outline: none;
  transition: border-color 0.15s;
}
.tint-colour-row input[type="text"]:focus { border-color: var(--purple); }

.crop-info { font-size: 0.75rem; color: var(--text-muted); text-align: center; }

@media (max-width: 640px) {
  .export-panel { grid-template-columns: 1fr; }
  .dl-wrap { align-items: stretch; }
  .bright-btn { text-align: center; }
}

/* ═══════════════════════════════════════════════
   TAB BLOCK BUILDER
   ═══════════════════════════════════════════════ */

/* Settings hint below start-id input */
.tbb-hint {
  font-size: 0.82rem;
  line-height: 1.45;
  margin-bottom: 0;
}

/* Constrain the start-id number input */
#start-id {
  max-width: 6rem;
}

/* Override global text-input width for .tz-filter (already has its own width) */
/* and keep tab-name / hex / filename inputs manageable */
.tab-name-input {
  flex: 1;
  width: auto;
  font-size: 0.9rem;
  padding: 0.45rem 0.75rem;
}

.tab-name-input::placeholder { color: var(--text-muted); }

.color-hex-input {
  width: 5.5rem;
  font-size: 0.82rem;
  padding: 0.35rem 0.6rem;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

#filename-input {
  flex: 1;
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
}

#filename-input::placeholder { color: var(--text-muted); }

/* Colors collapsible <details> */
#colors-details {
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
}

.colors-summary {
  padding: 0.4rem 0;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.colors-summary::-webkit-details-marker { display: none; }

.colors-summary::before {
  content: '▶';
  font-size: 0.55rem;
  transition: transform 0.18s;
  display: inline-block;
}

details[open] .colors-summary::before {
  transform: rotate(90deg);
}

.colors-body {
  padding-top: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.colors-intro {
  margin-bottom: 0;
}

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

.color-picker-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

input[type="color"] {
  width: 2.25rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px 3px;
  cursor: pointer;
  background: var(--surface-raised);
}

.color-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.color-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.color-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.btn-colors-reset {
  align-self: flex-start;
  padding: 0.35rem 0.75rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}

.btn-colors-reset:hover {
  border-color: var(--purple);
  color: var(--purple-bright);
}

/* Tab editors (dynamically generated) */
#tabs-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.tab-editor {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.tab-editor-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.tab-badge {
  background: var(--purple-dim);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 700;
  min-width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-remove-tab {
  padding: 0.3rem 0.65rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}

.btn-remove-tab:hover {
  border-color: #c44;
  color: #c44;
}

.tab-editor-body {
  padding: 1rem 1rem 1.1rem;
}

/* Paragraph blocks */
.paragraphs-container {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.paragraph-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
}

.paragraph-block:focus-within {
  border-color: var(--purple-dim);
}

.para-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.65rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

/* Neutralise global label margin inside para-toolbar */
.para-toolbar label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.size-group {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.btn-size {
  padding: 0.2rem 0.65rem;
  border: none;
  border-right: 1px solid var(--border);
  background: var(--surface-raised);
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.12s, color 0.12s;
  font-weight: 500;
}

.btn-size:last-child { border-right: none; }

.btn-size:hover:not(.active) {
  background: var(--bg);
  color: var(--text);
}

.btn-size.active {
  background: var(--purple-dim);
  color: var(--text);
  font-weight: 600;
}

.btn-link {
  padding: 0.2rem 0.65rem;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--purple-bright);
  font-weight: 500;
  transition: background 0.12s, border-color 0.12s;
}

.btn-link:hover {
  background: var(--purple-dim);
  border-color: var(--purple);
}

.btn-remove-para {
  margin-left: auto;
  padding: 0.2rem 0.5rem;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 0.72rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}

.btn-remove-para:hover {
  border-color: #c44;
  color: #c44;
}

.para-content {
  padding: 0.65rem 0.8rem;
  min-height: 3.5rem;
  font-size: 0.92rem;
  line-height: 1.55;
  outline: none;
  color: var(--text);
  word-wrap: break-word;
  background: var(--surface-raised);
}

.para-content:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
  display: block;
}

.para-content a {
  color: var(--purple-bright);
  text-decoration: underline;
}

.btn-add-para {
  width: 100%;
  padding: 0.5rem;
  background: none;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  font-weight: 500;
}

.btn-add-para:hover {
  border-color: var(--purple);
  color: var(--purple-bright);
}

/* Add tab button */
#btn-add-tab {
  width: 100%;
  padding: 0.85rem;
  background: none;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--text-muted);
  cursor: pointer;
  margin-top: 0.75rem;
  font-weight: 500;
  transition: border-color 0.15s, color 0.15s;
}

#btn-add-tab:hover {
  border-color: var(--purple);
  color: var(--purple-bright);
}

/* Export section */
.tbb-filename-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tbb-filename-ext {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  white-space: nowrap;
}

.tbb-filename-preview {
  font-size: 0.78rem;
  margin-bottom: 0;
  min-height: 1.2em;
}

.tbb-filename-preview span {
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  color: var(--text);
}

.tbb-output-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 1.75rem;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--text);
  color: var(--bg);
  padding: 0.65rem 1.4rem;
  border-radius: 20px;
  font-size: 0.87rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
  z-index: 1000;
  white-space: nowrap;
}

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

/* Drag and drop */
.drag-handle {
  cursor: grab;
  color: var(--border);
  display: flex;
  align-items: center;
  padding: 2px 3px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color 0.12s, background 0.12s;
}

.drag-handle:hover {
  color: var(--text-muted);
  background: var(--surface-raised);
}

.drag-handle:active { cursor: grabbing; }

.tab-editor.dragging { opacity: 0.35; }

.tab-editor.drop-before {
  box-shadow: 0 -3px 0 0 var(--purple);
}

.tab-editor.drop-after {
  box-shadow: 0 3px 0 0 var(--purple);
}

/* ── Preview gallery (used on svg-uke-chord-maker, favicon-maker) ── */

.preview-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  min-height: 60px;
}

/* ═══════════════════════════════════════════════
   FAVICON MAKER
   ═══════════════════════════════════════════════ */

.fm-preview-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
}

/* Checkerboard behind transparent icons */
.fm-icon {
  background: repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 0 0 / 12px 12px;
  border-radius: 2px;
}

#gradient-fields .field-group {
  min-width: 10rem;
}

/* ── Upload / drop zones (shared) ── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  text-align: center;
  cursor: default;
  transition: border-color 0.2s, background 0.2s;
  background: var(--surface);
}

.upload-zone.drag-over {
  border-color: var(--purple);
  background: var(--surface-raised);
}

.upload-zone .upload-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.6;
}

.upload-zone .upload-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.upload-zone .upload-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* ── HTML Packager ── */
.pkg-file-list {
  max-height: 260px;
  overflow-y: auto;
  font-size: 0.8rem;
  font-family: "SF Mono", "Fira Code", Consolas, "Liberation Mono", Menlo, monospace;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.pkg-file-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.pkg-file-row .pkg-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.pkg-file-row .pkg-size {
  flex-shrink: 0;
  color: var(--text-muted);
  opacity: 0.7;
}

.pkg-file-row.pkg-junk .pkg-name {
  text-decoration: line-through;
  opacity: 0.38;
}

.pkg-file-row.pkg-junk .pkg-size {
  opacity: 0.2;
}

.pkg-toggle {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.7rem;
  line-height: 1;
  padding: 0.15rem 0.4rem;
  opacity: 0.5;
  transition: opacity 0.15s, border-color 0.15s, color 0.15s, background 0.15s;
}

.pkg-toggle:hover {
  opacity: 1;
  border-color: var(--text-muted);
}

.pkg-file-row.pkg-junk .pkg-toggle {
  border-color: var(--purple);
  color: var(--purple);
  opacity: 0.85;
}

.pkg-file-row.pkg-junk .pkg-toggle:hover {
  background: var(--purple-dim);
  opacity: 1;
}

.pkg-warning {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-left: 3px solid var(--yellow);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
}

.pkg-warning[hidden] { display: none; }

.pkg-warning-label {
  font-weight: 600;
  color: var(--yellow);
  flex-shrink: 0;
}

.pkg-warning select {
  flex: 1;
  min-width: 8rem;
}

.pkg-counts {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: -0.25rem;
}

/* ── Tooltips ── */
.label-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.tooltip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.tooltip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  background: none;
  border: 1.5px solid var(--text-muted);
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.6rem;
  font-style: italic;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1;
  padding: 0;
  text-transform: none;
  opacity: 0.5;
  transition: opacity 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.tooltip-btn::after {
  content: 'i';
}

.tooltip-btn:hover,
.tooltip-btn[aria-expanded="true"] {
  opacity: 1;
  color: var(--purple);
  border-color: var(--purple);
}

.tooltip-popup {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  z-index: 200;
  width: 280px;
  max-width: min(280px, calc(100vw - 2rem));
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.55;
  text-transform: none;
}

.tooltip-popup[hidden] { display: none; }

.tooltip-header {
  display: flex;
  justify-content: flex-end;
  padding: 0.5rem 0.5rem 0;
}

.tooltip-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  letter-spacing: 0;
  line-height: 1;
  opacity: 0.5;
  padding: 0.15rem 0.3rem;
  text-transform: none;
  transition: opacity 0.15s;
}

.tooltip-close:hover { opacity: 1; }

.tooltip-body {
  padding: 0.1rem 0.9rem 0.9rem;
}

.tooltip-body p {
  margin: 0 0 0.5rem;
}

.tooltip-body p:last-child { margin-bottom: 0; }

.tooltip-body ul,
.tooltip-body ol {
  margin: 0.25rem 0 0.5rem 1.1rem;
  padding: 0;
}

.tooltip-body li { margin-bottom: 0.25rem; }
.tooltip-body li:last-child { margin-bottom: 0; }

.tooltip-body a { color: var(--purple); text-decoration: underline; }
.tooltip-body strong { color: var(--text); font-weight: 600; }
.tooltip-body em { font-style: italic; }

.tooltip-body code {
  font-family: "SF Mono", "Fira Code", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.85em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1em 0.3em;
}

/* ── Scrolling Banner Builder ────────────────────────────────────────────── */

.sbb-settings {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem 1.5rem;
  align-items: start;
}
.sbb-span { grid-column: 1 / -1; }

.sbb-swatch-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.25rem;
}

.sbb-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: transform 0.1s, box-shadow 0.15s;
}
.sbb-swatch:hover { transform: scale(1.12); }
.sbb-swatch.active { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--purple); }

.sbb-swatch-transparent {
  background: repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 0 0 / 12px 12px;
}

.sbb-range-label { font-size: 0.75rem; color: var(--text-muted); flex-shrink: 0; }

.sbb-number {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  padding: 0.5rem 0.65rem;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}
.sbb-number:focus { border-color: var(--purple); }

.sbb-add-btns { display: flex; gap: 0.5rem; }

.sbb-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  padding: 1.5rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin: 0;
}

.sbb-item-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  background: var(--surface);
}
.sbb-item-card:last-child { margin-bottom: 0; }

.sbb-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.sbb-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
}
.sbb-badge-text  { background: #e9d5ff; color: #6b21a8; }
.sbb-badge-image { background: #d1fae5; color: #065f46; }
[data-theme="dark"] .sbb-badge-text  { background: #3b0764; color: #d8b4fe; }
[data-theme="dark"] .sbb-badge-image { background: #052e16; color: #86efac; }

.sbb-item-actions { display: flex; gap: 0.25rem; }

.sbb-btn-icon {
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  padding: 0;
  line-height: 1;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.sbb-btn-icon:hover:not(:disabled) { background: var(--surface); color: var(--text); }
.sbb-btn-icon.sbb-delete:hover:not(:disabled) { border-color: #dc2626; color: #dc2626; }
.sbb-btn-icon:disabled { opacity: 0.3; cursor: not-allowed; }

.sbb-item-body { display: flex; flex-direction: column; gap: 0.4rem; }

.sbb-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  padding: 0.45rem 0.65rem;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.sbb-input:focus { border-color: var(--purple); }

.sbb-size-toggle {
  display: inline-flex;
  align-self: flex-start;
}
.sbb-size-toggle label {
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
  border-bottom: none;
  border-right: 1px solid var(--border);
}
.sbb-size-toggle label:last-of-type { border-right: none; }

.sbb-preview-outer {
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  min-height: 60px;
  transition: height 0.2s;
}

.sbb-preview-track {
  display: inline-flex;
  flex-shrink: 0;
  min-width: max-content;
  align-items: center;
  white-space: nowrap;
  will-change: transform;
}

@keyframes sbb-preview-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

.sbb-output {
  width: 100%;
  min-height: 180px;
  max-height: 420px;
  resize: vertical;
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.75rem;
  outline: none;
}

@media (max-width: 640px) {
  .sbb-settings { grid-template-columns: 1fr; }
  .sbb-span { grid-column: 1; }
}
