:root {
  color-scheme: dark;
  --bg: #080b10;
  --surface: #111721;
  --surface-2: #171f2b;
  --surface-3: #202837;
  --ink: #f7f4ec;
  --muted: #a5adba;
  --muted-2: #737e8e;
  --line: rgba(255, 255, 255, 0.14);
  --strong-line: rgba(255, 255, 255, 0.28);
  --accent: #25dfd2;
  --accent-strong: #12bcae;
  --accent-2: #ffb703;
  --accent-3: #ff4d8d;
  --danger: #ff6570;
  --shadow: 0 22px 48px rgba(0, 0, 0, 0.36);
  --button-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background:
    linear-gradient(150deg, rgba(255, 77, 141, 0.16), transparent 34%),
    linear-gradient(310deg, rgba(37, 223, 210, 0.16), transparent 38%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 88px),
    linear-gradient(180deg, #0d1016 0%, #141b25 52%, #080b10 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

.visually-hidden-file {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(42, 52, 69, 0.98), rgba(21, 28, 40, 0.98));
  color: var(--ink);
  padding: 0 12px;
  cursor: pointer;
  box-shadow: var(--button-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  font-size: 0.82rem;
  font-weight: 720;
  line-height: 1;
  white-space: nowrap;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease,
    color 140ms ease,
    transform 140ms ease;
}

button:hover:not(:disabled) {
  border-color: rgba(37, 223, 210, 0.5);
  background: linear-gradient(180deg, rgba(55, 67, 87, 0.98), rgba(24, 32, 46, 0.98));
  box-shadow:
    0 10px 26px rgba(0, 0, 0, 0.28),
    0 0 18px rgba(37, 223, 210, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

button:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.26);
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(37, 223, 210, 0.28);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.44;
  box-shadow: none;
}

button.primary {
  border-color: rgba(92, 255, 236, 0.7);
  background:
    linear-gradient(135deg, rgba(255, 183, 3, 0.92), rgba(37, 223, 210, 0.92) 47%, rgba(18, 188, 174, 0.96)),
    #12bcae;
  color: #061014;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.2);
  box-shadow:
    0 10px 28px rgba(18, 188, 174, 0.26),
    0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}

button.primary:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.74);
  background:
    linear-gradient(135deg, #ffd166, #2af0df 48%, #16c8b9),
    #25dfd2;
  box-shadow:
    0 14px 34px rgba(18, 188, 174, 0.34),
    0 0 34px rgba(255, 183, 3, 0.14);
}

button.large {
  min-height: 54px;
  padding: 0 28px;
  font-size: 1rem;
  font-weight: 820;
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.app-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent 30%),
    repeating-linear-gradient(0deg, transparent 0 58px, rgba(255, 255, 255, 0.025) 58px 59px);
  opacity: 0.78;
}

.topbar,
.workspace,
.statusbar {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  max-width: 100vw;
  min-height: 58px;
  padding: 10px 12px;
  background: rgba(9, 13, 19, 0.82);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 16px 32px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(18px);
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 10px;
  min-width: 0;
  min-height: 36px;
}

.brand-mark {
  display: inline-grid;
  grid-template-columns: repeat(4, 4px);
  align-items: end;
  gap: 3px;
  width: 34px;
  height: 34px;
  padding: 7px 6px;
  border: 1px solid rgba(37, 223, 210, 0.34);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    #111721;
  box-shadow: 0 0 24px rgba(37, 223, 210, 0.13);
}

.brand-mark span {
  display: block;
  width: 4px;
  min-height: 5px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: 0 0 10px rgba(37, 223, 210, 0.32);
  animation: brand-level 1.8s ease-in-out infinite;
}

.brand-mark span:nth-child(1) {
  height: 10px;
}

.brand-mark span:nth-child(2) {
  height: 18px;
  animation-delay: -0.45s;
}

.brand-mark span:nth-child(3) {
  height: 13px;
  animation-delay: -0.9s;
}

