:root {
  --bg: #212529;
  --panel: #252a2e;
  --border: #495057;
  --text: #f8f9fa;
  --muted: #9cb3c8;
  --accent: #588CC4;
  --shadow: rgba(0, 0, 0, 0.35);
  --gradient-a: #212529;
  --gradient-b: #343a40;
}

body[data-theme="light"] {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --border: #d5e0ee;
  --text: #0f172a;
  --muted: #5b6b7d;
  --accent: #3272B9;
  --shadow: rgba(15, 23, 42, 0.08);
  --gradient-a: rgba(37, 99, 235, 0.08);
  --gradient-b: rgba(45, 212, 191, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 20% 20%, var(--gradient-a), transparent 32%),
    radial-gradient(circle at 80% 0%, var(--gradient-b), transparent 28%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 6px;
}

.logo {
  max-height: 48px;
  width: auto;
  display: block;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  padding: 8px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px var(--shadow);
}

.theme-icon {
  width: 1.5rem;
  height: 1.5rem;
  display: inline-block;
  background: center/contain no-repeat
    url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20viewBox%3D%270%200%2035%2035%27%20fill%3D%27currentColor%27%3E%3Cpath%20d%3D%27M17.5%2C25.88a8.38%2C8.38%2C0%2C1%2C1%2C8.38-8.38A8.389%2C8.389%2C0%2C0%2C1%2C17.5%2C25.88Zm0-14.26a5.88%2C5.88%2C0%2C1%2C0%2C5.88%2C5.88A5.887%2C5.887%2C0%2C0%2C0%2C17.5%2C11.62Z%27/%3E%3Cpath%20d%3D%27M17.5%2C5.471h-.034A1.251%2C1.251%2C0%2C0%2C1%2C16.25%2C4.187l.075-2.721A1.267%2C1.267%2C0%2C0%2C1%2C17.609.25a1.251%2C1.251%2C0%2C0%2C1%2C1.215%2C1.284l-.075%2C2.721A1.249%2C1.249%2C0%2C0%2C1%2C17.5%2C5.471Z%27/%3E%3Cpath%20d%3D%27M26.893%2C9.364a1.25%2C1.25%2C0%2C0%2C1-.859-2.158l1.978-1.871A1.25%2C1.25%2C0%2C0%2C1%2C29.73%2C7.151L27.752%2C9.022A1.242%2C1.242%2C0%2C0%2C1%2C26.893%2C9.364Z%27/%3E%3Cpath%20d%3D%27M33.5%2C18.837h-.036l-2.722-.077a1.249%2C1.249%2C0%2C0%2C1-1.213-1.284%2C1.211%2C1.211%2C0%2C0%2C1%2C1.285-1.214l2.721.077a1.25%2C1.25%2C0%2C0%2C1-.035%2C2.5Z%27/%3E%3Cpath%20d%3D%27M28.748%2C30.13a1.248%2C1.248%2C0%2C0%2C1-.909-.392L25.97%2C27.759a1.25%2C1.25%2C0%2C1%2C1%2C1.817-1.717l1.869%2C1.98a1.249%2C1.249%2C0%2C0%2C1-.908%2C2.108Z%27/%3E%3Cpath%20d%3D%27M17.4%2C34.75h-.037a1.249%2C1.249%2C0%2C0%2C1-1.213-1.285l.079-2.721a1.25%2C1.25%2C0%2C0%2C1%2C2.5.072l-.079%2C2.721A1.249%2C1.249%2C0%2C0%2C1%2C17.4%2C34.75Z%27/%3E%3Cpath%20d%3D%27M6.112%2C29.989a1.249%2C1.249%2C0%2C0%2C1-.857-2.159l1.98-1.867A1.25%2C1.25%2C0%2C1%2C1%2C8.95%2C27.781L6.969%2C29.648A1.242%2C1.242%2C0%2C0%2C1%2C6.112%2C29.989Z%27/%3E%3Cpath%20d%3D%27M4.221%2C18.72H4.184l-2.721-.081A1.25%2C1.25%2C0%2C0%2C1%2C.251%2C17.352%2C1.237%2C1.237%2C0%2C0%2C1%2C1.537%2C16.14l2.721.081a1.25%2C1.25%2C0%2C0%2C1-.037%2C2.5Z%27/%3E%3Cpath%20d%3D%27M8.135%2C9.335a1.248%2C1.248%2C0%2C0%2C1-.91-.393L5.359%2C6.961a1.25%2C1.25%2C0%2C1%2C1%2C1.82-1.715L9.046%2C7.228a1.251%2C1.251%2C0%2C0%2C1-.911%2C2.107Z%27/%3E%3C/svg%3E");
}

body[data-theme="dark"] .theme-icon {
  background: center/contain no-repeat
    url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20viewBox%3D%270%200%2024%2024%27%20fill%3D%27currentColor%27%3E%3Cpath%20fill-rule%3D%27evenodd%27%20clip-rule%3D%27evenodd%27%20d%3D%27M3.39703%2011.6315C3.39703%2016.602%207.42647%2020.6315%2012.397%2020.6315C15.6858%2020.6315%2018.5656%2018.8664%2020.1358%2016.23C16.7285%2017.3289%2012.6922%2016.7548%209.98282%2014.0455C7.25201%2011.3146%206.72603%207.28415%207.86703%203.89293C5.20697%205.47927%203.39703%208.38932%203.39703%2011.6315ZM21.187%2013.5851C22.0125%2013.1021%2023.255%2013.6488%2023%2014.5706C21.7144%2019.2187%2017.4543%2022.6315%2012.397%2022.6315C6.3219%2022.6315%201.39703%2017.7066%201.39703%2011.6315C1.39703%206.58874%204.93533%202.25845%209.61528%200.999986C10.5393%200.751502%2011.0645%201.99378%2010.5641%202.80935C8.70026%205.84656%208.83194%2010.0661%2011.397%2012.6312C13.9319%2015.1662%2018.1365%2015.3702%2021.187%2013.5851Z%27/%3E%3C/svg%3E");
  filter: invert(1) brightness(1.3);
}

.theme-toggle:hover {
  transform: translateY(-1px);
}

.theme-toggle:active {
  transform: translateY(0);
}

.controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

.control-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 240px;
}

