:root {
  /* Common variables from both files (merged, with integration defaults) */
  --footer-height: 140px;
  --gap: 12px;
  --pad: 12px;
  --btn-min-width: 120px;
  --btn-height: 44px;
  --bg-footer: #f7f7f8;
  --border: #e0e0e5;
  --accent: #0b76ff;
  --radius: 4px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial;
}

/* --- Header (shared) --- */
header.page-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #ffffff, #fbfbfd);
  border-bottom: 1px solid var(--border);
  z-index: 50;
  padding: 0 12px;
  box-shadow: 0 2px 8px rgba(10, 10, 20, 0.03);
}

header.page-header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #111;
}

/* --- Documentation & action buttons (shared) --- */
.doc-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 88px;
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff, #f1f6ff);
  color: #0b76ff;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(11, 118, 255, 0.06);
  font-size: 14px;
}

.doc-btn:focus {
  outline: 3px solid rgba(11, 118, 255, 0.14);
  outline-offset: 2px;
}

/* Specific positioning for mic button in integration page (first file) */
#mic-sample-btn {
  right: 110px;
}

/* --- Start Screen (shared) --- */
.start-screen {
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(180deg, rgba(250, 250, 252, 1), rgba(255, 255, 255, 0));
  z-index: 20;
  overflow-y: auto;
}

.start-card {
  width: 100%;
  max-width: 760px;
  text-align: center;
  padding: 28px;
  border-radius: 10px;
  box-shadow: 0 8px 26px rgba(20, 20, 30, 0.08);
  background: white;
  border: 1px solid var(--border);
}

.start-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
}

/* --- Form Fields (shared) --- */
.field-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.field-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 160px;
  text-align: left;
}

.url-input,
.select-input {
  font-size: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  width: 100%;
  box-sizing: border-box;
  background: white;
  transition: border 0.1s, box-shadow 0.1s;
}

.url-input:focus,
.select-input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 2px rgba(11, 118, 255, 0.2);
}

.select-input {
  appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2"><polyline points="6 9 12 15 18 9"></polyline></svg>');
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.label-visible {
  font-size: 13px;
  color: #1e1e2f;
  text-align: left;
  margin-bottom: 4px;
  font-weight: 600;
}

.required-star {
  color: #d32f2f;
  margin-left: 4px;
}

/* --- Buttons --- */
button.start-btn {
  min-width: var(--btn-min-width);
  height: var(--btn-height);
  padding: 0 24px;
  border-radius: var(--radius);
  border: 0;
  background: linear-gradient(180deg, var(--accent), #005edd);
  color: white;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(11, 118, 255, 0.25);
  align-self: center;
  font-size: 16px;
  transition: transform 0.06s;
}

button.start-btn:active {
  transform: translateY(1px);
}

/* --- Iframe (shared) --- */
.main-iframe {
  display: none;
  width: 100%;
  height: calc(100vh - var(--footer-height));
  border: 0;
}

/* --- Footer (shared base, then specialized per page below) --- */
.footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--footer-height);
  background: var(--bg-footer);
  border-top: 1px solid var(--border);
  padding: var(--pad);
  box-shadow: 0 -6px 18px rgba(20, 20, 30, 0.04);
  padding-bottom: calc(var(--pad) + env(safe-area-inset-bottom, 0px));
  overflow: visible;
  display: none;
}

.footer .inner {
  position: absolute;
  left: var(--pad);
  right: var(--pad);
  bottom: calc(var(--pad) + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: flex-end;
  gap: var(--gap);
  max-width: 1200px;
  margin: 0 auto;
}

/* --- Integration page specific: message form & controls --- */
form#message-form {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  width: 100%;
  flex-wrap: wrap;
}

textarea.input-box {
  flex: 1;
  height: calc(var(--footer-height) - (var(--pad) * 2) - 10px);
  min-height: 40px;
  resize: vertical;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.4;
  background: white;
  color: #111;
  overflow: auto;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: flex-end;
  margin-bottom: 4px;
}

.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.checkbox-row label {
  font-size: 14px;
  color: #333;
  cursor: pointer;
}

button.submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--btn-min-width);
  height: var(--btn-height);
  padding: 0 18px;
  border-radius: var(--radius);
  border: 0;
  background: linear-gradient(180deg, var(--accent), #005edd);
  color: white;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 12px rgba(11, 118, 255, 0.18);
  transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.08s ease;
  white-space: nowrap;
  align-self: flex-end;
}

button.submit-btn:active {
  transform: translateY(1px);
}

button.submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.controls-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.controls-col .checkbox-row {
  align-self: flex-start;
}

/* --- Readonly inputs & preview URL (shared) --- */
.readonly-input {
  background: #f4f4f7;
  color: #2c2c3a;
  border-style: dashed;
  cursor: default;
}

#final-url {
  font-size: 12px;
  font-family: monospace;
}

/* --- Avatar state badge (integration only, safe to include) --- */
.avatar-state-label {
  position: absolute;
  right: 18px;
  bottom: 12px;
  background: rgba(11, 118, 255, 0.1);
  color: #0b76ff;
  border: 1px solid #e0e0e5;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 15px;
  font-weight: 600;
  z-index: 2;
  pointer-events: none;
  user-select: none;
  backdrop-filter: blur(2px);
  transition: opacity 0.2s;
}

.auth-badge {
  background: rgba(0, 0, 0, 0.03);
  border-left: 3px solid #0b76ff;
}

/* --- Microphone page specific extra styles (safe to include globally) --- */
.status-line {
  font-size: 12px;
  color: #666;
  text-align: left;
  min-height: 16px;
}

.small-note {
  font-size: 12px;
  color: #5a5a70;
  margin-top: 4px;
  text-align: left;
}

.small-note code {
  background: #f0f0f2;
  padding: 2px 4px;
  border-radius: 4px;
}

/* --- Utility / misc --- */
hr {
  margin: 8px 0;
  border: 0;
  height: 1px;
  background: var(--border);
}

.note-text {
  font-size: 12px;
  color: #5a5a70;
  margin-top: 4px;
  text-align: left;
}

.visually-hidden {
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

/* --- Responsive overrides (merged from both files) --- */
@media (max-width: 600px) {
  :root {
    --footer-height: 160px;
    --btn-min-width: 88px;
    --btn-height: 40px;
  }

  .doc-btn {
    right: 8px;
    min-width: 72px;
    height: 34px;
    font-size: 13px;
  }

  /* Override for mic button if present */
  #mic-sample-btn {
    right: 90px;
  }

  .start-card {
    padding: 16px;
  }

  .field-row {
    flex-direction: column;
    align-items: stretch;
  }

  .controls-col {
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .checkbox-row {
    align-self: stretch;
    justify-content: flex-start;
  }

  textarea.input-box {
    height: calc(var(--footer-height) - (var(--pad) * 2) - 10px);
  }

  .footer .inner {
    left: 8px;
    right: 8px;
  }

  .avatar-state-label {
    right: 8px;
    bottom: 8px;
    font-size: 13px;
    padding: 5px 8px;
  }
}

/* --- Microphone page footer inner center alignment (inline style override, but here as fallback) --- */
.mic-only .footer .inner,
.footer .inner:only-child {
  justify-content: center;
}
