:root {
  color-scheme: light;
  --ink: #18302a;
  --muted: #61726d;
  --line: #d9e3df;
  --surface: #ffffff;
  --surface-soft: #f3f7f5;
  --green-deep: #12372a;
  --green: #237a57;
  --green-light: #dff2e8;
  --teal: #187b84;
  --blue: #356d9b;
  --amber: #a56612;
  --red: #b33b35;
  --shadow: 0 12px 32px rgba(24, 48, 42, 0.08);
  --radius: 8px;
  font-family:
    Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #eef3f1;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(#eef3f1 0 220px, #f7f9f8 220px 100%);
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  min-height: 68px;
  padding: 10px clamp(16px, 4vw, 48px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: #fff;
  background: var(--green-deep);
  border-bottom: 4px solid #8dbb9e;
}

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

.brand img {
  width: 92px;
  height: 36px;
  object-fit: contain;
  object-position: left center;
}

.brand div {
  min-width: 0;
  display: grid;
}

.brand strong {
  font-size: 1.05rem;
  line-height: 1.2;
}

.brand span {
  color: #cfe1d8;
  font-size: 0.83rem;
}

.device-badge {
  flex: 0 0 auto;
  padding: 7px 10px;
  color: #e7f3ed;
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
}

main {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.access-state {
  min-height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.access-state div:last-child {
  display: grid;
  gap: 4px;
}

.access-state span {
  color: var(--muted);
  font-size: 0.9rem;
}

.access-state.is-error {
  padding: 28px;
  align-items: flex-start;
  justify-content: flex-start;
  border-left: 4px solid var(--amber);
}

.access-state.is-error .spinner {
  display: none;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #d8e5df;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.workspace {
  display: grid;
  gap: 16px;
}

.page-heading {
  padding: 2px 2px 8px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.page-heading h1 {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 2.15rem);
  line-height: 1.15;
}

.page-heading p:not(.eyebrow) {
  max-width: 700px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.security-note {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--green-deep);
  font-size: 0.8rem;
  font-weight: 700;
}

.security-note svg {
  width: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.panel {
  padding: clamp(18px, 3vw, 26px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.section-title {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.step {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  background: var(--green);
  border-radius: 50%;
}

.section-title h2 {
  margin: 0;
  font-size: 1.06rem;
}

.section-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.history-title {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
}

.history-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--green);
  background: var(--green-light);
  border-radius: 50%;
}

.history-icon svg,
.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--green-deep);
  background: #fff;
  border: 1px solid #b7c7c0;
  border-radius: 6px;
}

.icon-button:hover:not(:disabled) {
  background: var(--surface-soft);
}

.icon-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.meeting-history-list {
  display: grid;
}

.meeting-history-item {
  min-width: 0;
  padding: 13px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  border-top: 1px solid var(--line);
}

.meeting-history-item:first-child {
  padding-top: 0;
  border-top: 0;
}

.meeting-history-item:last-child {
  padding-bottom: 0;
}

.meeting-history-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.meeting-history-main strong {
  overflow: hidden;
  font-size: 0.88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meeting-history-main span,
.meeting-history-main small,
.meeting-history-status small {
  color: var(--muted);
  font-size: 0.74rem;
}

.meeting-history-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meeting-history-status {
  min-width: 108px;
  display: grid;
  justify-items: end;
  gap: 4px;
}

.meeting-status {
  padding: 5px 8px;
  font-size: 0.7rem;
  font-weight: 800;
  border-radius: 999px;
  white-space: nowrap;
}

.meeting-status.is-completed {
  color: #155c3e;
  background: #dff2e8;
}

.meeting-status.is-processing {
  color: #165f68;
  background: #e4f2f3;
}

.meeting-status.is-recording {
  color: #8d2f2a;
  background: #f8e7e5;
}

.meeting-status.is-error {
  color: #7d4b0d;
  background: #f8ecd8;
}

.meeting-history-actions {
  display: flex;
  justify-content: flex-end;
}

.button-compact {
  min-height: 36px;
  padding: 7px 11px;
  font-size: 0.76rem;
  text-decoration: none;
  white-space: nowrap;
}

.history-loading,
.history-empty {
  padding: 12px 0 2px;
  color: var(--muted);
  font-size: 0.82rem;
}

.meeting-result {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.meeting-result-heading {
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.meeting-result-heading > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.meeting-result-heading span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.meeting-result-heading strong {
  overflow: hidden;
  font-size: 0.95rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-tabs {
  margin-bottom: 10px;
  display: inline-flex;
  padding: 3px;
  background: #e9efec;
  border-radius: 7px;
}

.result-tab {
  min-height: 34px;
  padding: 6px 11px;
  color: #4e625c;
  font-size: 0.76rem;
  font-weight: 750;
  background: transparent;
  border: 0;
  border-radius: 5px;
}

.result-tab.is-selected {
  color: var(--green-deep);
  background: #fff;
  box-shadow: 0 1px 3px rgba(24, 48, 42, 0.12);
}

.meeting-result-content {
  max-height: 420px;
  margin: 0;
  padding: 15px;
  overflow: auto;
  color: #334b45;
  font-family: inherit;
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #f7faf9;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.meeting-result-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.field {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.field-wide {
  grid-column: 1 / -1;
}

.field > span {
  color: #304a43;
  font-size: 0.8rem;
  font-weight: 750;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #bdcbc6;
  border-radius: 6px;
  outline: none;
}

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

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(35, 122, 87, 0.12);
}

.mode-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.processing-mode-selector {
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.processing-option {
  min-width: 0;
  min-height: 72px;
  padding: 13px 14px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  background: #f8faf9;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.processing-option.is-selected {
  background: #edf7f2;
  border-color: #70a88b;
}

.processing-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.option-mark {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 2px solid #91a29b;
  border-radius: 50%;
}

.processing-option.is-selected .option-mark {
  border-color: var(--green);
  box-shadow: inset 0 0 0 4px #fff;
  background: var(--green);
}

.processing-option > span:nth-of-type(2) {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.processing-option strong {
  font-size: 0.87rem;
}

.processing-option small {
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.35;
}

.processing-option em {
  padding: 4px 7px;
  color: #fff;
  font-size: 0.65rem;
  font-style: normal;
  font-weight: 800;
  background: var(--green);
  border-radius: 999px;
}

.subsection-label {
  margin: 0 0 9px;
  color: #304a43;
  font-size: 0.78rem;
  font-weight: 800;
}

.mode-option {
  min-width: 0;
  min-height: 80px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.mode-option.is-selected {
  background: var(--green-light);
  border-color: #79ae91;
}

.mode-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-option svg {
  width: 26px;
  flex: 0 0 26px;
  fill: none;
  stroke: var(--green);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.mode-option span {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.mode-option strong,
.mode-option small {
  overflow-wrap: anywhere;
}

.mode-option strong {
  font-size: 0.9rem;
}

.mode-option small {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.35;
}

.mode-option.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.recorder-console {
  margin-top: 16px;
  padding: 24px;
  display: grid;
  justify-items: center;
  text-align: center;
  background: #f8faf9;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.recording-state {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.status-dot {
  width: 9px;
  height: 9px;
  background: #95a69f;
  border-radius: 50%;
}

.status-dot.is-recording {
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(179, 59, 53, 0.1);
  animation: pulse 1.5s ease-in-out infinite;
}

.status-dot.is-paused {
  background: var(--amber);
}

@keyframes pulse {
  50% {
    opacity: 0.45;
  }
}

#timer {
  margin: 12px 0;
  font-family: "Segoe UI Mono", "Roboto Mono", monospace;
  font-size: clamp(2.15rem, 8vw, 3.8rem);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 1;
}

.level-meter {
  width: min(320px, 100%);
  height: 6px;
  overflow: hidden;
  background: #dce5e1;
  border-radius: 999px;
}

.level-meter span {
  width: 2%;
  height: 100%;
  display: block;
  background: var(--teal);
  border-radius: inherit;
  transition: width 80ms linear;
}

#recordingHint {
  max-width: 620px;
  margin: 14px 0 18px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.recording-actions,
.preview-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.button {
  min-height: 42px;
  padding: 9px 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.86rem;
  font-weight: 750;
  border: 1px solid transparent;
  border-radius: 6px;
}

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

.button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.button-primary {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.button-primary:hover:not(:disabled) {
  background: #1c694a;
}

.button-secondary {
  color: var(--ink);
  background: #fff;
  border-color: #b7c7c0;
}

.button-danger {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.consent {
  margin-top: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: #3e544e;
  font-size: 0.82rem;
  line-height: 1.4;
  background: #f8faf9;
  border-left: 3px solid var(--green);
}

.consent input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--green);
}

.preview-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
}

.preview-row audio {
  width: 100%;
}

.recording-summary {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.preview-actions {
  margin-top: 18px;
  justify-content: flex-end;
}

.upload-progress {
  margin-top: 16px;
  display: grid;
  gap: 7px;
}

.progress-track,
.pipeline-progress {
  height: 8px;
  overflow: hidden;
  background: #dce5e1;
  border-radius: 999px;
}

.progress-track span,
.pipeline-progress span {
  width: 0;
  height: 100%;
  display: block;
  background: var(--teal);
  border-radius: inherit;
  transition: width 180ms ease;
}

.upload-progress > span {
  color: var(--muted);
  font-size: 0.8rem;
}

.pipeline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px;
  align-items: center;
  gap: 14px;
}

.pipeline strong {
  color: var(--green);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.delivery-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.live-insights-panel {
  border-left: 4px solid var(--teal);
}

.live-title {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
}

.live-pulse {
  width: 11px;
  height: 11px;
  background: var(--teal);
  border-radius: 50%;
  box-shadow: 0 0 0 5px rgba(24, 123, 132, 0.11);
  animation: pulse 1.7s ease-in-out infinite;
}

.segment-count {
  padding: 6px 9px;
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 800;
  background: #e8f5f5;
  border-radius: 999px;
  white-space: nowrap;
}

.live-result-tabs {
  margin-top: -4px;
}

.live-summary {
  min-height: 90px;
  padding: 15px;
  color: #334b45;
  font-size: 0.84rem;
  line-height: 1.55;
  white-space: pre-wrap;
  background: #f7faf9;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  width: min(390px, calc(100% - 36px));
  padding: 13px 15px;
  color: #fff;
  font-size: 0.84rem;
  line-height: 1.4;
  background: var(--green-deep);
  border-radius: 6px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
}

.toast.is-error {
  background: #7e2b27;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 720px) {
  body {
    background: #f7f9f8;
  }

  .topbar {
    min-height: 62px;
    padding: 8px 14px;
  }

  .brand img {
    width: 78px;
    height: 30px;
  }

  .device-badge {
    display: none;
  }

  main {
    width: min(100% - 20px, 1080px);
    padding: 16px 0 32px;
  }

  .page-heading {
    display: grid;
    gap: 10px;
  }

  .security-note {
    justify-self: start;
  }

  .panel {
    padding: 17px 15px;
  }

  .form-grid,
  .processing-mode-selector,
  .mode-selector,
  .preview-row {
    grid-template-columns: 1fr;
  }

  .meeting-history-item {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
  }

  .meeting-history-status {
    min-width: auto;
  }

  .meeting-history-actions {
    grid-column: 1 / -1;
  }

  .meeting-history-actions .button {
    width: 100%;
  }

  .field-wide {
    grid-column: auto;
  }

  .recorder-console {
    padding: 21px 12px;
  }

  .recording-actions,
  .preview-actions {
    width: 100%;
  }

  .button {
    flex: 1 1 132px;
  }

  .preview-actions {
    justify-content: stretch;
  }

  .recording-summary {
    grid-template-columns: 1fr 1fr;
  }

  .processing-option {
    grid-template-columns: 18px minmax(0, 1fr);
  }

  .processing-option em {
    display: none;
  }

  .live-title {
    grid-template-columns: 16px minmax(0, 1fr);
  }

  .segment-count {
    grid-column: 2;
    justify-self: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
