:root {
  --bg: #0b1220;
  --panel: rgba(17, 24, 39, 0.55);
  --panel-border: rgba(255, 255, 255, 0.15);
  --glass: rgba(255, 255, 255, 0.06);
  --accent: #f59e0b;
  --accent-soft: rgba(245, 158, 11, 0.18);
  --text: #e5e7eb;
}

body.light-mode {
  --bg: #f3f4f6;
  --panel: rgba(255, 255, 255, 0.75);
  --panel-border: rgba(0, 0, 0, 0.1);
  --glass: rgba(0, 0, 0, 0.03);
  --text: #1f2937;
  --accent: #d97706;
  --accent-soft: rgba(217, 119, 6, 0.15);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(circle at 20% 20%, rgba(245, 158, 11, 0.15), transparent 35%),
    radial-gradient(circle at 80% 10%, rgba(94, 234, 212, 0.15), transparent 30%),
    linear-gradient(135deg, #060a14, #0b1220 55%, #060a14);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 32px 36px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  max-width: 1200px;
  width: 100%;
  text-align: left;
  min-height: 80vh;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

h1 {
  font-size: 2.3rem;
  letter-spacing: 0.02em;
  margin-bottom: 8px;
  text-align: center;
}

p {
  font-size: 1.05rem;
  color: rgba(229, 231, 235, 0.85);
  margin-bottom: 16px;
  text-align: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.25);
  backdrop-filter: blur(10px);
}

.pill span {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.18);
}

.panel {
  margin-top: 24px;
  display: none;
  gap: 16px;
  text-align: left;
}

.panel.active {
  display: grid;
}

#scraper input[type="url"],
#scraper input[type="number"] {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--glass);
  color: var(--text);
  width: 100%;
  backdrop-filter: blur(8px);
}

#scraper .row {
  display: flex;
  gap: 12px;
  width: 100%;
}

#scraper .row input[type="url"] {
  flex: 1;
}

#scraper .row input[type="number"] {
  width: 10%;
  min-width: 72px;
}

#proxy {
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 12px;
}

#proxy input,
#proxy select {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--glass);
  color: var(--text);
  backdrop-filter: blur(8px);
}

#proxy input[type="number"] {
  -moz-appearance: textfield;
}

#proxy input[type="number"]::-webkit-outer-spin-button,
#proxy input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#scraper button,
#proxy button {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.9), rgba(255, 204, 112, 0.9));
  color: #0f172a;
  border: 1px solid rgba(255, 204, 112, 0.7);
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
  box-shadow: none;
  backdrop-filter: blur(6px);
}

#scraper button:disabled {
  background: rgba(245, 158, 11, 0.35);
  color: rgba(15, 23, 42, 0.65);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

#scraper button:not(:disabled):hover,
#proxy button:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 34px rgba(245, 158, 11, 0.45);
}

#proxy .proxy-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  grid-column: 1 / -1;
}

#proxy button.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  box-shadow: none;
}

#proxyStatus {
  grid-column: 1 / -1;
}

#status {
  min-height: 20px;
  font-size: 0.95rem;
}

#linkActions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  color: rgba(229, 231, 235, 0.9);
}

.toggle input {
  appearance: none;
  width: 48px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
  position: relative;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.toggle input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: transform 150ms ease, background 150ms ease;
}

.toggle input:checked {
  background: rgba(245, 158, 11, 0.3);
  border-color: rgba(245, 158, 11, 0.6);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.toggle input:checked::after {
  transform: translateX(22px);
  background: #f59e0b;
}

#breadcrumbNav {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
  margin: 0.5rem 0;
  color: #cbd5f5;
  justify-content: space-between;
}

#breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  font-size: 0.9rem;
}

.crumb {
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: #e5e7eb;
  transition: background 0.15s ease, color 0.15s ease;
}

.crumb:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.crumb.active {
  background: rgba(255, 184, 0, 0.15);
  color: #ffb800;
}

#childSegments {
  display: flex;
  align-items: center;
}

#childSegments select {
  background: rgba(255, 255, 255, 0.06);
  color: #e5e7eb;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  font-size: 0.9rem;
}

#childSegments select:focus {
  outline: 1px solid rgba(255, 184, 0, 0.6);
}

#linkActions button {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

#linkActions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

#linkActions button:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(255, 255, 255, 0.08);
}

#linkActions .link-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
}

#progress {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
}

#progress .fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f59e0b, #fcd34d);
  transition: width 120ms ease;
}

#linkResultTabs {
  width: 100%;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px;
  margin-top: 12px;
  backdrop-filter: blur(12px);
}

#tabButtons {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

#tabButtons button {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

#tabButtons button.active {
  background: rgba(255, 184, 0, 0.2);
  border-color: rgba(255, 184, 0, 0.6);
}

#tabButtons button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

#tabPanels {
  width: 100%;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

#links {
  width: 100%;
  min-height: 150px;
  max-height: 360px;
  overflow: auto;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  color: rgba(229, 231, 235, 0.9);
  font-size: 0.95rem;
  backdrop-filter: none;
}

#links table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  border: 1px solid var(--panel-border);
  overflow: hidden;
}

#links th,
#links td {
  padding: 9px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#links thead th {
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.05);
  z-index: 1;
}

#links th.select-col,
#links td.select-col {
  width: 50px;
}

#links th.link-col,
#links td.link-col {
  word-break: break-all;
}

#links tr.selected {
  background: rgba(245, 158, 11, 0.12);
}

#links a {
  color: #fbbf24;
  text-decoration: none;
  transition: color 150ms ease;
}

#links a:hover {
  color: #fcd34d;
  text-decoration: underline;
}

