:root {
  --a4n-bg: #f4f8f2;
  --a4n-bg-2: #eaf2e7;
  --a4n-surface: #ffffff;
  --a4n-surface-soft: #f8fbf7;

  --a4n-line: #d7e2d5;
  --a4n-line-strong: #c8d6c6;

  --a4n-text: #333333;
  --a4n-muted: #6e756f;

  --a4n-primary: #169247;
  --a4n-primary-strong: #11773a;
  --a4n-primary-soft: #e9f6ed;

  --a4n-graphite: #333333;
  --a4n-graphite-soft: #f1f2f1;

  --a4n-success: #169247;
  --a4n-danger: #5a615b;

  --a4n-accent: #f4b400;
  --a4n-accent-soft: #fff4d6;

  --a4n-shadow: 0 16px 42px rgba(29, 53, 33, 0.08);
  --a4n-shadow-soft: 0 8px 20px rgba(29, 53, 33, 0.05);
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, #fcfefb 0%, #f7faf5 28%, var(--a4n-bg) 60%, var(--a4n-bg-2) 100%);
  color: var(--a4n-text);
  overflow: hidden;
  font-family: Montserrat, Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.a4n-app {
  height: 100vh;
  padding: 8px;
}

.a4n-shell {
  height: calc(100vh - 16px);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--a4n-line-strong);
  border-radius: 24px;
  box-shadow: var(--a4n-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.a4n-topbar {
  display: grid;
  grid-template-columns: minmax(96px, 140px) minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--a4n-line);
  background: linear-gradient(180deg, #fbfdfb 0%, #f2f7f0 100%);
}

.a4n-brand-block {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.a4n-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.a4n-brand-badge {
  width: 50px;
  height: 50px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--a4n-primary-strong), var(--a4n-primary));
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: 0 10px 24px rgba(22, 146, 71, 0.22);
}

.a4n-logo {
  height: 60px;
  width: auto;
  object-fit: contain;
  display: block;
}

.a4n-title {
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--a4n-text);
}

.a4n-subtitle {
  font-size: 0.74rem;
  color: var(--a4n-muted);
  line-height: 1.2;
}

.a4n-toolbar {
  display: grid;
  grid-template-columns:
    minmax(220px, 280px)
    minmax(260px, 340px)
    minmax(430px, 1fr)
    minmax(150px, 170px);
  gap: 12px;
  align-items: end;
  min-width: 0;
}

.a4n-toolbar-label {
  font-size: 0.7rem;
  font-weight: 800;
  color: #667067;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.a4n-input-group .form-select,
.a4n-input-group .btn {
  border-color: var(--a4n-line-strong);
  min-height: 42px;
}

.form-select {
  color: var(--a4n-text);
  background-color: #fff;
}

.form-select:focus {
  border-color: rgba(22, 146, 71, 0.4);
  box-shadow: 0 0 0 0.2rem rgba(22, 146, 71, 0.08);
}

.a4n-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(96px, 1fr));
  gap: 10px;
  min-width: 0;
}