.select-shell {
  position: relative;
}

.select-shell select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0a1a2c;
  background: var(--panel);
  color: var(--text);
  font-size: 15px;
  appearance: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.select-shell::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 14px;
  height: 14px;
  color: var(--muted);
  background: center/contain no-repeat
    url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
  transform: translateY(-50%);
  pointer-events: none;
}

body[data-theme="dark"] .select-shell::after {
  filter: invert(1) brightness(1.4);
}

.status-message {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  flex: 1 1 240px;
}

.viewer {
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  display: flex;
  justify-content: center;
}

.frame {
  width: 100%;
  max-width: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.frame img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 72vh;
  object-fit: fill;
  background: var(--panel);
}

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.2));
  color: #fff;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.loading-overlay.visible {
  opacity: 1;
}

.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  font-weight: 600;
  letter-spacing: 0.3px;
}

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

.page-footer {
  max-width: 1200px;
  margin: 0 auto 28px;
  padding: 0 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  justify-content: space-between;
}

.page-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.page-footer a:hover {
  text-decoration: underline;
}

@media (max-width: 640px) {
  .controls {
    align-items: flex-start;
  }
  .status-message {
    order: 3;
  }

  body {
    font-size: 14px;
  }

  .logo {
    max-height: 36px;
  }

  .theme-toggle {
    padding: 7px 12px;
    font-size: 13px;
    min-width: 78px;
  }

  .controls label,
  .select-shell select {
    font-size: 14px;
  }

  .status-message {
    font-size: 13px;
  }
}
