*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #f5f5f0;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #555;
  --primary: #c62828;
  --primary-dark: #8e0000;
  --primary-light: #ffebee;
  --recording: #d32f2f;
  --success: #2e7d32;
  --border: #ccc;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  --header-bg: #00bcd4;
  --font-brand: "Gotham", "Gotham Rounded", Montserrat, sans-serif;
  --btn-minutes: #3b6faf;
  --btn-memo: #00bcd4;
  --btn-home: #3a5a8c;
}

html {
  font-size: 18px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  background: #e0e0e0;
  color: var(--text);
  line-height: 1.7;
}

.app-shell {
  min-height: 100vh;
}

.app-frame {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
}

@media (min-width: 431px) {
  body {
    padding: 2rem 1rem;
  }

  .app-shell {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: calc(100vh - 4rem);
  }

  .app-frame {
    width: 390px;
    max-width: 100%;
    min-height: calc(100vh - 4rem);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    overflow: hidden;
  }
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
  background: var(--header-bg);
  color: #fff;
  padding: 1rem 1.25rem 1.1rem;
  text-align: center;
}

.header-brand {
  margin: 0;
  font-family: var(--font-brand);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.header-tagline,
.header-subtitle {
  margin: 0.35rem 0 0;
  font-family: var(--font-brand);
  font-size: 0.85rem;
  font-weight: 400;
  line-height: 1.45;
}

main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  width: 100%;
}

.status-section {
  text-align: center;
  margin-bottom: 2rem;
}

.status {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
  min-height: 2.5em;
}

.status.processing {
  color: #1565c0;
}

.status.error {
  color: var(--primary);
}

/* 録音中パネル */
.recording-panel {
  text-align: center;
  margin-bottom: 1.5rem;
  padding: 1.25rem 1rem;
  background: #ffebee;
  border: 3px solid var(--recording);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.recording-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--recording);
  letter-spacing: 0.08em;
}

.rec-dot {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  background: var(--recording);
  border-radius: 50%;
  animation: rec-dot-blink 0.8s ease-in-out infinite;
}

@keyframes rec-dot-blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.85); }
}

.recording-timer {
  margin: 0 0 1rem;
  font-size: 3rem;
  font-weight: 800;
  color: #b71c1c;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
  line-height: 1.2;
}

.waveform-wrap {
  width: 100%;
  max-width: 400px;
  height: 80px;
  margin: 0 auto 0.5rem;
  background: #fff;
  border: 2px solid #ef9a9a;
  border-radius: 12px;
  overflow: hidden;
}

#waveformCanvas {
  display: block;
  width: 100%;
  height: 80px;
}

.waveform-caption {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
}

body.is-recording .status-section .status {
  display: none;
}

.record-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

.record-btn {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: min(320px, 90vw);
  min-height: 64px;
  padding: 1rem 2.5rem;
  border: none;
  border-radius: 16px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.record-btn:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: scale(1.02);
}

.record-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.record-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.record-btn.recording {
  animation: btn-blink 0.7s ease-in-out infinite;
}

@keyframes btn-blink {
  0%, 100% {
    background: #e53935;
    box-shadow: 0 0 0 0 rgba(229, 57, 53, 0.7), 0 6px 20px rgba(183, 28, 28, 0.5);
  }
  50% {
    background: #b71c1c;
    box-shadow: 0 0 28px 6px rgba(229, 57, 53, 0.9), 0 6px 20px rgba(183, 28, 28, 0.4);
  }
}

