/* 古いiPhone（iOS 12前後）でも崩れにくいよう、新しいCSS機能は使わない */
:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --text: #222222;
  --muted: #6b6b6b;
  --line: #ddd8cc;
  --accent: #1f6f5c;
  --accent-text: #ffffff;
  --rec: #c0392b;
  --danger: #b03a2e;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1b1b;
    --card: #262626;
    --text: #eeeeee;
    --muted: #a8a8a8;
    --line: #3a3a3a;
    --accent: #4fb397;
    --accent-text: #0f1f1a;
    --rec: #e8665a;
    --danger: #e8665a;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", sans-serif;
  font-size: 17px;
  line-height: 1.6;
  padding: 0 16px 48px;
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
}

main, .top { max-width: 640px; margin: 0 auto; }

.top { padding-top: calc(12px + env(safe-area-inset-top)); }
.top h1 { font-size: 20px; margin: 0; }
.today { margin: 0 0 8px; color: var(--muted); font-size: 15px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 20px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* 大きな話すボタン */
.mic-btn {
  display: block;
  width: 100%;
  min-height: 72px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 20px;
  font-weight: bold;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mic-btn[hidden] { display: none; }
.mic-btn .mic-icon { margin-right: 8px; }
.mic-btn.listening {
  background: var(--rec);
  -webkit-animation: pulse 1.4s ease-in-out infinite;
  animation: pulse 1.4s ease-in-out infinite;
}
@-webkit-keyframes pulse { 50% { opacity: .75; } }
@keyframes pulse { 50% { opacity: .75; } }

.mic-status { min-height: 1.6em; margin: 6px 0 4px; color: var(--muted); font-size: 15px; }
.mic-status.error { color: var(--danger); }

textarea {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 17px; /* 16px未満だとiPhoneで勝手に拡大されるため */
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  resize: vertical;
  -webkit-appearance: none;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }

.interim { min-height: 1.4em; margin: 4px 0 0; color: var(--muted); font-size: 15px; }

.row { display: -webkit-box; display: -webkit-flex; display: flex; margin-top: 12px; }
.row > * { -webkit-box-flex: 1; -webkit-flex: 1; flex: 1; margin-left: 8px; }
.row > *:first-child { margin-left: 0; }

.btn {
  display: block;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: bold; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); background: transparent; }
.btn:disabled { opacity: .5; }

.file-btn { position: relative; overflow: hidden; line-height: 26px; }
.file-btn input { position: absolute; left: 0; top: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }

.hint { color: var(--muted); font-size: 15px; margin: 8px 0 0; }
.hint.small { font-size: 13px; }
.hint[hidden] { display: none; }

.section-title { font-size: 17px; margin: 8px 0 8px; }
.count { color: var(--muted); font-weight: normal; font-size: 15px; }

.day-head { font-size: 15px; color: var(--muted); margin: 16px 0 6px; font-weight: bold; }

.entry {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  font: inherit;
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.entry-time { display: block; color: var(--muted); font-size: 13px; }
.entry-text { display: block; white-space: pre-wrap; word-break: break-word; }

.empty { color: var(--muted); text-align: center; padding: 24px 0; }

.backup h2 { font-size: 17px; margin: 0; }
/* バックアップのボタンは縦に並べる（小さい画面でも文字が折り返さないように） */
.backup .row { display: block; }
.backup .row > * { width: 100%; margin: 8px 0 0; }

/* 編集ダイアログ（<dialog>は古いiOSで使えないためdivで実装） */
.editor {
  position: fixed; left: 0; top: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, .45);
  padding: 16px;
  padding-top: calc(16px + env(safe-area-inset-top));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 10;
}
.editor[hidden] { display: none; }
.editor-box {
  max-width: 640px; margin: 0 auto;
  background: var(--card); border-radius: 14px; padding: 16px;
}
.editor-box h2 { font-size: 18px; margin: 0; }

.toast {
  position: fixed; left: 16px; right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 480px; margin: 0 auto;
  background: #333; color: #fff;
  padding: 12px 16px; border-radius: 10px;
  text-align: center; font-size: 15px;
  z-index: 20;
}
.toast[hidden] { display: none; }
