/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #6c5ce7;
  --primary-dark: #5a4bd1;
  --bg: #0f0f1a;
  --card-bg: #1a1a2e;
  --text: #e8e8f0;
  --text-muted: #8888aa;
  --border: #2a2a40;
  --danger: #ff6b6b;
  --success: #51cf66;
  --warning: #ffd43b;
  --radius: 14px;
  --shadow: 0 4px 12px rgba(0,0,0,.3);
}

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ===== Top Bar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  padding: .85rem 1.1rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 2px 10px rgba(108,92,231,.4);
}
.topbar h1 {
  font-size: 1.1rem;
  font-weight: 600;
  flex: 1;
}
.icon-btn {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.icon-btn:active { background: rgba(255,255,255,.3); }
.icon-btn.active { background: rgba(255,255,255,.35); }

/* ===== Container ===== */
.container {
  flex: 1;
  padding: 1rem;
  padding-bottom: 5rem;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
}

/* ===== Cards ===== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem;
  margin-bottom: 1rem;
}
.card h2 {
  font-size: .95rem;
  margin-bottom: .75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ===== Input Card ===== */
.input-card {
  padding: 1rem;
}
.parse-form {
  display: flex;
  gap: .5rem;
}
.parse-form input {
  flex: 1;
  padding: .75rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: .95rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.parse-form input:focus { border-color: var(--primary); }
.parse-form input:disabled { opacity: .5; }
.parse-btn {
  padding: .75rem 1.4rem;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity .15s, transform .1s;
  min-width: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.parse-btn:active { transform: scale(.96); }
.parse-btn:disabled { opacity: .5; cursor: not-allowed; }

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hint {
  text-align: center;
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .6rem;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  padding: .7rem 1.2rem;
  border-radius: 10px;
  font-size: .88rem;
  display: flex;
  align-items: center;
  gap: .6rem;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
  max-width: 90vw;
  animation: toastIn .3s ease;
}
.toast.error {
  background: var(--danger);
  color: #fff;
}
.toast.success {
  background: var(--success);
  color: #fff;
}
.toast button {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 .2rem;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== Result Card ===== */
.result-card {
  padding: 1rem;
}
.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .6rem;
}
.result-header h2 { margin-bottom: 0; }
.clear-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: .3rem .7rem;
  border-radius: 6px;
  font-size: .8rem;
  cursor: pointer;
  text-decoration: none;
}
.clear-btn:active, .clear-btn:hover { background: var(--border); }

.video-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: .8rem;
  line-height: 1.4;
  word-break: break-word;
}

/* ===== Player ===== */
.player-wrap {
  position: relative;
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  margin-bottom: .8rem;
}
.player-wrap video {
  width: 100%;
  max-height: 240px;
  display: block;
  object-fit: contain;
  background: #000;
}

/* ===== Audio Player ===== */
.audio-player {
  margin-bottom: .8rem;
}
.audio-player audio {
  width: 100%;
  border-radius: 10px;
}

/* ===== Image Gallery ===== */
.image-gallery-section {
  margin-bottom: .8rem;
}
.gallery-toolbar {
  display: flex;
  gap: .5rem;
  margin-bottom: .5rem;
}
.gallery-toolbar-btn {
  padding: .35rem .8rem;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  background: var(--card-bg);
  color: var(--text-muted);
  font-size: .8rem;
  cursor: pointer;
  transition: border-color .15s;
}
.gallery-toolbar-btn:active, .gallery-toolbar-btn:hover { background: var(--border); }
.gallery-toolbar-btn.primary {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(108,92,231,.1);
}
.image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: .5rem;
}
.gallery-img-wrap {
  position: relative;
  cursor: pointer;
}
.gallery-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}
.gallery-check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border: 2px solid #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  color: #fff;
  background: rgba(0,0,0,.3);
  transition: background .15s;
}
.gallery-check.checked {
  background: var(--primary);
  border-color: var(--primary);
}

