:root {
  --bg: #0c0f14;
  --bg-elevated: #141a24;
  --bg-input: #0e131c;
  --border: rgba(94, 234, 212, 0.12);
  --accent: #5eead4;
  --accent-dim: rgba(94, 234, 212, 0.55);
  --text: #e8edf5;
  --text-muted: #8b98ab;
  --danger: #f87171;
  --font-sans: "DM Sans", system-ui, sans-serif;
  --radius: 12px;
  --shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--text);
  background:
    radial-gradient(ellipse 120% 80% at 50% -20%, rgba(94, 234, 212, 0.08), transparent),
    radial-gradient(ellipse 80% 50% at 100% 50%, rgba(56, 189, 248, 0.06), transparent),
    var(--bg);
}

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 2rem 1.1rem 2.8rem;
}

header.hero {
  text-align: center;
  margin-bottom: 1.5rem;
}

header.hero h1 {
  margin: 0 0 0.35rem;
  font-weight: 700;
  font-size: clamp(1.55rem, 4vw, 2.1rem);
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #f0fdfa 0%, var(--accent) 55%, #38bdf8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

header.hero .hero-guide {
  max-width: 52rem;
  margin: 0.75rem auto 0;
  text-align: left;
}

header.hero .hero-guide p,
header.hero .hero-guide .hero-guide__lead {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.58;
}

header.hero .hero-guide--collapsible > .hero-guide__lead {
  margin-bottom: 0.65rem;
}

header.hero .hero-guide a:link,
header.hero .hero-guide a:visited {
  color: #fff;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.45);
  text-underline-offset: 0.15em;
}

header.hero .hero-guide a:hover {
  text-decoration-color: rgba(255, 255, 255, 0.9);
}

header.hero .hero-guide__section {
  margin-top: 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(14, 19, 28, 0.55);
  overflow: hidden;
}

header.hero .hero-guide__section summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  cursor: pointer;
  list-style: none;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  color: var(--text);
  user-select: none;
}

header.hero .hero-guide__section summary::-webkit-details-marker {
  display: none;
}

header.hero .hero-guide__section summary::before {
  content: "▸";
  flex-shrink: 0;
  color: var(--accent);
  font-size: 0.9rem;
  transition: transform 0.15s ease;
}

header.hero .hero-guide__section[open] summary::before {
  transform: rotate(90deg);
}

header.hero .hero-guide__section summary strong {
  font-weight: 700;
}

header.hero .hero-guide__section summary:hover {
  background: rgba(94, 234, 212, 0.06);
}

header.hero .hero-guide__section summary:focus-visible {
  outline: 2px solid rgba(94, 234, 212, 0.45);
  outline-offset: -2px;
}

header.hero .hero-guide__body {
  padding: 0 0.85rem 0.85rem;
  border-top: 1px solid var(--border);
}

header.hero .hero-guide__body p {
  margin: 0.75rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.58;
}

header.hero .hero-guide__body ul,
header.hero .hero-guide__body ol {
  margin: 0.65rem 0 0;
  padding-left: 1.35rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.58;
}

header.hero .hero-guide__body li + li {
  margin-top: 0.4rem;
}

header.hero .hero-guide__steps li + li {
  margin-top: 0.5rem;
}

header.hero .hero-guide__body code {
  font-size: 0.88em;
  color: var(--accent);
}

header.hero .hero-guide__heading {
  margin: 1rem 0 0;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-dim);
}

header.hero .hero-guide__tip {
  margin-top: 0.85rem;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(94, 234, 212, 0.2);
  background: rgba(94, 234, 212, 0.06);
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.controls {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr auto auto;
  gap: 0.65rem;
  align-items: end;
}

.field-label {
  display: block;
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-dim);
}

.text-input,
.select {
  width: 100%;
  padding: 0.62rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
}

.btn {
  padding: 0.65rem 1rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  color: #042f2e;
  background: linear-gradient(135deg, #5eead4 0%, #2dd4bf 50%, #22d3ee 100%);
}

.btn.secondary {
  background: #213041;
  color: var(--text);
  border: 1px solid var(--border);
}

.status {
  margin-top: 0.7rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  min-height: 1.2rem;
}

.status.error {
  color: var(--danger);
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.65rem;
  margin-bottom: 0.8rem;
}

.search-results {
  list-style: none;
  margin: 0 0 0.8rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(14, 19, 28, 0.55);
}

.search-results:empty {
  display: none;
}

.search-results li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid rgba(94, 234, 212, 0.08);
}

.search-results li:last-child {
  border-bottom: none;
}

.search-results .result-id {
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
  color: var(--accent);
  font-weight: 600;
  margin-right: 0.5rem;
}

.search-results .result-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.upload-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.65rem;
  margin-bottom: 0.8rem;
}

.chain-panel {
  margin-top: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(14, 19, 28, 0.55);
  padding: 0.75rem;
}

.anim-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.5rem;
  align-items: center;
}

.anim-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: auto;
}

.speed-wrap {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
}

.speed-wrap input[type="range"] {
  width: 180px;
}

.chain-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.45rem;
}

.chain-title {
  margin: 0;
  font-size: 0.8rem;
  color: var(--accent-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.chain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.45rem 0.7rem;
}

.chain-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border: 1px solid rgba(94, 234, 212, 0.12);
  border-radius: 8px;
  padding: 0.35rem 0.45rem;
}

.chain-id {
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
  font-size: 0.84rem;
  color: var(--text);
}

.chain-color {
  width: 30px;
  height: 24px;
  border: none;
  background: transparent;
  cursor: pointer;
}

.mini-btn {
  padding: 0.38rem 0.62rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #213041;
  color: var(--text);
  text-decoration: none;
  font-size: 0.78rem;
  cursor: pointer;
}

#viewer {
  margin-top: 0.9rem;
  position: relative;
  overflow: hidden;
  width: 100%;
  height: min(68vh, 560px);
  min-height: 360px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0b1018;
}

@media (max-width: 820px) {
  .controls {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  main {
    padding: 1.2rem 0.8rem 2rem;
  }

  .controls {
    grid-template-columns: 1fr;
  }
}
