:root {
  --account-theme: #0284c7;
  --bg-page: #f1f5f9;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-sub: #475569;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --radius-card: 16px;
  --radius-btn: 12px;
  --shadow-card: 0 2px 10px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-page);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
}

button, input, textarea {
  font-family: inherit;
  font-size: inherit;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: fixed;
  top: -9999px;
  left: -9999px;
  opacity: 0;
  pointer-events: none;
}

/* ==================== 固定ヘッダー（誤爆防止・画面幅いっぱい） ==================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg-card);
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.1);
}

.header-account-banner {
  width: 100%;
  background: var(--account-theme);
  color: #ffffff;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 3px solid rgba(0, 0, 0, 0.18);
  transition: background-color 0.25s ease;
}

.account-identity {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.account-badge {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: rgba(0, 0, 0, 0.28);
  color: #ffffff;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 3px;
}

.account-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.3);
}

/* ==================== タブ切替 ==================== */
.status-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
}

.status-tab {
  border: none;
  background: transparent;
  padding: 11px 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
}

.status-tab.active {
  color: var(--account-theme);
  border-bottom-color: var(--account-theme);
  background: rgba(2, 132, 199, 0.04);
}

.tab-count {
  font-size: 11px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
}

.status-tab.active .tab-count {
  background: var(--account-theme);
  color: #ffffff;
}

/* ==================== 媒体フィルタチップ ==================== */
.platform-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  overflow-x: auto;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  scrollbar-width: none;
}

.platform-bar::-webkit-scrollbar {
  display: none;
}

.platform-chip {
  border: 1.5px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}

.platform-chip.active {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}

.platform-chip.chip-x.active {
  background: #0f172a;
  border-color: #0f172a;
}

.platform-chip.chip-ig.active {
  background: linear-gradient(135deg, #833ab4, #fd1d1d, #fcb045);
  border-color: transparent;
}

.platform-chip.chip-th.active {
  background: #1e293b;
  border-color: #1e293b;
}

.platform-chip.chip-tt.active {
  background: #000000;
  border-color: #00f2fe;
  box-shadow: 0 0 0 1px #ff0050;
}

/* ==================== メインエリア ==================== */
.app-main {
  max-width: 600px;
  margin: 0 auto;
  padding: 12px 12px 96px;
}

/* 投稿済タブ上部 AI分析用コピーバー */
.posted-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #0f172a;
  color: #ffffff;
  padding: 11px 14px;
  border-radius: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
}

.posted-summary-text {
  font-size: 12.5px;
  font-weight: 700;
  color: #cbd5e1;
}

.btn-ai-copy {
  border: none;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
}

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

/* ==================== 投稿カード ==================== */
.posts-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.post-card {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-card);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

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

.card-badges-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.badge-platform {
  font-size: 11.5px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 6px;
  color: #ffffff;
}

.badge-platform.pf-X {
  background: #0f172a;
}

.badge-platform.pf-Instagram {
  background: linear-gradient(135deg, #833ab4, #e1306c, #f77737);
}

.badge-platform.pf-Threads {
  background: #334155;
}

.badge-platform.pf-TikTok {
  background: #000000;
  border-left: 3px solid #00f2fe;
  border-right: 3px solid #ff0050;
}

.badge-post-type {
  font-size: 11.5px;
  font-weight: 700;
  background: #f1f5f9;
  color: #334155;
  padding: 3px 8px;
  border-radius: 6px;
}

.card-schedule {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  gap: 4px;
}

.time-slot-pill {
  background: #e0f2fe;
  color: #0369a1;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

/* 仮説タグ（控えめな小バッジ） */
.hypothesis-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}

.hypothesis-tags {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.hypo-tag {
  font-size: 11px;
  color: #64748b;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 1px 7px;
  border-radius: 5px;
}

.post-id-label {
  font-size: 10.5px;
  color: #94a3b8;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* BGM・音源・投稿設定メモ（目立つ注意枠） */
.bgm-alert-box {
  background: #fffbeb;
  border: 1.5px solid #f59e0b;
  color: #92400e;
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 12.5px;
  font-weight: 700;
  display: flex;
  align-items: flex-start;
  gap: 7px;
}

/* メディアプレビュー */
.media-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
}

.media-item {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: #0f172a;
  border: 1px solid var(--border-color);
  aspect-ratio: 16 / 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.media-item img,
.media-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.media-caption-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.78);
  color: #f8fafc;
  font-size: 10.5px;
  padding: 3px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 本文プレビュー・インライン編集 */
.body-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 11px 12px;
}

.body-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.body-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.body-header-btns {
  display: flex;
  gap: 6px;
}

.btn-mini {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
  cursor: pointer;
}

.body-text-display {
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-main);
  cursor: pointer;
}

.body-text-display.collapsed {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.expand-hint {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--account-theme);
  margin-top: 4px;
  cursor: pointer;
  display: inline-block;
}

/* リプ欄・1コメ目プレビュー */
.subtext-preview {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #cbd5e1;
  font-size: 12.5px;
  color: var(--text-sub);
  white-space: pre-wrap;
  word-break: break-word;
}

.subtext-tag {
  font-size: 11px;
  font-weight: 800;
  color: #475569;
  display: block;
  margin-bottom: 2px;
}

/* インライン編集フォーム */
.inline-edit-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inline-edit-box textarea {
  width: 100%;
  border: 1.5px solid #94a3b8;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
}

