:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #eef3f5;
  --text: #17202a;
  --muted: #64727f;
  --line: #d9e1e6;
  --teal: #0f766e;
  --teal-strong: #0b5d57;
  --blue: #2563eb;
  --amber: #d97706;
  --red: #dc2626;
  --shadow: 0 18px 45px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.06) 1px, transparent 1px),
    linear-gradient(180deg, rgba(37, 99, 235, 0.05) 1px, transparent 1px),
    var(--bg);
  background-size: 34px 34px;
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px;
  background: rgba(255, 255, 255, 0.92);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 18px;
}

.brand small {
  color: var(--muted);
  margin-top: 2px;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 16px);
  grid-template-rows: repeat(2, 16px);
  gap: 3px;
  width: 38px;
  height: 38px;
}

.brand-mark span {
  border: 1px solid rgba(15, 118, 110, 0.38);
  background: var(--surface-soft);
}

.brand-mark span:first-child {
  background: var(--teal);
}

.brand-mark span:nth-child(2) {
  background: #f3c969;
}

.brand-mark span:nth-child(3) {
  grid-column: span 2;
  background: #2f80ed;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  text-align: left;
}

.nav-tab:hover,
.nav-tab.is-active {
  color: var(--text);
  background: var(--surface-soft);
  border-color: var(--line);
}

.active-api {
  margin-top: auto;
  padding: 14px;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.active-api span,
.active-api small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.active-api strong {
  display: block;
  margin: 6px 0 2px;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

h3 {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.select-label {
  color: var(--muted);
  font-size: 13px;
}

select,
input,
textarea {
  width: 100%;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

select,
input {
  min-height: 42px;
  padding: 0 12px;
}

select:focus,
input:focus,
textarea:focus {
  border-color: rgba(15, 118, 110, 0.65);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

#apiSelect {
  width: min(34vw, 280px);
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

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

.panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 72px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

textarea {
  display: block;
  min-height: 430px;
  resize: vertical;
  padding: 16px;
  border: 0;
  border-radius: 0 0 8px 8px;
  line-height: 1.7;
}

.file-button,
.primary-button,
.secondary-button,
.icon-button,
.record-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 700;
  white-space: nowrap;
}

.file-button,
.secondary-button,
.icon-button {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line);
}

.file-button {
  padding: 0 12px;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.primary-button {
  min-width: 132px;
  padding: 0 16px;
  color: #fff;
  background: var(--teal);
}

.primary-button:hover {
  background: var(--teal-strong);
}

.secondary-button {
  padding: 0 14px;
}

.secondary-button.compact {
  min-width: 86px;
}

.icon-button {
  width: 40px;
  padding: 0;
}

.control-band {
  margin-top: 16px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.progress-track {
  height: 6px;
  margin-top: 14px;
  overflow: hidden;
  background: var(--surface-soft);
  border-radius: 999px;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--blue);
  transition: width 0.2s ease;
}

.status-line {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.speech-layout,
.api-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
}

.speech-controls,
.api-form {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 16px;
}

.speech-controls .panel-head,
.api-form .panel-head {
  padding: 0 0 14px;
  border-bottom: 1px solid var(--line);
}

.record-button {
  min-width: 92px;
  padding: 0 14px;
  color: #fff;
  background: var(--blue);
}

.record-button.is-recording {
  background: var(--red);
}

.record-dot {
  width: 9px;
  height: 9px;
  background: currentColor;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.22);
}

.transcript-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
}

.transcript-box {
  min-height: 510px;
  max-height: 62vh;
  overflow: auto;
  padding: 14px;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.7;
}

.utterance {
  margin: 0 0 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.utterance:last-child {
  border-bottom: 0;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segmented button {
  min-height: 34px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-weight: 700;
}

.segmented button:hover {
  color: var(--text);
  background: var(--surface);
}

.api-list-panel {
  min-height: 530px;
}

.api-list {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.api-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.api-item.is-active {
  border-color: rgba(15, 118, 110, 0.58);
  box-shadow: inset 4px 0 0 var(--teal);
}

.api-item strong,
.api-item small {
  display: block;
}

.api-item small {
  margin-top: 3px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.api-actions {
  display: flex;
  gap: 6px;
}

.api-actions button {
  min-height: 34px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 700;
}

.empty-state {
  padding: 18px;
  color: var(--muted);
  background: #f8fafb;
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 14px;
  }

  .nav-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-tab {
    justify-content: center;
    padding: 0 8px;
    font-size: 13px;
  }

  .active-api {
    display: none;
  }

  .workspace {
    padding: 16px;
  }

  .topbar,
  .tool-grid,
  .speech-layout,
  .api-layout,
  .transcript-columns,
  .field-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .top-actions {
    align-items: end;
  }

  #apiSelect {
    width: 100%;
  }

  textarea,
  .transcript-box {
    min-height: 300px;
  }
}

@media (max-width: 560px) {
  .nav-tab {
    min-height: 48px;
    flex-direction: column;
    gap: 3px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr 44px;
  }

  .select-label {
    grid-column: 1 / -1;
  }

  h1 {
    font-size: 24px;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .api-item {
    grid-template-columns: 1fr;
  }
}
