:root {
  --page-bg: #e9edf7;
  --bg: #eef2f8;
  --panel: #ffffff;
  --text: #1f2430;
  --muted: #5f6674;
  --stroke: #d5dbe8;
  --accent: #1d7cff;
  --accent-border: #0b61dc;
  --button-bg: #6767ff;
  --button-border: #5858e6;
  --titlebar-top: #ffffff;
  --titlebar-bottom: #f8fbff;
  --titlebar-shadow: rgba(17, 28, 45, 0.06);
  --drag-bg: #eef5ff;
  --error: #bb2f24;
  --logo-color: #6767ff;
  --grid-a: rgba(23, 32, 48, 0.08);
  --grid-b: rgba(23, 32, 48, 0.16);
}

:root.theme-dark {
  --page-bg: #141924;
  --bg: #0f1623;
  --panel: #171f2d;
  --text: #e7ecf6;
  --muted: #9ca8bc;
  --stroke: #2a3548;
  --accent: #3b89ff;
  --accent-border: #2a76e8;
  --button-bg: #6767ff;
  --button-border: #5858e6;
  --titlebar-top: #1d2636;
  --titlebar-bottom: #182030;
  --titlebar-shadow: rgba(0, 0, 0, 0.28);
  --drag-bg: #1a2639;
  --error: #ff7d73;
  --logo-color: #6767ff;
  --grid-a: rgba(201, 216, 243, 0.14);
  --grid-b: rgba(201, 216, 243, 0.24);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

html {
  background: var(--page-bg);
}

body {
  margin: 0;
  font-family: "SF Pro Text", "Segoe UI", sans-serif;
  color: var(--text);
  background: transparent;
}

.app {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 1rem;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  padding: 0.75rem;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: var(--panel);
}

.stage-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.color-control {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.color-control input {
  width: 32px;
  height: 24px;
  border: 1px solid var(--stroke);
  border-radius: 6px;
  padding: 0;
  background: transparent;
}

.alpha-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 30px;
  padding: 0.28rem 0.5rem 0.28rem 0.6rem;
  font-size: 0.76rem;
  letter-spacing: 0.01em;
  line-height: 1;
  background: transparent;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  color: inherit;
}

.alpha-label {
  color: var(--muted);
  font-weight: 600;
}

.alpha-switch {
  width: 34px;
  height: 20px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--bg);
  display: inline-flex;
  align-items: center;
  padding: 2px;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.alpha-knob {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transform: translateX(0);
  transition: transform 140ms ease, background-color 140ms ease;
}

.alpha-toggle[aria-pressed="true"] .alpha-switch {
  background: var(--button-bg);
  border-color: var(--button-border);
}

.alpha-toggle[aria-pressed="true"] .alpha-knob {
  transform: translateX(14px);
  background: #ffffff;
}

.alpha-toggle:hover {
  filter: none;
  border-color: var(--stroke);
}

.playback-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-width: min(540px, 100%);
  transition: opacity 180ms ease;
}

.playback-controls > * {
  flex-shrink: 0;
}

.toolbar.toolbar--gif .playback-controls {
  opacity: 0.38;
  pointer-events: none;
}

.playback-controls input[type="range"] {
  width: min(280px, 45vw);
  margin: 0;
  flex-shrink: 1;
}

.frame-label {
  display: inline-flex;
  align-items: baseline;
  gap: 0.2rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  min-width: 96px;
}

.frame-prefix,
.frame-divider {
  opacity: 0.75;
}

.frame-number {
  display: inline-block;
  min-width: 3ch;
  text-align: right;
}

button {
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid var(--button-border);
  background: var(--button-bg);
  color: #fff;
  border-radius: 8px;
  font-size: 0.9rem;
  padding: 0.45rem 0.8rem;
  line-height: 1.2;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  position: relative;
  z-index: 1;
}

button:hover {
  filter: brightness(1.05);
}

.brand {
  margin-top: 0.8rem;
  display: flex;
  justify-content: center;
}

.brand .preview-logo {
  cursor: pointer;
}

.preview-heading {
  margin-top: 1rem;
  padding: 0.78rem 1rem 0.72rem;
  border: 1px solid var(--stroke);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  background: linear-gradient(180deg, var(--titlebar-top) 0%, var(--titlebar-bottom) 100%);
  box-shadow: inset 0 -1px 0 var(--titlebar-shadow);
}

.preview-logo {
  display: block;
  height: clamp(30px, 3.6vw, 39px);
  width: min(280px, 65vw);
  max-width: min(280px, 65vw);
  fill: var(--logo-color);
}

