:root {
  color-scheme: dark;
  --bg: #061814;
  --rail: #092019;
  --surface: #102820;
  --surface-soft: #16352a;
  --surface-deep: #071c17;
  --line: #285449;
  --line-bright: #3d7b6d;
  --text: #f3fff9;
  --muted: #9bb9ae;
  --blue: #16a3b8;
  --cyan: #5eead4;
  --green: #7ee787;
  --red: #f05d5e;
  --amber: #f2c14e;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(120deg, rgba(94, 234, 212, 0.09), transparent 34%),
    linear-gradient(180deg, #08211a 0%, #061814 100%);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

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

.console-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.side-rail {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100vh;
  padding: 28px 22px;
  border-right: 1px solid rgba(61, 123, 109, 0.55);
  background: rgba(9, 32, 25, 0.94);
}

.brand-entry {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.brand-entry:hover .brand-mark {
  transform: translateY(-1px);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: linear-gradient(145deg, #7ee787, #5eead4);
  color: #031611;
  font-size: 30px;
  font-weight: 900;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.brand-copy strong {
  font-size: 22px;
}

.brand-copy span,
.section-kicker {
  margin: 0;
  color: var(--cyan);
  font-size: 13px;
  letter-spacing: 0;
}

.status-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-deep);
}

.status-card span {
  color: var(--muted);
  font-size: 13px;
}

.status-card strong {
  color: var(--muted);
  font-size: 20px;
}

.status-card strong.ready {
  color: var(--green);
}

.status-card strong.running {
  color: var(--green);
}

.status-card strong.error {
  color: #ff9c9c;
}

.start-button {
  width: 100%;
  min-height: 54px;
  margin-top: auto;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-size: 19px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(22, 163, 184, 0.26);
}

.start-button:hover {
  background: #0f8fa2;
}

.start-button.running {
  background: var(--red);
  box-shadow: 0 12px 28px rgba(240, 93, 94, 0.24);
}

.main-stage {
  min-width: 0;
  padding: 28px;
}

.workspace-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

h1 {
  margin: 4px 0 0;
  font-size: 32px;
  line-height: 1.2;
}

.remember-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  white-space: nowrap;
}

.key-strip,
.control-panel,
.transcript-card,
.dock-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 40, 32, 0.92);
  box-shadow: var(--shadow);
}

.key-strip {
  padding: 16px;
  margin-bottom: 14px;
}

.key-strip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.control-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.control-panel {
  padding: 16px;
}

.language-panel {
  grid-column: span 1;
}

.tuning-panel,
.meter-panel {
  background: rgba(22, 53, 42, 0.9);
}

.panel-title {
  margin-bottom: 12px;
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
}

.language-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px minmax(0, 1fr);
  align-items: end;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.field span,
.slider-row span,
.meter-line span {
  color: var(--muted);
  font-size: 13px;
}

input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-bright);
  border-radius: 6px;
  background: #071c17;
  color: var(--text);
  outline: none;
  padding: 10px 12px;
}

textarea {
  margin-top: 12px;
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--cyan);
}

.swap-button {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--cyan);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.slider-row,
.meter-line {
  display: grid;
  grid-template-columns: 52px minmax(120px, 1fr) 60px;
  align-items: center;
  gap: 12px;
}

.slider-row + .slider-row {
  margin-top: 14px;
}

.speed-control-row {
  display: none !important;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--cyan);
}

.meter {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #061814;
}

#levelBar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--amber), var(--red));
  transition: width 80ms linear;
}

.transcript-layout {
  display: grid;
  grid-template-columns: 0.95fr 1.05fr;
  gap: 14px;
  margin-bottom: 14px;
}

.transcript-card {
  min-height: 430px;
  padding: 16px;
}

.translated-card {
  border-color: rgba(126, 231, 135, 0.42);
}

.card-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  color: var(--muted);
}

.card-title strong {
  padding: 3px 10px;
  border-radius: 999px;
  background: #21483f;
  color: var(--text);
  font-size: 12px;
}

.text-output {
  height: 350px;
  overflow-y: auto;
  border: 1px solid #24594d;
  border-radius: 6px;
  background: #061814;
  padding: 14px;
  line-height: 1.7;
  word-break: break-word;
}

.line {
  padding: 7px 0;
  border-bottom: 1px dashed rgba(155, 185, 174, 0.24);
}

.source-output .line {
  color: #c0efe5;
}

.translated-output .line {
  color: #9df7a9;
  font-weight: 700;
}

.partial {
  opacity: 0.68;
  font-style: italic;
}

.utility-dock {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.dock-panel {
  padding: 14px 16px;
}

summary {
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}

.log-output {
  height: 150px;
  margin-top: 12px;
  overflow-y: auto;
  border: 1px solid #24594d;
  border-radius: 6px;
  background: #061814;
  padding: 10px;
  color: var(--muted);
  font-family: Consolas, "Cascadia Code", monospace;
  font-size: 12px;
  line-height: 1.5;
}

.profile-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  padding: 18px;
  background: rgba(0, 0, 0, 0.58);
}

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

