:root {
  color-scheme: light dark;
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-code: #0f172a;
  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-strong: #cbd5e1;
  --accent-primary: #ea580c;
  --accent-hover: #c2410c;
  --accent-soft: #fff7ed;
  --accent-border: #fdba74;
  --badge-bg: #ffedd5;
  --badge-text: #9a3412;
  --valid-bg: #dcfce7;
  --valid-text: #166534;
  --warn-bg: #fef3c7;
  --warn-border: #fde68a;
  --warn-text: #92400e;
  --error-bg: #fef2f2;
  --error-border: #fecaca;
  --error-text: #b91c1c;
  --info-bg: #eff6ff;
  --info-border: #bfdbfe;
  --info-text: #1d4ed8;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06);
  --radius-md: 10px;
  --radius-lg: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-page: #0b0f19;
    --bg-surface: #111827;
    --bg-subtle: #1e293b;
    --bg-code: #090d16;
    --text-main: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #1e293b;
    --border-strong: #334155;
    --accent-primary: #f97316;
    --accent-hover: #fb923c;
    --accent-soft: rgba(249, 115, 22, 0.12);
    --accent-border: rgba(249, 115, 22, 0.4);
    --badge-bg: rgba(249, 115, 22, 0.18);
    --badge-text: #fdba74;
    --valid-bg: rgba(34, 197, 94, 0.18);
    --valid-text: #86efac;
    --warn-bg: rgba(245, 158, 11, 0.16);
    --warn-border: rgba(245, 158, 11, 0.35);
    --warn-text: #fcd34d;
    --error-bg: rgba(239, 68, 68, 0.12);
    --error-border: rgba(239, 68, 68, 0.35);
    --error-text: #fca5a5;
    --info-bg: rgba(59, 130, 246, 0.12);
    --info-border: rgba(59, 130, 246, 0.35);
    --info-text: #93c5fd;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  }
}

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

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-page);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent-primary);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.app-shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 20px 16px;
}

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 11px;
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(234, 88, 12, 0.28);
}

.brand-logo svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

.brand-titles h1 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand-titles h1 a {
  color: var(--text-main);
  text-decoration: none;
}

.brand-subtitle {
  margin: 3px 0 0;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.format-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.format-pill {
  appearance: none;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.format-pill:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-soft);
}

/* Parser Input Workspace Card */
.parser-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin-bottom: 22px;
}

.input-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-subtle);
  overflow-x: auto;
}

.input-tab-btn {
  appearance: none;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 12px 18px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.input-tab-btn:hover {
  color: var(--text-main);
  background: rgba(148, 163, 184, 0.08);
}

.input-tab-btn.is-active {
  color: var(--accent-primary);
  background: var(--bg-surface);
  border-bottom-color: var(--accent-primary);
}

.input-tab-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  flex-shrink: 0;
}

.tab-panel {
  padding: 20px;
}

.is-hidden,
[hidden] {
  display: none !important;
}

/* URL Form */
.url-form-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.url-input-wrap {
  flex: 1 1 320px;
  position: relative;
}

.feed-url-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  font-size: 0.96rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-page);
  color: var(--text-main);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.feed-url-input:focus,
.raw-feed-textarea:focus,
.search-input:focus,
.sort-select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  appearance: none;
  height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--accent-primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-subtle);
  color: var(--text-main);
  border-color: var(--border-strong);
}

.btn-secondary:hover,
.btn-secondary.is-active {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-soft);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-color);
}

.btn-ghost:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

/* Raw XML/JSON Textarea */
.raw-feed-textarea {
  width: 100%;
  min-height: 170px;
  padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.86rem;
  line-height: 1.5;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-page);
  color: var(--text-main);
  resize: vertical;
  margin-bottom: 12px;
}

/* File Dropzone */
.file-dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-page);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.file-dropzone:hover,
.file-dropzone.is-dragover {
  border-color: var(--accent-primary);
  background: var(--accent-soft);
}

.file-dropzone svg {
  width: 36px;
  height: 36px;
  fill: var(--accent-primary);
  margin-bottom: 8px;
}

.dropzone-title {
  margin: 0 0 4px;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-main);
}

.dropzone-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Status Banner */
.status-banner {
  margin: 0 20px 18px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-info {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info-text);
}

.status-error {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error-text);
}

