:root {
  color-scheme: light;
  --bg: #eef5f2;
  --panel: #ffffff;
  --text: #14211f;
  --muted: #647470;
  --line: #d5e2dd;
  --accent: #0f6b5f;
  --accent-dark: #0a5148;
  --danger: #b83245;
  --warn: #9b6117;
  --soft: #edf7f4;
  --shadow: 0 18px 44px rgba(20, 33, 31, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: "Segoe UI", "Apple SD Gothic Neo", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) 14px calc(env(safe-area-inset-bottom) + 34px);
}

.app-header,
.section-head,
.record-status,
.record-controls,
.export-grid {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-header {
  justify-content: space-between;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

.content-stack {
  display: grid;
  gap: 14px;
}

.record-panel,
.tab-panel,
.gate {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

.record-panel {
  display: grid;
  gap: 16px;
}

.record-status {
  justify-content: space-between;
  min-height: 84px;
}

#recordTimer {
  display: block;
  font-size: 52px;
  line-height: 1;
  letter-spacing: 0;
}

.pulse {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle, #ff5468 0 36%, #ffd7dd 37% 100%);
  opacity: 0.35;
}

.pulse.is-recording {
  opacity: 1;
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    transform: scale(0.88);
  }
}

.title-row {
  display: grid;
  gap: 8px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px 13px;
  color: var(--text);
}

textarea {
  resize: vertical;
}

.large-textarea {
  min-height: 300px;
}

.context-textarea {
  min-height: 90px;
}

.primary-action,
.secondary-action,
.icon-button,
.tab-button {
  min-height: 44px;
  border-radius: 8px;
  font-weight: 800;
}

.primary-action,
.secondary-action {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
}

.primary-action {
  flex: 1;
  background: var(--accent);
  color: #fff;
}

.primary-action.is-recording {
  background: var(--danger);
}

.secondary-action {
  background: var(--soft);
  color: var(--accent-dark);
}

.secondary-action.full {
  width: 100%;
}

.secondary-action:disabled,
.primary-action:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.icon-button {
  width: 44px;
  display: inline-grid;
  place-items: center;
  background: var(--soft);
  color: var(--accent-dark);
  font-size: 20px;
}

.privacy-note {
  font-size: 13px;
  color: var(--warn);
}

.toolbar-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.tab-button {
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.tab-button.is-active {
  background: var(--accent);
  color: #fff;
}

.section-head {
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.recording-list {
  display: grid;
  gap: 10px;
}

.recording-item {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdfc;
}

.recording-item.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 107, 95, 0.12);
}

.recording-main {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.recording-main strong {
  display: block;
}

.recording-meta {
  color: var(--muted);
  font-size: 12px;
}

.recording-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.recording-actions button {
  min-height: 38px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
}

.recording-actions button.danger {
  background: #fff0f2;
  color: var(--danger);
}

.summary-view,
.report-view {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 14px;
  line-height: 1.65;
}

.summary-view.empty,
.report-view.empty,
.empty-list {
  color: var(--muted);
  text-align: center;
  padding: 24px 14px;
}

.summary-group {
  display: grid;
  gap: 6px;
}

.summary-group ul {
  margin: 0;
  padding-left: 20px;
}

.export-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}

.toast {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  z-index: 20;
  display: none;
  border-radius: 8px;
  background: #14211f;
  color: #fff;
  padding: 13px 14px;
  text-align: center;
  font-weight: 800;
}

.toast.show {
  display: block;
}

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(238, 245, 242, 0.72);
  backdrop-filter: blur(6px);
}

.busy-card {
  min-width: 220px;
  display: grid;
  justify-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 22px;
  box-shadow: var(--shadow);
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 4px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

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

@media (min-width: 800px) {
  body:not(.allow-desktop) .content-stack {
    display: none;
  }
}
