:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --text: #111827;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --accent: #1e3a8a;
  --accent-soft: #eef2ff;
  --success: #15803d;
  --radius-card: 12px;
  --radius-btn: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  --font: 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 20px 16px 40px;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.view[hidden] {
  display: none;
}

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
  padding: 13px 18px;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:active {
  background: #16306f;
}

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-block {
  width: 100%;
}

.ic {
  width: 20px;
  height: 20px;
  flex: none;
}

/* ---------- ログイン ---------- */
#view-login {
  justify-content: center;
  min-height: 80vh;
}

.hero {
  text-align: center;
  padding: 24px 0 8px;
}

.hero-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 18px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-mark svg {
  width: 28px;
  height: 28px;
}

.hero-title {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 8px;
}

.hero-sub {
  color: var(--text-muted);
  font-size: 15px;
  margin: 0 0 8px;
}

/* ---------- トップバー ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-label {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.topbar-user {
  font-size: 17px;
  font-weight: 700;
  margin: 2px 0 0;
}

.link-muted {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  padding: 4px;
}

.spacer {
  width: 32px;
}

/* ---------- カード ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 16px;
}

.card-head {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 10px;
}

.event-list,
.tip-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.event-list li {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.event-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.event-time {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--accent);
  min-width: 44px;
}

.event-body {
  flex: 1;
}

.event-title {
  font-size: 15px;
}

.event-loc {
  font-size: 13px;
  color: var(--text-muted);
}

.event-empty {
  color: var(--text-muted);
  font-size: 14px;
  border-bottom: none !important;
}

/* 予定を1件だけ行動計画へ追加するボタン（右端） */
.ev-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: none;
  align-self: center;
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.ev-add-btn:hover {
  background: var(--accent-soft);
}

.ev-add-btn:active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.ev-add-btn svg {
  width: 14px;
  height: 14px;
  flex: none;
}

.ev-add-btn:disabled {
  background: var(--surface);
  color: var(--text-muted);
  cursor: default;
}

/* 追加済みの予定（操作不可の淡色表示） */
.ev-added {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  align-self: center;
  color: var(--success);
  opacity: 0.7;
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}

.ev-added svg {
  width: 14px;
  height: 14px;
  flex: none;
}

.tip-card {
  background: var(--surface);
  border-color: var(--border);
}

.tip-list li {
  font-size: 14px;
  color: var(--text);
}

/* 話し方の例: 型の3分割カード */
.tip-slots {
  display: flex;
  align-items: stretch;
  gap: 4px;
  margin-bottom: 12px;
}

.tip-slot {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 5px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: center;
}

.tip-slot-label {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.2;
}

.tip-slot-value {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tip-slot-time {
  background: #eef2ff;
  border-color: #dfe4f7;
}

.tip-slot-time .tip-slot-value {
  color: #1e3a8a;
}

.tip-slot-place {
  background: #ecfdf5;
  border-color: #d1fae5;
}

.tip-slot-place .tip-slot-value {
  color: #047857;
}

.tip-slot-what {
  background: #fff7ed;
  border-color: #fed7aa;
}

.tip-slot-what .tip-slot-value {
  color: #c2410c;
}

.tip-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  color: var(--text-muted);
}

.tip-arrow svg {
  width: 14px;
  height: 14px;
}

.tip-examples {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 2px;
}

.tip-example {
  margin: 0;
  font-size: 14px;
  color: var(--text);
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tip-hl {
  border-radius: 4px;
  padding: 1px 5px;
}

.tip-hl-time {
  background: #eef2ff;
  color: #1e3a8a;
}

.tip-hl-place {
  background: #ecfdf5;
  color: #047857;
}

.tip-hl-what {
  background: #fff7ed;
  color: #c2410c;
}

.tip-note {
  margin: 10px 0 0;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ---------- 登録済みの行動計画 ---------- */
.plan-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pl-item {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.pl-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.pl-time {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--accent);
  min-width: 92px;
  font-size: 14px;
}

.pl-body {
  flex: 1;
  min-width: 0;
}

.pl-title {
  font-size: 15px;
}

.pl-loc {
  font-size: 13px;
  color: var(--text-muted);
}

.pl-actions {
  display: flex;
  gap: 2px;
  flex: none;
  align-self: center;
}

.pl-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}

.pl-icon-btn:hover {
  background: #f3f4f6;
  color: var(--text);
}

.pl-icon-btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.pl-icon-btn.confirming {
  background: #fef2f2;
  color: #b91c1c;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
}

.pl-manual {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  align-self: center;
  color: var(--text-muted);
  font-size: 12px;
}

.pl-manual svg {
  width: 14px;
  height: 14px;
  flex: none;
}

.pl-item.editing {
  display: block;
}

.pl-edit {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pl-edit-times {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pl-sep {
  color: var(--text-muted);
}

.pl-input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  width: 100%;
}

.pl-input:focus {
  outline: none;
  border-color: var(--accent);
}

.pl-time-input {
  flex: none;
  width: 118px;
}

.pl-edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.pl-save,
.pl-cancel {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 8px;
  padding: 8px 12px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}

.pl-save {
  background: var(--accent);
  color: #fff;
}

.pl-cancel {
  background: var(--surface);
  color: var(--text-muted);
  border-color: var(--border);
}

.pl-save svg,
.pl-cancel svg {
  width: 15px;
  height: 15px;
  flex: none;
}

/* ---------- 今日の予定を取り込むボタン ---------- */
#import-btn {
  display: flex;
  width: 100%;
  margin-top: 14px;
  padding: 10px 14px;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  box-shadow: none;
}

#import-btn:active {
  background: var(--accent-soft);
}

