* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0D0D0D;
  color: #fff;
  font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1A1A1A;
  padding: 8px 10px;
  flex-shrink: 0;
  z-index: 10;
}

.toolbar-left {
  display: flex;
  align-items: center;
  min-width: 0;
}

.toolbar-right {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.btn {
  border: 0;
  cursor: pointer;
  color: #fff;
  font-weight: bold;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 6px;
  font-family: inherit;
  min-width: 60px;
  height: 28px;
  line-height: 20px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-import {
  background: #4F46E5;
}

.btn-play {
  background: #1E3A5F;
  margin-left: 16px;
}

.btn-stop {
  background: #3A1E1E;
  margin-left: 8px;
}

.btn-metronome {
  background: #1E6B3A;
  margin-left: 8px;
  border-radius: 6px;
  min-width: 60px;
}

.btn-metronome-off {
  background: #3A3A3A !important;
}

.btn-spectrum {
  background: #25A3B3;
  margin-left: 8px;
  min-width: 52px;
}

.btn-help {
  background: #3A3A3A;
  font-size: 11px;
  padding: 4px 8px;
  min-width: 0;
  margin-right: 10px;
  font-weight: normal;
}

.btn-lang {
  background: #3A3A3A;
  font-size: 11px;
  padding: 4px 8px;
  min-width: 0;
  margin-right: 10px;
  font-weight: normal;
}

.file-name {
  color: #666666;
  font-size: 12px;
  margin-left: 12px;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.time-text {
  color: #818CF8;
  font-size: 18px;
  font-weight: bold;
  font-family: Consolas, monospace;
  margin-right: 12px;
}

.main-area {
  display: flex;
  flex: 1;
  min-height: 0;
}

.viz-area {
  flex: 1;
  background: #0A0A0A;
  display: flex;
  flex-direction: column;
  position: relative;
  min-width: 0;
}

.viz-grid {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

.waveform-container {
  flex: 0 0 50%;
  position: relative;
  overflow: hidden;
  background: #0A0A0A;
  pointer-events: none;
}

#waveform-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  will-change: transform;
  transform: translateZ(0);
}

.beatrow-container {
  flex: 0 0 36px;
  position: relative;
  overflow: hidden;
  background: #2A2A2A;
  pointer-events: none;
}

#beatrow-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  will-change: transform;
  transform: translateZ(0);
}

.spectrogram-container {
  flex: 0 0 50%;
  position: relative;
  overflow: hidden;
  background: #0A0A0A;
  pointer-events: none;
}

#spectrogram-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  will-change: transform;
  transform: translateZ(0);
  background: #0A0A0A;
}

#overlay-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 60;
  cursor: crosshair;
  display: none;
  outline: none;
  touch-action: none;
  pointer-events: auto;
  will-change: transform;
  transform: translateZ(0);
}

.placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333333;
  font-size: 16px;
  font-weight: bold;
  z-index: 5;
  pointer-events: none;
  text-align: center;
  padding: 20px;
}

.loading {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  color: #818CF8;
  font-size: 20px;
  font-weight: bold;
  z-index: 6;
  pointer-events: none;
}

.focus-highlight {
  position: absolute;
  inset: 0;
  border: 2px solid transparent;
  z-index: 100;
  pointer-events: none;
}

.edge-shadow {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 10px;
  z-index: 70;
  pointer-events: none;
}

.edge-shadow-left {
  left: 0;
  background: linear-gradient(to right, #0A0A0A, #0A0A0A00);
}

.edge-shadow-right {
  right: 0;
  background: linear-gradient(to left, #0A0A0A, #0A0A0A00);
}

.sidebar {
  width: 300px;
  background: #111111;
  border-left: 1px solid #222222;
  display: none;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
}

.sidebar-section {
  background: #141414;
  padding: 10px 14px;
  border-bottom: 1px solid #222222;
  flex-shrink: 0;
}

.sidebar-import-export {
  display: flex;
}

.btn-config {
  background: #2A3050;
  color: #A0A0CC;
  font-size: 12px;
  font-weight: bold;
  padding: 4px 8px;
  border-radius: 6px;
  min-width: 0;
}

.btn-config + .btn-config {
  margin-left: 6px;
}

.section-label {
  color: #888888;
  font-size: 10px;
  font-weight: bold;
  margin-bottom: 6px;
}

.sidebar-segments {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding-bottom: 0;
}

.segments-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.segments-header .section-label {
  margin-bottom: 0;
}

.btn-add-segment {
  background: #1E2A50;
  color: #818CF8;
  font-size: 11px;
  font-weight: bold;
  padding: 3px 8px;
  border-radius: 6px;
  min-width: 0;
}

#segment-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
}

#segment-scroll::-webkit-scrollbar {
  width: 5px;
}

#segment-scroll::-webkit-scrollbar-track {
  background: transparent;
}

#segment-scroll::-webkit-scrollbar-thumb {
  background: #3A3A3A;
  border-radius: 3px;
}

#segment-scroll::-webkit-scrollbar-thumb:hover {
  background: #4A4A4A;
}

.seg-row {
  border-radius: 6px;
  padding: 6px 10px 6px 6px;
  margin-bottom: 8px;
  cursor: pointer;
}

