:root {
  color-scheme: light dark;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  font-size: 16px;
}

body {
  margin: 0;
  background: #111820;
  color: #f4f6f8;
}

.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.version-badge {
  align-self: flex-start;
  background: rgba(0, 179, 255, 0.15);
  border: 1px solid rgba(0, 179, 255, 0.45);
  color: #8bd8ff;
  border-radius: 999px;
  padding: 0.2rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
}

header h1 {
  margin: 0;
  font-size: 2.1rem;
}

.subtitle {
  margin: 0;
  color: #c2cad6;
}

.card {
  background: rgba(15, 24, 34, 0.95);
  border: 1px solid rgba(94, 114, 130, 0.35);
  border-radius: 12px;
  padding: 1.75rem;
  box-shadow: 0 24px 48px rgba(4, 8, 15, 0.35);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 2.25rem;
}

h2, h3 {
  margin: 0;
}

.hint {
  color: #9caec0;
  margin: 0;
}

.warning {
  margin: 0;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: rgba(255, 102, 102, 0.12);
  border: 1px solid rgba(255, 102, 102, 0.45);
  color: #ff8a7a;
  font-weight: 600;
}

.warning + .field-row {
  margin-top: 0.75rem;
}

.field-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.field-row label {
  font-weight: 600;
}

input[type="text"],
input[type="url"],
input[type="password"],
input[type="number"],
select {
  background: rgba(18, 27, 38, 0.95);
  border: 1px solid rgba(94, 114, 130, 0.35);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  color: inherit;
  width: 100%;
  box-sizing: border-box;
}

input:focus,
select:focus {
  outline: 2px solid #00b3ff;
  outline-offset: 2px;
}

.primary {
  align-self: flex-start;
  background: linear-gradient(135deg, #00b3ff, #0078ff);
  border: none;
  border-radius: 8px;
  color: #ffffff;
  font-weight: 600;
  padding: 0.65rem 1.4rem;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(0, 123, 255, 0.28);
}

.secondary {
  align-self: flex-start;
  background: transparent;
  border: 1px solid rgba(94, 114, 130, 0.6);
  border-radius: 8px;
  color: #e0e7ef;
  font-weight: 600;
  padding: 0.55rem 1.2rem;
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease;
}

.secondary:hover {
  border-color: #40c4ff;
  color: #40c4ff;
}

.error {
  color: #ff6b6b;
}

.hidden {
  display: none !important;
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.manifest-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  justify-content: space-between;
}

.manifest-info {
  flex: 1 1 280px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  word-break: break-all;
}

.manifest-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
  min-width: 240px;
}

.manifest-actions .secondary {
  width: 100%;
}

@media (min-width: 720px) {
  .manifest-actions {
    flex-direction: row;
    flex-wrap: wrap;
    min-width: unset;
  }

  .manifest-actions .secondary {
    width: auto;
  }
}

.copy-status {
  font-size: 0.85rem;
  color: #8bd8ff;
  min-width: 3.5rem;
}

.group {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.25rem;
  border: 1px solid rgba(94, 114, 130, 0.4);
  border-radius: 12px;
  background: rgba(18, 27, 38, 0.9);
}

.group + .group {
  margin-top: 1.5rem;
}

.group h3 {
  color: #d9e4ef;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem 1rem;
}

.field-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-weight: 600;
}

.field-grid label.wide-field {
  grid-column: span 2;
}

.field-label-with-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.input-with-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.input-with-toggle input {
  flex: 1;
}

.mask-toggle {
  border: 1px solid rgba(94, 114, 130, 0.6);
  border-radius: 6px;
  background: transparent;
  color: #e0e7ef;
  font-weight: 600;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease;
}

.mask-toggle:hover {
  border-color: #40c4ff;
  color: #40c4ff;
}

.api-key-link-wrapper {
  font-weight: 400;
  font-size: 0.85rem;
  display: none;
}

.api-key-link {
  font-size: 0.85rem;
  color: #40c4ff;
  text-decoration: none;
  font-weight: 600;
}

.api-key-link:hover {
  text-decoration: underline;
}

.api-key-link-wrapper:not(.hidden) {
  display: inline-flex;
}

.field-hint {
  font-weight: 400;
  font-size: 0.85rem;
  color: #9caec0;
}

