:root {
  --bg: #0f1115;
  --card: #141821;
  --fg: #e6eaf2;
  --muted: #9aa3b2;
  --border: #222839;
  --grad-a: #7c3aed;
  /* violet-600 */
  --grad-b: #06b6d4;
  /* cyan-500 */
  --ok: #10b981;
  /* emerald-500 */
  --warn: #f59e0b;
  /* amber-500 */
  --danger: #ef4444;
  /* red-500 */
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 40px 16px 0;
  /* Removing bottom padding, footer handles it */
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

.card {
  width: 100%;
  max-width: 760px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

h2 {
  margin: 0 0 8px;
  font-weight: 700;
  letter-spacing: .2px;
}

p.sub {
  margin: 0 0 24px;
  color: var(--muted);
}

/* ===== Drop Zone ===== */
.drop {
  border: 2px dashed #2a3246;
  border-radius: 16px;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: border-color .2s ease, background .2s ease;
  cursor: pointer;
  padding: 16px;
  background: #121624;
}

.drop.hover {
  border-color: #3f4c6b;
  background: #121a2a;
}

.drop small {
  color: var(--muted);
}

input[type="file"] {
  display: none;
}

/* ===== Input Panel (Save from Link) ===== */
.panel {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  background: #111524;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.label {
  font-size: 13px;
  color: var(--muted);
}

.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0d1120;
  color: var(--fg);
  outline: none;
}

.input::placeholder {
  color: #6b7280;
}

/* ===== Buttons & Layout ===== */
.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: stretch;
  margin-top: 16px;
}

/* Adjust row margin for the input panel version if needed, but 16px is standard across both pages mostly. 
   save_from_link had margin-top:4px, upload_page had 16px. We'll default to 16px. 
   We can add a specific class if needed, but spacing consistency is good. */

.btn {
  border: 0;
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s ease, transform .02s ease;
  user-select: none;
  -webkit-user-select: none;
}

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

.btn-grad {
  background-image: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  color: white;
}

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

.btn[disabled] {
  opacity: .5;
  cursor: not-allowed;
}

.btn-cancel {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, .35);
  color: #fecaca;
}

.btn-cancel:hover {
  filter: brightness(1.05);
}

