.studio-body {
  padding: 10px 16px max(20px, env(safe-area-inset-bottom));
  gap: 10px;
}

/* Lock viewport height only on pointer-fine desktop monitors; touch/mobile desktop-view stays scrollable */
@media (min-width: 1024px) and (min-height: 760px) and (hover: hover) and (pointer: fine) {
  .studio-body {
    height: 100vh;
    height: 100dvh;
    padding-bottom: 12px;
    overflow: hidden;
  }

  .studio-body .table-scroll {
    max-height: none;
  }
}

.studio-body .card {
  flex-shrink: 0;
  padding: 10px 16px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

/* 1. Top File Loader */
.file-grid {
  display: grid;
  grid-template-columns: 230px 1fr auto;
  gap: 8px 12px;
  align-items: center;
}

.target-disabled-zone {
  opacity: 0.42;
  filter: grayscale(90%);
  pointer-events: none;
  user-select: none;
  transition: all 0.2s ease;
}

.file-label {
  font-size: 13px;
  font-weight: 600;
}

.file-path-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.file-path-box {
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 180px;
  min-width: 0;
}

.status-line {
  grid-column: 1 / -1;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.progress-wrap {
  flex: 0 0 260px;
  max-width: 100%;
  display: none;
}

.progress-wrap .progress-track {
  height: 10px;
}

.studio-notice {
  flex-shrink: 0;
}

/* 2. Live White Timeline Display */
.zoom-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.zoom-toolbar-title {
  font-size: 13.5px;
  font-weight: 700;
  margin-right: 4px;
}

.zoom-info {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-left: 4px;
}

.legend-pills {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  font-size: 12px;
  font-weight: 600;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-dot-ref { background: var(--ref-green); }
.legend-dot-orig { background: var(--orig-pink); }
.legend-dot-sync { background: var(--sync-indigo); }
.legend-dot-gold { background: var(--highlight-gold); }

.canvas-container {
  padding: 0;
  overflow-x: auto;
  overflow-y: hidden;
  position: relative;
  -webkit-overflow-scrolling: touch;
}

.timeline-scroll-spacer {
  position: relative;
  width: 100%;
  height: 118px;
}

.timeline-sticky-canvas,
#timelineCanvas {
  position: sticky;
  left: 0;
  top: 0;
  width: 100%;
  height: 118px;
  display: block;
  cursor: grab;
}

#timelineCanvas:active {
  cursor: grabbing;
}

/* 3. Tabs Container */
.tabs-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 300px;
}

.tabs-header {
  display: flex;
  gap: 6px;
  border-bottom: 2px solid var(--border-pink);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}

.tabs-header::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  background: var(--accent-light);
  color: var(--text-main);
  border: 1.5px solid var(--border-pink);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  padding: 8px 15px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.tab-btn:hover {
  background: #ffc4de;
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--accent-hover);
  transform: translateY(2px);
  padding-bottom: 10px;
}

.tab-content {
  display: none;
  background: var(--bg-card);
  border: 1.5px solid var(--border-pink);
  border-top: none;
  border-radius: 0 12px 12px 12px;
  padding: 12px 16px;
  flex: 1;
  min-height: 0;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
}

.tab-toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  flex-shrink: 0;
}

.inline-controls-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* Simple Tab Form */
.simple-controls-grid {
  display: grid;
  grid-template-columns: 195px auto 1fr;
  gap: 14px 12px;
  align-items: center;
  padding: 16px;
}

.simple-nudge-group {
  grid-column: 2 / -1;
}

.control-field-label {
  font-weight: 700;
  font-size: 13.5px;
}

.stats-banner {
  border-style: dashed;
  border-color: var(--accent-pink);
  font-size: 13.5px;
  font-weight: 600;
}

/* Tables */
.table-scroll {
  padding: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 220px;
  max-height: 52vh;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--accent-light);
  color: var(--text-main);
  font-weight: 700;
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1.5px solid var(--border-pink);
  z-index: 2;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid #f9dce8;
  transition: background-color 0.12s;
  cursor: pointer;
}

tbody tr:hover {
  background: var(--bg-hover);
}

tbody tr.selected-row {
  background: #fff3cd !important;
  outline: 2px solid var(--highlight-gold);
  outline-offset: -2px;
}

tbody tr.dropped-row {
  opacity: 0.55;
  background: #fdf2f6;
}

td {
  padding: 7px 10px;
  vertical-align: middle;
}

.empty-table-cell {
  text-align: center;
  padding: 26px;
  color: var(--text-muted);
}

.inline-offset-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.inline-offset-group .field-num {
  width: 90px;
  padding: 4px 6px;
  font-size: 12.5px;
  text-align: center;
}

.trans-edit-input {
  width: 100%;
  font-weight: 500;
}

.chunk-sample {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 175px;
}

.custom-filter-input {
  width: 165px;
}

/* Translation Controls Bar */
.translate-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 9px 14px;
  position: relative;
  z-index: 50;
  flex-shrink: 0;
}

.toolbar-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex-shrink: 0;
}

.toolbar-label {
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}

.accent-label {
  color: var(--accent-hover);
}

.translate-status-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.translate-status-row > span {
  flex: 1 1 240px;
  min-width: 0;
}

/* 4. Common Bottom Bar */
.bottom-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.bottom-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--border-pink);
}

.line-split-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.split-chars-input {
  width: 74px;
  padding: 4px 8px;
}

.split-delay-input {
  width: 84px;
  padding: 4px 8px;
}

.bottom-row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.bottom-status {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.filename-preview-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.filename-input {
  width: 260px;
  max-width: 100%;
}

.studio-body .site-footer {
  padding: 2px 8px 4px;
}

/* Tablet Breakpoint */
@media (max-width: 1023px) {
  .studio-body {
    padding: 10px 12px;
  }

  .file-grid {
    grid-template-columns: 185px 1fr auto;
    gap: 8px 10px;
  }

  .simple-controls-grid {
    grid-template-columns: 165px auto 1fr;
    gap: 12px 10px;
    padding: 14px;
  }

  .table-scroll {
    min-height: 280px;
    max-height: 440px;
  }
}

/* Mobile Phone Breakpoint */
@media (max-width: 720px) {
  .studio-body {
    padding: 8px 10px;
    gap: 8px;
  }

  .studio-body .card {
    padding: 10px 12px;
  }

  .file-grid,
  .simple-controls-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .simple-nudge-group {
    grid-column: 1 / -1;
  }

  .simple-controls-grid {
    padding: 12px;
  }

  .file-grid .btn,
  .simple-controls-grid .field-num,
  .toolbar-field,
  .translate-toolbar .btn,
  .filename-preview-group,
  .filename-preview-group .btn-primary {
    width: 100%;
  }

  .toolbar-field .toolbar-label {
    min-width: 44px;
  }

  .toolbar-field .custom-dropdown {
    flex: 1;
    min-width: 0;
  }

  .legend-pills {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
  }

  .tab-btn {
    padding: 8px 12px;
    font-size: 12.5px;
  }

  .tab-content {
    padding: 10px 12px;
  }

  .table-scroll {
    min-height: 250px;
    max-height: 380px;
  }

  .filename-preview-group {
    margin-left: 0;
  }

  .filename-input {
    flex: 1 1 180px;
    width: 100%;
  }
}