.inline-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ==================== アクションボタン群（片手親指操作向け） ==================== */
.card-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-action-main {
  width: 100%;
  border: none;
  border-radius: var(--radius-btn);
  padding: 13px 14px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s ease, background-color 0.2s ease;
}

.btn-action-main:active {
  transform: scale(0.98);
}

.btn-copy-text {
  background: var(--account-theme);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(2, 132, 199, 0.25);
}

.btn-prepare-media {
  background: #0f172a;
  color: #ffffff;
}

.btn-prepare-media.loading {
  background: #334155;
  opacity: 0.9;
  cursor: wait;
}

.btn-share-ready {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.secondary-actions-row {
  display: flex;
  gap: 8px;
}

.btn-secondary-action {
  flex: 1;
  border: 1.5px solid #cbd5e1;
  background: #ffffff;
  color: #1e293b;
  border-radius: 10px;
  padding: 10px 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.btn-secondary-action:active {
  background: #f1f5f9;
}

.btn-complete-post {
  border-color: #10b981;
  background: #ecfdf5;
  color: #065f46;
}

.btn-complete-post.confirming {
  background: #059669;
  color: #ffffff;
  border-color: #059669;
}

/* フォールバック個別共有・直接保存UI */
.fallback-share-panel {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.fallback-title {
  font-size: 11.5px;
  font-weight: 700;
  color: #475569;
  margin: 0;
}

.fallback-file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #ffffff;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.fallback-filename {
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fallback-btns {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.btn-fallback-item {
  border: 1px solid #94a3b8;
  background: #f8fafc;
  color: #0f172a;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
}

/* ==================== 「投稿済」タブ：効果測定表示＆入力フォーム ==================== */
.metrics-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 9px 11px;
  flex-wrap: wrap;
}

.badge-unmeasured {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #f59e0b;
  font-size: 12px;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 999px;
}

.metrics-compact-line {
  font-size: 13px;
  font-weight: 800;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.metrics-highlight-rate {
  background: #dcfce7;
  color: #166534;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
}

.permalink-small {
  font-size: 12px;
  font-weight: 700;
  color: var(--account-theme);
  text-decoration: none;
}

.posted-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.btn-toggle-metrics {
  flex: 1;
  border: 1.5px solid var(--account-theme);
  background: #f0f9ff;
  color: #0369a1;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
  font-weight: 800;
  cursor: pointer;
}

.btn-revert-posted {
  border: 1px solid #cbd5e1;
  background: transparent;
  color: #64748b;
  border-radius: 10px;
  padding: 10px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.metrics-form-box {
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.metrics-grid-4 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.field-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.field-item label {
  font-size: 11.5px;
  font-weight: 700;
  color: #475569;
}

.field-item input,
.field-item textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  background: #ffffff;
}

.metrics-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-save-metrics {
  border: none;
  background: #059669;
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 800;
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
}

/* ==================== 空状態・ローディング ==================== */
.empty-state {
  background: #ffffff;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-card);
  padding: 36px 18px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 34px;
  margin-bottom: 8px;
}

.loading-box {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-sub);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #cbd5e1;
  border-top-color: var(--account-theme);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin: 0 auto 10px;
}

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

/* ==================== 設定モーダル ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(15, 23, 42, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(3px);
}

.modal-card {
  background: #ffffff;
  width: 100%;
  max-width: 440px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.28);
}

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

.modal-header h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
}

.modal-close-btn {
  border: none;
  background: #f1f5f9;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
}

.modal-desc {
  font-size: 12.5px;
  color: var(--text-sub);
  margin: 0 0 14px;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group label {
  font-size: 12.5px;
  font-weight: 700;
  color: #334155;
}

.form-group input {
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
}

.btn-primary-full {
  width: 100%;
  border: none;
  background: #0284c7;
  color: #ffffff;
  font-size: 14.5px;
  font-weight: 800;
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  margin-top: 4px;
}

.demo-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 16px 0 12px;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 700;
}

.demo-divider::before,
.demo-divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid #e2e8f0;
}

.demo-divider span {
  padding: 0 10px;
}

.demo-hint {
  font-size: 12px;
  color: var(--text-sub);
  margin: 0 0 10px;
}

.demo-account-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-mock {
  width: 100%;
  border: 1.5px solid #0284c7;
  background: #f0f9ff;
  color: #0369a1;
  font-size: 13.5px;
  font-weight: 800;
  padding: 11px;
  border-radius: 10px;
  cursor: pointer;
}

.btn-mock-sub {
  border-color: #7c3aed;
  background: #f5f3ff;
  color: #6d28d9;
}

.reset-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
}

.btn-danger-outline {
  width: 100%;
  border: 1px solid #fca5a5;
  background: #fef2f2;
  color: #dc2626;
  font-size: 12.5px;
  font-weight: 700;
  padding: 9px;
  border-radius: 8px;
  cursor: pointer;
}

/* ==================== トースト通知 ==================== */
.toast-container {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  width: calc(100% - 24px);
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast-item {
  pointer-events: auto;
  background: rgba(15, 23, 42, 0.96);
  color: #ffffff;
  padding: 12px 14px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13.5px;
  font-weight: 700;
  animation: toastSlideUp 0.2s ease-out;
}

.toast-undo-btn {
  border: none;
  background: #38bdf8;
  color: #0f172a;
  font-size: 12.5px;
  font-weight: 800;
  padding: 6px 11px;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
}

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