/* ===== Live Stream ===== */
.live-player {
  margin-bottom: .8rem;
}
.live-player video {
  width: 100%;
  max-height: 240px;
  border-radius: 10px;
  background: #000;
}

/* ===== Source Tags ===== */
.source-info {
  display: flex;
  gap: .5rem;
  margin-bottom: .8rem;
  flex-wrap: wrap;
}
.source-tag, .quality-tag, .author-tag {
  padding: .25rem .6rem;
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 600;
}
.source-tag {
  background: rgba(108,92,231,.15);
  color: var(--primary);
}
.quality-tag {
  background: rgba(255,212,59,.15);
  color: var(--warning);
}
.author-tag {
  background: rgba(81,207,102,.15);
  color: var(--success);
}

/* ===== Download Button ===== */
.download-btn {
  display: block;
  width: 100%;
  text-align: center;
  padding: .75rem;
  border: none;
  background: linear-gradient(135deg, var(--success), #40c057);
  color: #fff;
  border-radius: 10px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.download-btn:active, .download-btn:hover { opacity: .8; }

/* ===== History Card ===== */
.history-card {
  padding: 1rem;
  display: none;
}
.history-card.visible { display: block; }

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .6rem;
}
.history-header h2 { margin-bottom: 0; }
.clear-history-btn {
  background: none;
  border: none;
  color: var(--danger);
  font-size: .82rem;
  cursor: pointer;
  padding: .2rem .5rem;
}

.history-list { list-style: none; }
.history-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem 0;
  border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: none; }
.history-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.history-title {
  font-size: .88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-time {
  font-size: .75rem;
  color: var(--text-muted);
}
.replay-btn {
  background: var(--primary);
  border: none;
  color: #fff;
  padding: .35rem .7rem;
  border-radius: 6px;
  font-size: .8rem;
  cursor: pointer;
  white-space: nowrap;
}
.replay-btn:active, .replay-btn:hover { opacity: .7; }

/* ===== Tips Card ===== */
.tips-card { padding: 1rem; }
.tips-list {
  padding-left: 1.2rem;
  font-size: .88rem;
  color: var(--text-muted);
  line-height: 1.8;
}
.tips-list li::marker { color: var(--primary); }

.empty-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: .88rem;
  padding: .8rem 0;
}

/* ===== Transition ===== */
.slide-enter-active { transition: max-height .3s ease, opacity .3s ease; }
.slide-leave-active { transition: max-height .2s ease; }
.slide-enter-from { max-height: 0; opacity: 0; }
.slide-leave-to { max-height: 0; opacity: 0; }

/* ===== Bottom Navigation ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 10px rgba(0,0,0,.1);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .15rem;
  padding: .5rem 0;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: .72rem;
  cursor: pointer;
  transition: color .15s;
}
.nav-item .nav-icon { font-size: 1.3rem; }
.nav-item.active { color: var(--primary); }
.nav-item:active, .nav-item:hover { opacity: .7; }

/* ===== Home Page ===== */
.stats-card {
  display: flex;
  justify-content: space-around;
  text-align: center;
}
.stat-item { display: flex; flex-direction: column; gap: .2rem; }
.stat-num { font-size: 1.6rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: .8rem; color: var(--text-muted); }

.platform-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}
.platform-tag {
  padding: .3rem .7rem;
  background: rgba(108,92,231,.1);
  color: var(--primary);
  border-radius: 6px;
  font-size: .82rem;
  font-weight: 500;
}

/* ===== Me Page ===== */
.profile-card {
  text-align: center;
  padding: 1.5rem 1rem;
}
.profile-avatar {
  width: 64px;
  height: 64px;
  margin: 0 auto .6rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
}
.profile-name { font-size: 1.1rem; margin-bottom: .3rem; }
.profile-desc { font-size: .82rem; color: var(--text-muted); }

