:root {
  color: #172033;
  background: #f5f8fd;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  --blue: #1268ed;
  --blue-dark: #0b54c7;
  --blue-soft: #edf5ff;
  --line: #dce4f1;
  --line-strong: #c7d4e8;
  --muted: #67738a;
  --green: #0ba97a;
  --red: #c53b45;
  --shadow: 0 10px 28px rgb(32 72 126 / 7%);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% -10%, rgb(215 231 255 / 45%), transparent 34rem),
    #f6f9fe;
  color: #172033;
  font-size: 14px;
}

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

button,
select,
label[for],
input[type="checkbox"] {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgb(18 104 237 / 24%);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 9px 14px;
  border-radius: 7px;
  background: #172033;
  color: #fff;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  min-height: 82px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(20px, 3vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 94%);
}

.brand,
.brand > span:last-child,
.topbar-actions,
.service-status,
.button,
.card-heading,
.card-heading > div,
.file-summary,
.panel-title,
.primary-row,
.language-row,
.dialog-header,
.detail-toolbar,
.detail-actions,
.pagination {
  display: flex;
  align-items: center;
}

.brand {
  gap: 14px;
  min-width: 0;
}

.brand > span:last-child {
  min-width: 0;
  align-items: flex-start;
  flex-direction: column;
  gap: 2px;
}