#links,
#consoleLog,
#resultBody {
  -webkit-mask-image: linear-gradient(180deg,
      transparent 0%,
      #000 18px,
      #000 calc(100% - 18px),
      transparent 100%);
  mask-image: linear-gradient(180deg,
      transparent 0%,
      #000 18px,
      #000 calc(100% - 18px),
      transparent 100%);
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
}

#htmlResults {
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 12px;
  color: rgba(229, 231, 235, 0.9);
  font-size: 0.95rem;
  display: none;
  backdrop-filter: blur(10px);
}

#htmlResults.active {
  display: block;
}

#resultControls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

#resultControls button {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 6px 10px;
  font-weight: 600;
  cursor: pointer;
}

#resultControls select {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  min-width: 160px;
}

#resultControls button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#resultBody {
  background: rgba(0, 0, 0, 0.18);
  border-radius: 8px;
  padding: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow: auto;
}

#consoleLog {
  width: 100%;
  max-height: 380px;
  overflow: auto;
  ;
  color: rgba(229, 231, 235, 0.9);
  font-size: 0.95rem;
  backdrop-filter: blur(10px);
}

#consoleLog table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  min-width: 420px;
}

#consoleLog th,
#consoleLog td {
  padding: 8px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}

#consoleLog th {
  font-weight: 700;
  color: rgba(229, 231, 235, 0.9);
}

#consoleLog th.id,
#consoleLog td.id {
  width: 10%;
  color: var(--accent);
  font-weight: 700;
}

#consoleLog th.url,
#consoleLog td.url {
  width: 70%;
  word-break: break-all;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

#consoleLog th.proxy-col,
#consoleLog td.proxy-col {
  width: 10%;
  text-align: center;
}

#consoleLog .proxy-on,
#consoleLog .proxy-off {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(0, 255, 128, 0.15);
}

#consoleLog .proxy-on {
  background: #34d399;
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.7);
}

#consoleLog .proxy-off {
  background: rgba(255, 255, 255, 0.15);
  box-shadow: none;
}

#consoleLog th.task,
#consoleLog td.task {
  width: 10%;
  color: rgba(229, 231, 235, 0.85);
}

#consoleLog th.progress-col,
#consoleLog td.progress-col {
  width: 10%;
}

#consoleLog .progress {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

#consoleLog .progress .fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f59e0b, #fcd34d);
  transition: width 120ms ease;
}

#tabs {
  margin-top: 20px;
  display: flex;
  gap: 10px;
}

.tab {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.tab.active {
  background: var(--accent);
  color: #0f172a;
  box-shadow: 0 10px 25px rgba(245, 158, 11, 0.3);
}

.tab:not(.active):hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(255, 255, 255, 0.08);
}

/* panel show/hide is defined above; keep this block to avoid overrides */

/* Force dropdown text to black for readability */
select,
option {
  color: #000 !important;
  background: #fff;
}

/* --- New UI Styles --- */

/* Settings Panel */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  width: 100%;
  margin-bottom: 20px;
}

@media (max-width: 800px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

.setting-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.setting-col h3 {
  margin-bottom: 8px;
  font-size: 1.1em;
  color: var(--accent);
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 4px;
}

.form-row,
.form-group {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-bottom: 6px;
}

.form-row label {
  flex: 1;
  font-size: 0.9em;
  color: rgba(229, 231, 235, 0.9);
}

body.light-mode .form-row label {
  color: var(--text);
}

.form-row input[type="number"] {
  width: 80px;
  padding: 6px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: var(--glass);
  color: var(--text);
}

.form-group input[type="text"] {
  flex: 1;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: var(--glass);
  color: var(--text);
}

.checkbox-group {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
  margin: 8px 0;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9em;
  cursor: pointer;
}

.settings-actions {
  margin-top: 20px;
  display: flex;
  align-items: center;
  margin-left: auto;
  justify-content: flex-end;
  gap: 10px;
}

.status-text {
  font-size: 0.9em;
  opacity: 0.8;
}

/* Dropdown */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-btn {
  /* inherit button styles */
}

.dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--bg);
  min-width: 160px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  z-index: 10;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  overflow: hidden;
  padding: 4px;
}

.dropdown:hover .dropdown-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dropdown-content button {
  color: var(--text);
  padding: 10px 14px;
  text-decoration: none;
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 4px !important;
  margin: 0 !important;
  font-weight: normal !important;
}

.dropdown-content button:hover {
  background: var(--accent-soft) !important;
  transform: none !important;
}

/* Header & Theme */
.header-row {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  margin-bottom: 8px;
  width: 100%;
}

.theme-btn {
  position: absolute;
  right: 0;
  top: 0;
  background: transparent;
  border: 1px solid var(--panel-border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(4px);
}

.theme-btn:hover {
  background: var(--glass);
  transform: scale(1.05);
}

/* Sessions */
.session-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.session-controls input {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: var(--glass);
  color: var(--text);
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 480px;
  overflow-y: auto;
}

.session-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: var(--glass);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  transition: border-color 0.2s;
}

.session-item:hover {
  border-color: var(--accent);
}

.session-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.session-name {
  font-weight: bold;
  font-size: 1rem;
}

.session-date {
  font-size: 0.8em;
  opacity: 0.7;
}

.session-actions {
  display: flex;
  gap: 8px;
}

.session-actions button {
  padding: 6px 12px !important;
  font-size: 0.85rem !important;
}

.search-input {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: var(--glass);
  color: var(--text);
  width: 180px;
  transition: width 0.2s;
}

.search-input:focus {
  width: 240px;
  border-color: var(--accent);
  outline: none;
}