.btn-label {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.mode-panel {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  width: min(420px, 95vw);
}

.mode-btn {
  flex: 1 1 auto;
  min-width: 110px;
  padding: 0.75rem 1rem;
  border: 2px solid transparent;
  border-radius: 12px;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.mode-btn-minutes {
  background: var(--btn-minutes);
  border-color: var(--btn-minutes);
}

.mode-btn-minutes:hover:not(:disabled) {
  background: #325f99;
  border-color: #325f99;
}

.mode-btn-memo {
  background: var(--btn-memo);
  border-color: var(--btn-memo);
}

.mode-btn-memo:hover:not(:disabled) {
  background: #00a8bd;
  border-color: #00a8bd;
}

.mode-btn-home {
  background: var(--btn-home);
  border-color: var(--btn-home);
}

.mode-btn-home:hover:not(:disabled) {
  background: #314d78;
  border-color: #314d78;
}

.mode-btn-active {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.mode-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.result-section {
  margin-bottom: 2rem;
}

.result-section h2 {
  font-size: 1.3rem;
  margin: 0 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 3px solid #263238;
  color: #263238;
}

.result-section.has-warning .minutes-box {
  border-color: #ff9800;
}

.minutes-warning {
  margin: 0 0 0.75rem;
  padding: 0.75rem 1rem;
  background: #fff3e0;
  border: 2px solid #ff9800;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  color: #e65100;
}

.result-box {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  font-size: 1.1rem;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow);
  min-height: auto;
  height: auto;
  max-height: none;
  overflow: visible;
}

.minutes-box {
  white-space: normal;
  line-height: 1.8;
  height: auto;
  max-height: none;
  overflow: visible;
}

.minutes-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2rem 1rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: #1565c0;
}

.loading-spinner {
  width: 1.5rem;
  height: 1.5rem;
  border: 4px solid #bbdefb;
  border-top-color: #1565c0;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.minutes-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.action-btn {
  width: 100%;
  padding: 1rem 1.5rem;
  font-size: 1.15rem;
  font-weight: 700;
  font-family: inherit;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  touch-action: manipulation;
}

.action-btn-continue {
  background: #2e7d32;
  color: #fff;
}

.action-btn-continue:hover {
  background: #1b5e20;
}

.action-btn-retry {
  background: #ef6c00;
  color: #fff;
}

.action-btn-retry:hover {
  background: #e65100;
}

.action-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* 議事録（プレーン形式・記号なし） */
.minutes-box .minutes-document {
  font-size: 1.1rem;
  color: var(--text);
  line-height: 1.85;
}

.minutes-box .minutes-divider {
  height: 0;
  border: none;
  border-top: 2px solid #90a4ae;
  margin: 1rem 0;
}

.minutes-box .minutes-title {
  margin: 0.5rem 0 1rem;
  font-size: 1.4rem;
  font-weight: 800;
  text-align: center;
  color: #263238;
  letter-spacing: 0.12em;
}

.minutes-box .minutes-meta {
  margin: 0.35rem 0;
  font-size: 1.1rem;
  color: #37474f;
}

.minutes-box .minutes-section-title {
  margin: 1.1rem 0 0.5rem;
  font-size: 1.2rem;
  font-weight: 800;
  color: #1a1a1a;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid #c62828;
}

.minutes-box .minutes-bullet {
  margin: 0.4rem 0 0.4rem 0.5rem;
  padding-left: 0.25rem;
  font-size: 1.1rem;
  line-height: 1.75;
}

.minutes-box .minutes-line {
  margin: 0.35rem 0;
}

.minutes-box .minutes-spacer {
  height: 0.5rem;
}

.minutes-footer {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.minutes-footer .secondary-btn {
  flex: 1;
  min-width: 9rem;
}

.secondary-btn {
  display: block;
  width: 100%;
  padding: 1rem 1.5rem;
  font-size: 1.15rem;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  touch-action: manipulation;
}

.copy-btn-minutes {
  background: var(--btn-minutes);
}

.copy-btn-minutes:hover {
  background: #325f99;
}

.copy-btn-memo {
  background: var(--btn-memo);
}

.copy-btn-memo:hover {
  background: #00a8bd;
}

.secondary-btn-outline {
  background: #fff;
  color: #455a64;
  border: 2px solid #455a64;
}

.secondary-btn-outline:hover {
  background: #eceff1;
}

.secondary-btn:hover {
  filter: brightness(0.95);
}

.copy-btn-minutes:hover,
.copy-btn-memo:hover {
  filter: none;
}

.secondary-btn-outline:hover {
  background: #eceff1;
}

.secondary-btn:active {
  transform: scale(0.99);
}

@media (min-width: 480px) {
  html {
    font-size: 20px;
  }
}
