:root {
  color-scheme: dark;
  --font-base: "Inter", "Segoe UI", system-ui, sans-serif;
  --bg-body: #050b12;
  --bg-overlay: radial-gradient(circle at 18% 22%, rgba(30, 120, 210, 0.08), transparent 60%),
    radial-gradient(circle at 80% 18%, rgba(105, 70, 210, 0.06), transparent 55%),
    radial-gradient(circle at 50% 90%, rgba(40, 150, 150, 0.08), transparent 60%);
  --bg-card: rgba(13, 22, 33, 0.95);
  --bg-panel: rgba(18, 30, 45, 0.92);
  --bg-input: rgba(11, 19, 29, 0.96);
  --border-soft: rgba(86, 110, 135, 0.35);
  --border-strong: rgba(86, 110, 135, 0.55);
  --shadow-soft: 0 18px 60px rgba(2, 12, 24, 0.45);
  --shadow-lift: 0 18px 45px rgba(0, 160, 220, 0.22);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --text-primary: #f2f6fb;
  --text-secondary: #b5c3d6;
  --text-muted: #8090a5;
  --accent: #35c9ff;
  --accent-strong: #368ff0;
  --accent-gradient: linear-gradient(135deg, #3bc9ff 0%, #4f8cff 100%);
  --success: #72f4cf;
  --danger: #ff8d9b;
  --warning: #ffd166;
  font-family: var(--font-base);
  font-size: 15px;
  line-height: 1.7;
}

* {
  box-sizing: border-box;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(8, 14, 22, 0.8);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(53, 213, 255, 0.75), rgba(63, 139, 255, 0.75));
  border-radius: 999px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-body);
  background-image: var(--bg-overlay);
  background-attachment: fixed;
  color: var(--text-primary);
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 3.2rem 2rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 3rem;
}

header {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

header h1 {
  margin: 0;
  font-size: 2.4rem;
  letter-spacing: 0.02em;
  font-weight: 700;
  background: linear-gradient(130deg, #ffffff 0%, #d1e7ff 45%, #7fb3ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  margin: 0 auto;
  max-width: 640px;
  font-size: 0.98rem;
  color: var(--text-secondary);
}

.version-badge {
  align-self: center;
  background: rgba(53, 213, 255, 0.15);
  border: 1px solid rgba(53, 213, 255, 0.45);
  color: #8deaff;
  border-radius: 999px;
  padding: 0.35rem 1.1rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.card {
  background: var(--bg-card);
  border-radius: calc(var(--radius-lg) - 6px);
  border: 1px solid rgba(86, 110, 135, 0.28);
  padding: 2rem 2.2rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(20px);
}

.card h2 {
  margin: 0;
  font-size: 1.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
}

.card h2::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 6px;
  background: var(--accent-gradient);
  box-shadow: var(--shadow-lift);
}

#configForm {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.hint {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.94rem;
}

.warning {
  margin: 0;
  padding: 1.1rem 1.4rem;
  border-radius: var(--radius-md);
  background: rgba(255, 141, 155, 0.08);
  border: 1px solid rgba(255, 141, 155, 0.35);
  color: var(--danger);
  font-weight: 600;
}

.error {
  margin: 0;
  color: var(--danger);
  font-weight: 600;
}

.field-row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.field-row label {
  font-weight: 600;
  color: var(--text-secondary);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.4rem 1.6rem;
}

.field-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.field-grid label.wide-field {
  grid-column: 1 / -1;
}

.field-hint {
  font-weight: 400;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
}

input[type="text"],
input[type="url"],
input[type="password"],
input[type="number"],
select {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: border 140ms ease, box-shadow 160ms ease, transform 100ms ease;
  min-height: 48px;
}

input:hover,
select:hover {
  border-color: rgba(53, 213, 255, 0.5);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 4px rgba(62, 180, 255, 0.18);
  transform: translateY(-1px);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath fill='%23a8bad1' d='M3.5 5l3.5 4 3.5-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1.1rem center;
  padding-right: 2.6rem;
  cursor: pointer;
}

.checkbox {
  flex-direction: row !important;
  align-items: flex-start;
  gap: 0.7rem !important;
  font-size: 0.94rem;
}

.checkbox input[type="checkbox"] {
  margin-top: 0.25rem;
  width: 20px;
  height: 20px;
  border-radius: 7px;
  accent-color: #58d7ff;
  cursor: pointer;
}

.checkbox span {
  font-weight: 600;
  color: var(--text-primary);
}

.inline-actions,
.actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.primary,
.secondary,
button.ghost {
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.75rem 1.7rem;
  transition: transform 120ms ease, box-shadow 180ms ease, background 180ms ease;
}

.primary {
  background: var(--accent-gradient);
  border: none;
  color: #051521;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
  box-shadow: var(--shadow-lift);
  cursor: pointer;
}

.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 50px rgba(63, 139, 255, 0.35);
}

.secondary {
  background: rgba(62, 84, 110, 0.25);
  border: 1px solid rgba(86, 110, 135, 0.55);
  color: var(--text-primary);
  cursor: pointer;
}