.profile-panel {
  width: min(420px, calc(100vw - 36px));
  min-height: calc(100vh - 36px);
  border: 1px solid var(--line-bright);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.46);
  padding: 18px;
  animation: profileSlideIn 180ms ease-out;
}

@keyframes profileSlideIn {
  from {
    transform: translateX(-24px);
    opacity: 0.65;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.profile-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.profile-head h2 {
  margin: 4px 0 0;
  font-size: 24px;
}

.profile-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-deep);
  color: var(--text);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.profile-section {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-deep);
}

.profile-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.profile-note,
.profile-placeholder {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.profile-note {
  margin: 10px 0 0;
}

.profile-placeholder {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

@media (max-width: 980px) {
  .console-shell {
    grid-template-columns: 1fr;
    min-height: 100svh;
  }

  .side-rail {
    position: static;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    height: auto;
    padding: 16px;
  }

  .status-card {
    margin-top: 0;
  }

  .start-button {
    width: 180px;
    margin-top: 0;
  }

  .control-grid,
  .transcript-layout,
  .utility-dock {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  body {
    background: #061814;
  }

  .console-shell {
    display: block;
    padding-bottom: 78px;
  }

  .side-rail {
    position: sticky;
    top: 0;
    z-index: 20;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 8px 10px;
    border-right: 0;
    border-bottom: 1px solid rgba(61, 123, 109, 0.55);
    background: rgba(6, 24, 20, 0.96);
    backdrop-filter: blur(10px);
  }

  .brand-entry {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 8px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    font-size: 20px;
  }

  .brand-copy {
    min-width: 0;
  }

  .brand-copy strong {
    font-size: 16px;
    white-space: nowrap;
  }

  .brand-copy span {
    font-size: 10px;
  }

  .status-card {
    min-width: 74px;
    padding: 6px 8px;
    gap: 2px;
    border-radius: 7px;
    box-shadow: none;
  }

  .status-card span {
    font-size: 10px;
  }

  .status-card strong {
    font-size: 13px;
  }

  .main-stage {
    padding: 10px;
  }

  .workspace-header {
    display: none;
  }

  .key-strip,
  .control-panel,
  .transcript-card,
  .dock-panel {
    border-radius: 7px;
    box-shadow: none;
  }

  .key-strip {
    padding: 10px;
    margin-bottom: 8px;
  }

  .key-strip-head {
    margin-bottom: 6px;
    font-size: 12px;
  }

  .remember-row {
    gap: 6px;
    font-size: 12px;
  }

  .control-grid {
    gap: 8px;
    margin-bottom: 8px;
  }

  .control-panel {
    padding: 10px;
  }

  .panel-title {
    margin-bottom: 8px;
    font-size: 13px;
  }

  .language-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38px minmax(0, 1fr);
    align-items: end;
    gap: 8px;
  }

  .language-row .field span {
    font-size: 11px;
  }

  .voice-panel {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
  }

  .voice-panel .panel-title {
    margin-bottom: 0;
  }

  .voice-panel .field span {
    display: none;
  }

  .tuning-panel .panel-title,
  .meter-panel .panel-title {
    display: none;
  }

  .start-button {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    z-index: 30;
    width: auto;
    min-height: 52px;
    margin: 0;
    border-radius: 12px;
    font-size: 17px;
    box-shadow: 0 14px 32px rgba(22, 163, 184, 0.38);
  }

  .swap-button {
    width: 38px;
    height: 44px;
    justify-self: stretch;
    font-size: 20px;
  }

  .slider-row,
  .meter-line {
    grid-template-columns: 44px minmax(80px, 1fr) 50px;
    gap: 8px;
  }

  .slider-row + .slider-row {
    margin-top: 12px;
  }

  input[type="text"],
  input[type="password"],
  select,
  textarea {
    min-height: 40px;
    font-size: 16px;
    padding: 8px 10px;
  }

  .transcript-layout {
    gap: 8px;
    margin-bottom: 8px;
  }

  .transcript-card {
    min-height: 0;
    padding: 10px;
  }

  .card-title {
    margin-bottom: 6px;
  }

  .text-output {
    height: 178px;
    padding: 9px;
    font-size: 14px;
    line-height: 1.6;
  }

  .translated-output {
    font-size: 15px;
  }

  .line {
    padding: 5px 0;
  }

  .utility-dock {
    gap: 8px;
  }

  .dock-panel {
    padding: 10px;
  }

  summary {
    font-size: 15px;
  }

  .log-output {
    height: 120px;
  }

  .profile-overlay {
    align-items: stretch;
    padding: 0;
  }

  .profile-panel {
    width: min(86vw, 360px);
    min-height: 100svh;
    border-top: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 0 14px 14px 0;
    padding: 14px;
  }

  .profile-head {
    margin-bottom: 12px;
  }

  .profile-head h2 {
    font-size: 22px;
  }

  .profile-section {
    padding: 12px;
  }

  .profile-section-title {
    align-items: flex-start;
  }
}

@media (max-width: 390px) {
  .brand-copy strong {
    font-size: 16px;
  }

  .status-card {
    min-width: 78px;
    padding: 7px 8px;
  }

  h1 {
    font-size: 22px;
  }

  .text-output {
    height: 160px;
  }
}
