:root {
  --bg: #f4fbff;
  --surface: rgba(255, 255, 255, 0.96);
  --surface-strong: #ffffff;
  --surface-muted: #eaf7fd;
  --text: #122f45;
  --muted: #5e7688;
  --muted-strong: #1b4d72;
  --line: rgba(0, 64, 119, 0.18);
  --line-soft: rgba(148, 212, 238, 0.42);
  --accent: #007ec3;
  --accent-hover: #006eaa;
  --accent-strong: #004077;
  --accent-soft: rgba(0, 126, 195, 0.1);
  --aqua: #94d4ee;
  --rose: #d24f5d;
  --sun: #94d4ee;
  --danger: #c82838;
  --success: #16884f;
  --warning: #9c6500;
  --shadow: 0 18px 48px rgba(0, 64, 119, 0.12);
  --shadow-soft: 0 10px 28px rgba(0, 64, 119, 0.1);
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Trebuchet MS", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: var(--font);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(244, 251, 255, 0.94) 56%, rgba(228, 246, 253, 0.9) 100%),
    linear-gradient(90deg, rgba(148, 212, 238, 0.18) 0 1px, transparent 1px 96px),
    linear-gradient(0deg, rgba(148, 212, 238, 0.14) 0 1px, transparent 1px 96px),
    var(--bg);
}

body {
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 0 62%, rgba(0, 126, 195, 0.06) 62% 78%, transparent 78% 100%),
    linear-gradient(135deg, transparent 0 66%, rgba(148, 212, 238, 0.22) 66% 100%);
  opacity: 1;
  z-index: 0;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(0, 126, 195, 0.05) 0 12px, transparent 12px 100%),
    linear-gradient(180deg, transparent 0 72%, rgba(0, 64, 119, 0.06) 72% 100%);
  opacity: 0.9;
  z-index: 0;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 44px;
}

.auth-shell {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: 100vh;
  width: min(100% - 40px, 720px);
  margin: 0 auto;
  padding: 48px 0;
}

.auth-card {
  display: grid;
  gap: 28px;
  width: 100%;
  padding: 38px;
  border-left: 12px solid var(--accent);
  background:
    linear-gradient(90deg, rgba(148, 212, 238, 0.2), transparent 44%),
    var(--surface-strong);
}

.auth-card h1 {
  margin: 4px 0 8px;
  font-size: 3rem;
  line-height: 1.05;
  letter-spacing: 0;
  color: var(--accent-strong);
}

.auth-copy {
  margin: 0;
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 16px;
}

#auth-form {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: end;
}

.auth-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

#auth-form .auth-actions,
#auth-form #auth-flash {
  grid-column: 1 / -1;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 20px;
  padding: 0 0 14px;
  border-bottom: 4px solid var(--accent);
}

.user-chip {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  max-width: 100%;
  padding: 8px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-strong);
  box-shadow: none;
}

.user-chip span {
  max-width: min(260px, 100%);
  overflow: visible;
  overflow-wrap: anywhere;
  color: var(--muted-strong);
  font-size: 0.9rem;
  font-weight: 720;
  text-overflow: clip;
  white-space: normal;
}

.topbar h1 {
  margin: 4px 0 0;
  max-width: 760px;
  font-size: clamp(2.1rem, 4vw, 3.5rem);
  line-height: 1.02;
  letter-spacing: 0;
  font-weight: 820;
  color: var(--accent-strong);
}

.topbar-chip,
.badge,
.task-meta span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  color: var(--muted-strong);
  background: var(--surface-strong);
  box-shadow: none;
  font-size: 0.9rem;
  font-weight: 680;
}

.badge {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(0, 126, 195, 0.22);
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 0.78rem;
  font-weight: 820;
}

.card {
  position: relative;
  min-width: 0;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.main-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: stretch;
}

.preview-head h4 {
  display: block;
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 720;
}

.small-note,
.empty-state {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.upload-card,
.panel {
  min-width: 0;
  padding: 24px;
}

.upload-card {
  padding: 20px;
}

.card-head,
.preview-head,
.editor-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  min-width: 0;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--line);
}