.settings-card { padding: 1rem; }
.setting-item {
  padding: .7rem 0;
  border-bottom: 1px solid var(--border);
}
.setting-item:last-child { border-bottom: none; }
.setting-label {
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: .5rem;
  display: block;
}
.theme-options, .color-options {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
}
.theme-btn {
  display: flex;
  align-items: center;
  gap: .3rem;
  padding: .4rem .8rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: .82rem;
  cursor: pointer;
  transition: border-color .15s;
}
.theme-btn.active {
  border-color: var(--primary);
  background: rgba(108,92,231,.1);
  color: var(--primary);
}
.color-btn {
  width: 32px;
  height: 32px;
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  color: #fff;
  transition: transform .1s;
}
.color-btn.active { border-color: var(--text); transform: scale(1.15); }
.color-btn:active, .color-btn:hover { opacity: .7; }

.stat-row, .about-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
}
.stat-row:last-child, .about-row:last-child { border-bottom: none; }
.stat-label2 { font-size: .88rem; color: var(--text-muted); }
.stat-value { font-size: .88rem; font-weight: 600; }

.danger-card { padding: 1rem; }
.danger-btn {
  width: 100%;
  padding: .7rem;
  border: 1.5px solid var(--danger);
  border-radius: 10px;
  background: none;
  color: var(--danger);
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
}
.danger-btn:active, .danger-btn:hover { background: rgba(255,107,107,.1); }

.about-card { padding: 1rem; }

/* ===== Activation Code ===== */
.activation-card { padding: 1rem; }
.activation-form {
  display: flex;
  gap: .5rem;
}
.activation-input {
  flex: 1;
  padding: .65rem .8rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .9rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.activation-input:focus { border-color: var(--primary); }
.activation-btn {
  padding: .65rem 1.2rem;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity .15s;
}
.activation-btn:active, .activation-btn:hover { opacity: .8; }
.activation-success {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem 0;
  flex-wrap: wrap;
}
.activation-badge {
  display: inline-block;
  padding: .25rem .7rem;
  border-radius: 6px;
  background: rgba(81,207,102,.15);
  color: var(--success);
  font-size: .8rem;
  font-weight: 600;
}
.activation-code-display {
  font-size: .88rem;
  color: var(--text-muted);
  font-family: monospace;
}
.activation-expire {
  font-size: .75rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: .2rem .55rem;
  border-radius: 4px;
  width: 100%;
}
.activation-warning {
  background: rgba(255,212,59,.1);
  border: 1px solid rgba(255,212,59,.25);
  color: var(--warning);
  padding: .6rem .9rem;
  border-radius: 8px;
  font-size: .82rem;
  margin-bottom: .75rem;
  text-align: center;
}

/* ===== Page Sections ===== */
.page-section { display: none; }
.page-section.visible { display: block; }

/* ===== Loading state on button ===== */
.parse-btn.loading .btn-text { display: none; }
.parse-btn:not(.loading) .spinner { display: none; }

/* ===== Profile Card ===== */
.profile-meta {
  display: flex;
  gap: .8rem;
  margin-top: .6rem;
  flex-wrap: wrap;
}
.profile-meta-item {
  font-size: .78rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: .2rem .55rem;
  border-radius: 4px;
}
.logout-btn {
  width: 100%;
  padding: .55rem;
  border: 1.5px solid var(--danger);
  border-radius: 8px;
  background: none;
  color: var(--danger);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.logout-btn:hover { background: var(--danger); color: #fff; }

/* ===== Auth Card ===== */
.auth-card { padding: 0; overflow: hidden; }
.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.auth-tab {
  flex: 1;
  padding: .75rem;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.auth-tab.active {
  color: var(--primary);
  background: var(--bg);
  border-bottom: 2px solid var(--primary);
}
.auth-form-wrap { padding: 1.2rem; }
.auth-form {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.auth-input {
  padding: .65rem .8rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .9rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.auth-input:focus { border-color: var(--primary); }
.auth-btn {
  padding: .7rem;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
  margin-top: .25rem;
}
.auth-btn:active, .auth-btn:hover { opacity: .8; }
.empty-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: .85rem;
  padding: .5rem 0;
}
