:root {
  --primary: #0095f6;
  --primary-dark: #0077c2;
  --danger: #e0245e;
  --warn: #d98026;
  --warn-bg: #fff6e5;
  --warn-border: #f5d18a;
  --info: #1a7fd4;
  --info-bg: #e7f3ff;
  --info-border: #b9ddf7;
  --ok: #2a7a48;
  --ok-bg: #e7f6ed;
  --bg: #ffffff;
  --bg-muted: #f7f8fa;
  --bg-hover: #eef1f5;
  --border: #e4e7ec;
  --border-strong: #cfd4db;
  --text: #1f2933;
  --text-muted: #6b7280;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  color: var(--text);
  background: var(--bg-muted);
  line-height: 1.6;
  font-size: 14px;
}

/* ==========================================================
   ヘッダー
   ========================================================== */
.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.app-header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}
.header-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}
.header-btn {
  background: white;
  border: 1px solid #d0d7de;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  color: #333;
}
.header-btn:hover {
  background: #f0f7ff;
  border-color: #0095f6;
  color: #0066c0;
}
.hamburger {
  display: none;
  background: transparent;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text);
}

/* ==========================================================
   レイアウト：サイドバー+メイン
   ========================================================== */
.layout {
  display: flex;
  min-height: calc(100vh - 54px);
}

.sidebar {
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding: 10px 8px;
  gap: 10px;
  overflow-y: auto;
  max-height: calc(100vh - 54px);
  position: sticky;
  top: 54px;
}

.main-panel {
  flex: 1;
  min-width: 0;
  padding: 16px 20px;
}

@media (max-width: 768px) {
  .hamburger { display: inline-block; }
  .sidebar {
    position: fixed;
    top: 54px;
    left: 0;
    bottom: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.2s;
    width: 82%;
    max-width: 320px;
    max-height: calc(100vh - 54px);
    box-shadow: 2px 0 8px rgba(0,0,0,0.08);
  }
  .sidebar.open { transform: translateX(0); }
  .main-panel { padding: 16px; }
}

/* ==========================================================
   サイドバー：アカウント一覧
   ========================================================== */
.sidebar-hint {
  padding: 14px 12px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  line-height: 1.7;
}

.account-item {
  position: relative;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s, border-color 0.12s;
}
.account-item:last-child {
  border-bottom: none;
}
.account-item:hover { background: var(--bg-hover); }
.account-item.active {
  background: var(--info-bg);
  border-color: var(--info-border);
}
.account-item.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 4px;
  background: var(--primary);
  border-radius: 2px;
}

.account-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.account-name {
  font-weight: 700;
  font-size: 14px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-status-icon { font-size: 14px; }

.account-meta {
  display: flex;
  gap: 10px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

/* 三点リーダーメニュー */
.account-menu-wrap {
  position: relative;
  margin-left: auto;
  flex-shrink: 0;
}
.account-menu-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
}
.account-menu-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.account-menu-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 30;
  min-width: 100px;
  overflow: hidden;
}
.account-menu-dropdown.open { display: block; }
.account-menu-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
}
.account-menu-dropdown button:hover { background: var(--bg-muted); }
.account-menu-dropdown button.danger { color: var(--danger); }
.account-menu-dropdown button.danger:hover { background: #fdeef3; }

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  padding: 3px 8px;
  color: var(--text);
}
.icon-btn:hover { background: var(--bg-muted); }
.icon-btn.danger { color: var(--danger); border-color: #f3c4d5; }
.icon-btn.danger:hover { background: #fdeef3; }

.btn-full { width: 100%; }

/* ==========================================================
   メインパネル
   ========================================================== */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
  flex-wrap: wrap;
}
.panel-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}
.panel-sub {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
}
.panel-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* 情報バナー */
.banner {
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  line-height: 1.6;
}
.banner.info { background: var(--info-bg); border: 1px solid var(--info-border); color: var(--info); }
.banner.warn { background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn); }
.banner.danger { background: #fdeef3; border: 1px solid #f3c4d5; color: var(--danger); }
.banner .banner-text { flex: 1; }
.banner button { white-space: nowrap; }

/* タブ */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  overflow: visible;
}
.tab {
  padding: 8px 14px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: inherit;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 700;
}

