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

:root {
  --bg:          #eef0f4;
  --card:        #ffffff;
  --border:      #dde1e8;
  --header-bg:   #2c3547;
  --header-text: #e8eaf0;
  --text:        #2f3642;
  --muted:       #7a8394;
  --blue:        #4f72a6;
  --blue-dark:   #3a5a8c;
  --blue-light:  #dce8f8;
  --green:       #3f7f5f;
  --green-dark:  #2f6349;
  --green-light: #d6ede3;
  --amber:       #a06c2a;
  --amber-light: #fdf0dc;
  --red:         #a33b30;
  --red-dark:    #882e25;
  --red-light:   #fde8e6;
  --shadow:      0 1px 4px rgba(0,0,0,0.07), 0 2px 12px rgba(0,0,0,0.05);
  --radius:      10px;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.6;
}

/* ── Header ──────────────────────────────────────────────────────────── */
header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 13px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
header h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
#header-project {
  color: #8fa3c0;
  font-size: 0.83rem;
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Layout ──────────────────────────────────────────────────────────── */
#app { max-width: 780px; margin: 28px auto; padding: 0 16px 64px; }

/* ── Cards ───────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card h2 {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card h2 .step-num {
  background: var(--header-bg);
  color: #aab8cc;
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 20px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* ── Info bar ────────────────────────────────────────────────────────── */
.info-bar {
  background: var(--blue-light);
  border: 1px solid #b8cfe8;
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
}
.info-bar strong { color: var(--blue-dark); }
.info-bar .project-id { color: var(--muted); font-family: monospace; font-size: 0.78rem; }

/* ── Form elements ───────────────────────────────────────────────────── */
label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
  margin-top: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
label:first-child { margin-top: 0; }

input[type="text"],
input[type="file"],
textarea,
select {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  background: #f8f9fb;
  color: var(--text);
  margin-bottom: 10px;
  transition: border-color 0.15s;
}
input[type="text"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--blue);
  background: #fff;
}
textarea { resize: vertical; min-height: 80px; font-family: inherit; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.13s, transform 0.08s;
  letter-spacing: 0.01em;
}
.btn:active { transform: scale(0.98); }

.btn-primary   { background: var(--blue);  color: #fff; }
.btn-primary:hover  { background: var(--blue-dark); }
.btn-secondary { background: #5a6680; color: #fff; }
.btn-secondary:hover { background: #48536a; }
.btn-success   { background: var(--green); color: #fff; }
.btn-success:hover  { background: var(--green-dark); }
.btn-danger    { background: var(--red);   color: #fff; }
.btn-danger:hover   { background: var(--red-dark); }

.btn + .btn { margin-left: 8px; }

/* ── Status messages ─────────────────────────────────────────────────── */
.status { margin-top: 8px; font-size: 0.84rem; min-height: 1.1em; }
.status-ok    { color: var(--green); }
.status-warn  { color: var(--amber); }
.status-error { color: var(--red); }

/* ── Hint text ───────────────────────────────────────────────────────── */
.hint {
  color: var(--muted);
  font-size: 0.83rem;
  margin-bottom: 12px;
  line-height: 1.5;
}

/* ── Divider ─────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

/* ── Video Tray ──────────────────────────────────────────────────────── */
#tray-list { margin-top: 6px; }
.tray-empty { color: var(--muted); font-size: 0.85rem; padding: 10px 0; }

.tray-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 4px;
  border-bottom: 1px solid #f0f2f5;
  font-size: 0.83rem;
}
.tray-row:last-child { border-bottom: none; }

.tray-num {
  color: #c0c8d6;
  font-size: 0.72rem;
  width: 16px;
  text-align: right;
  flex-shrink: 0;
  font-weight: 600;
}
.tray-name {
  flex: 1;
  word-break: break-all;
  color: var(--text);
  font-size: 0.81rem;
}
.tray-type {
  flex-shrink: 0;
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 20px;
  background: #e5e8ed;
  color: #5a6680;
}
.type-corclip   { background: var(--green-light); color: var(--green-dark); }
.type-upload    { background: var(--blue-light);  color: var(--blue-dark);  }
.type-facebook  { background: #dde8f8; color: #2a4a80; }
.type-instagram { background: #fce8f0; color: #8b2252; }
.type-youtube   { background: var(--amber-light); color: var(--amber); }
.type-tiktok    { background: #ede8f8; color: #5a2a8c; }
.type-twitter   { background: #ddf0f8; color: #155878; }
.type-video     { background: #f0f2f5; color: #5a6680; }

.tray-size {
  flex-shrink: 0;
  color: #b0b8c6;
  font-size: 0.76rem;
  width: 62px;
  text-align: right;
}
.tray-actions { flex-shrink: 0; display: flex; gap: 3px; }

.tray-btn {
  padding: 3px 7px;
  font-size: 0.76rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background: #edf0f4;
  color: #5a6680;
  font-weight: 600;
  line-height: 1.4;
  transition: background 0.12s;
}
.tray-btn:hover { background: #dde1e8; }
.tray-btn-dl  { background: var(--green-light); color: var(--green-dark); }
.tray-btn-dl:hover  { background: #c0e0d0; }
.tray-btn-del { background: var(--red-light);   color: var(--red); }
.tray-btn-del:hover { background: #f8c8c4; }

/* ── Recommendation box ──────────────────────────────────────────────── */
.rec-box {
  padding: 10px 14px;
  border-radius: 7px;
  font-size: 0.85rem;
  margin-bottom: 12px;
  line-height: 1.5;
}
.rec-ok   { background: var(--green-light); border: 1px solid #a8d8bc; color: var(--green-dark); }
.rec-warn { background: var(--amber-light); border: 1px solid #e8c884; color: var(--amber); }
.rec-bad  { background: var(--red-light);   border: 1px solid #f0b0a8; color: var(--red); }

/* ── Download buttons ────────────────────────────────────────────────── */
.download-links { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.download-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--green);
  color: #fff;
  border-radius: 7px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
  width: fit-content;
  transition: background 0.13s;
}
.download-link:hover { background: var(--green-dark); }
.download-link .dl-size { font-weight: 400; font-size: 0.8rem; opacity: 0.82; }

/* ── Link results ────────────────────────────────────────────────────── */
#links-results ul { list-style: none; margin-top: 8px; font-size: 0.83rem; }
#links-results li { padding: 3px 0; }
.result-ok  { color: var(--green); }
.result-err { color: var(--red); }

/* ── Load area ───────────────────────────────────────────────────────── */
#load-area { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }

/* ── Overlay ─────────────────────────────────────────────────────────── */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 36, 50, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  backdrop-filter: blur(2px);
}
#overlay.visible { display: flex; }

.overlay-box {
  background: #fff;
  border-radius: 12px;
  padding: 32px 44px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
  max-width: 300px;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.overlay-msg { font-size: 0.9rem; color: var(--text); font-weight: 600; }
.overlay-sub { font-size: 0.78rem; color: var(--muted); margin-top: 5px; }

/* ── Hidden ──────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
