:root {
  --background-color-light: #f5f7fa;
  --background-color-dark: #2a2a2a;
  --sidebar-color-light: #1b1c1d;

  --theme-light-color: rgba(152, 152, 152, 0.3);
  --tcm-blue-color: rgb(99,145,210);
  --mediux-color: #945af2;

  /* Same as fomantic ui red */
  --support-button-color: #db2828;

  /* Accessibility colors */
  --accessible-red-color: #ff203b;
  --accessible-green-color: #1256ff;
  --accessible-blue-color: rgb(26, 133, 255);
  --accessible-orange-color: rgb(212, 17, 89);
}

body {
  background-color: #1b1c1d;
}

/* Mediux button styling */
.ui.mediux.button {
  color: var(--mediux-color) !important;
}
.ui.mediux.button:hover {
  box-shadow: inset 0 -0.2em 0 var(--mediux-color);
}

/* Accessibility coloring */
body.accessible .ui .red.bar {
  background-color: var(--accessible-red-color) !important;
}
body.accessible .ui .green.bar {
  background-color: var(--accessible-green-color) !important;
}
body.accessible .ui .blue.bar {
  background-color: var(--accessible-blue-color) !important;
}
body.accessible .ui .orange.bar {
  background-color: var(--accessible-orange-color) !important;
}

.inverted.form input {
  /* background: #e4e4e4 !important; */
  background: #1b1c1d !important;
  color: white !important;
}

/* Fix header in place, lock window positioning */
body > div:first-of-type {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}

#main-content {
  /* Ensure main content is scrollable */
  overflow-x: hidden;
  /* Add margin for main content to space from header and sidebar */
  padding: 15px 15px 15px 115px;
  /* padding: 15px 15px 15px 15px; */
  /* Always position below header */
  z-index: 98;
}

/* FLoating log messages (toasts) */
#__current_log {
  /* Position message in the lower-right corner */
  position: fixed;
  bottom: 0.8em;
  right: 1em;
  /* Color semi-transparent black with a blue right border */
  color: white;
  background-color: rgba(21, 21, 21, 90%);
  border-right: 3px solid rgb(76, 154, 247);
  /* Add slight shadow */
  box-shadow: rgba(0, 0, 0, 60%) 5px 5px 5px;
  /* Curve edges */
  border-radius: 0.4em;
  padding: 0.785em 1em;
  /* Limit width */
  max-width: 400px;
  /* Position above all other content */
  z-index: 9999;
}

/* Stylize "code" color text */
code.color {
  /* Add stylized bubble */
  padding: .1em .2em;
  background-color: rgba(110, 118, 129, 0.4);
  border-radius: 6px;
  /* Do not italicize color name */
  font-style: normal;
}

/* Color inline color circles */
span.color.circle {
  /* --color: transparent; */
  border-radius: 50%;
  width: 8px;
  height: 8px;
  display: inline-block;
  background-color: var(--color, var(--default-color, transparent));
  border: 0.5px solid var(--color, var(--default-color, #ffffff7d));
  /* Add space between color bubble and name */
  margin-left: 4px;
}

img ~ .color.palette {
  margin-top: 0.3em;
}
/* Palette colors are styled separately */
.color.palette > span.color {
  /* --color: transparent; */
  width: 45px; /* 35px; */
  height: 85px; /* 75px; */
  display: inline-block;
  background-color: var(--color, transparent);
  /* border: 0.5px dashed var(--alt-color, white); */
  /* Add spacing */
  margin-left: 4px;
  /* Round edges of palette swatches */
  border-radius: 0.4rem;
  /* Show pointer on hover to indicate selectability */
  cursor: pointer;
}
.small.color.palette > span.color {
  width: 30px;
  height: 50px;
}

/* Header element alignment */
#page-header {
  align-items: center;
  display: flex;
  height: 70px;
  flex: 0 0 auto;
  /* Drop shadow so header is separated from rest of page */
  box-shadow: 1px 1px 10px -3px rgba(252, 252, 252, 0.8);
}
#page-header >* {
  display: flex;
  align-items: center;
}
/* Remove extra margin from header button */
#page-header .ui.button > .icon {
  margin: unset;
}
/* Right aligned header elements */
#page-header > [data-position="right"] {
  justify-content: flex-end;
  flex-grow: 1;
  margin-right: 25px;
  @media (max-width: 768px) {
    margin-right: unset;
  }
}
#page-header > [data-position="right"] >* {
  margin-right: 10px;
}