/* 並び替え */
.sort-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.sort-bar .sort-delete-all {
  margin-left: auto;
}
.btn-danger-outline {
  background: white;
  border: 1px solid #e74c3c;
  color: #c0392b;
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.btn-danger-outline:hover {
  background: #fdecea;
}
.sort-btn {
  padding: 5px 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
}
.sort-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ==========================================================
   空状態
   ========================================================== */
.empty-state {
  text-align: center;
  padding: 30px 16px;
  color: var(--text-muted);
}
.empty-state .emoji { font-size: 40px; display: block; margin-bottom: 14px; }
.empty-state h3 { color: var(--text); margin: 0 0 8px; font-size: 18px; }
.empty-state p { margin: 8px 0; }
.empty-state pre {
  display: inline-block;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  margin-top: 10px;
  font-family: "Menlo", "Consolas", monospace;
  font-size: 13px;
  text-align: left;
  color: var(--text);
}
.empty-state .big-cta {
  display: inline-block;
  margin-top: 14px;
  padding: 14px 28px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.empty-state .big-cta:hover { background: var(--primary-dark); }
.empty-state .link-cta {
  display: inline-block;
  margin-top: 10px;
  color: var(--primary);
}

/* ==========================================================
   ウェルカム（アカウント0件）
   ========================================================== */
.welcome {
  max-width: 760px;
  margin: 20px auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.welcome-hero {
  text-align: center;
  padding: 36px 24px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.welcome-hero .emoji { font-size: 48px; display: block; margin-bottom: 8px; }
.welcome-hero h3 { margin: 0 0 10px; font-size: 22px; color: var(--text); }
.welcome-hero p { color: var(--text-muted); margin: 10px 0 18px; }

.welcome-steps {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 28px;
}
.welcome-steps h4 {
  margin: 0 0 14px;
  font-size: 16px;
  color: var(--text);
}
.welcome-steps ol {
  margin: 0;
  padding-left: 22px;
  color: var(--text);
}
.welcome-steps ol li {
  margin-bottom: 12px;
  line-height: 1.75;
}
.welcome-steps .sub {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}
.welcome-foot {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  text-align: center;
}

.external-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}
.external-link:hover { text-decoration: underline; }

/* Facebookアカウント必要の注意ボックス */
.prereq-notice {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 18px;
  color: var(--text);
}
.prereq-notice.small {
  padding: 10px 12px;
  margin: 6px 0 14px;
  border-radius: 8px;
}
.prereq-title {
  font-weight: 700;
  color: var(--warn);
  font-size: 14px;
  margin-bottom: 6px;
}
.prereq-notice p {
  margin: 4px 0;
  font-size: 13px;
  line-height: 1.7;
}
.prereq-notice.small p { font-size: 12px; line-height: 1.65; }
.prereq-sub {
  font-size: 12px !important;
  color: var(--text-muted);
  margin-top: 6px !important;
}

/* ==========================================================
   モーダル内 インラインガイド
   ========================================================== */
.inline-guide {
  margin-top: -4px;
  margin-bottom: 16px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
}
.inline-guide > summary {
  cursor: pointer;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 13px;
  user-select: none;
  color: var(--info);
  list-style: none;
}
.inline-guide > summary::-webkit-details-marker { display: none; }
.inline-guide > summary::before {
  content: "▶";
  display: inline-block;
  margin-right: 6px;
  transition: transform 0.15s;
  color: var(--text-muted);
  font-size: 10px;
}
.inline-guide[open] > summary::before { transform: rotate(90deg); }
.inline-guide-body {
  padding: 4px 16px 14px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
}
.guide-intro {
  margin: 6px 0 12px;
  padding: 10px 12px;
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.65;
  color: var(--text);
}
.guide-steps { padding-left: 20px; margin: 0; }
.guide-steps li { margin-bottom: 10px; }
.guide-steps li p { margin: 4px 0; }
.guide-steps .sub { color: var(--text-muted); font-size: 12px; }
.perm-list {
  list-style: none;
  padding: 4px 0 0;
  margin: 4px 0 0;
}
.perm-list li {
  padding: 3px 0;
  font-family: "Menlo", "Consolas", monospace;
  font-size: 12px;
}
.perm-list code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.badge-required {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid var(--warn-border);
  margin-left: 4px;
  font-family: inherit;
}
.guide-foot {
  margin: 14px 0 0;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  text-align: center;
}

/* ==========================================================
   カード（下書き・予約・履歴共通）
   ========================================================== */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

/* Queue/History/Buzz tabs: keep original spaced style */
.card-list.card-list--spaced {
  gap: 10px;
  border: none;
  border-radius: 0;
  overflow: visible;
}

.card {
  background: var(--bg);
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  transition: background 0.12s;
}
.card:last-child {
  border-bottom: none;
}
.card:hover {
  box-shadow: none;
  background: var(--bg-muted);
}

/* Spaced card list: restore original card styling */
.card-list--spaced .card {
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: box-shadow 0.12s;
}
.card-list--spaced .card:last-child {
  border-bottom: 1px solid var(--border);
}
.card-list--spaced .card:hover {
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  background: var(--bg);
}

.card.dragging { opacity: 0.4; }
.card.drag-over { border-color: var(--primary); }

.card-summary {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
}
.card-summary:hover { background: var(--bg-muted); }
.card.open .card-summary { background: var(--bg-muted); border-bottom: 1px solid var(--border); }
.card.open { box-shadow: 0 2px 6px rgba(0,0,0,0.06); }

.drag-handle {
  color: var(--text-muted);
  cursor: grab;
  font-size: 16px;
  user-select: none;
  padding-top: 2px;
  flex-shrink: 0;
}
.toggle-icon {
  color: var(--text-muted);
  font-size: 12px;
  padding-top: 3px;
  flex-shrink: 0;
  width: 14px;
}

.card-content {
  flex: 1;
  min-width: 0;
}
.card-preview {
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  word-break: break-word;
}
.card-meta {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
  align-items: center;
  flex-wrap: wrap;
}
.status-pill {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid var(--info-border);
}
.status-pill.failed, .status-pill.missed {
  background: #fdeef3;
  color: var(--danger);
  border-color: #f3c4d5;
}
.status-pill.posted { background: var(--ok-bg); color: var(--ok); border-color: #b2e3c7; }
.status-pill.immediate { background: var(--bg-muted); color: var(--text); border-color: var(--border); }
.status-pill.scheduled-pill { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }

/* 展開エリア */
.card-expanded { display: none; padding: 12px; }
.card.open .card-expanded { display: block; }

.card-textarea {
  width: 100%;
  min-height: 120px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  line-height: 1.6;
  background: var(--bg);
}
.comment-divider {
  margin: 14px 0 6px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  position: relative;
}
.comment-divider::before, .comment-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 38%;
  border-top: 1px dashed var(--border);
}
.comment-divider::before { left: 0; }
.comment-divider::after { right: 0; }

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.datetime-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.datetime-row input[type="datetime-local"] {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}

/* ==========================================================
   バズ
   ========================================================== */
.buzz-rank {
  font-weight: 700;
  color: var(--primary);
  font-size: 16px;
  flex-shrink: 0;
}
.buzz-metrics {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
  flex-wrap: wrap;
}
.buzz-metrics a { color: var(--primary); text-decoration: none; }
.buzz-metrics a:hover { text-decoration: underline; }

/* ==========================================================
   ボタン
   ========================================================== */
.btn-primary, .btn-secondary, .btn-danger, .btn-ghost, .btn-eye {
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-muted); }
.btn-danger { background: var(--bg); color: var(--danger); border-color: #f3c4d5; }
.btn-danger:hover:not(:disabled) { background: #fdeef3; }
.btn-ghost { background: transparent; color: var(--primary); border: none; padding: 6px 10px; }
.btn-ghost:hover:not(:disabled) { background: var(--info-bg); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

button:disabled { opacity: 0.55; cursor: not-allowed; }
/* API通信中（setLoadingでスピナー表示中）のボタンだけ待機カーソル */
button.is-loading:disabled { cursor: wait; }

/* スピナー */
.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 6px;
  vertical-align: -2px;
}
.spinner.dark {
  border-color: rgba(0,0,0,0.2);
  border-top-color: var(--primary);
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-center {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

/* ==========================================================
   モーダル
   ========================================================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--bg);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-small { max-width: 380px; }
.modal-content h2 { margin: 0 0 16px; font-size: 18px; }

.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field-label small { font-weight: 400; color: var(--text-muted); }
.field-hint {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.field-hint a { color: var(--primary); }
.field input[type="text"],
.field input[type="password"],
.field input[type="datetime-local"],
.field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
}
.field textarea { resize: vertical; line-height: 1.6; }

.token-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.token-input-wrap input { flex: 1; }
.btn-eye {
  border: 1px solid var(--border-strong);
  background: var(--bg);
  padding: 8px 10px;
  font-size: 14px;
}

.token-test-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.token-test-result {
  font-size: 13px;
  color: var(--text-muted);
}
.token-test-result.ok { color: var(--ok); }
.token-test-result.err { color: var(--danger); }

.modal-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
  min-height: 20px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  align-items: center;
}

.confirm-message {
  font-size: 15px;
  margin: 0 0 8px;
  line-height: 1.6;
  white-space: pre-wrap;
}

/* ==========================================================
   トースト
   ========================================================== */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  max-width: calc(100% - 40px);
}
.toast {
  background: #2d3748;
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  max-width: 420px;
  line-height: 1.6;
  animation: toast-in 0.2s ease-out;
  white-space: pre-wrap;
}
.toast.success { background: #2a7a48; }
.toast.error { background: #c0392b; }
.toast.info { background: #0b5a9e; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =============================================================
   🤖 自動生成 UI
   ============================================================= */

/* サイドバーのバッジ */
.ag-badge {
  margin-top: 4px;
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 4px;
  font-weight: 600;
  display: inline-block;
}
.ag-badge.on {
  background: #e8f4fd;
  color: #1a5276;
  border: 1px solid #c8e6fb;
}
.ag-badge.err {
  background: #fdecea;
  color: #922b21;
  border: 1px solid #f5b7b1;
}

/* メインパネル上部のステータスバー */
.ag-status-bar {
  background: #f0f7ff;
  border-left: 4px solid #0095f6;
  padding: 8px 14px;
  font-size: 13px;
  color: #1a5276;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  border-radius: 4px;
  flex-wrap: wrap;
}
.ag-status-bar .ag-sep { color: #aaa; }
.ag-status-bar .ag-last { color: #555; font-size: 12px; }

/* モーダル内の自動生成セクション */
.auto-gen-fieldset {
  border: 1px solid #d0d7de;
  border-radius: 6px;
  padding: 14px 16px;
  margin-top: 16px;
  margin-bottom: 4px;
  background: #fafbfc;
}
.auto-gen-fieldset legend {
  padding: 0 6px;
  font-weight: 700;
  color: #1a5276;
  font-size: 14px;
}
.auto-gen-fieldset .field-hint {
  display: block;
  font-size: 12px;
  color: #666;
  line-height: 1.6;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 0;
}
.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}
.ag-settings-row {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.field-inline {
  flex: 0 0 auto;
  display: flex !important;
  flex-direction: column;
  gap: 4px;
}
.field-inline .field-label {
  font-size: 12px;
  color: #555;
}
.field-inline input[type="time"],
.field-inline input[type="number"] {
  width: 120px;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
}
.field-inline input:disabled {
  background: #eee;
  color: #999;
}
.field-hint-inline {
  font-size: 11px;
  color: #777;
}
.ag-status {
  margin-top: 10px;
  font-size: 12px;
  color: #555;
  white-space: pre-wrap;
  line-height: 1.5;
}
.ag-actions {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed #ddd;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.run-now-status {
  font-size: 12px;
  line-height: 1.4;
}
.run-now-status.ok { color: #2a7a48; }
.run-now-status.err { color: #c0392b; }

/* 空状態の選択肢 */
.empty-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 520px;
  margin: 16px auto 0;
  text-align: left;
}
.empty-option {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 14px 16px;
}
.empty-option.primary {
  border-color: #0095f6;
  background: #f0f7ff;
}
.empty-option-title {
  font-weight: 700;
  margin-bottom: 6px;
  color: #1a5276;
  font-size: 14px;
}
.empty-option p {
  margin: 4px 0;
  font-size: 13px;
  color: #333;
  line-height: 1.6;
}
.empty-option pre {
  background: #2c3e50;
  color: #ecf0f1;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
  margin: 6px 0;
  overflow-x: auto;
}

/* エンジンセレクタ */
.engine-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}
.engine-option {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  background: white;
  transition: border-color 0.15s, background 0.15s;
}
.engine-option:has(input:checked) {
  border-color: #0095f6;
  background: #f0f7ff;
}
.engine-option input[type="radio"] {
  margin-top: 2px;
  width: 18px;
  height: 18px;
  cursor: pointer;
}
.engine-option-body { flex: 1; min-width: 0; }
.engine-option-title {
  font-weight: 700;
  font-size: 14px;
  color: #1a5276;
  margin-bottom: 4px;
}
.engine-option-desc {
  font-size: 12px;
  color: #444;
  line-height: 1.6;
  margin-bottom: 4px;
}
.engine-option-status {
  font-size: 12px;
  margin-top: 4px;
}
.engine-option-status.ok { color: #22643a; }
.engine-option-status.warn { color: #7a4e1a; }

/* アプリ設定モーダル */
.settings-fieldset {
  border: 1px solid #d0d7de;
  border-radius: 6px;
  padding: 14px 16px;
  margin: 10px 0 16px;
  background: #fafbfc;
}
.settings-fieldset legend {
  padding: 0 6px;
  font-weight: 700;
  color: #1a5276;
  font-size: 14px;
}
.settings-intro {
  margin-bottom: 14px !important;
  line-height: 1.7;
}
.key-status {
  display: block;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  margin-top: 4px;
  margin-bottom: 4px;
}
.key-status.ok {
  background: #e6f7eb;
  color: #22643a;
  border: 1px solid #b6e6c7;
}
.key-status.warn {
  background: #fef5e6;
  color: #7a4e1a;
  border: 1px solid #f5d9a3;
}

/* 自動生成セクションのAPIキー未設定警告 */
.ag-apikey-notice {
  background: #fef5e6;
  border: 1px solid #f5d9a3;
  border-radius: 6px;
  padding: 10px 14px;
  margin: 8px 0 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.ag-apikey-notice .notice-text {
  flex: 1;
  font-size: 13px;
  color: #7a4e1a;
  line-height: 1.6;
  min-width: 200px;
}

/* =============================================================
   Status dot indicators (replaces emoji status icons)
   ============================================================= */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}
.status-dot.warn {
  background: var(--warn);
}
.status-dot.danger {
  background: var(--danger);
}

/* =============================================================
   Bulk delete (checkbox-based)
   ============================================================= */
.draft-checkbox,
.queue-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
  accent-color: var(--primary);
}
.bulk-delete-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px 12px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  flex-wrap: wrap;
}
.bulk-delete-bar .btn-danger,
.bulk-delete-bar .btn-secondary,
.bulk-delete-bar .btn-ghost {
  font-size: 12px;
  padding: 5px 12px;
}
.bulk-delete-bar .bulk-count {
  color: var(--text);
  margin-right: 8px;
}
.bulk-delete-bar .btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.bulk-delete-bar .btn-danger:hover:not(:disabled) {
  background: #c41a4d;
  border-color: #c41a4d;
}
.bulk-delete-bar .btn-danger:disabled,
.bulk-delete-bar .btn-secondary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* =============================================================
   Character counter
   ============================================================= */
.char-count {
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.char-count.warn {
  color: var(--warn);
}
.char-count.over {
  color: var(--danger);
  font-weight: 700;
}

/* =============================================================
   Multiple comments
   ============================================================= */
.comment-item {
  position: relative;
  margin-bottom: 10px;
}
.comment-item .btn-remove-comment {
  position: absolute;
  top: 4px;
  right: 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  line-height: 1;
}
.comment-item .btn-remove-comment:hover {
  color: var(--danger);
}
.comments-list {
  margin-top: 6px;
}

/* ==========================================================
   検索ボックス（下書き・投稿済みタブ）
   ========================================================== */
.search-input {
  margin-left: auto;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  min-width: 180px;
}
.search-input:focus {
  outline: none;
  border-color: var(--primary);
}
.search-hit-count {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ==========================================================
   予約日時クイックプリセット・注意書き
   ========================================================== */
.datetime-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 6px 0 10px;
}
.preset-btn {
  padding: 5px 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
}
.preset-btn:hover { background: var(--bg-hover); }
.preset-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.preset-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.schedule-note {
  font-size: 12px;
  color: var(--warn);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 6px;
  padding: 8px 10px;
  margin: 0 0 10px;
  line-height: 1.6;
}

/* ==========================================================
   サイドバーの状態アイコン（絵文字）
   ========================================================== */
.status-icon {
  font-size: 12px;
  flex-shrink: 0;
  cursor: help;
}

/* アカウントのドラッグ並び替え */
.account-item.dragging {
  opacity: 0.5;
  background: var(--bg-hover);
}

/* サイドバー: リスト部分だけスクロールし、「＋ アカウント追加」は常に下に固定 */
.sidebar {
  overflow-y: hidden;
}
.account-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
#btn-add-account {
  flex-shrink: 0;
}

/* ホームボタン・アーカイブ */
.home-btn {
  flex-shrink: 0;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--text);
}
.home-btn:hover { background: var(--bg-hover); }
.home-btn.active { background: var(--info-bg); border-color: var(--info-border); }
.archive-toggle {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.archive-toggle:hover { color: var(--text); }
.account-item.archived .account-name { color: var(--text-muted); font-weight: 400; }

/* 投稿の数字ピル */
.metrics-pills {
  font-size: 12px;
  color: var(--text);
  background: var(--bg-muted);
  border-radius: 999px;
  padding: 2px 10px;
  white-space: nowrap;
}

/* Threads風プレビュー */
.threads-preview {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: var(--bg);
  max-height: 380px;
  overflow-y: auto;
}
.tp-post {
  display: flex;
  gap: 10px;
  padding: 8px 0;
}
.tp-post.tp-reply {
  margin-left: 18px;
  border-left: 2px solid var(--border);
  padding-left: 14px;
}
.tp-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
  font-size: 15px;
}
.tp-body { min-width: 0; flex: 1; }
.tp-user { font-weight: 700; font-size: 14px; }
.tp-time { color: var(--text-muted); font-weight: 400; font-size: 12px; margin-left: 4px; }
.tp-text {
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 2px;
}
.tp-actions {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: 2px;
}

/* ホーム画面 */
.home-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.home-heading {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 700;
}
.home-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 6px;
  border-radius: 6px;
  cursor: pointer;
  border-bottom: 1px solid var(--bg-muted);
  min-width: 0;
}
.home-row:last-child { border-bottom: none; }
.home-row:hover { background: var(--bg-hover); }
.home-row.home-past { opacity: 0.45; }
.home-time {
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  min-width: 72px;
  color: var(--primary);
}
.home-acc {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-muted);
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.home-text {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.home-alert-text { color: var(--warn); font-size: 13px; }
.home-empty { color: var(--text-muted); font-size: 13px; padding: 6px; }

/* ヘッダー右上の ⋮ メニュー */
.header-menu-btn {
  font-size: 20px;
  padding: 4px 10px;
}
.account-menu-dropdown .menu-link {
  display: block;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.account-menu-dropdown .menu-link:hover { background: var(--bg-muted); }

/* ==========================================================
   オフィス画面（Canvas製。描画は office-render.js）
   ========================================================== */
.office { padding: 0 0 4px; }

.office-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.office-h { margin: 0; font-size: 16px; font-weight: 800; display: inline; }
.office-sub { color: var(--text-muted); font-size: 11px; margin-left: 8px; }
.office-bar-right { display: flex; align-items: center; gap: 8px; }
.office-updated { color: var(--text-muted); font-size: 11px; }

.office-canvas-wrap {
  overflow-x: auto;
  border-radius: 6px;
}
#office-canvas {
  display: block;
  margin: 0 auto;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(60, 45, 20, 0.15);
}

/* ホバーツールチップ（bodyの直下に置くのでposition: fixed） */
.office-tip {
  position: fixed;
  z-index: 200;
  max-width: 320px;
  background: rgba(30, 26, 22, 0.95);
  color: #f5efe4;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 12px;
  line-height: 1.65;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}
.office-tip .tip-name { font-weight: 800; font-size: 13px; }
.office-tip .tip-user { font-weight: 400; color: #c8bfae; font-size: 11px; }
.office-tip .tip-nums { color: #d8cfbf; font-size: 11px; }
.office-tip .tip-alert {
  margin-top: 3px;
  color: #ffb0a0;
  font-weight: 700;
}

/* ==========================================================
   モザイクモード（画面録画用）＋フォロワー帯の凡例
   ========================================================== */
.privacy-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 15px;
  padding: 4px 10px;
  cursor: pointer;
  line-height: 1;
}
.privacy-btn:hover { background: var(--bg-hover); }
.privacy-btn.on {
  background: #fdeef3;
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(224, 36, 94, 0.15);
}

/* モザイク対象（アカウント名・@ユーザー名・ID）。強めのblurで判読不能にする */
body.privacy-on .mask-name {
  filter: blur(7px);
  user-select: none;
}

.office-tip .tip-masked { letter-spacing: 1px; color: #9a9285; }

.tier-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11px;
  color: var(--text-muted);
  margin: 0 2px 6px;
}
.tier-item { display: inline-flex; align-items: center; gap: 4px; }
.tier-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
  border: 1px solid rgba(0,0,0,0.15);
}

/* =============================================================
   成績表（オフィスの下: 全垢のフォロワー・月間ビュー・直近投稿の伸び）
   ============================================================= */
.sk-head { display: flex; align-items: baseline; gap: 12px; margin: 20px 0 8px; flex-wrap: wrap; }
.sk-title { font-size: 15px; }
.sk-totals { font-size: 12px; color: var(--text-muted); }
.sk-totals b { color: var(--text); font-size: 13px; font-variant-numeric: tabular-nums; }
.sk-digest {
  margin: 0 0 10px;
  padding: 8px 16px;
  font-size: 13px;
  background: #e7f3ff;
  border: 1px solid #b9ddf7;
  border-radius: 10px;
}
.sk-digest .mask-name { font-weight: 700; }
.sk-table { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.sk-thead, .sk-row {
  display: grid;
  grid-template-columns: minmax(150px, 210px) 1fr 1.25fr 1fr;
  gap: 16px;
  align-items: center;
  padding: 9px 16px;
}
.sk-thead {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg-muted);
}
.sk-row { border-bottom: 1px solid var(--border); cursor: pointer; }
.sk-row:last-child { border-bottom: none; }
.sk-row:hover { background: var(--bg-hover); }
.sk-row-alert { background: #fdecf1; }
.sk-row-alert:hover { background: #fbdde6; }
.sk-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sk-names { min-width: 0; }
.sk-n1 { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sk-n2 { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sk-avatar { border-radius: 50%; object-fit: cover; display: block; background: var(--bg-hover); flex-shrink: 0; }
.sk-avatar-fallback { display: block; text-align: center; font-weight: 700; color: var(--text-muted); }
.sk-cell { display: flex; align-items: center; gap: 10px; }
.sk-stat { min-width: 72px; }
.sk-v { font-size: 17px; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.sk-s { font-size: 11px; }
.sk-spark { display: block; flex-shrink: 0; }
.sk-chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 0 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.sk-up { color: var(--ok); }
.sk-down { color: var(--danger); }
.sk-chip.sk-up { background: var(--ok-bg); }
.sk-chip.sk-down { background: #fdecf1; }
.sk-chip.sk-flat { color: var(--text-muted); background: var(--bg-hover); }
.sk-chip.sk-new { color: var(--info); background: #e7f3ff; }
.sk-chip.sk-alert { color: var(--danger); background: #fdecf1; }
.sk-delta { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sk-muted { color: var(--text-muted); }
.sk-note { font-size: 12px; color: var(--text-muted); }
.sk-posts { display: flex; align-items: flex-end; gap: 3px; height: 36px; }
.sk-pbar { width: 14px; border-radius: 3px 3px 0 0; background: #2a78d6; min-height: 2px; }
.sk-pbar-na { background: var(--border); }
.sk-dormant-head {
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-muted);
  border-bottom: 1px solid var(--border);
  border-top: 1px solid var(--border);
}
.sk-dormant-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 7px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.sk-dormant-row:hover { background: var(--bg-hover); }
.sk-dormant-row:last-child { border-bottom: none; }
.sk-dormant-row .sk-n1 { color: var(--text); width: 150px; flex-shrink: 0; }
@media (max-width: 900px) {
  .sk-thead { display: none; }
  .sk-row { grid-template-columns: 1fr 1fr; }
  .sk-who { grid-column: 1 / -1; }
}

/* ==========================================================
   添付メディア（画像/動画つき投稿）
   ========================================================== */
.media-field { margin: 14px 0 6px; }
.media-field .field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}
.media-box {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
.media-thumb {
  max-width: 100%;
  max-height: 240px;
  border-radius: 8px;
  display: block;
  background: var(--bg-muted);
}
.media-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.media-label { font-size: 12px; color: var(--text-muted); word-break: break-all; }
.media-limits { font-size: 11px; color: var(--text-muted); }
.media-hint {
  font-size: 12px;
  color: #8a6d1a;
  background: #fdf6e3;
  border-radius: 6px;
  padding: 8px 10px;
  line-height: 1.5;
}
.media-uploading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}
.media-none { font-size: 12px; color: var(--text-muted); }
.media-info {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-muted);
  border-radius: 6px;
  padding: 8px 10px;
  margin: 8px 0;
}
.media-pill { background: #eef4ff; color: #2a5db0; }
.history-media { margin-top: 8px; }
.history-media .media-thumb { max-height: 300px; }

/* Threads風プレビュー内のメディア */
.tp-media {
  max-width: 100%;
  max-height: 200px;
  border-radius: 10px;
  margin: 6px 0;
  display: block;
}
.tp-media-video {
  background: var(--bg-muted);
  color: var(--text-muted);
  font-size: 12px;
  padding: 24px 12px;
  text-align: center;
  border-radius: 10px;
  margin: 6px 0;
}
