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

:root {
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --radius: 16px;
  --radius-sm: 10px;

  --red: #ff2442;
  --orange: #ff8200;
  --blue: #1da1f2;

  --max-width: 520px;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#app {
  width: 100%;
  max-width: var(--max-width);
  padding: 20px 16px 60px;
}

/* ===== Header ===== */
.header {
  text-align: center;
  padding: 28px 0 20px;
}

.header-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.header-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.header-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* ===== Platform Badges ===== */
.platforms {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.platform-badge {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

/* ===== Input Section ===== */
.input-section {
  margin-bottom: 12px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.url-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 14px 16px;
  font-size: 15px;
  background: transparent;
  color: var(--text);
  min-width: 0;
}

.url-input::placeholder {
  color: #94a3b8;
  font-size: 14px;
}

.clear-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: #f1f5f9;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  color: #64748b;
  margin-right: 8px;
  flex-shrink: 0;
  transition: background 0.15s;
}

.clear-btn:hover {
  background: #e2e8f0;
}

.submit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  margin-top: 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.submit-btn:active {
  transform: scale(0.98);
  background: var(--primary-hover);
}

.submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ===== 鎸夐挳琛?===== */
.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.btn-row .submit-btn {
  flex: 1;
  margin-top: 0;
}

.clip-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  flex: 1;
}

.clip-btn:active {
  background: #f1f5f9;
  border-color: var(--primary);
  color: var(--primary);
}

.clip-btn.clip-clear {
  border-color: #fecaca;
  color: #dc2626;
}

.clip-btn.clip-clear:active {
  background: #fef2f2;
  border-color: #f87171;
}

.btn-icon {
  font-size: 18px;
}

/* ===== Hints ===== */
.hints {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 24px;
  font-size: 12px;
  color: var(--text-secondary);
  align-items: center;
}

.hint-btn {
  font-size: 11px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.hint-btn:active {
  background: #e2e8f0;
  color: var(--text);
}

/* ===== Loading ===== */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 0;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  margin-top: 16px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* ===== Error ===== */
.error {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px;
  background: #fef2f2;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.error-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.error-text {
  color: #dc2626;
  font-size: 14px;
  text-align: center;
  max-width: 100%;
  word-break: break-word;
}

/* ===== Result ===== */
.result {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.result-author {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.author-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f1f5f9;
  flex-shrink: 0;
  object-fit: cover;
}

.author-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.result-title {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.platform-tag {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 12px;
  background: #f1f5f9;
  color: var(--text-secondary);
  font-weight: 500;
  flex-shrink: 0;
}

/* ===== Media List ===== */
.media-list {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.media-card {
  background: #f8fafc;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.media-preview {
  width: 100%;
  aspect-ratio: 16/9;
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.media-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #f1f5f9;
}

.media-preview video {
  width: 100%;
  height: 100%;
  background: #000;
}

.media-type-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(0,0,0,0.6);
  color: white;
  font-weight: 500;
}

.media-card-body {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.media-filename {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.media-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.media-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.media-btn.download {
  background: var(--primary);
  color: white;
}

.media-btn.download:active {
  background: var(--primary-hover);
}

.media-btn.copy {
  background: #f1f5f9;
  color: var(--text-secondary);
}

.media-btn.copy:active {
  background: #e2e8f0;
}

/* ===== Result Actions ===== */
.result-actions {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
}

.action-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.action-btn.primary {
  background: #f1f5f9;
  color: var(--text);
}

.action-btn.primary:active {
  background: #e2e8f0;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 999;
  pointer-events: none;
  animation: toastIn 0.3s ease, toastOut 0.3s 1.7s ease;
  white-space: nowrap;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(16px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.8;
}

.footer-note {
  font-size: 11px;
  opacity: 0.7;
}

/* ===== Responsive ===== */
@media (min-width: 640px) {
  #app {
    padding: 40px 20px 80px;
  }

  .header-title {
    font-size: 28px;
  }
}

@media (display-mode: standalone) {
  .header {
    padding-top: 40px;
  }
}