/* Empty State Preview */
.empty-state-card {
  background: var(--bg-surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-align: center;
  margin-bottom: 28px;
}

.empty-state-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.empty-state-icon svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.empty-state-title {
  margin: 0 0 6px;
  font-size: 1.08rem;
  font-weight: 700;
}

.empty-state-desc {
  margin: 0 auto;
  max-width: 620px;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

/* Results Workspace */
.results-section {
  margin-bottom: 32px;
}

.channel-summary-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.diagnostics-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.badge-format {
  background: var(--badge-bg);
  color: var(--badge-text);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge-count {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}

.badge-validity {
  font-size: 0.76rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}

.badge-validity.is-valid {
  background: var(--valid-bg);
  color: var(--valid-text);
}

.badge-validity.has-warnings {
  background: var(--warn-bg);
  color: var(--warn-text);
  border: 1px solid var(--warn-border);
  cursor: pointer;
}

.badge-timing {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-inline-start: auto;
}

.validation-warnings-box {
  margin: 8px 0 12px;
  padding: 10px 14px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
  border-radius: 8px;
  font-size: 0.83rem;
}

.validation-warnings-list {
  margin: 0;
  padding-inline-start: 18px;
}

.validation-warnings-list li + li {
  margin-top: 4px;
}

.validation-warnings-list code {
  font-weight: 700;
  font-size: 0.78rem;
}

.channel-title {
  margin: 0 0 6px;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.3;
}

.channel-title a {
  color: var(--text-main);
}

.channel-title a:hover {
  color: var(--accent-primary);
}

.channel-description {
  margin: 0 0 12px;
  font-size: 0.94rem;
  color: var(--text-secondary);
}

.channel-meta-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.channel-meta-pill {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  padding: 2px 9px;
  border-radius: 6px;
}

/* Results Toolbar */
.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.view-switcher {
  display: inline-flex;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.view-switch-btn {
  appearance: none;
  border: none;
  background: transparent;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.view-switch-btn.is-active {
  background: var(--bg-surface);
  color: var(--accent-primary);
  box-shadow: var(--shadow-sm);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 260px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.search-wrap {
  flex: 1 1 180px;
  max-width: 280px;
}

.search-input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  font-size: 0.88rem;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-main);
}

.sort-select {
  height: 38px;
  padding: 0 10px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-main);
  cursor: pointer;
}

.btn-sm {
  height: 38px;
  padding: 0 12px;
  font-size: 0.85rem;
  border-radius: 8px;
}

.btn-icon-only {
  width: 38px;
  padding: 0;
}

/* Feed Items List */
.feed-items-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.feed-item-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease;
}

.feed-item-card:hover {
  border-color: var(--border-strong);
}

/* Compact Mode */
.feed-items-list.is-compact {
  gap: 8px;
}

.feed-items-list.is-compact .feed-item-card {
  padding: 12px 16px;
}

.feed-items-list.is-compact .feed-item-header {
  cursor: pointer;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.feed-items-list.is-compact .feed-item-title {
  margin: 0;
  font-size: 1rem;
  flex: 1 1 240px;
}

.feed-items-list.is-compact .feed-item-meta {
  margin: 0;
}

.feed-items-list.is-compact .feed-item-body {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.feed-items-list.is-compact .feed-item-card.is-expanded-row .feed-item-body {
  display: block;
}

.feed-item-title {
  margin: 0 0 8px;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.35;
}

.feed-item-title a {
  color: var(--text-main);
}

.feed-item-title a:hover {
  color: var(--accent-primary);
}

.feed-item-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.meta-categories {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.category-chip {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.podcast-chip {
  background: var(--accent-soft);
  color: var(--accent-primary);
  font-weight: 600;
}

.feed-item-summary {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.feed-item-content {
  font-size: 0.95rem;
  color: var(--text-secondary);
  overflow-wrap: break-word;
}

.feed-item-content p:first-child {
  margin-top: 0;
}

.feed-item-content p:last-child {
  margin-bottom: 0;
}

.feed-item-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 10px 0;
}

.feed-item-content pre,
.feed-item-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.86rem;
  background: var(--bg-subtle);
  border-radius: 5px;
}

.feed-item-content code {
  padding: 2px 5px;
}

.feed-item-content pre {
  padding: 12px;
  overflow-x: auto;
}

.feed-item-content blockquote {
  margin: 12px 0;
  padding: 8px 14px;
  border-inline-start: 3px solid var(--accent-primary);
  background: var(--bg-subtle);
  border-radius: 4px;
}

.feed-item-enclosures {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.enclosure-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.enclosure-player {
  width: 100%;
  max-width: 460px;
  height: 38px;
  border-radius: 8px;
}

.enclosure-video {
  height: auto;
  max-height: 320px;
  background: #000;
}

.enclosure-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-primary);
  border: 1px solid var(--accent-border);
}

.feed-item-footer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.read-original-link {
  font-size: 0.86rem;
  font-weight: 600;
}

.no-items-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 28px;
  text-align: center;
  color: var(--text-muted);
}

/* JSON Inspector View */
.json-inspector-card {
  background: var(--bg-code);
  color: #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  overflow-x: auto;
  border: 1px solid var(--border-strong);
}

.json-inspector-code {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.83rem;
  line-height: 1.55;
  white-space: pre;
}

@media (max-width: 640px) {
  .app-shell {
    padding: 18px 14px 12px;
  }

  .tab-panel {
    padding: 16px;
  }

  .url-form-row {
    flex-direction: column;
  }

  .url-input-wrap {
    flex: 1 1 auto;
  }

  .btn-group {
    width: 100%;
  }

  .btn-group .btn {
    flex: 1 1 auto;
  }
}