.brand-mark span:nth-child(4) {
  height: 22px;
  animation-delay: -1.2s;
}

.brand-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1;
  font-weight: 860;
  white-space: nowrap;
}

.brand-copy span {
  color: var(--accent-2);
  font-size: 0.68rem;
  font-weight: 780;
  text-transform: uppercase;
  white-space: nowrap;
}

.engine-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 10px;
  border: 1px solid rgba(37, 223, 210, 0.28);
  border-radius: 999px;
  color: var(--accent);
  background: rgba(17, 23, 33, 0.82);
  box-shadow: 0 0 16px rgba(37, 223, 210, 0.08);
  font-size: 0.72rem;
  font-weight: 820;
  white-space: nowrap;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  gap: 7px;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(37, 223, 210, 0.48) rgba(255, 255, 255, 0.08);
}

.toolbar::-webkit-scrollbar {
  height: 5px;
}

.toolbar::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.08);
}

.toolbar::-webkit-scrollbar-thumb {
  background: rgba(37, 223, 210, 0.48);
  border-radius: 999px;
}

.toolbar > button,
.toolbar > .segmented,
.toolbar > .zoom-axis-icon,
.toolbar > .threshold-control {
  flex: 0 0 auto;
}

.action-button {
  min-width: 62px;
}

.mode-button {
  min-width: 96px;
  justify-content: space-between;
}

.mode-button[aria-pressed="true"] {
  border-color: rgba(37, 223, 210, 0.52);
  color: var(--accent);
}

.mode-button-label {
  color: var(--muted);
  font-weight: 720;
}

.icon-action {
  min-width: 38px;
  padding: 0 10px;
  color: var(--accent-2);
  font-size: 0.95rem;
}

#uploadBtn,
#exportBtn {
  width: 38px;
  min-width: 38px;
  padding: 0;
}

.toolbar-divider {
  width: 1px;
  height: 30px;
  margin: 0 2px;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.22), transparent);
}

.zoom-axis-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  min-height: 34px;
  color: var(--muted);
  line-height: 1;
}

.zoom-axis-icon svg {
  display: block;
  width: 16px;
  height: 16px;
}

.button-icon {
  display: block;
  width: 15px;
  height: 15px;
  pointer-events: none;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: rgba(7, 11, 16, 0.72);
  box-shadow: var(--button-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.segmented button {
  border: 0;
  border-radius: 0;
  min-width: 36px;
  box-shadow: none;
  background: linear-gradient(180deg, rgba(35, 43, 57, 0.98), rgba(16, 22, 32, 0.98));
}

.segmented button + button {
  border-left: 1px solid rgba(255, 255, 255, 0.12);
}

.threshold-control {
  display: grid;
  grid-template-columns: auto 40px minmax(96px, 132px);
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(35, 43, 57, 0.92), rgba(16, 22, 32, 0.92));
  box-shadow: var(--button-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 720;
}

.threshold-control output {
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.threshold-control input {
  width: 100%;
  accent-color: var(--accent);
}

.threshold-control input[type="range"] {
  height: 18px;
}

.workspace {
  min-height: 0;
  padding: 10px;
  overflow: hidden;
}

.roll-panel {
  position: relative;
  height: 100%;
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.01)),
    var(--surface);
  box-shadow:
    var(--shadow),
    0 0 0 1px rgba(37, 223, 210, 0.06),
    0 0 42px rgba(255, 77, 141, 0.07);
  overflow: hidden;
}

.roll-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09);
}

.canvas-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  touch-action: none;
  background: #0a0f16;
  overflow: hidden;
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.pitch-scrollbar {
  position: absolute;
  top: 8px;
  right: 7px;
  bottom: 8px;
  z-index: 6;
  width: 14px;
  border: 1px solid rgba(37, 223, 210, 0.38);
  border-radius: 999px;
  background: rgba(3, 8, 13, 0.72);
  box-shadow:
    0 0 18px rgba(37, 223, 210, 0.08),
    0 1px 2px rgba(0, 0, 0, 0.4) inset;
  cursor: pointer;
}