.secondary:hover {
  background: rgba(62, 84, 110, 0.45);
  border-color: rgba(95, 180, 255, 0.6);
}

button.ghost {
  background: transparent;
  border: 2px dashed rgba(95, 120, 150, 0.7);
  color: var(--text-secondary);
  cursor: pointer;
}

button.ghost:hover {
  border-color: rgba(95, 180, 255, 0.6);
  color: #9fdcff;
}

button.ghost.danger {
  border-color: rgba(255, 141, 155, 0.6);
  color: rgba(255, 141, 155, 0.9);
}

button.ghost.danger:hover {
  border-color: rgba(255, 141, 155, 0.9);
  color: #ffe0e4;
}

.status-message {
  min-height: 1.6rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.status-message.success {
  color: var(--success);
}

.status-message.error {
  color: var(--danger);
}

.manifest-row {
  display: grid;
  grid-template-columns: 1fr minmax(230px, auto);
  gap: 1.6rem;
  align-items: start;
}

.manifest-info {
  background: rgba(6, 12, 18, 0.65);
  border-radius: var(--radius-md);
  padding: 1rem 1.2rem;
  border: 1px solid rgba(53, 213, 255, 0.25);
  color: var(--accent);
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.95rem;
  line-height: 1.5;
}

.manifest-actions {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.copy-status {
  font-size: 0.88rem;
  color: #8ae8ff;
  min-width: 4.5rem;
}

.divider {
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, rgba(62, 84, 110, 0), rgba(62, 84, 110, 0.55), rgba(62, 84, 110, 0));
  margin: 1.5rem 0;
  border-radius: 999px;
}

.group {
  background: var(--bg-panel);
  border-radius: var(--radius-md);
  border: 1px solid rgba(86, 110, 135, 0.25);
  padding: 1.7rem 1.9rem;
  display: flex;
  flex-direction: column;
  gap: 1.3rem;
  box-shadow: 0 18px 40px rgba(2, 12, 24, 0.4);
}

.group h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #eaf2ff;
}

.group h3 + * {
  margin-top: 0.25rem;
}

.newznab-preset-bar {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.newznab-list {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.newznab-empty-hint {
  margin: 0;
  padding: 1.4rem;
  border-radius: var(--radius-md);
  border: 2px dashed rgba(95, 120, 150, 0.4);
  background: rgba(6, 12, 18, 0.55);
  text-align: center;
  color: var(--text-muted);
  font-weight: 600;
}

.newznab-row {
  background: rgba(8, 16, 26, 0.92);
  border-radius: var(--radius-md);
  border: 1px solid rgba(86, 110, 135, 0.4);
  padding: 1.4rem 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  transition: transform 120ms ease, box-shadow 200ms ease, border 150ms ease;
}

.newznab-row:hover {
  transform: translateY(-3px);
  box-shadow: 0 24px 45px rgba(0, 0, 0, 0.35);
  border-color: rgba(95, 180, 255, 0.6);
}

.newznab-row .row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.2rem;
  flex-wrap: wrap;
}

.newznab-row .row-title {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.row-handle {
  font-size: 1.3rem;
  color: rgba(180, 200, 220, 0.6);
  cursor: grab;
  transition: color 150ms ease;
}

.row-handle:hover {
  color: rgba(180, 200, 220, 0.95);
}

.newznab-row .field-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.quality-filter {
  margin-top: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.quality-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.6rem;
}

.quality-checkbox-grid .checkbox {
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(86, 110, 135, 0.28);
  background: rgba(10, 20, 32, 0.8);
}

.language-multiselect {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.language-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.45rem;
  max-height: 180px;
  overflow-y: auto;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(86, 110, 135, 0.28);
  background: rgba(8, 16, 26, 0.8);
}

.language-checkbox-grid .checkbox {
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  background: transparent;
}

.language-checkbox-grid .checkbox:hover {
  background: rgba(62, 210, 255, 0.08);
}

.support-note {
  margin: 1.8rem 0 0;
  padding: 1.4rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(86, 110, 135, 0.35);
  background: rgba(8, 16, 26, 0.85);
  text-align: center;
  color: var(--text-secondary);
  font-size: 1rem;
}

.support-note a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.support-note a:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

@media (max-width: 960px) {
  .container {
    padding: 3rem 1.6rem 4rem;
  }

  .card {
    padding: 2rem 2.2rem;
  }

  .group {
    padding: 1.4rem 1.6rem;
  }
}

@media (max-width: 720px) {
  .container {
    padding: 2.5rem 1.2rem 3rem;
  }

  header h1 {
    font-size: 2.1rem;
  }

  .card {
    padding: 1.8rem;
    border-radius: 24px;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .manifest-row {
    grid-template-columns: 1fr;
    gap: 1.2rem;
  }

  .inline-actions,
  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .primary,
  .secondary,
  button.ghost {
    width: 100%;
    justify-content: center;
  }

  .language-checkbox-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .quality-checkbox-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .language-checkbox-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .quality-checkbox-grid {
    grid-template-columns: 1fr;
  }
}