.a4n-controls .btn,
.a4n-status-pill,
.a4n-mode-switch .btn {
  min-height: 42px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.btn-primary {
  background: linear-gradient(180deg, #1aa24d 0%, #148640 100%);
  border-color: #148640;
}

.btn-primary:hover {
  background: linear-gradient(180deg, #178f45 0%, #11773a 100%);
  border-color: #11773a;
}

.btn-danger {
  background: linear-gradient(180deg, #6a726b 0%, #555d56 100%);
  border-color: #555d56;
  color: #fff;
}

.btn-danger:hover {
  background: linear-gradient(180deg, #5f6760 0%, #4a524b 100%);
  border-color: #4a524b;
  color: #fff;
}

.btn-success {
  background: linear-gradient(180deg, #169247 0%, #11773a 100%);
  border-color: #11773a;
}

.btn-success:hover {
  background: linear-gradient(180deg, #148640 0%, #106c35 100%);
  border-color: #106c35;
}

.btn-outline-dark {
  border-color: #aeb8af;
  color: #3e463f;
  background: rgba(255, 255, 255, 0.86);
}

.btn-outline-dark:hover {
  background: #f4f7f3;
  border-color: #9eaa9f;
  color: #2f3730;
}

.a4n-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid #d6e6d7;
  background: #f2faf2;
  color: #1d6834;
  width: 100%;
  white-space: nowrap;
}

.a4n-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--a4n-primary);
  box-shadow: 0 0 0 4px rgba(22, 146, 71, 0.14);
  flex-shrink: 0;
}

.a4n-main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 0.72fr 1.48fr;
  gap: 12px;
  padding: 12px;
  overflow: hidden;
}

.a4n-panel {
  min-height: 0;
  border: 1px solid var(--a4n-line);
  border-radius: 22px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdfb 100%);
  box-shadow: var(--a4n-shadow-soft);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.a4n-panel-left,
.a4n-panel-right {
  height: 100%;
}

.a4n-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px 6px;
  border-bottom: 0;
  background: transparent;
  flex: 0 0 auto;
}

.a4n-section-kicker {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6c776d;
  margin-bottom: 2px;
}

.a4n-panel-title {
  font-size: 1rem;
  font-weight: 800;
  margin: 0;
  color: var(--a4n-text);
}

.a4n-panel-meta {
  color: var(--a4n-muted);
  font-size: 0.84rem;
  white-space: nowrap;
}

.a4n-transcript-box {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0 16px;
  border: 1px solid #dbe6da;
  border-radius: 20px;
  background: linear-gradient(180deg, #fbfdfb 0%, #f4f8f3 100%);
  padding: 14px;
  overflow-y: auto;
  overflow-x: hidden;
  white-space: pre-wrap;
  line-height: 1.58;
  color: #334136;
  font-size: 0.95rem;
}

.a4n-panel-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px 14px;
  color: var(--a4n-muted);
  font-size: 0.8rem;
  flex: 0 0 auto;
}

.a4n-results-grid {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 16px 16px;
}

.a4n-results-grid .row {
  margin-bottom: 0;
}

.a4n-mic-wrap {
  min-width: 0;
}

.a4n-mic-summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 8px 0 12px;
  border: 1px solid var(--a4n-line-strong);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
}

.a4n-mic-current {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: #3d463e;
}

.a4n-mic-current i {
  color: var(--a4n-primary);
  flex-shrink: 0;
}

#micCurrentLabel {
  display: block;
  min-width: 0;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.a4n-mic-settings {
  position: relative;
  flex-shrink: 0;
}

.a4n-mic-settings summary {
  list-style: none;
}

.a4n-mic-settings summary::-webkit-details-marker {
  display: none;
}

.a4n-mic-settings-trigger {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--a4n-line-strong);
  border-radius: 12px;
  background: #fff;
  color: #465247;
  cursor: pointer;
  transition: 0.15s ease;
}

.a4n-mic-settings-trigger:hover {
  background: #f4f7f3;
  border-color: #9eaa9f;
  color: #2f3730;
}

.a4n-mic-settings[open] .a4n-mic-settings-trigger {
  background: linear-gradient(180deg, #eef8f0 0%, #e2f1e6 100%);
  border-color: #bfdcc6;
  color: var(--a4n-primary-strong);
}

.a4n-mic-settings-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 300px;
  padding: 12px;
  border: 1px solid var(--a4n-line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 16px 42px rgba(29, 53, 33, 0.12);
  z-index: 1200;
}

.a4n-mic-settings-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.74rem;
  font-weight: 800;
  color: #667067;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.a4n-mode-wrap {
  position: relative;
  min-width: 0;
}

.a4n-mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: stretch;
  min-width: 0;
}

.a4n-mode-option {
  position: relative;
  min-width: 0;
}

.a4n-mode-option--conference {
  position: relative;
}

.a4n-mode-switch .btn {
  border-color: var(--a4n-line-strong);
  color: #3d463e;
  background: rgba(255, 255, 255, 0.88);
}

