:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --text: #171b22;
  --muted: #657080;
  --line: #d9e0e8;
  --accent: #0f766e;
  --accent-2: #b45309;
  --danger: #b42318;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

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

button {
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--accent);
  color: white;
  padding: 0 14px;
  cursor: pointer;
}

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

.ghost {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
}

h2 {
  font-size: 13px;
  line-height: 1.2;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0;
}

.topbar p,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  min-height: calc(100vh - 76px);
}

.settings {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.settings section,
.panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--text);
  padding: 9px 10px;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

input[type="range"] {
  padding: 0;
}

output {
  justify-self: end;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stats {
  display: grid;
  gap: 8px;
  margin: 0;
}

.stats div,
.counts div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 30px;
  border-bottom: 1px solid var(--surface-2);
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.counts {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

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

.tabs {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.tab {
  border-color: transparent;
  background: transparent;
  color: var(--text);
}

.tab.active {
  border-color: var(--line);
  background: var(--surface);
}

.panel {
  display: none;
  margin-top: 16px;
}

.panel.active {
  display: flex;
}

.panelHead {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(auto-fit, minmax(120px, max-content));
  align-items: end;
  gap: 10px;
}

.chatLog {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: min(58vh, 620px);
  min-height: 360px;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.message {
  max-width: min(860px, 92%);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  white-space: pre-wrap;
  line-height: 1.5;
}

.message.user {
  align-self: flex-end;
  border-color: #bfd6d2;
  background: #edf7f5;
}

.message.assistant {
  align-self: flex-start;
}

.message.error {
  border-color: #ffd1cc;
  background: #fff3f1;
  color: var(--danger);
}

.composer,
.imageForm,
.audioForm {
  display: grid;
  gap: 10px;
}

.composerActions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.composerActions button,
.imageForm button,
.audioForm button {
  margin-left: auto;
}

.fileButton,
.dropzone {
  width: auto;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 9px 12px;
  cursor: pointer;
}

.fileButton input,
.dropzone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.recorder {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.recorderStatus,
.recorderControls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.recorderStatus {
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.recorderStatus strong {
  color: var(--text);
  font-weight: 600;
}

.recorder audio {
  width: 100%;
  min-height: 38px;
}

.toggle {
  display: flex;
  width: fit-content;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.toggle input {
  width: auto;
}

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

.speakerOptions.active {
  display: grid;
}

.imageResult {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  align-items: start;
}

.imageResult img {
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

.transcript {
  min-height: 220px;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  white-space: pre-wrap;
  line-height: 1.5;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .settings {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .chatLog {
    height: 50vh;
    min-height: 300px;
  }
}