/* Supporter thanks text - random rating/thank-you in header */
.supporter-thanks {
  font-size: 0.91rem;
  color: var(--sidebar-text-color-light, rgba(255, 255, 255, 0.9));
  white-space: nowrap;
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 6px;
  transition: opacity 0.4s ease;
}
.supporter-thanks.supporter-thanks-fade-out {
  opacity: 0;
}
@media (max-width: 768px) {
  .supporter-thanks {
    display: none;
  }
}
.supporter-thanks .supporter-name {
  font-weight: bold;
  color: inherit;
}
.supporter-thanks .supporter-name-super .supporter-text-super,
.supporter-thanks .supporter-text-super {
  color: #d4af37 !important; /* gold */
}
body.dark .supporter-thanks {
  color: var(--sidebar-text-color-dark, rgba(255, 255, 255, 0.9));
}

#tcm-logo {
  /* Pad the entire width of the sidebar */
  flex: 0 0 94px; /* 0 0 109px */
  /* Center logo horizontally */
  justify-content: center;
}

/* Global background gradient */
body {
  background-image: linear-gradient(to bottom right, var(--background-color-light), #d9d9d9);
  /* linear-gradient(to bottom right, var(--background-color-dark), #313131) */ 
}

/* Don't put any scrollbars in the sidebar */
#nav-menu > .sidebar {
  overflow: hidden;
}

/* Style for the header on all pages */
#page-header {
  /* height: 70px; */
  background-color: var(--sidebar-color-light);
  z-index: 99; /* Position above all elements */
}

/* Remove outline from logo */
#tcm-logo img {
  max-height: 50px;
  @media (max-width: 768px) {
    /* Remove fixed width on logo */
    width: unset;
    flex: 0 0 70px;
  }
}
#tcm-logo, #tcm-logo:hover {
  box-shadow: none;
}

/* Position sidebar below header */
#nav-menu .sidebar {
  top: 70px;
}

/* Format for the search results */
.search.content {
  display: inline-block;
  vertical-align: middle;
  /* Cut off any long series name */
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
}
.search.content > img {
  height: 50px;
  width: 35px;
  vertical-align: middle;
  margin-right: 8px;
}
.search.result {
  padding: 7px !important;
}

/* Format right aligned fields and inputs */
.right.aligned.field,
.right.aligned.field input {
  text-align: right;
}
/* Adjacent input fields need additional top margin */
input ~ input {
  margin-top: 4px !important;
}

/* Dropdown headers are red */
.ui.dropdown >* .header {
  color: crimson !important;
}

/* Add shadow around search input when selected */
#search-bar input:focus {
  box-shadow: 0 0 1.1em 0 var(--tcm-blue-color) !important;
}

/* Support button */
#support-button {
  /* Add glow effect */
  border-radius: 0.25em;
  box-shadow: 0 0 1.1em 0 var(--support-button-color);
  @media (max-width: 768px) {
    /* Hide support button on mobile */
    display: none;
  }
}
/* Don't leave any additional margin */
#support-button .button {
  margin: 0;
}

html.ios {
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
html.ios,
html.ios body {
  height: initial !important;
}

/* Scrollbar customization */
::-webkit-scrollbar {
  width: 0.5em;
}
::-webkit-scrollbar-track {
  background: rgba(12, 12, 12, 0.2);
  border-radius: 100vw;
  margin-block: 0.5em;
}
::-webkit-scrollbar-thumb {
  background: var(--tcm-blue-color);
  border-radius: 100vw;
  border: 0.25em solid var(--tcm-blue-color);
}

/* Firefox support */
@supports (scrollbar-color: red blue) {
  * {
    scrollbar-color: var(--tcm-blue-color) rgba(12,12,12, 0.2);
  }
}

/* Mobile formatting */
@media only screen and (hover: none) and (pointer: coarse) {
  /* Prevent iOS auto-zoom on input focus (happens for font sizes <16px) */
  input:focus,
  select:focus,
  textarea:focus {
    font-size: 16px !important;
  }
}

@media (max-width: 768px) {
  /* Do not use absolute positioning, let items stack themselves */
  #page-header > div {
    position: unset;
  }

  /* Shrink search input */
  #header-search input {
    width: 100px;
  }

  /* Hide icons */
  #nav-menu i {
    display: none;
  }

  /* Use reduced padding */
  #main-content {
    /* padding-left: 95px; */
    padding-left: 15px;
  }
  #nav-menu {
    display: none;
  }
  #nav-menu .item {
    padding: 1.25em 0.1em;
  }
  #nav-menu .sidebar {
    top: 70px;
  }
}

/* Add glow effect on selected input fields */
html.dark body *:not(td) input:active,
html.dark body *:not(td) input:focus,
html.dark body *:not(td).dropdown:not(.inline):not(.icon):hover {
  /* Dark theme */
  box-shadow: 0px 0px 15px white !important;
}
html:not(dark) body *:not(td) input:active,
html:not(dark) body *:not(td) input:focus,
html:not(dark) body *:not(td) .dropdown:not(.inline):not(.icon):hover {
  /* Light theme */
  box-shadow: 0px 0px 15px #b6b6b6 !important;
}

