:root {
  --bg: #ffffff;
  --text: #0f172a; /* slate-900 */
  --muted: #64748b; /* slate-500 */
  --border: #e2e8f0; /* slate-200 */
  --card: #ffffff;
  --indigo: #4f46e5; /* indigo-600 */
  --indigo-700: #4338ca;
  --shadow: 0 2px 10px rgba(2, 6, 23, 0.06);
}

:root[data-theme="dark"] {
  --bg: #0b1220;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: #1e293b;
  --card: #0f172a;
  --indigo: #6366f1; /* slightly brighter in dark */
  --indigo-700: #4f46e5;
  --shadow: 0 2px 16px rgba(2, 6, 23, 0.45);
}

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

html, body {
  padding: 0;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.5;
}

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

.app-header {
  padding: 28px 20px 10px;
  text-align: center;
  background: linear-gradient(180deg, rgba(79, 70, 229, 0.08), transparent 70%);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: saturate(1.2);
}
.app-header h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0.3px;
}
.tagline {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.container {
  max-width: 1100px;
  margin: 10px auto 40px;
  padding: 0 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.url-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

input[type="url"],
input[type="text"],
input[type="date"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

button {
  background: var(--indigo);
  color: white;
  border: none;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.02s ease;
}
button:hover { background: var(--indigo-700); }
button:active { transform: translateY(1px); }

.hint, .note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.grid.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

#playerContainer {
  aspect-ratio: 16 / 9;
  width: 100%;
  background: #0b1220;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}
#player {
  width: 100%;
  height: 100%;
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.list li {
  display: grid;
  grid-template-columns: auto auto 1fr auto; /* checkbox | thumb | title | actions */
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.list li:last-child { border-bottom: none; }
.list .idx {
  color: var(--muted);
  font-size: 12px;
  width: 28px;
  text-align: right;
}
.list .title {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list .actions button {
  background: transparent;
  color: var(--indigo);
  border: 1px solid var(--indigo);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
}
.list .actions button:hover {
  background: rgba(79, 70, 229, 0.06);
}

.form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-row {
  display: grid;
  gap: 6px;
}
.form-row label {
  font-size: 12px;
  color: var(--muted);
}
.form .form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  justify-content: flex-start;
  align-items: center;
  margin-top: 6px;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.app-footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 24px 16px 40px;
}

/* Responsive */
@media (max-width: 900px) {
  .grid.two-cols {
    grid-template-columns: 1fr;
  }
  .form {
    grid-template-columns: 1fr;
  }
}
/* --- UI/UX Enhancements --- */

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.02s ease;
}
.icon-btn:hover { border-color: var(--indigo); background: rgba(79, 70, 229, 0.06); }
.icon-btn:active { transform: translateY(1px); }

.progress-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 10px;
}
.progress-toolbar .summary { color: var(--muted); font-size: 13px; }
.progress-toolbar .spacer { flex: 1; }

.btn {
  background: var(--indigo);
  color: #fff;
  border: 1px solid var(--indigo);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.02s ease, opacity 0.2s ease;
}
.btn:hover { opacity: 0.95; }
.btn:active { transform: translateY(1px); }
.btn.secondary {
  background: transparent;
  color: var(--indigo);
  border-color: var(--indigo);
}
.btn.secondary:hover { background: rgba(79, 70, 229, 0.06); }
.btn.danger {
  background: #ef4444;
  border-color: #ef4444;
}
.btn.danger:hover { background: #dc2626; }

.list .thumb {
  border-radius: 6px;
  border: 1px solid var(--border);
  display: block;
  object-fit: cover;
}
.list li:hover {
  background: rgba(2, 6, 23, 0.02);
}

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 20px;
  background: var(--text);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: var(--shadow);
  z-index: 50;
}
.toast.show {
  opacity: 0.95;
  transform: translate(-50%, -4px);
}

/* Subtle theming transitions */
body { transition: background-color 0.2s ease, color 0.2s ease; }

/* Sticky player on wide screens for better learning flow */
@media (min-width: 901px) {
  #playerContainer { position: sticky; top: 96px; }
}