.preview-name {
  margin: 0.46rem 0 0;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-title-row {
  margin-top: 0.46rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.preview-title-row .preview-name {
  margin: 0;
}

.preview-format-badge {
  display: inline-flex;
  align-items: center;
  height: 1.3rem;
  padding: 0 0.44rem;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
  background: var(--bg);
  flex-shrink: 0;
}

.preview-subtitle {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

.viewer {
  margin-top: 1rem;
  height: min(72vh, 780px);
  min-height: 300px;
  padding: 10px;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: var(--bg);
  display: grid;
  place-items: center;
  overflow: hidden;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.viewer--with-titlebar {
  margin-top: 0;
  border-top: 0;
  border-radius: 0 0 12px 12px;
}

.viewer--empty {
  border-width: 2px;
  border-style: dashed;
  cursor: pointer;
}

.viewer--with-titlebar.viewer--empty {
  border-top: 0;
}

.viewer--empty.viewer--dragover {
  border-color: var(--accent);
  background: var(--drag-bg);
}

.viewer--transparency-grid {
  background-color: transparent !important;
  background-image: conic-gradient(
    from 90deg at 10px 10px,
    var(--grid-a) 0 25%,
    var(--grid-b) 0 50%,
    var(--grid-a) 0 75%,
    var(--grid-b) 0 100%
  );
  background-size: 20px 20px;
}

.animation-host {
  width: 100%;
  height: 100%;
}

.animation-host svg,
.animation-host canvas,
.animation-host dotlottie-player {
  width: 100% !important;
  height: 100% !important;
  border-radius: 8px;
}

.viewer-empty {
  text-align: center;
  color: var(--muted);
  line-height: 1.45;
}

.about-box {
  margin-top: 1.15rem;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: 0 8px 24px rgba(17, 28, 45, 0.06);
  overflow: hidden;
}

.about-box__body {
  --about-copy-width: 40rem;
  padding: 0 1.2rem 0.9rem;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.about-box__body p {
  max-width: var(--about-copy-width);
  margin: 0.68rem auto 0;
  text-align: left;
}

.about-box__legal {
  font-size: 0.74rem;
  line-height: 1.45;
  opacity: 0.75;
}

.about-box__body a {
  color: var(--logo-color);
  font-weight: 700;
  text-decoration: none;
}

.about-box__legal a {
  font-weight: 600;
}

.about-box__body a:hover {
  text-decoration: underline;
}

.status {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.status.error {
  color: var(--error);
}

.metadata {
  margin-top: 0.9rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: var(--panel);
}

.metadata h2 {
  margin: 0 0 0.6rem;
  font-size: 0.95rem;
}

.metadata-grid {
  margin: 0;
  display: grid;
  gap: 0.55rem 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.meta-item {
  display: grid;
  gap: 0.1rem;
}

.meta-item dt {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  opacity: 0.8;
}

.meta-item dd {
  margin: 0;
  color: var(--text);
  font-size: 0.82rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  opacity: 1;
  word-break: break-word;
}

.theme-dock {
  margin-top: 0.8rem;
  padding-bottom: 0.4rem;
  display: flex;
  justify-content: flex-end;
}

.about-toggle {
  -webkit-appearance: none;
  appearance: none;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  min-height: 46px;
  min-width: 0;
  padding: 0.72rem 0.85rem;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1;
}

.about-toggle[aria-expanded="true"] {
  box-shadow: inset 0 -1px 0 var(--stroke);
}

.release-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.7rem;
  min-width: 0;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

.about-toggle__icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--stroke);
  border-radius: 50%;
  background:
    linear-gradient(var(--muted), var(--muted)) center / 10px 2px no-repeat,
    linear-gradient(var(--muted), var(--muted)) center / 2px 10px no-repeat;
  transition: transform 140ms ease;
  flex-shrink: 0;
}

.about-toggle[aria-expanded="true"] .about-toggle__icon {
  transform: rotate(45deg);
}

.about-toggle:hover {
  filter: none;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 30px;
  padding: 0.28rem 0.5rem 0.28rem 0.6rem;
  font-size: 0.76rem;
  letter-spacing: 0.01em;
  line-height: 1;
  background: var(--bg);
  border: 1px solid var(--stroke);
  border-radius: 8px;
  color: inherit;
}

.theme-label {
  color: var(--muted);
  font-weight: 600;
}

.theme-switch {
  width: 34px;
  height: 20px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--bg);
  display: inline-flex;
  align-items: center;
  padding: 2px;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.theme-knob {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transform: translateX(0);
  transition: transform 140ms ease, background-color 140ms ease;
}

.theme-toggle[aria-pressed="true"] .theme-switch {
  background: var(--button-bg);
  border-color: var(--button-border);
}

.theme-toggle[aria-pressed="true"] .theme-knob {
  transform: translateX(14px);
  background: #ffffff;
}

.theme-toggle:hover {
  filter: none;
  border-color: var(--stroke);
}

@media (max-width: 760px) {
  .toolbar {
    justify-content: flex-start;
  }

  .toolbar button {
    width: auto;
  }

  .playback-controls {
    width: 100%;
    flex-wrap: wrap;
  }

  .playback-controls input[type="range"] {
    width: 100%;
  }

  .frame-label {
    text-align: left;
  }

  .theme-dock {
    justify-content: center;
  }
}