.card-head h3 {
  margin: 7px 0 0;
  font-size: 1.28rem;
  letter-spacing: 0;
  font-weight: 820;
  color: var(--accent-strong);
}

.stack {
  display: grid;
  gap: 18px;
  margin-top: 20px;
}

.upload-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
  align-items: start;
}

.source-column,
.settings-column {
  display: grid;
  gap: 10px;
  align-content: start;
}

.settings-column .primary {
  width: 100%;
}

.primary-settings {
  grid-template-columns: 1fr;
}

.dropzone {
  display: grid;
  place-items: center;
  min-height: 172px;
  padding: 22px 18px;
  border-radius: var(--radius);
  border: 2px dashed rgba(0, 126, 195, 0.34);
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(148, 212, 238, 0.24) 0 18%, transparent 18% 100%),
    var(--surface-strong);
  box-shadow: var(--shadow-soft);
  text-align: center;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.dropzone:hover,
.dropzone.is-dragover {
  transform: translateY(-1px);
  border-color: rgba(0, 126, 195, 0.58);
  background: #ffffff;
  box-shadow: 0 14px 36px rgba(0, 126, 195, 0.14);
}

.dropzone-title {
  display: block;
  font-size: 1.05rem;
  font-weight: 760;
}

.dropzone-subtitle {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.source-summary,
.flash,
.task-card,
.preview-card,
.segments-wrap {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-strong);
  box-shadow: none;
}

.source-summary,
.flash {
  padding: 10px 12px;
  color: var(--muted-strong);
}

.flash {
  display: none;
}

.flash.is-visible {
  display: block;
}

.flash.info {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(0, 126, 195, 0.22);
}

.flash.success {
  color: var(--success);
  background: rgba(22, 136, 79, 0.1);
  border-color: rgba(22, 136, 79, 0.22);
}

.flash.error {
  color: var(--danger);
  background: rgba(215, 0, 21, 0.08);
  border-color: rgba(215, 0, 21, 0.16);
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 36px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  max-height: min(220px, calc(100vh - 36px));
  overflow: auto;
  overflow-wrap: anywhere;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-strong);
  box-shadow: 0 18px 44px rgba(0, 64, 119, 0.2);
  color: var(--muted-strong);
  font-weight: 720;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.info {
  color: var(--accent);
  background: #ffffff;
  border-color: rgba(0, 126, 195, 0.28);
}

.toast.success {
  color: var(--success);
  background: #f1fbf6;
  border-color: rgba(22, 136, 79, 0.3);
}

.toast.error {
  color: var(--danger);
  background: #fff4f5;
  border-color: rgba(215, 0, 21, 0.24);
}

.toast.is-hiding {
  opacity: 0;
  transform: translateY(6px);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(18, 47, 69, 0.42);
}

.modal-card {
  display: grid;
  gap: 16px;
  width: min(100%, 480px);
  padding: 24px;
  background: var(--surface-strong);
}

.modal-card h3 {
  margin: 6px 0 6px;
  color: var(--accent-strong);
  font-size: 1.35rem;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.record-actions,
.download-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.record-panel,
.transcription-action {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-muted);
}

.record-panel .small-note {
  font-size: 0.88rem;
}

.record-actions {
  gap: 8px;
}

.record-actions button {
  flex: 1 1 170px;
  min-height: 40px;
  padding: 9px 12px;
}

.download-row {
  justify-content: flex-end;
  max-width: 100%;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.settings-panel {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-muted);
  overflow: hidden;
  box-shadow: none;
}

.settings-panel summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  min-height: 46px;
  padding: 10px 12px;
  color: var(--text);
  cursor: pointer;
  font-weight: 820;
  list-style: none;
}

.settings-panel summary::-webkit-details-marker {
  display: none;
}

.settings-panel summary::after {
  content: "+";
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius);
  color: var(--accent);
  background: #ffffff;
  border: 1px solid var(--line);
  line-height: 1;
}

.settings-panel[open] summary::after {
  content: "-";
}

