:root {
  color-scheme: dark;
  --bg: #101114;
  --panel: #191c20;
  --panel-strong: #20242a;
  --text: #f1f5f9;
  --muted: #9aa4b2;
  --line: #30363f;
  --accent: #4fb477;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

.topbar {
  align-items: center;
  background: rgba(25, 28, 32, 0.96);
  border-bottom: 1px solid var(--line);
  display: flex;
  height: calc(42px + env(safe-area-inset-top));
  justify-content: space-between;
  left: 0;
  gap: 10px;
  padding: env(safe-area-inset-top) 10px 0;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 5;
}

.subtitle {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.quality-select,
.zoom-button {
  appearance: none;
  background-color: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
  height: 32px;
  min-height: 32px;
}

.quality-select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 13px) 13px,
    calc(100% - 8px) 13px;
  background-repeat: no-repeat;
  background-size: 5px 5px;
  padding: 0 24px 0 10px;
}

.zoom-control {
  align-items: center;
  display: inline-flex;
  position: relative;
}

.zoom-button {
  justify-content: center;
  min-height: 32px;
  padding: 0 8px;
  text-align: center;
  width: 58px;
}

.zoom-button[aria-expanded="true"] {
  border-color: rgba(79, 180, 119, 0.8);
}

.zoom-menu {
  background: rgba(25, 28, 32, 0.98);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.42);
  padding: 12px 12px 8px;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 190px;
  z-index: 10;
}

.zoom-slider {
  accent-color: var(--accent);
  display: block;
  height: 24px;
  margin: 0;
  padding: 0;
  width: 100%;
}

.zoom-ticks {
  color: var(--muted);
  display: flex;
  font-size: 11px;
  font-weight: 650;
  justify-content: space-between;
  line-height: 1;
  margin-top: 5px;
}

.icon-button {
  align-items: center;
  aspect-ratio: 1;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  display: inline-flex;
  font-size: 20px;
  justify-content: center;
  min-height: 32px;
  width: 32px;
}

.viewport {
  height: 100%;
  padding: calc(46px + env(safe-area-inset-top)) 0 calc(8px + env(safe-area-inset-bottom));
}

.screen-wrap {
  align-items: center;
  background: #050608;
  display: flex;
  height: 100%;
  justify-content: center;
  overflow: hidden;
  position: relative;
  touch-action: none;
  user-select: none;
  width: 100%;
}

.screen {
  display: block;
  object-fit: contain;
  transform-origin: center center;
}

.empty-state {
  color: var(--muted);
  font-size: 14px;
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  white-space: nowrap;
}

input,
textarea,
select,
button {
  border-radius: 8px;
  min-height: 42px;
}

input,
select,
textarea {
  background: #0f1115;
  border: 1px solid var(--line);
  color: var(--text);
  min-width: 0;
  padding: 0 12px;
}

button {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 650;
}

button:active {
  background: var(--accent);
  color: #07110b;
}

.zoom-slider {
  background: transparent;
  border: 0;
  min-height: 24px;
  padding: 0;
}

.keyboard-proxy {
  caret-color: transparent;
  color: transparent;
  height: 1px;
  left: 8px;
  opacity: 0.01;
  overflow: hidden;
  padding: 0;
  pointer-events: none;
  position: fixed;
  resize: none;
  top: calc(50px + env(safe-area-inset-top));
  width: 1px;
  z-index: 1;
}

@media (min-width: 760px) {
  .viewport {
    padding-left: 0;
    padding-right: 0;
  }
}

@media (max-width: 420px) {
  .topbar {
    gap: 6px;
    padding-left: 8px;
    padding-right: 8px;
  }

  .topbar-actions {
    gap: 6px;
  }

  .quality-select {
    max-width: 88px;
  }

  .zoom-button {
    width: 52px;
  }

  .zoom-menu {
    right: -74px;
    width: min(190px, calc(100vw - 16px));
  }
}