/* Format help notes */
p.help {
  color: #737373;
  font-size: 0.95em;
  font-style: italic;
  padding-top: 0.2em;
}

/* Make help text for active inputs more evident */
html.dark body input:active ~ p.help,
html.dark body input:focus ~ p.help,
html.dark body .input ~ p.help:hover,
html.dark body .dropdown:hover ~ p.help,
html.dark body .dropdown.active ~ p.help,
html.dark body .checkbox.field:hover p.help,
html.dark body .fields:hover ~ p.help {
  /* Dark theme */
  color: #cce2ff; /* #d7dfeb */
}
html:not(dark) body input:active ~ p.help,
html:not(dark) body input:focus ~ p.help,
html:not(dark) body .dropdown:hover ~ p.help,
html:not(dark) body .dropdown.active ~ p.help,
html:not(dark) body .checkbox.field:hover p.help,
html:not(dark) body .fields:hover ~ p.help {
  /* Light theme */
  color: #171515;
}

.blueprint.card [data-action="blacklist"]:hover {
  color: #db2828 !important;
}
.blueprint.card [data-action="import"]:hover {
  color: #2ecc40;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SHARED PANEL SYSTEM
   Used by: settings, system, recent, addSeries (and any future pages)
   ═══════════════════════════════════════════════════════════════════════════ */

/* Dot-grid background overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, rgba(0, 0, 0, 0.07) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
  z-index: 0;
}

html.dark body::before {
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
}

/* Glass-morphism section panel — light mode default */
.settings-panel {
  position: relative;
  z-index: 0;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  margin-bottom: 1.5rem;
  overflow: visible;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

/* Keep open dropdown menus above later panels in the same tab/page */
.settings-panel:has(.ui.dropdown.active),
.settings-panel:has(.ui.dropdown.visible) {
  z-index: 30;
}

html.dark .settings-panel {
  background: linear-gradient(160deg, rgba(30, 33, 42, 0.6), rgba(99, 145, 210, 0.05));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: none;
}

/* Panel title bar */
.settings-panel-header {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.85rem 1.25rem;
  font-size: 0.8em;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  color: rgb(60, 100, 160);
  flex-wrap: wrap;
  row-gap: 0.4rem;
}

html.dark .settings-panel-header {
  color: var(--tcm-blue-color);
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

/* Panel body padding */
.settings-panel > section,
.settings-panel .content > section {
  padding: 1.25rem;
}

/* Suppress extra Fomantic accordion content padding so our section controls it */
.settings-panel.ui.accordion .content {
  padding: 0;
}

/* Subdued note at the top of a panel section */
.section-note {
  font-size: 0.85em;
  color: rgba(0, 0, 0, 0.45);
  margin: 0 0 1rem;
}

html.dark .section-note {
  color: rgba(255, 255, 255, 0.4);
}

/* ── Pill-group selector (page size, generic filters, etc.) ──────────────── */

/* Wrapping pill row with optional label */
.pill-filter-group {
  display: inline-flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

html.dark .pill-filter-group {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

.pill-filter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.22rem 0.65rem;
  font-size: 0.78em;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  min-height: 26px;
  line-height: 1;
  text-transform: none;
}

html.dark .pill-filter-btn {
  color: rgba(255, 255, 255, 0.38);
}

.pill-filter-btn:hover:not(.active) {
  background: rgba(0, 0, 0, 0.07);
  color: rgba(0, 0, 0, 0.7);
}

html.dark .pill-filter-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.65);
}

.pill-filter-btn.active {
  background: var(--tcm-blue-color);
  color: white;
  box-shadow: 0 1px 4px rgba(99, 145, 210, 0.45);
}

/* Dim label that annotates what a pill group controls, e.g. "per page" */
.pill-filter-label {
  font-size: 0.72em;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: rgba(0, 0, 0, 0.3);
  white-space: nowrap;
}

html.dark .pill-filter-label {
  color: rgba(255, 255, 255, 0.28);
}

/* ═══════════════════════════════════════════════════════════════════════════
   PANEL ACTION BUTTONS
   Buttons that sit inside .settings-panel-header rows.
   Base is blue-toned. Add modifier classes for colour variants:
     .panel-action-btn--warn     amber
     .panel-action-btn--success  green
   ═══════════════════════════════════════════════════════════════════════════ */

.panel-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.3rem 0.8rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: none;
  border-radius: 6px;
  border: 1px solid rgba(99, 145, 210, 0.38);
  background: rgba(99, 145, 210, 0.09);
  color: var(--tcm-blue-color);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.panel-action-btn:hover {
  background: rgba(99, 145, 210, 0.18);
  border-color: rgba(99, 145, 210, 0.6);
}

.panel-action-btn i.icon {
  margin: 0;
  font-size: 0.88em;
}

/* Amber / warning variant */
.panel-action-btn--warn {
  border-color: rgba(234, 179, 8, 0.35);
  background: rgba(234, 179, 8, 0.07);
  color: #b45309;
}

html.dark .panel-action-btn--warn {
  color: #fbbf24;
}

.panel-action-btn--warn:hover {
  background: rgba(234, 179, 8, 0.16);
  border-color: rgba(234, 179, 8, 0.6);
}

/* Green / success variant */
.panel-action-btn--success {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.07);
  color: #15803d;
}

html.dark .panel-action-btn--success {
  color: #4ade80;
}

.panel-action-btn--success:hover {
  background: rgba(34, 197, 94, 0.16);
  border-color: rgba(34, 197, 94, 0.6);
}

/* ═══════════════════════════════════════════════════════════════════════════
   INLINE EDITABLE LIST — shared by Fonts (replacements), Templates (season
   titles, filter conditions, translations), and any future row-based editors.
   ═══════════════════════════════════════════════════════════════════════════ */

/* Label row with right-aligned action buttons */
.repl-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.repl-header > label {
  margin: 0 !important;
  flex-shrink: 0;
}

.repl-header-actions {
  display: flex;
  gap: 0.35rem;
  margin-left: auto;
}

/* Small inline action button (Add, Analyze, …) */
.repl-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.25rem 0.6rem;
  font-size: 0.76em;
  font-weight: 600;
  border-radius: 5px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: rgba(0, 0, 0, 0.04);
  color: rgba(0, 0, 0, 0.55);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

html.dark .repl-action-btn {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.45);
}