.settings-panel summary small {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 620;
}

.settings-panel .form-grid {
  padding: 0 12px 12px;
}

.settings-panel .source-summary {
  margin: 0 16px 16px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted-strong);
  font-size: 0.92rem;
  font-weight: 760;
}

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

select,
input[type="number"],
input[type="search"],
input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(0, 64, 119, 0.2);
  appearance: none;
  outline: none;
  background: #ffffff;
  color: var(--text);
  box-shadow: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

select:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
  border-color: rgba(0, 126, 195, 0.62);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(148, 212, 238, 0.3);
}

textarea {
  min-height: 220px;
  line-height: 1.58;
  resize: vertical;
}

button,
.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  padding: 11px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  font-weight: 820;
  line-height: 1.18;
  overflow-wrap: anywhere;
  white-space: normal;
  border: 2px solid transparent;
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease, background 120ms ease;
}

button:hover,
.download-link:hover {
  transform: translateY(-1px);
}

.primary {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 12px 24px rgba(0, 126, 195, 0.2);
}

.primary:hover {
  background: var(--accent-hover);
}

.secondary,
.download-link {
  color: var(--accent);
  background: #ffffff;
  border-color: var(--line);
}

.download-link {
  flex: 0 1 auto;
  min-width: 104px;
}

.ghost {
  color: var(--muted-strong);
  background: transparent;
  border-color: rgba(0, 64, 119, 0.18);
}

.compact {
  min-height: 38px;
  padding: 9px 12px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  transform: none;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  align-items: start;
  gap: 20px;
  margin-top: 20px;
}

.admin-panel {
  display: grid;
  grid-column: 1 / -1;
  gap: 16px;
}

.admin-create-user {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto;
  align-items: end;
  gap: 12px;
}

.admin-users-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.admin-users-pager {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(112px, 1fr) minmax(0, auto);
  gap: 8px;
  align-items: center;
}

.admin-users-pager span {
  color: var(--muted-strong);
  font-size: 0.9rem;
  font-weight: 720;
  text-align: center;
  white-space: normal;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  gap: 8px;
  color: var(--muted-strong);
  font-weight: 720;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.admin-users-list {
  display: grid;
  gap: 10px;
  margin-top: 0;
  max-height: 440px;
  overflow: auto;
  padding-right: 4px;
}

.admin-user-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 12px 12px 12px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-muted);
  overflow: visible;
}

.admin-user-row::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  border-radius: var(--radius) 0 0 var(--radius);
  background: rgba(0, 64, 119, 0.18);
}

.admin-user-row.is-admin {
  border-color: rgba(0, 126, 195, 0.36);
  background:
    linear-gradient(90deg, rgba(148, 212, 238, 0.24) 0, transparent 42%),
    var(--surface-strong);
}

.admin-user-row.is-admin::before {
  background: var(--accent);
}

.admin-user-main {
  position: relative;
  z-index: 1;
  min-width: 0;
  padding-left: 4px;
}

.admin-user-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.admin-user-main strong {
  display: block;
  overflow-wrap: anywhere;
  text-transform: uppercase;
}

.admin-current-mark,
.admin-role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: var(--radius);
  font-size: 0.74rem;
  font-weight: 860;
  line-height: 1;
  text-transform: uppercase;
}

.admin-current-mark {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px solid rgba(0, 126, 195, 0.22);
}

.admin-user-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.86rem;
}

.admin-user-meta > span:not(.admin-role-badge) {
  flex: 1 1 220px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.admin-role-badge.admin {
  color: #ffffff;
  background: var(--accent);
  border: 1px solid var(--accent);
}

.admin-role-badge.user {
  color: var(--muted-strong);
  background: #ffffff;
  border: 1px solid var(--line);
}

.admin-user-actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.admin-user-actions button {
  flex: 1 1 170px;
}

.task-history-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.task-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-top: 14px;
}

.task-toolbar span {
  color: var(--muted-strong);
  font-size: 0.9rem;
  font-weight: 760;
  overflow-wrap: anywhere;
  white-space: normal;
}