.brand strong {
  overflow: hidden;
  max-width: 62vw;
  color: #121a2a;
  font-size: clamp(18px, 1.55vw, 25px);
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand small {
  color: var(--muted);
  font-size: 13px;
}

.brand-mark {
  display: flex;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 10px;
  background: linear-gradient(145deg, #287ef5, #075ddd);
  box-shadow: 0 7px 15px rgb(18 104 237 / 24%);
}

.brand-mark span {
  width: 3px;
  border-radius: 3px;
  background: #fff;
}

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

.brand-mark span:nth-child(2),
.brand-mark span:nth-child(4) {
  height: 22px;
}

.brand-mark span:nth-child(3) {
  height: 30px;
}

.topbar-actions {
  flex: 0 0 auto;
  gap: 10px;
}

.service-status {
  min-height: 38px;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #40506a;
  font-size: 13px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #a0a9b7;
}

.service-status.ready .status-dot {
  background: var(--green);
}

.service-status.warning .status-dot {
  background: #e59b17;
}

.service-status.error .status-dot {
  background: var(--red);
}

.button,
.icon-button,
.text-button,
.mode-tab,
.source-tab {
  border: 0;
  background: transparent;
  color: #243149;
}

.button {
  min-height: 38px;
  justify-content: center;
  gap: 7px;
  padding: 0 15px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  font-weight: 600;
  white-space: nowrap;
}

.button:hover:not(:disabled) {
  border-color: #91b6ef;
  background: #f8fbff;
  color: var(--blue-dark);
}

.button.compact {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.button.primary {
  min-width: 148px;
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  box-shadow: 0 5px 12px rgb(18 104 237 / 18%);
}

.button.primary:hover:not(:disabled) {
  border-color: var(--blue-dark);
  background: var(--blue-dark);
  color: #fff;
}

.button.danger {
  border-color: #e6b8bc;
  color: #ac2530;
}

.button.danger:hover:not(:disabled) {
  border-color: #d98990;
  background: #fff5f5;
  color: #8e1720;
}

.button.wide {
  width: 100%;
}

.page-shell {
  width: min(1440px, calc(100% - 48px));
  margin: 0 auto;
  padding: 0 0 24px;
}

.stepper {
  display: grid;
  max-width: 800px;
  margin: 0 auto;
  padding: 17px 0 15px;
  grid-template-columns: repeat(3, 1fr);
  list-style: none;
}

.stepper li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #718099;
}

.stepper li:not(:last-child)::after {
  position: absolute;
  top: 20px;
  right: 18px;
  width: 32%;
  height: 1px;
  background: #cfd9e8;
  content: "";
}

.step-number,
.section-number {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #e4e9f1;
  color: #58657b;
  font-weight: 700;
}

.step-number {
  width: 40px;
  height: 40px;
  font-size: 18px;
}

.stepper li.active .step-number,
.section-number {
  background: var(--blue);
  color: #fff;
}

.stepper li > span:last-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.stepper strong {
  color: #263249;
  font-size: 15px;
}

.stepper small {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.global-message {
  min-height: 0;
  margin-bottom: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
}

.global-message:not(:empty) {
  min-height: 38px;
  margin-bottom: 10px;
  padding: 9px 13px;
  border: 1px solid #bfd7fb;
  background: #eff6ff;
  color: #245a9e;
}

.global-message.error:not(:empty) {
  border-color: #efc6ca;
  background: #fff5f5;
  color: #a52b35;
}

.global-message.success:not(:empty) {
  border-color: #b8e3d4;
  background: #effbf6;
  color: #18775a;
}

.mode-tabs {
  display: inline-flex;
  margin-bottom: 10px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #eaf0f9;
}

.mode-tab {
  min-width: 148px;
  padding: 9px 18px;
  border-radius: 6px;
  font-weight: 700;
}

.mode-tab.active {
  background: #fff;
  color: var(--blue);
  box-shadow: 0 2px 7px rgb(38 62 96 / 10%);
}

.card {
  margin-bottom: 12px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgb(255 255 255 / 96%);
  box-shadow: var(--shadow);
}

.card-heading {
  min-height: 34px;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.card-heading > div {
  gap: 9px;
}

.card h2,
.dialog h2,
.card h3,
.dialog h3 {
  margin: 0;
  color: #192338;
}

.card h2,
.dialog h2 {
  font-size: 17px;
}

.card h3,
.dialog h3 {
  font-size: 14px;
}

.section-number {
  width: 24px;
  height: 24px;
  font-size: 13px;
}

.source-tabs {
  display: grid;
  width: min(540px, 100%);
  grid-template-columns: 1fr 1fr;
  border-radius: 7px 7px 0 0;
  background: #f0f3f9;
}

.source-tab {
  min-height: 39px;
  border: 1px solid transparent;
  border-bottom-color: var(--line-strong);
  font-weight: 700;
}

.source-tab.active {
  border-color: #78aaf5 #78aaf5 #fff;
  border-radius: 7px 7px 0 0;
  background: #fff;
  color: var(--blue);
}

.source-layout {
  display: grid;
  align-items: stretch;
  gap: 18px;
  grid-template-columns: minmax(330px, 0.9fr) minmax(420px, 1.1fr);
}

.dropzone,
.record-box {
  display: flex;
  min-height: 132px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 7px;
  border: 1px dashed #7bb1fa;
  border-radius: 8px;
  background: #fbfdff;
  text-align: center;
}

.dropzone.dragging {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.dropzone strong {
  font-size: 14px;
}

.dropzone strong span {
  color: var(--blue);
}

.dropzone small,
.record-box p {
  color: var(--muted);
}

.upload-symbol,
.record-symbol {
  color: var(--blue);
  font-size: 32px;
  line-height: 1;
}

.record-box {
  border-style: solid;
  border-color: var(--line);
}

.record-device {
  display: flex;
  width: min(100%, 260px);
  align-items: center;
  gap: 8px;
  color: #4f5e76;
  font-size: 13px;
}

.record-device select {
  min-width: 0;
  flex: 1;
}

#recording-device-name {
  color: var(--muted);
}

.recording-level {
  width: min(100%, 260px);
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f2;
}

.recording-level span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.recording-time {
  color: #4f5e76;
  font-variant-numeric: tabular-nums;
}

.button-row {
  display: flex;
  gap: 8px;
}

.notice {
  margin: 5px 0 0;
  padding: 8px 10px;
  border-radius: 6px;
  background: #f0f5fd;
  color: #4f607a;
}

.notice.error {
  background: #fff1f1;
  color: #a62d37;
}

.audio-preview {
  display: flex;
  min-width: 0;
  min-height: 132px;
  justify-content: center;
  flex-direction: column;
  gap: 11px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.audio-preview.empty {
  color: var(--muted);
  background: #fbfcfe;
}

.file-summary {
  min-width: 0;
  gap: 12px;
}

.file-summary > span:last-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.file-summary strong,
.file-summary small {
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-summary small {
  color: var(--muted);
}

.file-icon {
  display: inline-flex;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: var(--blue);
  color: #fff;
  font-size: 21px;
}

audio {
  width: 100%;
  height: 36px;
}

.processing-settings {
  display: grid;
  gap: 14px 18px;
  margin: 14px 0 0;
  padding: 13px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  grid-template-columns: 1.25fr 1.25fr 0.75fr 0.75fr;
}

.processing-settings legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.switch-setting {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.switch-setting > span:first-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.switch-setting small {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.switch-control {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 23px;
  flex: 0 0 auto;
}

.switch-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-control span {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: #b6c0cf;
}

.switch-control span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgb(0 0 0 / 20%);
  content: "";
}

.switch-control input:checked + span {
  background: var(--blue);
}

.switch-control input:checked + span::after {
  left: 20px;
}

.switch-control input:focus-visible + span {
  outline: 3px solid rgb(18 104 237 / 24%);
  outline-offset: 2px;
}

.select-setting,
.language-row label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: #47566d;
  font-size: 12px;
  font-weight: 700;
}

select,
input[type="password"] {
  min-height: 38px;
  padding: 0 32px 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: #26344b;
}

.primary-row {
  justify-content: flex-end;
  gap: 14px;
  margin-top: 13px;
}

.task-state {
  margin-right: auto;
  padding: 5px 9px;
  border-radius: 5px;
  background: #edf3fb;
  color: #52627a;
  font-size: 12px;
}

.task-state.completed,
.task-state.transcribed {
  background: #e8f8f2;
  color: #16805f;
}

.task-state.failed {
  background: #fff0f1;
  color: #b32d38;
}

.result-grid,
.direct-grid,
.history-text-grid {
  display: grid;
  align-items: stretch;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr);
}

.text-panel {
  min-width: 0;
}

.panel-title {
  min-height: 27px;
  justify-content: space-between;
  gap: 12px;
  color: #26334a;
  font-weight: 700;
}

.panel-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

textarea,
pre {
  width: 100%;
  margin: 0;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: #202b3e;
  line-height: 1.62;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

textarea {
  display: block;
  min-height: 148px;
  padding: 11px 12px;
  resize: vertical;
}

textarea[readonly] {
  background: #fafcff;
}

.panel-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.direction-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--blue);
  font-size: 25px;
  font-weight: 700;
}

.original-block {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #c9dcf8;
  border-radius: 7px;
  background: #f6faff;
}

.original-block pre {
  max-height: 108px;
  overflow: auto;
  padding: 9px 10px;
  border: 0;
  background: transparent;
}

.text-button {
  padding: 4px 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.text-button:hover {
  text-decoration: underline;
}

.direct-card {
  min-height: 540px;
}

.language-row {
  justify-content: center;
  gap: 12px;
  margin: 2px 0 14px;
}

.language-row label {
  min-width: 220px;
}

.direct-grid textarea {
  min-height: 290px;
}

footer {
  padding: 5px 0 2px;
  color: #738199;
  text-align: center;
  font-size: 12px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

.dialog {
  width: min(920px, calc(100% - 32px));
  max-height: calc(100vh - 40px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: #172033;
  box-shadow: 0 24px 72px rgb(20 41 77 / 24%);
}

.dialog::backdrop {
  background: rgb(18 30 50 / 42%);
}

.dialog-header {
  min-height: 72px;
  justify-content: space-between;
  gap: 20px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
}

.dialog-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.icon-button {
  display: inline-flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  font-size: 25px;
}

.icon-button:hover {
  background: #edf3fb;
}

.access-dialog {
  width: min(410px, calc(100% - 32px));
  padding: 28px;
  overflow: visible;
}

.access-dialog form {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.access-dialog h2,
.access-dialog p {
  text-align: center;
}

.access-dialog p {
  margin: 0 0 4px;
  color: var(--muted);
  line-height: 1.6;
}

.access-dialog label {
  font-weight: 700;
}

.access-dialog input {
  width: 100%;
  padding-right: 11px;
}

.dialog-symbol {
  display: inline-flex;
  width: 48px;
  height: 48px;
  align-items: center;
  justify-content: center;
  align-self: center;
  border-radius: 12px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 26px;
  font-weight: 700;
}

.form-error {
  min-height: 20px;
  color: var(--red) !important;
  font-size: 12px;
}

.history-dialog > section {
  max-height: calc(100vh - 112px);
  overflow: auto;
  padding: 16px 20px 20px;
}

.history-list {
  display: grid;
  gap: 9px;
  min-height: 180px;
}

.history-empty {
  display: grid;
  min-height: 180px;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
}

.history-item {
  display: grid;
  width: 100%;
  gap: 5px 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #223049;
  text-align: left;
  grid-template-columns: minmax(0, 1fr) auto;
}

.history-item:hover {
  border-color: #94b9ef;
  background: #fafdff;
}

.history-item strong,
.history-item .history-summary {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item small {
  color: var(--muted);
}

.history-item .history-metadata {
  grid-column: 1 / -1;
}

.history-item .history-summary {
  color: #536078;
  grid-column: 1 / -1;
}

.history-badge {
  align-self: start;
  padding: 3px 7px;
  border-radius: 4px;
  background: #edf3fb;
  color: #50617b;
  font-size: 12px;
}

.pagination {
  justify-content: center;
  gap: 14px;
  margin-top: 14px;
  color: var(--muted);
}

.detail-toolbar {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.history-meta {
  display: grid;
  margin: 0 0 12px;
  padding: 12px;
  border-radius: 8px;
  background: #f5f8fd;
  gap: 10px 18px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.history-meta div {
  min-width: 0;
}

.history-meta dt {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
}

.history-meta dd {
  overflow: hidden;
  margin: 0;
  color: #26344b;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-text-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.history-section {
  min-width: 0;
  margin-bottom: 12px;
}

.history-section.full-width {
  grid-column: 1 / -1;
}

.history-section pre {
  min-height: 90px;
  max-height: 190px;
  overflow: auto;
  padding: 10px 11px;
  background: #fbfcfe;
}

.detail-actions {
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.guide-dialog {
  width: min(560px, calc(100% - 32px));
}

.guide-steps {
  display: grid;
  gap: 16px;
  margin: 0;
  padding: 20px 32px 8px 56px;
}

.guide-steps li {
  padding-left: 5px;
}

.guide-steps li::marker {
  color: var(--blue);
  font-weight: 800;
}

.guide-steps strong,
.guide-steps span {
  display: block;
}

.guide-steps span {
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.6;
}

.guide-dialog > .notice {
  margin: 12px 20px 20px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1040px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .source-layout {
    grid-template-columns: 1fr;
  }

  .processing-settings {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  body {
    font-size: 13px;
  }

  .topbar {
    min-height: auto;
    gap: 13px;
    padding: 13px 16px;
  }

  .brand strong {
    max-width: calc(100vw - 88px);
    white-space: normal;
  }

  .brand small {
    display: none;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .service-status {
    grid-column: 1 / -1;
  }

  .page-shell {
    width: min(100% - 24px, 1440px);
  }

  .stepper {
    gap: 6px;
    padding: 12px 0;
  }

  .stepper li {
    justify-content: center;
  }

  .stepper li:not(:last-child)::after,
  .stepper small {
    display: none;
  }

  .step-number {
    width: 30px;
    height: 30px;
    font-size: 14px;
  }

  .stepper strong {
    font-size: 12px;
  }

  .mode-tabs {
    display: grid;
    width: 100%;
    grid-template-columns: 1fr 1fr;
  }

  .mode-tab {
    min-width: 0;
    padding-inline: 8px;
  }

  .card {
    padding: 14px;
  }

  .source-layout {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .switch-setting small {
    white-space: normal;
  }

  .primary-row {
    align-items: stretch;
    flex-direction: column;
  }

  .task-state {
    margin: 0;
    text-align: center;
  }

  .result-grid,
  .direct-grid,
  .history-text-grid {
    grid-template-columns: 1fr;
  }

  .direction-mark {
    height: 24px;
    transform: rotate(90deg);
  }

  .language-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
  }

  .language-row label {
    min-width: 0;
  }

  .history-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-section.full-width {
    grid-column: auto;
  }

  .detail-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .detail-actions .button {
    width: 100%;
  }
}

@media (max-width: 430px) {
  .topbar-actions {
    grid-template-columns: 1fr;
  }

  .service-status {
    grid-column: auto;
  }

  .stepper li > span:last-child {
    display: none;
  }

  .source-tabs,
  .mode-tabs {
    grid-template-columns: 1fr;
  }

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

  .language-row .button {
    justify-self: center;
  }

  .history-meta {
    grid-template-columns: 1fr;
  }
}