#import-btn:disabled {
  color: var(--text-muted);
  cursor: default;
}

/* display 指定が hidden 属性を打ち消さないよう明示する */
#import-btn[hidden] {
  display: none;
}

.plan-reset-btn {
  display: block;
  margin: 12px 0 0;
  padding: 6px 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.plan-reset-btn[hidden] {
  display: none;
}

.plan-reset-btn:hover {
  color: var(--text);
}

.plan-reset-btn.confirming {
  color: #b91c1c;
  font-weight: 600;
  text-decoration: none;
}

/* ---------- マイク ---------- */
.mic-area {
  text-align: center;
  padding: 12px 0 4px;
}

.mic-btn {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

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

.ic-mic {
  width: 34px;
  height: 34px;
}

.mic-btn.recording {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(30, 58, 138, 0.28);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(30, 58, 138, 0);
  }
}

.mic-hint {
  margin: 14px 0 0;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------- 確認（メイン画面内セクション） ---------- */
.confirm-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-margin-top: 12px;
}

.confirm-section[hidden] {
  display: none;
}

.confirm-head {
  margin: 4px 0 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.transcript-card {
  background: var(--surface);
}

.transcript-text {
  margin: 0;
  font-size: 15px;
  color: var(--text);
  /* 複数回録音した発話を行ごとに表示する */
  white-space: pre-line;
}

.plan-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.plan-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.plan-cat {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 3px 10px;
}

.plan-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.plan-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.plan-field label {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 44px;
}

.plan-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
}

.plan-input:focus {
  outline: none;
  border-color: var(--accent);
}

.time-input {
  flex: none;
  width: 92px;
}

.master-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--success);
}

.master-badge svg {
  width: 15px;
  height: 15px;
}

/* ---------- 日付言及の警告 ---------- */
.plan-warn {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 12px;
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
}

.plan-warn svg {
  width: 16px;
  height: 16px;
  flex: none;
  margin-top: 1px;
}

/* ---------- カード削除ボタン ---------- */
.plan-delete {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}

.plan-delete:hover {
  background: #f3f4f6;
  color: var(--text);
}

.plan-delete svg {
  width: 15px;
  height: 15px;
  flex: none;
}

.plan-empty {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 20px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.action-bar {
  display: flex;
  gap: 10px;
  position: sticky;
  bottom: 0;
  padding: 12px 0 4px;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

.action-bar .btn {
  flex: 1;
}

/* 狭い端末では縦積み（登録ボタンを上に） */
@media (max-width: 400px) {
  .action-bar {
    flex-direction: column-reverse;
  }
}

/* ---------- トースト ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 20;
  max-width: 90%;
}

/* ---------- スピナー ---------- */
.spinner,
.spinner-sm {
  display: inline-block;
  flex: none;
  border-radius: 50%;
  border: 3px solid rgba(30, 58, 138, 0.18);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

.spinner {
  width: 34px;
  height: 34px;
}

.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.spinner-white {
  border-color: rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
}

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

.mic-btn:disabled {
  cursor: default;
}

.plan-reset-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ---------- スケルトン（読み込み中） ---------- */
.event-list .skeleton-li,
.plan-list .skeleton-li {
  display: block;
  border-bottom: none;
  padding: 4px 0;
}

.skeleton-row {
  display: block;
  height: 14px;
  border-radius: 7px;
  background: #eceef1;
  animation: shimmer 1.3s ease-in-out infinite;
}

@keyframes shimmer {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}