.task-list {
  display: grid;
  gap: 12px;
  align-content: start;
  margin-top: 14px;
  min-width: 0;
  min-height: 0;
  counter-reset: task-card;
}

.task-card {
  position: relative;
  counter-increment: task-card;
  min-width: 0;
  overflow: visible;
  padding: 15px 15px 15px 60px;
  cursor: pointer;
  transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.task-card::before {
  content: counter(task-card, decimal-leading-zero);
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  width: 44px;
  height: 100%;
  color: #fff;
  background:
    linear-gradient(135deg, var(--accent) 0 62%, var(--accent-strong) 62% 100%);
  font-size: 0.78rem;
  font-weight: 900;
}

.task-card:hover,
.task-card.active {
  transform: translateY(-1px);
  border-color: rgba(0, 126, 195, 0.3);
  background: var(--surface-strong);
  box-shadow: 0 14px 30px rgba(0, 64, 119, 0.12);
}

.task-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 7px;
  min-width: 0;
}

.task-card strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.task-delete {
  justify-self: end;
  max-width: 100%;
  min-height: 32px;
  padding: 6px 9px;
  border-color: rgba(215, 0, 21, 0.16);
  background: rgba(215, 0, 21, 0.06);
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 820;
  white-space: normal;
}

.task-delete.is-confirming {
  border-color: rgba(156, 101, 0, 0.28);
  background: rgba(156, 101, 0, 0.12);
  color: var(--warning);
}

.task-confirm {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(156, 101, 0, 0.24);
  background: rgba(156, 101, 0, 0.08);
  color: var(--warning);
  font-size: 0.88rem;
  font-weight: 720;
}

.task-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.91rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.task-status {
  display: inline-flex;
  margin-top: 10px;
  padding: 7px 10px;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 820;
  text-transform: uppercase;
}

.task-status.queued {
  background: var(--accent-soft);
  color: var(--accent);
}

.task-status.processing {
  background: rgba(178, 90, 0, 0.1);
  color: var(--warning);
}

.task-status.completed {
  background: rgba(36, 138, 61, 0.1);
  color: var(--success);
}

.task-status.failed {
  background: rgba(215, 0, 21, 0.08);
  color: var(--danger);
}

.task-progress {
  position: relative;
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 64, 119, 0.12);
}

.task-progress-fill {
  height: 100%;
  min-width: 3px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--aqua));
  transition: width 0.35s ease;
}

.task-progress-text {
  margin-top: 7px !important;
  font-size: 0.82rem !important;
  color: var(--muted-strong) !important;
}

.editor-panel {
  display: flex;
  flex-direction: column;
  min-height: 620px;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.editor-panel.is-target {
  border-color: rgba(0, 126, 195, 0.45);
  box-shadow: 0 22px 54px rgba(0, 126, 195, 0.18);
  transform: translateY(-1px);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 360px;
  padding: 24px;
  text-align: center;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(148, 212, 238, 0.22) 0 14%, transparent 14% 100%),
    var(--surface-muted);
  border: 2px dashed rgba(0, 126, 195, 0.24);
}

.hidden {
  display: none !important;
}

.editor-content {
  display: grid;
  gap: 18px;
  min-height: 0;
}

.editor-progress {
  display: grid;
  gap: 18px;
  min-height: 360px;
  align-content: center;
  padding: 24px 0;
}

.progress-summary,
.progress-details {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.progress-summary h4 {
  margin: 4px 0 0;
  font-size: 1.35rem;
  line-height: 1.15;
}

.progress-summary strong {
  font-size: 2rem;
  line-height: 1;
  font-weight: 760;
  color: var(--accent);
}

.progress-track {
  position: relative;
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: rgba(0, 64, 119, 0.1);
  box-shadow: none;
}

.progress-fill {
  width: 0;
  height: 100%;
  min-width: 4px;
  border-radius: inherit;
  background:
    linear-gradient(90deg, var(--accent), var(--aqua));
  transition: width 0.45s ease;
}

.progress-details {
  align-items: flex-start;
  color: var(--muted-strong);
  font-size: 0.95rem;
}

.progress-details span:last-child {
  color: var(--muted);
  text-align: right;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.preview-card,
.segments-wrap {
  padding: 18px;
}

.segments-editor {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  max-height: 520px;
  overflow: auto;
  padding-right: 6px;
}

.segments-editor::-webkit-scrollbar {
  width: 10px;
}

.segments-editor::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(0, 126, 195, 0.36);
  background-clip: padding-box;
}

.segment-row {
  display: grid;
  grid-template-columns: 112px 132px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--surface-muted);
  border: 1px solid var(--line);
}

