:root {
  --bg-color: #0a0a0c;
  --card-bg: rgba(28, 28, 30, 0.85);
  --card-border: rgba(255, 255, 255, 0.08);
  --text-main: #f5f5f7;
  --text-sub: #86868b;
  --ios-blue: #007aff;
  --ios-blue-hover: #0062cc;
  --ios-red: #ff453a;
  --ios-green: #30d158;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
  padding: max(20px, env(safe-area-inset-top)) 16px max(30px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  align-items: flex-start;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 4px;
}

.logo-wrap {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 122, 255, 0.25);
  flex-shrink: 0;
}

.app-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.header-text h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  background: linear-gradient(135deg, #007aff, #5856d6);
  padding: 2px 7px;
  border-radius: 6px;
  color: #fff;
  letter-spacing: 0;
}

.subtitle {
  font-size: 13px;
  color: var(--text-sub);
  margin-top: 2px;
}

/* Main Card */
.main-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.textarea-wrapper {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s;
}

.textarea-wrapper:focus-within {
  border-color: var(--ios-blue);
}

textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  font-family: inherit;
}

textarea::placeholder {
  color: rgba(255, 255, 255, 0.3);
  font-size: 13px;
}

.input-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-sub {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-main);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background 0.15s;
}

.btn-sub:active {
  background: rgba(255, 255, 255, 0.16);
}

.btn-primary {
  width: 100%;
  margin-top: 12px;
  background: linear-gradient(135deg, #007aff 0%, #0051ba 100%);
  border: none;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  padding: 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(0, 122, 255, 0.35);
  transition: transform 0.1s, opacity 0.15s;
}

.btn-primary:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Result Card */
.result-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.video-container {
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  aspect-ratio: 9/16;
  max-height: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-container video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.info-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.video-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-main);
  word-break: break-word;
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.meta-author {
  font-size: 13px;
  color: var(--ios-blue);
  font-weight: 500;
}

.meta-tag {
  font-size: 11px;
  background: rgba(48, 209, 88, 0.15);
  color: var(--ios-green);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.action-buttons {
  display: flex;
  gap: 10px;
}

.btn-download {
  flex: 2;
  background: #30d158;
  color: #000;
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  padding: 13px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(48, 209, 88, 0.3);
  transition: transform 0.1s, opacity 0.15s;
}

.btn-download:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.btn-secondary {
  flex: 1;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 500;
  padding: 13px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s;
}

.btn-secondary:active {
  background: rgba(255, 255, 255, 0.18);
}

.ios-tip {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  line-height: 1.5;
}

/* Error Box */
.error-box {
  background: rgba(255, 69, 58, 0.1);
  border: 1px solid rgba(255, 69, 58, 0.25);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.error-msg {
  color: var(--ios-red);
  font-size: 13px;
  font-weight: 500;
  white-space: pre-wrap;
  word-break: break-word;
}

.btn-toggle-diag {
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  padding: 2px 0;
}

.diag-log {
  background: rgba(0, 0, 0, 0.5);
  padding: 10px;
  border-radius: 8px;
  color: #bbb;
  font-size: 11px;
  font-family: monospace;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 180px;
  overflow-y: auto;
}

/* PWA Guide Card */
.pwa-guide-card {
  background: rgba(28, 28, 30, 0.6);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-sub);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guide-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
  font-weight: 600;
}

.guide-steps {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  line-height: 1.45;
}

.guide-steps strong {
  color: #fff;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(30px);
  background: rgba(50, 50, 52, 0.95);
  color: #fff;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.25s ease;
  z-index: 1000;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