.pitch-scrollbar-thumb {
  position: absolute;
  left: 2px;
  right: 2px;
  min-height: 24px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: 0 0 14px rgba(37, 223, 210, 0.35);
}

.pitch-scrollbar[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.48;
}

.hover-hint {
  position: absolute;
  z-index: 5;
  min-width: 178px;
  max-width: calc(100% - 12px);
  padding: 9px 11px;
  border: 1px solid rgba(37, 223, 210, 0.45);
  border-radius: 8px;
  background: rgba(9, 13, 19, 0.92);
  box-shadow:
    0 14px 28px rgba(0, 0, 0, 0.38),
    0 0 22px rgba(37, 223, 210, 0.12);
  color: var(--ink);
  font-size: 0.78rem;
  line-height: 1.45;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(10px);
}

.upload-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(3, 7, 12, 0.44);
  backdrop-filter: blur(4px);
  pointer-events: auto;
}

.upload-overlay[hidden] {
  display: none;
}

.upload-progress-panel {
  display: grid;
  width: min(360px, 100%);
  gap: 12px;
  padding: 18px;
  border: 1px solid rgba(37, 223, 210, 0.42);
  border-radius: 8px;
  background: rgba(9, 13, 19, 0.92);
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.42),
    0 0 28px rgba(37, 223, 210, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.upload-progress-label {
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 780;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-progress-track {
  height: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.upload-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  box-shadow: 0 0 16px rgba(37, 223, 210, 0.35);
  transition: width 140ms ease;
}

.upload-progress-percent {
  color: var(--accent-2);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  font-weight: 760;
  text-align: right;
}

.upload-cancel-button {
  justify-self: center;
  min-width: 88px;
  border-color: rgba(255, 101, 112, 0.58);
  color: var(--danger);
}

.hover-hint.selection-hint {
  min-width: min(370px, calc(100% - 12px));
  padding: 10px 11px 9px;
  border-color: rgba(255, 207, 74, 0.58);
  background: rgba(9, 13, 19, 0.86);
}

.hover-hint-title {
  margin-bottom: 7px;
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 820;
  letter-spacing: 0;
  text-transform: uppercase;
}

.selection-stats {
  width: 100%;
  border-collapse: collapse;
  color: var(--ink);
  font-size: 0.72rem;
  line-height: 1.28;
}

.selection-stats th,
.selection-stats td {
  padding: 3px 5px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  text-align: right;
  white-space: nowrap;
}

.selection-stats thead th {
  border-top: 0;
  color: var(--muted-2);
  font-size: 0.66rem;
  font-weight: 760;
}

.selection-stats th:first-child,
.selection-stats td:first-child {
  text-align: left;
}

.selection-stats tbody th {
  color: var(--accent);
  font-weight: 780;
}

.hover-hint-meta,
.hover-hint-empty {
  color: var(--muted);
  font-size: 0.7rem;
}

.hover-hint-meta {
  margin-top: 7px;
}

.start-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(180deg, rgba(8, 11, 16, 0.58), rgba(8, 11, 16, 0.86)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 72px);
  backdrop-filter: blur(7px);
}

.start-overlay[hidden] {
  display: none;
}

.start-stack {
  display: grid;
  justify-items: center;
  gap: 18px;
}

.start-visual {
  display: grid;
  grid-template-columns: repeat(5, 12px);
  align-items: end;
  gap: 8px;
  height: 74px;
}

.start-visual span {
  display: block;
  width: 12px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent-3), var(--accent-2) 45%, var(--accent));
  box-shadow:
    0 0 18px rgba(37, 223, 210, 0.32),
    0 0 28px rgba(255, 77, 141, 0.18);
  animation: meter-rise 1.5s ease-in-out infinite;
}