.btn-telegram {
  background-color: #0088cc;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ===== Metadata & Progress ===== */
.meta {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #111524;
  color: var(--muted);
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.progress {
  height: 12px;
  background: #0d1120;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 12px;
}

.bar {
  height: 100%;
  width: 0%;
  background-image: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  transition: width .25s ease;
}

.stats {
  margin-top: 10px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.stats .pct {
  color: var(--fg);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #0d1120;
}

.stats .sep {
  opacity: .45;
}

.stats .item {
  white-space: nowrap;
}

.stats .badge-cancelled {
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(239, 68, 68, .35);
  color: #fecaca;
  background: rgba(239, 68, 68, .08);
  font-weight: 700;
}

/* ===== Result Card ===== */
.result-card {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #0e1324;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-title {
  font-weight: 700;
  letter-spacing: .2px;
}

.link-line {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  word-break: break-all;
}

.stream-link {
  text-decoration: none;
  font-weight: 600;
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ===== Navbar ===== */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 1000;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.nav-brand {
  font-weight: 700;
  font-size: 18px;
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 20px;
}

.nav-item {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s;
  padding: 8px 12px;
  border-radius: 8px;
}

.nav-item:hover,
.nav-item.active {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.05);
}

/* Page padding adjustment for fixed navbar */
body {
  padding-top: 80px;
  /* 60px navbar + 20px space */
}

/* Hide old menu styles if any remain referenced, but mostly replaced above */

/* ===== Auth & Forms ===== */
.auth-card {
  max-width: 400px;
  text-align: center;
}

.auth-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.btn-google {
  background: white;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background .2s;
}

.btn-google:hover {
  background: #f1f1f1;
}

.btn-google img {
  width: 18px;
  height: 18px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  margin: 8px 0;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-footer {
  font-size: 13px;
  color: var(--muted);
  margin-top: 16px;
}

.auth-footer a {
  color: var(--grad-b);
  text-decoration: none;
  font-weight: 600;
}

.full-width {
  width: 100%;
}

.checkbox-field {
  flex-direction: row;
  align-items: center;
  font-size: 13px;
}

.status-text {
  font-size: 12px;
  margin-top: 2px;
  display: block;
}

.status-text.success {
  color: var(--ok);
}

.status-text.error {
  color: var(--danger);
}

.status-text.muted {
  color: var(--muted);
}

/* ===== Browsing UI (Grid/List) ===== */
.breadcrumbs {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.breadcrumbs a {
  text-decoration: none;
  color: var(--fg);
  font-weight: 500;
}

.breadcrumbs a:hover {
  text-decoration: underline;
}

.breadcrumbs .sep {
  opacity: 0.5;
}

.file-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.file-item {
  background: #111524;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: all .2s;
  position: relative;
}

.file-item:hover {
  border-color: var(--grad-b);
  background: #151a2d;
}

.file-icon {
  font-size: 24px;
  margin-bottom: 0;
  display: block;
  flex-shrink: 0;
}

.file-name {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-grow: 1;
  text-align: left;
}

.folder-item .file-icon {
  color: var(--warn);
}

/* Action Menu for Files */
.item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all .2s;
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--fg);
}

/* Context Menu */
.context-menu {
  position: absolute;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  z-index: 100;
  min-width: 160px;
  overflow: hidden;
  display: none;
  flex-direction: column;
}

.context-menu.show {
  display: flex;
}

.context-item {
  padding: 10px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--fg);
  transition: background .1s;
}

.context-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.context-item.delete {
  color: var(--danger);
}

/* Folder Navigator in Modal */
.folder-nav-container {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #0d1120;
  max-height: 300px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.folder-nav-header {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
}

.folder-nav-list {
  overflow-y: auto;
  flex-grow: 1;
}

.folder-nav-item {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  font-size: 14px;
}

.folder-nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.folder-nav-item:last-child {
  border-bottom: none;
}


/* ===== Dialog/Modal ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  display: none;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal h3 {
  margin: 0 0 16px;
  font-size: 18px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* ===== Footer ===== */
.main-footer {
  background: #0b0e14;
  border-top: 1px solid var(--border);
  padding: 40px 20px 20px;
  margin-top: 60px;
  width: 100%;
}

.footer-content {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 40px;
  justify-content: center;
}

.footer-section {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: center;
}

@media (min-width: 600px) {
  .footer-section {
    text-align: left;
    justify-content: flex-start;
  }

  .footer-content {
    justify-content: space-between;
  }
}

.footer-section h3 {
  font-size: 16px;
  color: var(--fg);
  margin: 0;
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color 0.2s;
  justify-content: center;
}

@media (min-width: 600px) {
  .footer-links a {
    justify-content: flex-start;
  }
}

.footer-links a:hover {
  color: var(--grad-b);
}

.bot-link {
  color: var(--grad-b) !important;
  font-weight: 500;
}

.footer-bottom {
  max-width: 900px;
  margin: 40px auto 0;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  text-align: center;
  font-size: 13px;
  color: #52525b;
}

/* ===== Landing Page ===== */
.landing-hero {
  text-align: center;
  padding: 60px 20px;
  max-width: 800px;
  margin: 0 auto;
}

.landing-hero h1 {
  font-size: 48px;
  font-weight: 800;
  margin-bottom: 20px;
  background: linear-gradient(135deg, var(--fg), #9aa3b2);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.1;
}

.landing-hero p {
  font-size: 18px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 30px;
}

.landing-section {
  max-width: 900px;
  margin: 60px auto;
  padding: 0 20px;
}

.landing-section h2 {
  font-size: 32px;
  margin-bottom: 30px;
  text-align: center;
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.landing-section p {
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 20px;
  font-size: 16px;
}

.landing-section ul {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 12px;
}

.landing-section li {
  position: relative;
  padding-left: 24px;
  color: var(--fg);
  line-height: 1.5;
}

.landing-section li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--ok);
  font-weight: bold;
}

.btn-cta {
  display: inline-block;
  background-image: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  color: white;
  padding: 16px 32px;
  border-radius: 99px;
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.2s, filter 0.2s;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.4);
}

.btn-cta:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

/* Legal Pages */
.legal-container {
  max-width: 800px;
  margin: 40px auto;
  width: 100%;
  padding: 40px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
}

.legal-container h1 {
  font-size: 32px;
  margin-bottom: 40px;
  text-align: center;
  color: var(--fg);
}

.legal-container h3 {
  color: var(--fg);
  margin-top: 30px;
  margin-bottom: 10px;
  font-size: 20px;
}

.legal-container p,
.legal-container ul {
  color: var(--muted);
  line-height: 1.6;
  font-size: 16px;
}

.legal-container ul {
  list-style: disc;
  padding-left: 20px;
  margin-top: 10px;
}

.legal-container li {
  margin-bottom: 8px;
}