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

html,
body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(135deg, #0f172a, #020617);
  color: #0f172a;
}

.app {
  min-height: 100vh;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
  color: #020617;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  color: #e5e7eb;
}

.app-title {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.app-subtitle {
  margin-top: 0.25rem;
  font-size: 0.95rem;
  color: #9ca3af;
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  font-size: 0.75rem;
  color: #e5e7eb;
  backdrop-filter: blur(6px);
  background: rgba(15, 23, 42, 0.5);
}

.app-main {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  grid-auto-rows: minmax(0, auto);
  gap: 1.25rem;
}

.panel {
  background: rgba(15, 23, 42, 0.96);
  border-radius: 0.9rem;
  padding: 1rem 1.1rem;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.upload-panel {
  grid-column: 1 / 2;
}

.preview-panel {
  grid-column: 2 / 3;
  grid-row: 1 / 3;
}

.clip-panel {
  grid-column: 1 / 2;
}

.settings-panel {
  grid-column: 1 / 3;
}

.result-panel {
  grid-column: 1 / 3;
}

.panel-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: #e5e7eb;
  margin-bottom: 0.75rem;
}

.drop-zone {
  position: relative;
  border-radius: 0.85rem;
  border: 1px dashed rgba(129, 140, 248, 0.7);
  background: radial-gradient(circle at top left, rgba(59, 130, 246, 0.14), transparent 55%),
              radial-gradient(circle at bottom right, rgba(56, 189, 248, 0.12), transparent 55%),
              rgba(15, 23, 42, 0.9);
  padding: 1.25rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease, background 0.2s ease;
}

.drop-zone.dragover {
  border-color: #60a5fa;
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.45), 0 18px 40px rgba(37, 99, 235, 0.45);
  transform: translateY(-1px);
}

.drop-zone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.drop-icon {
  font-size: 2.1rem;
  margin-bottom: 0.25rem;
}

.drop-title {
  font-size: 1rem;
  color: #e5e7eb;
}

.drop-subtitle {
  font-size: 0.85rem;
  color: #9ca3af;
}

.drop-hint {
  margin-top: 0.35rem;
  font-size: 0.78rem;
  color: #6b7280;
}

.file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-info {
  margin-top: 0.6rem;
  font-size: 0.8rem;
  color: #9ca3af;
  min-height: 1rem;
}

.video-wrapper {
  position: relative;
  width: 100%;
  border-radius: 0.75rem;
  overflow: hidden;
  background: radial-gradient(circle at top left, rgba(59, 130, 246, 0.18), transparent 55%),
              rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.video-player {
  width: 100%;
  display: block;
  background: #020617;
}

.video-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: #9ca3af;
}

.meta-item {
  display: flex;
  justify-content: space-between;
  gap: 0.35rem;
}

.time-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.55rem;
}

.time-row label {
  font-size: 0.88rem;
  color: #d1d5db;
  flex: 0 0 70px;
}

.time-row input {
  flex: 1;
  border-radius: 0.55rem;
  border: 1px solid rgba(148, 163, 184, 0.5);
  padding: 0.45rem 0.6rem;
  background: rgba(15, 23, 42, 0.8);
  color: #e5e7eb;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.time-row input:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.6);
  background: rgba(15, 23, 42, 0.95);
}

.time-summary {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #9ca3af;
  margin-bottom: 0.6rem;
}

.time-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem 1rem;
  margin-bottom: 0.8rem;
}

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: #d1d5db;
}

.setting-item label {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.setting-item select,
.setting-item input[type="range"] {
  width: 100%;
}

.setting-item select {
  border-radius: 0.5rem;
  border: 1px solid rgba(148, 163, 184, 0.5);
  padding: 0.38rem 0.5rem;
  background: rgba(15, 23, 42, 0.9);
  color: #e5e7eb;
  font-size: 0.86rem;
  outline: none;
}

.setting-item select:focus {
  border-color: #60a5fa;
}

.setting-item input[type="range"] {
  accent-color: #3b82f6;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.checkbox-label input {
  width: 14px;
  height: 14px;
}

.convert-actions {
  margin-top: 0.6rem;
  display: flex;
  justify-content: flex-end;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.7rem;
  font-size: 0.8rem;
  color: #9ca3af;
}

.progress-bar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: rgba(30, 64, 175, 0.6);
  overflow: hidden;
}

.progress-bar-inner {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #22c55e, #3b82f6);
  transition: width 0.15s linear;
}

.progress-text {
  min-width: 90px;
  text-align: right;
}

.result-content {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.gif-preview-wrapper {
  flex: 1.2;
  min-width: 220px;
  border-radius: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.18), transparent 55%),
              rgba(15, 23, 42, 0.95);
  padding: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
}

.gif-placeholder {
  font-size: 0.9rem;
  color: #6b7280;
}

.gif-preview {
  max-width: 100%;
  max-height: 260px;
  display: none;
}

.result-meta {
  flex: 0.9;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: #9ca3af;
}

.result-actions {
  flex-basis: 100%;
  margin-top: 0.4rem;
  display: flex;
  justify-content: flex-end;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.08s ease, box-shadow 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  user-select: none;
  text-decoration: none;
}

.btn:disabled,
.btn.disabled {
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
}

.primary-btn {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #f9fafb;
  box-shadow: 0 10px 25px rgba(37, 99, 235, 0.55);
}

.primary-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  transform: translateY(-0.5px);
  box-shadow: 0 14px 35px rgba(37, 99, 235, 0.7);
}

.secondary-btn {
  background: rgba(15, 23, 42, 0.9);
  color: #e5e7eb;
  border: 1px solid rgba(148, 163, 184, 0.6);
}

.secondary-btn:hover:not(.disabled) {
  border-color: #60a5fa;
  color: #e5e7eb;
  background: radial-gradient(circle at top left, rgba(59, 130, 246, 0.25), transparent 55%),
              rgba(15, 23, 42, 0.96);
}

.ghost-btn {
  background: transparent;
  color: #9ca3af;
  border: 1px solid rgba(148, 163, 184, 0.45);
}

.ghost-btn:hover:not(:disabled) {
  color: #e5e7eb;
  border-color: #6b7280;
  background: rgba(15, 23, 42, 0.75);
}

.wide-btn {
  min-width: 210px;
}

.app-footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: #6b7280;
}

@media (max-width: 960px) {
  .app-main {
    grid-template-columns: minmax(0, 1fr);
  }

  .upload-panel,
  .preview-panel,
  .clip-panel,
  .settings-panel,
  .result-panel {
    grid-column: 1 / 2;
  }

  .preview-panel {
    order: 2;
  }

  .upload-panel {
    order: 1;
  }

  .clip-panel {
    order: 3;
  }

  .settings-panel {
    order: 4;
  }

  .result-panel {
    order: 5;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app {
    padding: 1.1rem 0.9rem 2rem;
  }

  .panel {
    padding: 0.9rem 0.85rem;
  }

  .app-title {
    font-size: 1.45rem;
  }

  .settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .time-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .convert-actions,
  .result-actions {
    justify-content: stretch;
  }

  .wide-btn {
    width: 100%;
  }
}