.start-visual span:nth-child(1) {
  height: 32px;
  animation-delay: -0.4s;
}

.start-visual span:nth-child(2) {
  height: 54px;
  animation-delay: -0.9s;
}

.start-visual span:nth-child(3) {
  height: 72px;
  animation-delay: -0.15s;
}

.start-visual span:nth-child(4) {
  height: 45px;
  animation-delay: -0.65s;
}

.start-visual span:nth-child(5) {
  height: 60px;
  animation-delay: -1.1s;
}

.start-overlay p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 650;
  text-align: center;
}

.statusbar {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  align-items: center;
  min-height: 38px;
  padding: 7px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(9, 13, 19, 0.84);
  color: var(--muted);
  box-shadow: 0 -16px 32px rgba(0, 0, 0, 0.2);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  backdrop-filter: blur(18px);
}

.statusbar > * {
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#currentStatus {
  flex: 1 1 470px;
}

.current-status {
  display: grid;
  grid-template-columns: max-content 8ch 8.5ch 9ch 10ch;
  gap: 8px;
  align-items: baseline;
}

.current-status-label,
.current-status-cell {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.current-status-label {
  color: var(--muted-2);
}

.current-status-number {
  text-align: right;
}

#rangeStatus,
#windowStatus,
#engineBadge,
.status-link {
  flex: 0 0 auto;
}

.status-link {
  color: var(--accent);
  font-weight: 760;
  text-decoration: none;
}

.status-link:hover {
  color: var(--accent-2);
  text-decoration: none;
}

.status-primary {
  color: var(--ink);
  font-weight: 700;
}

.status-message {
  flex: 1 1 180px;
  color: var(--accent);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

@keyframes brand-level {
  0%,
  100% {
    transform: scaleY(0.7);
  }
  50% {
    transform: scaleY(1.08);
  }
}

@keyframes meter-rise {
  0%,
  100% {
    transform: scaleY(0.78);
    opacity: 0.72;
  }
  50% {
    transform: scaleY(1.08);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media (max-width: 900px) {
  .topbar {
    align-items: center;
    flex-direction: row;
    gap: 10px;
  }

  .brand {
    width: auto;
    justify-content: flex-start;
  }

  .toolbar {
    width: auto;
    justify-content: flex-start;
  }
}

@media (max-width: 620px) {
  button {
    min-height: 31px;
    padding: 0 9px;
    font-size: 0.76rem;
  }

  .topbar {
    min-height: 50px;
    padding: 8px 8px;
    gap: 8px;
  }

  .brand {
    gap: 8px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    padding: 6px 5px;
  }

  .brand h1 {
    max-width: 148px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.88rem;
  }

  .brand-copy span {
    display: none;
  }

  .workspace {
    padding: 7px;
  }

  .toolbar {
    gap: 6px;
  }

  .action-button {
    min-width: 50px;
  }

  .mode-button {
    min-width: 86px;
  }

  .icon-action {
    min-width: 34px;
    padding: 0 8px;
  }

  #uploadBtn,
  #exportBtn {
    width: 34px;
    min-width: 34px;
  }

  .toolbar-divider {
    display: none;
  }

  .threshold-control {
    width: auto;
    flex-basis: auto;
    grid-template-columns: auto 38px minmax(86px, 112px);
    min-height: 31px;
    padding: 0 8px;
  }

  .start-visual {
    grid-template-columns: repeat(5, 10px);
    gap: 7px;
    height: 62px;
  }

  .start-visual span {
    width: 10px;
  }

  .statusbar {
    gap: 8px;
    min-height: 0;
    padding: 6px 8px;
    font-size: 0.71rem;
  }

  .status-message {
    text-align: right;
  }
}

@media (max-height: 620px) {
  .topbar {
    min-height: 0;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .workspace {
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .statusbar {
    min-height: 28px;
    padding-top: 5px;
    padding-bottom: 5px;
  }
}