.quality-filter {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.quality-filter-header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.quality-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.5rem;
}

.quality-checkbox-grid .checkbox {
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  border: 1px solid rgba(94, 114, 130, 0.4);
  background: rgba(18, 27, 38, 0.9);
}

.language-multiselect {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.language-multiselect .field-label {
  font-weight: 600;
}

.language-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 0.35rem;
  max-height: 100px;
  overflow-y: auto;
  padding-right: 0.35rem;
}

.language-checkbox-grid .checkbox {
  padding: 0.3rem 0.45rem;
  border-radius: 8px;
  border: 1px solid rgba(94, 114, 130, 0.35);
  background: rgba(18, 27, 38, 0.85);
}

.language-multiselect.language-required {
  border: 1px solid rgba(0, 179, 255, 0.4);
  border-radius: 10px;
  padding: 0.6rem;
}


.checkbox {
  flex-direction: row !important;
  align-items: center;
  gap: 0.6rem !important;
}

.checkbox span {
  font-weight: 600;
}

.actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.status-message {
  min-height: 1.5rem;
  display: inline-flex;
  align-items: center;
}

.status-message.success {
  color: #6fde8d;
}

.status-message.error {
  color: #ff6b6b;
}

.divider {
  width: 100%;
  height: 1px;
  background: rgba(94, 114, 130, 0.4);
  margin: 1rem 0;
}

.newznab-preset-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.newznab-preset-bar select {
  min-width: 240px;
}

.newznab-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 0.75rem;
}

.newznab-empty-hint {
  margin: 0;
  padding: 1rem;
  border: 1px dashed rgba(94, 114, 130, 0.35);
  border-radius: 10px;
  text-align: center;
  color: #9caec0;
}

.newznab-row {
  border: 1px solid rgba(64, 84, 104, 0.7);
  border-radius: 12px;
  padding: 1rem;
  background: rgba(14, 22, 30, 0.95);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.newznab-row .row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.newznab-row .row-title {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.row-label {
  font-weight: 600;
}

.row-handle {
  font-size: 1.2rem;
  line-height: 1;
  color: #6f8096;
  cursor: grab;
  user-select: none;
}

.row-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

button.ghost {
  background: transparent;
  border: 1px dashed rgba(94, 114, 130, 0.6);
  border-radius: 8px;
  color: #cdd5e0;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  font-weight: 600;
  transition: border-color 120ms ease, color 120ms ease;
}

button.ghost:hover {
  border-color: #40c4ff;
  color: #40c4ff;
}

button.ghost.danger {
  border-color: rgba(255, 107, 107, 0.5);
  color: #ff8a7a;
}

button.ghost.danger:hover {
  border-color: #ff6b6b;
  color: #ff6b6b;
}

.newznab-row .field-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.newznab-row .row-inline {
  justify-content: flex-start;
}

.newznab-row .row-status {
  min-height: 1.2rem;
}

.newznab-actions-top {
  margin-top: 0.25rem;
}

.newznab-controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#newznabGroup .divider {
  margin: 1rem 0 0.5rem;
}

.support-note {
  margin: 1rem 0 0;
  color: #c2cad6;
}

.support-note a {
  color: #40c4ff;
  font-weight: 600;
  text-decoration: none;
}

.support-note a:hover {
  text-decoration: underline;
}

@media (max-width: 720px) {
  .manifest-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .primary {
    width: 100%;
    text-align: center;
  }

  .newznab-preset-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .newznab-preset-bar select,
  .newznab-preset-bar button,
  .newznab-preset-bar .secondary {
    width: 100%;
  }

  .newznab-row {
    padding: 0.85rem;
  }

  .newznab-row .row-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .row-controls {
    width: 100%;
    justify-content: flex-start;
  }

  .newznab-row .field-grid {
    grid-template-columns: 1fr;
  }

  #newznab-test-search .field-grid {
    grid-template-columns: 1fr;
  }

  #newznab-test-search .actions {
    align-items: stretch;
  }

  #newznab-test-search .actions .secondary,
  .newznab-controls .secondary,
  .newznab-controls button {
    width: 100%;
  }

  .newznab-controls {
    align-items: stretch;
  }
}