.a4n-mode-switch .btn-check:checked + .btn {
  background: linear-gradient(180deg, #eef8f0 0%, #e2f1e6 100%);
  border-color: #bfdcc6;
  color: var(--a4n-primary-strong);
}

.a4n-mode-option-summary {
  min-height: 42px;
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  gap: 8px;
  padding: 3px;
  border: 1px solid var(--a4n-line-strong);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  transition: 0.15s ease;
  width: 100%;
  min-width: 0;
}

.a4n-mode-main-btn {
  flex: 1 1 auto;
  min-height: 100%;
  border: 0 !important;
  border-radius: 10px;
  background: transparent !important;
  box-shadow: none !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding-left: 8px;
  padding-right: 8px;
  color: inherit;
}

.a4n-mode-main-btn:hover,
.a4n-mode-main-btn:focus,
.a4n-mode-main-btn:active {
  border: 0;
  background: transparent;
  box-shadow: none;
  color: inherit;
}

.a4n-mode-switch .btn-check:checked + .a4n-mode-option-summary {
  background: linear-gradient(180deg, #eef8f0 0%, #e2f1e6 100%);
  border-color: #bfdcc6;
}

.a4n-mode-switch .btn-check:checked + .a4n-mode-option-summary .a4n-mode-main-btn {
  color: var(--a4n-primary-strong);
}

.a4n-mode-settings {
  position: relative;
  flex: 0 0 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.a4n-mode-settings summary {
  list-style: none;
}

.a4n-mode-settings summary::-webkit-details-marker {
  display: none;
}

.a4n-mode-settings-trigger {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--a4n-line-strong);
  border-radius: 12px;
  background: #fff;
  color: #465247;
  cursor: pointer;
  transition: 0.15s ease;
}

.a4n-mode-settings-trigger:hover {
  background: #f4f7f3;
  border-color: #9eaa9f;
  color: #2f3730;
}

.a4n-mode-settings[open] .a4n-mode-settings-trigger {
  background: linear-gradient(180deg, #eef8f0 0%, #e2f1e6 100%);
  border-color: #bfdcc6;
  color: var(--a4n-primary-strong);
}

.a4n-mode-settings-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 300px;
  padding: 12px;
  border: 1px solid var(--a4n-line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 16px 42px rgba(29, 53, 33, 0.12);
  z-index: 1200;
}

.a4n-mode-settings-heading {
  display: block;
  margin-bottom: 8px;
  font-size: 0.74rem;
  font-weight: 800;
  color: #667067;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.a4n-role-toggle {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 10px;
  border: 1px solid var(--a4n-line-strong);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
}

.a4n-role-toggle-text {
  min-width: 0;
}

.a4n-role-toggle-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #3d463e;
  line-height: 1.1;
}

.a4n-role-toggle-subtitle {
  font-size: 0.68rem;
  color: var(--a4n-muted);
  line-height: 1.35;
  margin-top: 2px;
}

.a4n-role-switch {
  margin: 0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.a4n-role-switch .form-check-input {
  width: 2.5rem;
  height: 1.35rem;
  margin: 0;
  border-color: #b9c8bc;
  background-color: #dfe8e1;
  box-shadow: none;
  cursor: pointer;
}

.a4n-role-switch .form-check-input:focus {
  border-color: rgba(22, 146, 71, 0.4);
  box-shadow: 0 0 0 0.2rem rgba(22, 146, 71, 0.08);
}

.a4n-role-switch .form-check-input:checked {
  background-color: var(--a4n-primary);
  border-color: var(--a4n-primary);
}

.a4n-info-trigger {
  cursor: pointer;
  color: #7b857c;
  font-size: 0.9rem;
}

.a4n-info-trigger:hover {
  color: var(--a4n-primary);
}

.a4n-mode-hint {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 240px;
  padding: 8px 10px;
  font-size: 0.76rem;
  line-height: 1.35;
  background: #333333;
  color: #fff;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: 0.15s ease;
  z-index: 1000;
}

.a4n-mode-option--conference > .a4n-mode-hint {
  left: 0;
}

.a4n-mode-option--conference:hover > .a4n-mode-hint,
.a4n-mode-option--conference:focus-within > .a4n-mode-hint {
  opacity: 1;
  transform: translateY(0);
}

.a4n-status-wrap {
  min-width: 0;
}

.placeholder-text {
  color: #9aa79c;
}

.result-card {
  border: 1px solid var(--a4n-line);
  border-radius: 20px;
  background: linear-gradient(180deg, #ffffff 0%, #fcfefc 100%);
  padding: 12px;
  height: 100%;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.result-card-main {
  min-height: 172px;
}

.result-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex: 0 0 auto;
}

.result-title {
  font-size: 0.92rem;
  font-weight: 800;
  margin: 0;
  color: #334034;
}

.result-textarea {
  resize: none;
  border-radius: 16px;
  border-color: #d8e3d9;
  background: #fcfefc;
  color: #334034;
  line-height: 1.5;
  font-size: 0.94rem;
  box-shadow: none;
  overflow-y: auto;
}

.result-textarea:focus {
  border-color: rgba(22, 146, 71, 0.38);
  box-shadow: 0 0 0 0.2rem rgba(22, 146, 71, 0.08);
}

.result-textarea-main {
  min-height: 0;
  height: 128px;
  flex: 1 1 auto;
}

.btn-soft {
  background: linear-gradient(180deg, #eef8f0 0%, #e5f1e7 100%);
  border: 1px solid #cadecf;
  color: var(--a4n-primary-strong);
  font-weight: 700;
  font-size: 0.86rem;
  padding: 6px 10px;
}

.btn-soft:hover {
  background: #dcecdf;
  color: #0f6b33;
}

.icd-card {
  min-height: 96px;
  max-height: 150px;
}

.icd-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 100%;
  overflow: auto;
}

.icd-item {
  border: 1px solid #dce6dc;
  border-radius: 14px;
  padding: 8px 10px;
  background: #fafcf9;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.icd-code {
  border: 0;
  background: linear-gradient(180deg, #fff2c9 0%, #ffe08c 100%);
  color: #866000;
  border-radius: 10px;
  padding: 5px 9px;
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}

.icd-code:hover {
  background: #ffd96e;
}

.icd-desc {
  color: #3e4d40;
  line-height: 1.35;
  font-size: 0.9rem;
}

.analysis-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 47, 34, 0.24);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.analysis-overlay.show {
  display: flex;
}

.analysis-modal {
  width: min(460px, 100%);
  background: #fff;
  border-radius: 22px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(29, 53, 33, 0.18);
  border: 1px solid var(--a4n-line);
}

.analysis-progress {
  height: 10px;
  border-radius: 999px;
  background: #e7efe5;
  overflow: hidden;
}

.analysis-progress-bar {
  height: 100%;
  width: 35%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--a4n-primary), #39a863);
  animation: loadingBar 1.2s ease-in-out infinite;
}

@keyframes loadingBar {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(320%); }
}

.copy-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #333333;
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  box-shadow: 0 12px 30px rgba(29, 53, 33, 0.22);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: 0.22s ease;
  z-index: 3000;
}

.copy-toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1535.98px) {
  .a4n-topbar {
    grid-template-columns: minmax(88px, 124px) minmax(0, 1fr);
  }

  .a4n-logo {
    height: 60px;
  }

  .a4n-toolbar {
    grid-template-columns:
      minmax(200px, 250px)
      minmax(230px, 300px)
      minmax(390px, 1fr)
      minmax(145px, 165px);
    gap: 10px;
  }

  .a4n-controls {
    grid-template-columns: repeat(4, minmax(84px, 1fr));
    gap: 8px;
  }

  .a4n-controls .btn,
  .a4n-status-pill,
  .a4n-mode-switch .btn {
    min-height: 40px;
    font-size: 0.9rem;
  }

  .result-card-main {
    min-height: 164px;
  }

  .result-textarea-main {
    height: 120px;
  }
}