.segment-time {
  color: var(--muted);
  font-weight: 720;
  font-size: 0.84rem;
  line-height: 1.35;
}

.segment-row label {
  gap: 5px;
  font-size: 0.82rem;
}

.segment-row input[type="text"],
.segment-row textarea {
  min-height: 34px;
  padding: 8px 10px;
  line-height: 1.35;
}

.segment-row textarea {
  height: auto;
  max-height: 220px;
  overflow-y: auto;
  resize: none;
}

.segments-more {
  width: 100%;
}

.download-link[aria-disabled="true"] {
  pointer-events: none;
  opacity: 0.45;
}

@media (min-width: 1081px) {
  .task-history-panel,
  .editor-panel {
    position: sticky;
    top: 20px;
    height: clamp(560px, 72vh, 760px);
    min-height: 0;
    overflow: hidden;
  }

  .task-history-panel .card-head,
  .task-toolbar,
  .editor-head,
  .preview-head {
    flex: 0 0 auto;
  }

  .task-list,
  .editor-content {
    flex: 1 1 auto;
    overflow: auto;
    padding-right: 6px;
  }

  .task-list::-webkit-scrollbar,
  .editor-content::-webkit-scrollbar {
    width: 10px;
  }

  .task-list::-webkit-scrollbar-thumb,
  .editor-content::-webkit-scrollbar-thumb {
    border: 3px solid transparent;
    border-radius: 999px;
    background: rgba(0, 126, 195, 0.36);
    background-clip: padding-box;
  }

  #editor-empty,
  .editor-progress {
    flex: 1 1 auto;
    min-height: 0;
  }

  .segments-editor {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
}

@media (max-width: 1080px) {
  .main-grid,
  .upload-form,
  .workspace {
    grid-template-columns: 1fr;
  }

  .task-list {
    max-height: 480px;
    overflow: auto;
    padding-right: 6px;
  }

  .task-toolbar {
    grid-template-columns: 1fr;
  }

  .segment-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 20px, 100%);
    padding-top: 16px;
  }

  .auth-shell {
    width: min(100% - 20px, 100%);
    padding: 20px 0;
  }

  .auth-card {
    padding: 24px;
  }

  .auth-card h1 {
    font-size: 2.35rem;
  }

  #auth-form {
    grid-template-columns: 1fr;
  }

  .topbar,
  .card-head,
  .preview-head,
  .editor-head {
    flex-direction: column;
  }

  .user-chip,
  .auth-actions {
    display: grid;
    width: 100%;
  }

  .download-row {
    justify-content: stretch;
    width: 100%;
  }

  .download-link {
    flex: 1 1 128px;
  }

  .upload-card,
  .panel {
    padding: 18px;
  }

  .dropzone {
    min-height: 180px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .admin-create-user,
  .admin-user-row,
  .admin-users-toolbar,
  .admin-users-pager {
    grid-template-columns: 1fr;
  }

  .admin-user-actions {
    justify-content: stretch;
  }

  .admin-user-actions button {
    flex: 1 1 140px;
  }

  .record-actions,
  .download-row,
  .modal-actions {
    display: grid;
  }

  .task-card-head {
    grid-template-columns: 1fr;
  }

  .task-card {
    padding-left: 52px;
  }

  .task-card::before {
    width: 38px;
  }

  .task-delete {
    justify-self: start;
  }

  .progress-summary,
  .progress-details {
    display: grid;
    gap: 10px;
  }

  .progress-details span:last-child {
    text-align: left;
  }
}
