:root {
  --bg: #f6f7f2;
  --surface: #ffffff;
  --surface-strong: #fdfbf5;
  --text: #18211f;
  --muted: #63706b;
  --line: #d8dfd8;
  --primary: #146c5d;
  --primary-hover: #0f5a4d;
  --accent: #d45d3b;
  --accent-soft: #ffe9df;
  --focus: #2f80ed;
  --shadow: 0 18px 45px rgba(25, 42, 36, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(20, 108, 93, 0.10), transparent 38%),
    linear-gradient(225deg, rgba(212, 93, 59, 0.13), transparent 34%),
    var(--bg);
  font-family:
    "Malgun Gothic",
    "Apple SD Gothic Neo",
    system-ui,
    sans-serif;
}

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

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  padding: 0 16px;
  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    background 0.15s ease;
}

button:hover:not(:disabled) {
  border-color: #9db2aa;
  transform: translateY(-1px);
}

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

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(47, 128, 237, 0.25);
  border-color: var(--focus);
}

.app-shell {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

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

.topbar,
.control-strip,
.panel {
  border: 1px solid rgba(216, 223, 216, 0.9);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 92px;
  border-radius: 8px;
  padding: 18px 22px;
  background: rgba(255, 255, 255, 0.88);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.7rem, 3vw, 2.45rem);
  line-height: 1.12;
}

h2 {
  font-size: 1rem;
  line-height: 1.3;
}

.status-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.status-pill,
.record-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  padding: 0 12px;
  color: var(--muted);
  background: #eef2ed;
  font-size: 0.9rem;
  font-weight: 700;
}

.record-pill.active {
  color: #9b2d18;
  background: var(--accent-soft);
}

.control-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, max-content)) 1fr;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  border-radius: 8px;
  padding: 14px;
  background: rgba(253, 251, 245, 0.92);
}

.primary-action {
  border-color: var(--primary);
  color: #ffffff;
  background: var(--primary);
  font-weight: 800;
}

.primary-action:hover:not(:disabled) {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

.wide {
  width: 100%;
}

.meter {
  justify-self: end;
  display: grid;
  grid-template-columns: repeat(8, 8px);
  align-items: end;
  gap: 5px;
  width: 112px;
  height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.meter span {
  display: block;
  height: 6px;
  border-radius: 999px;
  background: var(--primary);
  opacity: 0.35;
  transform-origin: bottom;
}

.meter.listening span {
  animation: levelPulse 0.85s ease-in-out infinite;
}

.meter.listening span:nth-child(2n) {
  animation-delay: 0.12s;
}

.meter.listening span:nth-child(3n) {
  animation-delay: 0.24s;
}

@keyframes levelPulse {
  0%,
  100% {
    height: 8px;
    opacity: 0.35;
  }
  50% {
    height: 30px;
    opacity: 0.95;
  }
}

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

.panel {
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
}

.transcript-panel,
.output-panel {
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr);
  min-height: 380px;
}

.settings-panel {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 18px;
}

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

.panel-heading p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.88rem;
}

.interim {
  flex: 1;
  min-width: 160px;
  color: var(--accent);
  font-size: 0.93rem;
  font-weight: 700;
  text-align: right;
}

.field {
  display: grid;
  gap: 7px;
}

label,
.check-row {
  color: #31413c;
  font-size: 0.92rem;
  font-weight: 800;
}

input[type="text"],
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 0 12px;
}

.check-row {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 28px;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

textarea {
  width: 100%;
  min-height: 100%;
  resize: vertical;
  border: 0;
  background: transparent;
  color: var(--text);
  line-height: 1.75;
  padding: 18px;
}

textarea::placeholder {
  color: #8b9692;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
  font-size: 0.88rem;
  padding: 8px 0 0;
}

a {
  color: var(--primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.document-page {
  width: min(820px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.document-panel {
  display: grid;
  gap: 18px;
  border: 1px solid rgba(216, 223, 216, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  padding: 24px;
}

.document-panel section {
  display: grid;
  gap: 8px;
}

.document-panel h1 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
}

.document-panel p {
  color: #31413c;
  line-height: 1.75;
}

.document-updated {
  color: var(--muted);
  font-size: 0.9rem;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 5;
  max-width: min(360px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #18211f;
  color: #ffffff;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  font-weight: 700;
}

.selection-copy {
  position: fixed;
  z-index: 10;
  min-height: 34px;
  border-color: #22312d;
  border-radius: 999px;
  background: #18211f;
  color: #ffffff;
  box-shadow: 0 12px 28px rgba(24, 33, 31, 0.22);
  font-size: 0.86rem;
  font-weight: 800;
  padding: 0 13px;
}

.selection-copy:hover:not(:disabled) {
  border-color: #18211f;
  background: #263632;
}

.selection-copy:focus-visible {
  outline: 3px solid rgba(47, 128, 237, 0.35);
  outline-offset: 2px;
}

@media (max-width: 900px) {
  .control-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .meter {
    grid-column: 1 / -1;
    justify-self: stretch;
    width: 100%;
  }

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

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1200px);
    padding: 10px 0;
  }

  .topbar,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-group,
  .action-row {
    justify-content: flex-start;
  }

  .control-strip {
    grid-template-columns: 1fr;
  }

  .transcript-panel,
  .output-panel {
    min-height: 320px;
  }
}