@media (max-width: 1399.98px) {
  .a4n-topbar {
    grid-template-columns: minmax(80px, 112px) minmax(0, 1fr);
    gap: 14px;
    padding: 10px 14px;
  }

  .a4n-toolbar {
    grid-template-columns:
      minmax(180px, 220px)
      minmax(210px, 280px)
      1fr
      minmax(138px, 155px);
    gap: 8px;
  }

  .a4n-logo {
    height: 50px;
  }

  .a4n-main {
    grid-template-columns: 0.8fr 1.35fr;
    gap: 10px;
    padding: 10px;
  }

  .result-card-main {
    min-height: 156px;
  }

  .result-textarea-main {
    height: 112px;
  }

  .icd-card {
    max-height: 140px;
  }

  #micCurrentLabel {
    max-width: 140px;
  }

  .a4n-mic-settings-panel {
    width: 260px;
  }

  .a4n-mode-settings-panel {
    width: 260px;
  }
}

@media (max-width: 1199.98px) {
  body {
    overflow: auto;
  }

  .a4n-app {
    height: auto;
    min-height: 100vh;
    padding: 10px;
  }

  .a4n-shell {
    height: auto;
    min-height: calc(100vh - 20px);
  }

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

  .a4n-brand-block {
    justify-content: flex-start;
  }

  .a4n-brand {
    justify-content: flex-start;
  }

  .a4n-toolbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .a4n-controls {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .a4n-main {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .a4n-panel,
  .a4n-results-grid {
    min-height: unset;
  }

  .a4n-transcript-box {
    min-height: 240px;
  }

  .result-card-main,
  .icd-card {
    min-height: unset;
    max-height: unset;
  }

  .result-textarea-main {
    height: 180px;
  }

  .a4n-mode-hint {
    position: static;
    width: auto;
    max-width: none;
    margin-top: 8px;
    opacity: 1;
    pointer-events: auto;
    transform: none;
    display: none;
  }

  .a4n-mode-option--conference:hover > .a4n-mode-hint,
  .a4n-mode-option--conference:focus-within > .a4n-mode-hint {
    display: block;
  }

  .a4n-mic-settings-panel {
    position: static;
    width: 100%;
    margin-top: 8px;
    box-shadow: none;
  }

  .a4n-mode-settings-panel {
    position: static;
    width: 100%;
    margin-top: 8px;
    box-shadow: none;
  }

  #micCurrentLabel {
    max-width: none;
  }

  .a4n-role-toggle {
    width: 100%;
  }

  .a4n-mode-option-summary {
    padding-left: 0;
  }
}

@media (max-width: 767.98px) {
  .a4n-topbar {
    padding: 14px;
  }

  .a4n-main {
    padding: 10px;
  }

  .a4n-controls {
    grid-template-columns: 1fr 1fr;
  }

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

  .a4n-panel-meta {
    white-space: normal;
  }

  .a4n-panel-footer {
    flex-direction: column;
  }

  .result-textarea-main {
    height: 150px;
  }

  .a4n-producer {
    width: 100%;
    justify-content: space-between;
  }

  .a4n-producer-logo {
    max-width: 150px;
  }

  .a4n-mic-summary {
    padding-left: 10px;
  }
}