.gif-tool {
  max-width: 640px;
  margin: 0 auto;
}

.gif-tool .gif-field {
  margin-top: 0.9rem;
}

.gif-tool label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.gif-tool input[type="number"],
.gif-tool input[type="file"],
.gif-tool select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  color-scheme: light;
}

body.dark-mode .gif-tool input[type="number"],
body.dark-mode .gif-tool input[type="file"],
body.dark-mode .gif-tool select {
  color-scheme: dark;
}

.gif-tool select option {
  background: #fff;
  color: var(--ink);
}

body.dark-mode .gif-tool select option {
  background: #0b1430;
  color: var(--on-navy);
}

.gif-tool .gif-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.1rem;
}

.gif-tool .gif-btn {
  min-height: 44px;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 8px;
  background: var(--navy);
  color: var(--on-navy);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.gif-tool .gif-btn:hover:not(:disabled) {
  opacity: 0.9;
}

.gif-tool .gif-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.gif-tool .gif-btn-secondary {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text);
}

.gif-editor {
  display: none;
  margin-top: 1rem;
  padding: 0.9rem 1rem 1rem;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--glass-border);
  box-shadow: var(--panel-shadow);
}

.gif-editor.is-open {
  display: block;
}

.gif-editor h3 {
  margin: 0 0 0.7rem;
  font-size: 1rem;
}

.gif-editor .gif-edit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-top: 0.55rem;
}

.gif-editor .gif-edit-row label {
  margin: 0;
}

.gif-editor input[type="number"] {
  width: 4.5rem;
}

.gif-editor input[type="range"] {
  flex: 1 1 160px;
  min-width: 120px;
}

.gif-frames-title {
  margin: 1.2rem 0 0.5rem;
  font-size: 1rem;
}

.gif-frames {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.6rem;
  overflow-x: auto;
  padding: 0.4rem 0 0.6rem;
  min-height: 9rem;
}

.gif-frame {
  width: 120px;
  flex-shrink: 0;
  padding: 0.35rem;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
  cursor: pointer;
}

.gif-frame.is-selected {
  border-color: rgba(0, 120, 212, 0.85);
  box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.28);
}

.gif-frame.is-dragging {
  opacity: 0.55;
  cursor: grabbing;
}

.gif-frame.is-drop-target {
  border-color: rgba(0, 120, 212, 0.9);
  box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.3);
}

.gif-frame-index {
  margin-bottom: 0.25rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
}

.gif-frame canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
  background: #fff;
}

.gif-frame-name {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gif-status {
  margin-top: 0.9rem;
  min-height: 1.3rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.gif-status.is-error {
  color: #d12f2f;
}

.gif-status.is-success {
  color: #2a7a3a;
}

body.dark-mode .gif-status.is-error {
  color: #ff8b8b;
}

body.dark-mode .gif-status.is-success {
  color: #8ee0a4;
}

.gif-downloads {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.gif-download {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.7rem 1.1rem;
  border-radius: 8px;
  background: linear-gradient(180deg, #00a3ff, #0078d4);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}

.gif-download:hover {
  opacity: 0.92;
}

body.dark-mode .gif-download {
  color: #fff;
}

.gif-download svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.gif-result {
  margin-top: 1rem;
  text-align: center;
}

.gif-result img {
  max-width: 300px;
  margin: 0 auto;
  border-radius: 8px;
  box-shadow: var(--panel-shadow);
}

@media (max-width: 640px) {
  .gif-tool .gif-actions,
  .gif-downloads {
    flex-direction: column;
  }

  .gif-tool .gif-btn,
  .gif-download {
    width: 100%;
    justify-content: center;
  }
}
