/* ===== リセット & 変数 ===== */
*, *::before, *::after {
  margin: 0; padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --orange:       #F59E0B;
  --orange-dark:  #D97706;
  --orange-light: #FCD34D;
  --orange-pale:  #FEF3C7;
  --cream:        #FFFDF7;
  --white:        #FFFFFF;
  --text:         #3D2D1A;
  --muted:        #92745A;
  --border:       rgba(245,158,11,0.2);
  --shadow-sm:    0 2px 8px rgba(180,120,20,0.10);
  --shadow-md:    0 6px 24px rgba(180,120,20,0.14);
  --shadow-lg:    0 12px 40px rgba(180,120,20,0.20);
  --radius:       16px;
  --bnav-h:       72px;
}

body {
  font-family: 'Zen Maru Gothic', 'Noto Sans JP', sans-serif;
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== 認証画面 ===== */
.auth-screen {
  display: none;
  position: fixed; inset: 0;
  z-index: 200;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.auth-screen.active { display: flex; }

.auth-bg {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, #FFA96B 0%, #FFCC80 50%, #FFE8A3 100%);
}

.auth-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.45;
  animation: blobFloat 8s ease-in-out infinite;
}
.blob1 { width: 320px; height: 320px; background: #FFBA6B; top: -60px; left: -80px; animation-delay: 0s; }
.blob2 { width: 260px; height: 260px; background: #FFD98C; bottom: -60px; right: -40px; animation-delay: 3s; }
.blob3 { width: 200px; height: 200px; background: #FFF0B8; top: 38%; left: 48%; animation-delay: 1.5s; }

@keyframes blobFloat {
  0%,100% { transform: translate(0,0) scale(1); }
  50%      { transform: translate(20px,-20px) scale(1.08); }
}

.auth-card {
  position: relative;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 40px 32px 36px;
  border-radius: 28px;
  box-shadow: 0 20px 60px rgba(180,100,20,0.22), 0 0 0 1px rgba(255,255,255,0.6);
  text-align: center;
  width: 90%; max-width: 340px;
  animation: authCardIn 0.6s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes authCardIn {
  from { opacity: 0; transform: translateY(30px) scale(0.92); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes authShake {
  0%,100% { transform: translateX(0); }
  20%,60% { transform: translateX(-8px); }
  40%,80% { transform: translateX(8px); }
}

.auth-icon  { font-size: 52px; margin-bottom: 8px; display: block; }
.auth-title { font-size: 26px; font-weight: 700; color: var(--orange-dark); margin-bottom: 4px; }
.auth-sub   { font-size: 13px; color: var(--muted); margin-bottom: 22px; font-weight: 300; }

/* ===== ユーザー選択 ===== */
.user-select-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.user-select {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.user-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border: 2px solid var(--border);
  border-radius: 16px;
  background: rgba(255,255,255,0.7);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.user-btn:active { transform: scale(0.95); }
.user-btn.selected {
  border-color: var(--orange);
  background: var(--orange-pale);
  box-shadow: 0 0 0 3px rgba(245,158,11,0.2);
}
.user-emoji { font-size: 32px; line-height: 1; }
.user-name  { font-size: 13px; font-weight: 700; color: var(--text); }

/* ===== パスワード ===== */
.password-wrap {
  position: relative;
  margin-bottom: 16px;
}
.password-input {
  width: 100%;
  padding: 14px 48px 14px 18px;
  border: 2px solid var(--border);
  border-radius: 14px;
  font-size: 16px;
  font-family: inherit;
  background: rgba(255,255,255,0.8);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  text-align: center;
}
.password-input:focus {
  border-color: var(--orange-light);
  box-shadow: 0 0 0 4px var(--orange-pale);
}
.eye-btn {
  position: absolute; right: 14px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  font-size: 18px; cursor: pointer; padding: 4px;
  user-select: none; line-height: 1;
}

.btn-login {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, var(--orange) 0%, var(--orange-dark) 100%);
  color: white;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(245,158,11,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-login:hover  { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(245,158,11,0.5); }
.btn-login:active { transform: translateY(0); }

.auth-error {
  color: #D97706;
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
  font-weight: 500;
}

/* ===== メインアプリ ===== */
.main-app {
  display: none;
  min-height: 100vh;
  padding-bottom: var(--bnav-h);
}
.main-app.active { display: block; }

/* ===== ヘッダー ===== */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: rgba(255,253,247,0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.header-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--orange-dark);
  display: flex;
  align-items: center;
  gap: 6px;
}
.header-icon { font-size: 20px; }

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-user {
  font-size: 12px;
  font-weight: 600;
  color: var(--orange-dark);
  background: var(--orange-pale);
  padding: 4px 10px;
  border-radius: 20px;
}
.logout-btn {
  background: none; border: none;
  color: var(--muted); font-size: 12px;
  cursor: pointer; padding: 6px 8px;
  border-radius: 8px;
  font-family: inherit;
  transition: background 0.2s;
}
.logout-btn:hover { background: var(--orange-pale); }

/* ===== ページ共通 ===== */
.page { display: none; animation: pageIn 0.28s ease; }
.page.active { display: block; }

@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page-inner {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 24px;
}

.page-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.page-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--orange-dark);
}

.topic-count {
  background: var(--orange);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
}
.topic-count.empty { display: none; }

/* ===== トピックリスト ===== */
.topics-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ===== トピックカード ===== */
.topic-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid transparent;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  animation: cardIn 0.35s cubic-bezier(0.34,1.2,0.64,1) both;
}
.topic-card:hover  { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.topic-card:active { transform: scale(0.98); }

.topic-card.urgent {
  border-left-color: #EF4444;
  background: linear-gradient(to right, #FFF5F5, var(--white));
}
.topic-card.resolved {
  border-left-color: #52B788;
  cursor: default;
  opacity: 0.88;
}
.topic-card.resolved:hover { transform: none; box-shadow: var(--shadow-sm); }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.topic-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 6px;
}

.topic-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ===== バッジ ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-urgent {
  background: #FEE2E2;
  color: #EF4444;
}
.resolved-badge {
  font-size: 11px;
  color: #52B788;
  font-weight: 700;
}

.topic-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 8px;
  word-break: break-all;
}

.topic-meta {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}

.resolution-memo {
  font-size: 12px;
  color: #52B788;
  background: #EEFBF4;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  line-height: 1.5;
  word-break: break-all;
}

/* ===== 話し合いに戻すボタン ===== */
.btn-reopen {
  display: inline-block;
  margin-top: 10px;
  padding: 6px 12px;
  background: none;
  border: 1.5px solid #D1D5DB;
  border-radius: 20px;
  font-size: 12px;
  font-family: inherit;
  color: #6B7280;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.btn-reopen:hover {
  border-color: var(--orange);
  color: var(--orange-dark);
  background: var(--orange-pale);
}
.btn-reopen:active { transform: scale(0.97); }

/* ===== 空っぽ状態 ===== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
}
.empty-icon  { font-size: 48px; margin-bottom: 12px; }
.empty-title { font-size: 15px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.empty-sub   { font-size: 13px; color: var(--muted); font-weight: 300; }

/* ===== ボトムナビ ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bnav-h);
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 20px rgba(180,120,20,0.08);
}
.bnav-btn {
  flex: 1;
  background: none; border: none;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px;
  cursor: pointer;
  padding: 8px 4px;
  transition: transform 0.15s;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  font-family: inherit;
}
.bnav-btn:active { transform: scale(0.9); }
.bnav-icon  { font-size: 22px; line-height: 1; }
.bnav-label { font-size: 10px; color: var(--muted); font-weight: 500; }

.bnav-btn[data-page].active .bnav-label { color: var(--orange-dark); font-weight: 700; }
.bnav-btn[data-page].active::after {
  content: '';
  position: absolute; top: 0; left: 20%; right: 20%; height: 3px;
  background: var(--orange);
  border-radius: 0 0 4px 4px;
}

/* 追加ボタン（中央） */
.add-btn {
  position: relative;
}
.add-icon {
  display: flex; align-items: center; justify-content: center;
  width: 46px; height: 46px;
  background: linear-gradient(135deg, var(--orange), var(--orange-dark));
  color: white; border-radius: 50%;
  font-size: 24px; font-weight: 300; line-height: 1;
  box-shadow: 0 4px 14px rgba(245,158,11,0.45);
  transition: transform 0.15s, box-shadow 0.15s;
}
.add-btn:active .add-icon {
  transform: scale(0.88);
  box-shadow: 0 2px 6px rgba(245,158,11,0.3);
}

/* ===== モーダル ===== */
.modal-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 300;
  background: rgba(30,18,0,0.55);
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-overlay.active {
  display: flex;
  animation: overlayIn 0.25s ease;
}
@keyframes overlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-card {
  background: var(--white);
  border-radius: 24px 24px 0 0;
  width: 100%; max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: sheetUp 0.32s cubic-bezier(0.34,1.2,0.64,1);
  padding-bottom: env(safe-area-inset-bottom);
}
@keyframes sheetUp {
  from { transform: translateY(100%); opacity: 0.5; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 20px 0;
  position: sticky; top: 0;
  background: var(--white);
  z-index: 1;
}
.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.modal-close {
  background: #F3F4F6;
  border: none;
  border-radius: 50%;
  width: 32px; height: 32px;
  font-size: 14px; font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  transition: background 0.15s;
}
.modal-close:hover { background: #E5E7EB; }

.modal-body {
  padding: 16px 20px 28px;
}

/* ===== フォーム ===== */
.form-group { margin-bottom: 20px; }

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--orange-dark);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 13px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  background: var(--cream);
  outline: none;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus {
  border-color: var(--orange-light);
  box-shadow: 0 0 0 4px var(--orange-pale);
}

.form-textarea {
  width: 100%;
  padding: 13px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--cream);
  outline: none;
  color: var(--text);
  resize: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  line-height: 1.6;
}
.form-textarea:focus {
  border-color: var(--orange-light);
  box-shadow: 0 0 0 4px var(--orange-pale);
}

/* ===== カテゴリチップ ===== */
.cat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.cat-chip {
  padding: 8px 14px;
  border: 2px solid var(--border);
  border-radius: 20px;
  background: var(--cream);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.12s;
  color: var(--text);
  font-weight: 500;
}
.cat-chip:active { transform: scale(0.95); }
.cat-chip.selected {
  border-color: var(--orange);
  background: var(--orange-pale);
  color: var(--orange-dark);
}

/* ===== 優先度トグル ===== */
.priority-toggle {
  display: flex;
  gap: 8px;
}
.priority-btn {
  flex: 1;
  padding: 11px 8px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--cream);
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.priority-btn.active {
  border-color: var(--orange);
  background: var(--orange-pale);
  color: var(--orange-dark);
}
.priority-btn#priorityUrgent.active {
  border-color: #EF4444;
  background: #FEE2E2;
  color: #DC2626;
}

/* ===== 送信ボタン ===== */
.btn-submit {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, var(--orange) 0%, var(--orange-dark) 100%);
  color: white;
  border: none;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(245,158,11,0.38);
  transition: transform 0.15s, box-shadow 0.15s;
  margin-top: 4px;
}
.btn-submit:hover  { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(245,158,11,0.48); }
.btn-submit:active { transform: translateY(0); }
.btn-submit:disabled { background: linear-gradient(135deg, #ccc, #aaa); box-shadow: none; transform: none; cursor: not-allowed; }

.btn-submit.btn-resolve {
  background: linear-gradient(135deg, #52B788 0%, #40916C 100%);
  box-shadow: 0 6px 20px rgba(82,183,136,0.38);
}
.btn-submit.btn-resolve:hover { box-shadow: 0 10px 28px rgba(82,183,136,0.48); }

.form-error {
  color: #DC2626;
  font-size: 12px;
  margin-bottom: 8px;
  min-height: 16px;
  font-weight: 500;
}

/* ===== トピック詳細 ===== */
.topic-detail-badges {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.topic-detail-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 10px;
  word-break: break-all;
}
.topic-detail-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 20px;
}

.topic-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}
.btn-resolve-action {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #52B788, #40916C);
  color: white;
  border: none;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(82,183,136,0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-resolve-action:hover  { transform: translateY(-2px); }
.btn-resolve-action:active { transform: scale(0.97); }

.btn-delete-action {
  width: 100%;
  padding: 13px;
  background: none;
  color: #9CA3AF;
  border: 2px solid #E5E7EB;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.btn-delete-action:hover {
  border-color: #EF4444;
  color: #EF4444;
  background: #FEF2F2;
}

/* ===== 解決モーダル ===== */
.resolve-topic-summary {
  background: var(--orange-pale);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 18px;
}
.resolve-topic-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--orange-dark);
  line-height: 1.5;
  word-break: break-all;
}

/* ===== セレブレーション ===== */
.celebration {
  display: none;
  position: fixed; inset: 0; z-index: 400;
  pointer-events: none;
  justify-content: center;
  align-items: center;
}
.celebration.active {
  display: flex;
  animation: celebFadeInOut 2s ease forwards;
}
@keyframes celebFadeInOut {
  0%   { opacity: 0; }
  20%  { opacity: 1; }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}
.celebration-inner {
  background: rgba(255,255,255,0.95);
  border-radius: 24px;
  padding: 28px 36px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  animation: celebBounce 0.5s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes celebBounce {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.celebration-emoji { font-size: 52px; margin-bottom: 8px; }
.celebration-text  { font-size: 18px; font-weight: 700; color: var(--orange-dark); }

/* ===== ローディング / エラー ===== */
.loading-msg { color: var(--muted); font-size: 14px; padding: 32px; text-align: center; }
.error-msg   { color: #EF4444; font-size: 13px; padding: 16px; text-align: center; }

/* ===== アニメーション共通 ===== */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== レスポンシブ ===== */
@media (min-width: 640px) {
  .modal-card {
    border-radius: 24px;
    margin-bottom: 20px;
    max-height: 85vh;
  }
  .modal-overlay { align-items: center; padding: 20px; }
  .topic-card:hover { transform: translateY(-3px); }
}