.repl-action-btn:hover {
  background: rgba(99, 145, 210, 0.12);
  border-color: rgba(99, 145, 210, 0.4);
  color: var(--tcm-blue-color);
}

.repl-action-btn i.icon {
  margin: 0;
  font-size: 0.92em;
}

/* → arrow separator between input pair */
.repl-arrow {
  flex-shrink: 0;
  color: rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
}

html.dark .repl-arrow {
  color: rgba(255, 255, 255, 0.22);
}

.repl-arrow i.icon {
  margin: 0 !important;
  font-size: 0.9em;
}

/* Per-row × delete button */
.repl-delete-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 5px;
  background: transparent;
  color: rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

html.dark .repl-delete-btn {
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.28);
}

.repl-delete-btn:hover {
  background: rgba(220, 53, 69, 0.1);
  border-color: rgba(220, 53, 69, 0.4);
  color: #dc3545;
}

.repl-delete-btn i.icon {
  margin: 0;
  font-size: 0.78em;
}

/* Card extras (shared with settings-style labels; series/templates do not load settings.css) */
.help-tip {
  margin-left: 0.35em;
  color: rgba(0, 0, 0, 0.3);
  font-size: 0.95rem;
  font-weight: normal;
  cursor: default;
  position: relative;
  display: inline-block;
  vertical-align: middle;
  user-select: none;
}

html.dark .help-tip {
  color: rgba(255, 255, 255, 0.35);
}

.help-tip::after {
  content: attr(data-tip);
  display: none;
  position: absolute;
  left: 1.4em;
  top: 50%;
  transform: translateY(-50%);
  width: 280px;
  background: rgba(18, 20, 28, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 0.6em 0.85em;
  font-size: 0.92em;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.85);
  white-space: normal;
  z-index: 500;
  pointer-events: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.help-tip:hover::after {
  display: block;
}

.field.card-extra-field > label {
  position: relative;
}

/* Card extras: type selector in panel header */
.card-extras-root .card-extras-type-header .card-extras-header-title {
  flex: 1;
  min-width: 0;
}

.card-extras-root .card-extras-type-header .card-extras-type-select {
  margin-left: auto;
  width: auto;
  min-width: 11rem;
  max-width: min(55vw, 24rem);
  flex-shrink: 0;
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
  background: rgba(255, 255, 255, 0.95);
}

html.dark .card-extras-root .card-extras-type-header .card-extras-type-select {
  background: rgba(30, 33, 42, 0.9);
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.92);
}

.card-extra-native-select {
  width: 100%;
  max-width: 420px;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  font-size: 0.95rem;
  background: rgba(255, 255, 255, 0.95);
}

html.dark .card-extra-native-select {
  background: rgba(30, 33, 42, 0.9);
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.92);
}

.card-extras-panel-host .card-extra-type-panel[hidden] {
  display: none !important;
}

/* Episode extras fullscreen modal: centered title row */
#episode-extras-modal.fullscreen.modal > .header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  text-align: center;
  font-weight: 600;
}

#episode-extras-modal .field[data-value="translation-key"] input,
#episode-extras-modal .field[data-value="translation-value"] input {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin-bottom: 0.35rem;
}

#episode-extras-modal .card-extras-body {
  max-height: min(50vh, 26rem);
  overflow-y: auto;
}