.seg-grid {
  display: flex;
  flex-wrap: wrap;
}

.seg-header {
  flex: 1;
  color: #999999;
  font-size: 10px;
  font-weight: bold;
  align-self: center;
}

.seg-header-remove {
  align-self: center;
}

.seg-collapsed-header {
  width: 18px;
  color: #999999;
  font-size: 10px;
  font-weight: bold;
  align-self: center;
  flex-shrink: 0;
}

.seg-inputs {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  margin-top: 6px;
}

.seg-field {
  flex: 3;
  min-width: 0;
}

.seg-col2 {
  flex: 2;
  margin-left: 6px;
}

.seg-span2 {
  flex: 1 0 100%;
  margin-top: 6px;
  max-width: 100%;
}

.seg-label {
  color: #666666;
  font-size: 9px;
  margin-bottom: 2px;
}

.seg-static-box {
  background: #0A0A0A;
  border: 1px solid #333333;
  height: 24px;
  line-height: 24px;
  text-align: center;
  font-family: Consolas, monospace;
  font-size: 12px;
  font-weight: bold;
}

.seg-time {
  font-family: Consolas, monospace;
  font-size: 11px;
  font-weight: bold;
  margin-top: 6px;
  width: 100%;
}

.seg-row2 {
  display: flex;
  width: 100%;
  margin-top: 4px;
}

.seg-row2 .seg-label {
  font-size: 12px;
  align-self: center;
}

.seg-row2 .seg-cell {
  font-size: 11px;
  align-self: center;
}

.seg-cell {
  font-family: Consolas, monospace;
  font-size: 11px;
  font-weight: bold;
  align-self: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.seg-fixed-col {
  width: 20px;
  flex-shrink: 0;
  align-self: center;
}

.seg-remove {
  background: transparent;
  border: 0;
  color: #FF8585;
  font-size: 11px;
  width: 20px;
  height: 20px;
  cursor: pointer;
  border-radius: 4px;
  line-height: 20px;
  font-family: inherit;
}

.seg-remove:hover {
  background: #444444;
}

.stepper {
  display: flex;
  align-items: stretch;
  height: 24px;
}

.stepper-btn {
  border: 0;
  width: 16px;
  height: 24px;
  color: #fff;
  font-size: 9px;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  font-family: inherit;
}

.stepper-input {
  flex: 1;
  min-width: 0;
  background: #0A0A0A;
  border: 1px solid #333333;
  color: #fff;
  font-family: Consolas, monospace;
  font-size: 12px;
  font-weight: bold;
  text-align: center;
  height: 24px;
  outline: none;
  padding: 0 2px;
}

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1A1A1A;
  padding: 4px 10px;
  flex-shrink: 0;
  font-size: 11px;
  color: #9A9A9A;
  position: relative;
  z-index: 100;
  pointer-events: auto;
}

.statusbar-left {
  display: flex;
  align-items: center;
}

.statusbar-left span + span {
  margin-left: 20px;
}

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.dialog {
  width: 680px;
  max-width: 92vw;
  max-height: 88vh;
  background: #0D0D0D;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #222222;
}

.dialog-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1A1A1A;
  padding: 10px 16px;
}

.dialog-nav-title {
  color: #fff;
  font-size: 14px;
  font-weight: bold;
}

.dialog-nav-btns {
  display: flex;
  gap: 8px;
}

.dialog-nav-btn {
  background: transparent;
  color: #CCCCCC;
  border: 0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 6px;
  font-family: inherit;
  min-width: 100px;
}

.dialog-nav-btn:hover {
  background: #262626;
}

.dialog-nav-btn.active {
  background: #262626;
}

.dialog-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.help-group {
  padding: 0 24px;
  margin-bottom: 16px;
  margin-top: 12px;
}

.help-group-title {
  color: #818CF8;
  font-size: 13px;
  font-weight: bold;
  margin-bottom: 6px;
}

.help-item {
  display: flex;
  padding: 6px 0;
  border-bottom: 1px solid #2A2A2A;
}

.help-op {
  flex: 1;
  color: #B5B5E0;
  font-family: Consolas, monospace;
  font-size: 12.5px;
  padding-right: 14px;
}

.help-desc {
  flex: 1;
  color: #CCCCCC;
  font-size: 13px;
}

.about-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 24px 16px;
  max-width: 380px;
  margin: 0 auto;
}

.about-icon {
  width: 96px;
  height: 96px;
  margin-bottom: 14px;
}

.about-name {
  color: #fff;
  font-size: 22px;
  font-weight: bold;
  text-align: center;
}

.about-tagline {
  color: #888888;
  font-size: 12px;
  margin: 4px 0 22px;
  text-align: center;
}

.about-row {
  display: flex;
  width: 100%;
  margin: 5px 0;
}

.about-label {
  width: 90px;
  color: #666666;
  font-size: 12px;
  flex-shrink: 0;
}

.about-value {
  color: #CCCCCC;
  font-size: 12px;
  word-break: break-all;
}

.dialog-footer {
  display: flex;
  justify-content: center;
  padding: 12px;
}

.dialog-close {
  background: #4F46E5;
  color: #fff;
  border: 0;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  padding: 6px 16px;
  border-radius: 6px;
  min-width: 90px;
  height: 32px;
}