/* 音声ログ＋クイックメモ — あるの世界観 */

:root {
  --pearl: #faf8fc;
  --pearl-deep: #f0eaf7;
  --lavender: #c9b8e8;
  --lavender-soft: #e8dff5;
  --pink: #f5d4e8;
  --pink-soft: #fceef6;
  --gold: #d4b86a;
  --gold-soft: #f0e6c8;
  --text: #4a3f5c;
  --text-muted: #8a7f9a;
  --glass: rgba(255, 255, 255, 0.55);
  --glass-border: rgba(255, 255, 255, 0.75);
  --shadow: 0 8px 32px rgba(180, 150, 210, 0.18);
  --radius: 20px;
  --mic-idle: linear-gradient(145deg, #e8dff5 0%, #d4c4eb 50%, #c9b8e8 100%);
  --mic-active: linear-gradient(145deg, #f5a8c8 0%, #e890b8 50%, #d878a8 100%);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(232, 223, 245, 0.9), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(245, 212, 232, 0.5), transparent),
    radial-gradient(ellipse 50% 30% at 0% 80%, rgba(212, 184, 106, 0.15), transparent),
    linear-gradient(180deg, var(--pearl) 0%, var(--pearl-deep) 100%);
  padding: env(safe-area-inset-top) 16px calc(24px + env(safe-area-inset-bottom));
  line-height: 1.5;
}

/* 控えめキラキラ */
.sparkles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(212, 184, 106, 0.6), transparent),
    radial-gradient(1px 1px at 30% 60%, rgba(201, 184, 232, 0.5), transparent),
    radial-gradient(1.5px 1.5px at 70% 15%, rgba(245, 212, 232, 0.6), transparent),
    radial-gradient(1px 1px at 85% 45%, rgba(212, 184, 106, 0.4), transparent),
    radial-gradient(1px 1px at 50% 85%, rgba(201, 184, 232, 0.4), transparent),
    radial-gradient(1px 1px at 92% 78%, rgba(245, 212, 232, 0.5), transparent);
  opacity: 0.7;
  z-index: 0;
}

/* ヘッダー */
.header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0 8px;
}

.header-text {
  flex: 1;
}

.header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, #6b5b7a 0%, #9b7bb8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.mascot {
  width: 48px;
  height: 48px;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(180, 150, 210, 0.3));
  flex-shrink: 0;
}

.settings-btn {
  flex-shrink: 0;
}

main {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ガラスカード */
.card {
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 18px;
}

.section-title {
  margin: 0 0 12px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.subsection-title {
  margin: 16px 0 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* マイクボタン */
.voice-section {
  text-align: center;
}

.live-text-wrap {
  margin-bottom: 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 14px;
  border: 1px solid rgba(201, 184, 232, 0.4);
  text-align: left;
}

.live-label {
  margin: 0 0 4px;
  font-size: 0.72rem;
  color: #d878a8;
  font-weight: 600;
}

.live-text {
  margin: 0;
  font-size: 0.95rem;
  min-height: 1.4em;
  word-break: break-word;
}

.mic-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: min(72vw, 200px);
  height: min(72vw, 200px);
  margin: 8px auto 20px;
  border: none;
  border-radius: 50%;
  background: var(--mic-idle);
  box-shadow:
    0 8px 24px rgba(180, 150, 210, 0.35),
    inset 0 2px 4px rgba(255, 255, 255, 0.6),
    inset 0 -2px 4px rgba(150, 120, 180, 0.15);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.mic-btn:active {
  transform: scale(0.96);
}

.mic-btn.recording {
  background: var(--mic-active);
  box-shadow:
    0 0 0 6px rgba(245, 168, 200, 0.25),
    0 8px 28px rgba(232, 144, 184, 0.45),
    inset 0 2px 4px rgba(255, 255, 255, 0.4);
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 6px rgba(245, 168, 200, 0.25), 0 8px 28px rgba(232, 144, 184, 0.45); }
  50% { box-shadow: 0 0 0 12px rgba(245, 168, 200, 0.12), 0 8px 28px rgba(232, 144, 184, 0.45); }
}

.mic-icon {
  font-size: 2.4rem;
  line-height: 1;
}

.mic-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.mic-btn.recording .mic-label {
  color: #fff;
}

/* ログ一覧 */
.log-list,
.memo-list,
.dict-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.log-item {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(201, 184, 232, 0.25);
  text-align: left;
}

.log-item:last-child {
  border-bottom: none;
}

.log-time {
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--lavender);
  min-width: 2.8em;
  padding-top: 2px;
}

.log-text {
  flex: 1;
  font-size: 0.9rem;
  word-break: break-word;
}

.empty-msg {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
  padding: 8px 0;
}

.empty-msg[hidden] {
  display: none;
}

/* クイックメモ */
.memo-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.memo-input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid rgba(201, 184, 232, 0.5);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.65);
  font-size: 1rem;
  color: var(--text);
  outline: none;
}

.memo-input:focus {
  border-color: var(--lavender);
  box-shadow: 0 0 0 3px rgba(201, 184, 232, 0.25);
}

.memo-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(201, 184, 232, 0.25);
}

.memo-item:last-child {
  border-bottom: none;
}

.memo-item.checked .memo-text {
  text-decoration: line-through;
  opacity: 0.5;
}

.memo-check {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-top: 2px;
  accent-color: var(--lavender);
}

.memo-text {
  flex: 1;
  font-size: 0.9rem;
  word-break: break-word;
  padding-top: 2px;
}

.memo-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* ボタン共通 */
.icon-btn {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(201, 184, 232, 0.4);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.6);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.icon-btn:active,
.add-btn:active,
.export-btn:active {
  transform: scale(0.97);
}

.memo-mic-btn.recording {
  background: var(--pink);
  border-color: #e890b8;
}

.add-btn {
  padding: 12px 16px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--lavender-soft) 0%, var(--lavender) 100%);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.add-btn.small {
  padding: 10px 14px;
  font-size: 0.82rem;
}

.delete-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: rgba(245, 212, 232, 0.5);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
}

/* 週ログへ渡す */
.export-btn {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--gold-soft) 0%, rgba(212, 184, 106, 0.45) 100%);
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(212, 184, 106, 0.25);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.export-hint {
  margin: 10px 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* 設定ダイアログ */
.settings-dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: calc(100vw - 32px);
  width: 420px;
  background: transparent;
  box-shadow: none;
}

.settings-dialog::backdrop {
  background: rgba(74, 63, 92, 0.35);
  backdrop-filter: blur(4px);
}

.dialog-inner {
  background: var(--pearl);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 18px;
  max-height: 80dvh;
  overflow-y: auto;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.dialog-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.close-btn {
  width: 36px;
  height: 36px;
  font-size: 0.9rem;
}

.dict-section {
  margin-bottom: 20px;
}

.dict-section h3 {
  margin: 0 0 6px;
  font-size: 0.9rem;
}

.dict-hint {
  margin: 0 0 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.dict-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(201, 184, 232, 0.2);
  font-size: 0.88rem;
}

.dict-add-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.dict-add-row input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid rgba(201, 184, 232, 0.5);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  font-size: 0.88rem;
}

.replace-row {
  flex-wrap: wrap;
}

.replace-row input {
  flex: 1 1 40%;
}

.arrow {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* トースト */
.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: rgba(74, 63, 92, 0.88);
  color: #fff;
  padding: 12px 20px;
  border-radius: 14px;
  font-size: 0.85rem;
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  z-index: 100;
  pointer-events: none;
  max-width: calc(100vw - 32px);
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
