:root {
  --bg0: #0f1412;
  --bg1: #1a2420;
  --panel: rgba(232, 240, 234, 0.92);
  --ink: #14201a;
  --muted: #4d5f55;
  --accent: #0f7a4a;
  --accent-2: #c45c26;
  --line: rgba(20, 32, 26, 0.12);
  --danger: #a12020;
  --ok: #0b6b3a;
  --shadow: 0 18px 50px rgba(8, 16, 12, 0.35);
  --radius: 18px;
  --font: "IBM Plex Sans Thai", system-ui, sans-serif;
  --display: "Outfit", "IBM Plex Sans Thai", sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg0);
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 500px at 10% -10%, #2d6a4f 0%, transparent 55%),
    radial-gradient(700px 420px at 100% 0%, #9c4a1f 0%, transparent 50%),
    linear-gradient(160deg, #0f1412, #1b2621 45%, #101614);
}

.shell {
  width: min(860px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2.5rem 0 4rem;
}

.brand {
  margin-bottom: 1.5rem;
}

.brand-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.login-shell {
  width: min(440px, calc(100% - 2rem));
}

.login-panel .field-label {
  margin-top: 0.85rem;
}

.login-panel .field-label:first-of-type {
  margin-top: 0;
}

.login-panel input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  font: inherit;
  background: #fff;
  color: var(--ink);
  margin-bottom: 0.15rem;
}

.turnstile-wrap {
  margin: 1rem 0 0.25rem;
  display: flex;
  justify-content: center;
}

.login-panel .btn.wide {
  margin-top: 1rem;
}

.brand-mark {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #d7efe3;
  font-size: 0.9rem;
}

.brand h1 {
  margin: 0.25rem 0 0.35rem;
  font-family: var(--display);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  color: #f3faf6;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0;
  color: #b7cfc2;
}

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  backdrop-filter: blur(8px);
}

.field-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.45rem;
}

.row {
  display: flex;
  gap: 0.6rem;
}

input[type="url"],
input[type="text"],
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus,
button:focus-visible {
  outline: 2px solid rgba(15, 122, 74, 0.45);
  outline-offset: 2px;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 0.75rem 1.05rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

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

.btn.primary:hover {
  filter: brightness(1.06);
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

.btn.wide {
  width: 100%;
  padding: 0.9rem 1rem;
}

.btn.compact {
  padding: 0.45rem 0.75rem;
  border-radius: 10px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.video-layout {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 12px;
  background: #dfe8e2;
}

.meta h2 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  line-height: 1.35;
}

.muted {
  color: var(--muted);
  margin: 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.dest-row {
  margin-bottom: 1rem;
}

.dest-toggle {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 0.55rem 0.85rem;
  font: inherit;
  cursor: pointer;
}

.chip.active {
  background: #123528;
  color: #e8f6ef;
  border-color: #123528;
}

.folder-block {
  margin-bottom: 1rem;
}

.actions {
  margin-top: 0.25rem;
}

.progress-block {
  margin-top: 1rem;
}

.download-summary {
  margin: 0.25rem 0 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: rgba(18, 53, 40, 0.08);
  border: 1px solid var(--line);
}

.summary-line {
  margin: 0;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.45;
}

.progress-bar {
  height: 10px;
  background: rgba(20, 32, 26, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

#progressFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #2ecc71);
  transition: width 0.25s ease;
}

.error {
  color: var(--danger);
  margin: 0.75rem 0 0;
}

.success {
  color: var(--ok);
  margin: 0.75rem 0 0;
  font-weight: 600;
}

dialog {
  border: 0;
  border-radius: 16px;
  padding: 0;
  width: min(480px, calc(100% - 2rem));
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(8, 14, 11, 0.55);
}

.dialog-body {
  margin: 0;
  padding: 1rem 1.1rem 1.2rem;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.dialog-head h3 {
  margin: 0;
}

.path {
  margin: 0.5rem 0 0.75rem;
  word-break: break-all;
  font-size: 0.85rem;
}

.folder-nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.folder-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.folder-list li button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0.7rem 0.85rem;
  font: inherit;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}

.folder-list li:last-child button {
  border-bottom: 0;
}

.folder-list li button:hover {
  background: rgba(15, 122, 74, 0.08);
}

@media (max-width: 700px) {
  .row {
    flex-direction: column;
  }

  .video-layout,
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}
