:root {
  --bg: #f0f2f5;
  --panel: #ffffff;
  --line: #dcdcde;
  --text: #1d2327;
  --muted: #50575e;
  --accent: #2271b1;
  --accent-soft: #f0f6fc;
  --success-bg: #edf7ed;
  --success-line: #59a05a;
  --error-bg: #fcebec;
  --error-line: #cc1818;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Yu Gothic UI", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  height: 48px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
}

.topbar-inner {
  width: 100%;
  padding: 0 16px;
}

.logo {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 48px);
}

.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 16px 10px;
}

.menu-title {
  color: var(--muted);
  font-size: 12px;
  margin: 0 8px 8px;
}

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

.menu-item {
  display: block;
  text-decoration: none;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 4px;
}

.menu-item:hover { background: #f6f7f7; }

.menu-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.content {
  padding: 18px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
}

.label {
  color: var(--muted);
  margin: 0;
}

.value {
  margin: 0.4rem 0 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.stat-sub {
  margin: 0.35rem 0 0;
  font-size: 12px;
  line-height: 1.45;
}

.value-split {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  margin: 0.4rem 0 0;
}

.value-split-num {
  font-size: 1.5rem;
  font-weight: 700;
}

.value-split-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.value-split-sep {
  color: var(--muted);
  font-weight: 400;
}

.dashboard-schedule-panel {
  margin-bottom: 12px;
}

.dashboard-schedule-heading {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.dashboard-schedule-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.dashboard-schedule-check {
  margin: 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.btn {
  border: 1px solid var(--line);
  background: #f6f7f7;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.link-btn {
  display: inline-block;
  margin-top: 8px;
  text-decoration: none;
}
.btn.danger {
  background: #b32d2e;
  border-color: #b32d2e;
  color: #fff;
}

.input, .textarea {
  width: 100%;
  margin: 6px 0 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: #111;
}

.textarea {
  min-height: 140px;
  resize: vertical;
}

.hint { color: var(--muted); }

.article {
  border-top: 1px solid #f0f0f1;
  padding: 14px 0;
}

.article:first-child { border-top: none; }

.article-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.meta {
  color: var(--muted);
  margin-top: 2px;
  font-size: 12px;
}

.tag {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef0f2;
  margin-right: 6px;
}

.tag.category {
  background: #e9f3fb;
  color: #0a4b78;
}

.body {
  white-space: pre-wrap;
  line-height: 1.65;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
}

.image-grid img {
  width: 100%;
  border-radius: 4px;
  border: 1px solid var(--line);
}

.flash-wrap { margin-bottom: 12px; }

.flash {
  padding: 8px 10px;
  border-radius: 4px;
  margin-bottom: 8px;
  font-size: 14px;
}

.flash.success {
  background: var(--success-bg);
  border: 1px solid var(--success-line);
}

.flash.error {
  background: var(--error-bg);
  border: 1px solid var(--error-line);
}

.form h3 { margin: 1.2rem 0 0.6rem; }

.check-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.bulk-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.table th,
.table td {
  border: 1px solid var(--line);
  padding: 8px;
  vertical-align: top;
  font-size: 13px;
}

.table th {
  background: #f6f7f7;
  text-align: left;
}

.episode {
  max-width: 560px;
  white-space: pre-wrap;
  line-height: 1.5;
}

.status {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  display: inline-block;
}

.status.used {
  background: #ffe8b3;
  color: #8a4f00;
}

.status.fresh {
  background: #e7f5ea;
  color: #1e6f3d;
}

.status.archived {
  background: #eceef1;
  color: #50575e;
}
.status.failed {
  background: #fcebec;
  color: #a10000;
}

.filter-form {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-form-articles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 14px;
}

.filter-form-articles .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.filter-form-articles .field-tag {
  min-width: 200px;
  flex: 1 1 220px;
}

.filter-label {
  font-size: 12px;
  color: var(--muted);
}

.filter-input-date {
  margin: 0;
  max-width: 11rem;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

.article-tags-cell {
  max-width: 320px;
}

.pill-tag {
  display: inline-block;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, #f0f6fc 0%, #e7eef6 100%);
  border: 1px solid #c5d9ed;
  color: #0a4b78;
  margin: 0 6px 6px 0;
  line-height: 1.35;
}

.article-images-cell {
  max-width: 200px;
}

.article-images-cell .article-images-open {
  font-size: 12px;
  padding: 6px 10px;
}

/* 画像プレビュー: 全画面に近いガラス調オーバーレイ */
.modal-backdrop.article-images-modal-backdrop.open {
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.55) 0%,
    rgba(236, 242, 249, 0.72) 45%,
    rgba(248, 250, 252, 0.6) 100%
  );
  backdrop-filter: blur(22px) saturate(1.2);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
}

.article-images-modal-panel {
  width: min(1120px, 98vw);
  max-height: 94vh;
  overflow: auto;
}

.modal-backdrop.article-images-modal-backdrop.open .article-images-modal-panel {
  width: 100%;
  max-width: none;
  height: 100vh;
  max-height: none;
  border-radius: 0;
  border: none;
  border-left: 1px solid rgba(255, 255, 255, 0.75);
  border-right: 1px solid rgba(255, 255, 255, 0.75);
  display: flex;
  flex-direction: column;
  padding: 14px 16px 18px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.04), 0 32px 90px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.article-images-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.article-images-modal-head-text {
  flex: 1;
  min-width: 0;
}

.article-images-modal-title {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.45;
  color: var(--text);
}

.article-images-modal-head .btn {
  flex-shrink: 0;
}

.article-images-modal-status {
  margin: 8px 0 0;
  min-height: 1.4em;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

.article-images-modal-status.is-busy {
  color: var(--accent);
  font-weight: 600;
}

.article-images-modal-status.is-success {
  color: #1e6f3d;
  font-weight: 600;
}

.article-images-modal-status.is-error {
  color: #a10000;
  font-weight: 600;
}

.article-images-modal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

.article-images-modal-item {
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 8px;
  position: relative;
  border-radius: 8px;
}

.article-images-modal-item.is-regenerating {
  opacity: 0.92;
}

.article-images-modal-item.is-regenerating::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: linear-gradient(
    100deg,
    transparent 35%,
    rgba(255, 255, 255, 0.55) 50%,
    transparent 65%
  );
  background-size: 220% 100%;
  animation: article-img-shimmer 1.1s ease-in-out infinite;
  pointer-events: none;
}

@keyframes article-img-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.article-images-modal-img {
  width: 100%;
  flex: 1;
  min-height: 0;
  max-height: none;
  height: auto;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fbfcfe 0%, #f0f4f8 100%);
}

.article-images-modal-img.is-image-flash {
  animation: article-img-pop 0.75s ease-out;
}

@keyframes article-img-pop {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 113, 177, 0.45);
    filter: brightness(1.08);
  }
  100% {
    box-shadow: 0 0 0 20px rgba(34, 113, 177, 0);
    filter: brightness(1);
  }
}

.article-images-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  flex-shrink: 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal-backdrop.open {
  display: flex;
}

.modal-panel {
  width: min(560px, 92vw);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
}

@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--line); }
  .stats, .grid-2 { grid-template-columns: 1fr; }
  .image-grid { grid-template-columns: 1fr; }
  .filter-form { grid-template-columns: 1fr; }
  .article-images-modal-grid {
    grid-template-columns: 1fr;
  }
}

/* 管理者ページ: 接続（ほぼ固定）と運用調整の視覚的分離 */
.admin-intro-panel {
  margin-bottom: 14px;
}

.admin-page-head h2 {
  margin: 0 0 6px;
  font-size: 1.25rem;
}

.admin-page-lead {
  margin: 0;
  line-height: 1.55;
  max-width: 56rem;
}

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

.admin-tab-shell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
}

.admin-tab {
  flex: 1 1 160px;
  max-width: 320px;
  margin: 0;
  padding: 12px 16px 10px;
  border: none;
  border-bottom: 3px solid transparent;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.admin-tab:hover {
  background: #f0f1f3;
  color: var(--text);
}

.admin-tab[aria-selected="true"] {
  background: #fff;
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.admin-tab--ops[aria-selected="true"] {
  color: #1d2327;
  border-bottom-color: #646970;
}

.admin-tab-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.admin-tab-badge--stable {
  background: var(--accent-soft);
  color: var(--accent);
}

.admin-tab-badge--ops {
  background: #f0f1f3;
  color: #50575e;
  border: 1px solid var(--line);
}

.admin-tab-panels {
  padding: 16px;
  background: #fff;
}

.admin-tab-panel {
  min-height: 120px;
}

.admin-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px 16px;
  margin: 0 0 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.admin-section-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.form h3.admin-section-title {
  margin: 0;
}

.admin-section-desc {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
  max-width: 56rem;
}

.admin-subheading {
  margin: 1.1rem 0 0.45rem;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.admin-tab-panel .admin-subheading:first-of-type {
  margin-top: 0;
}

.admin-form-actions {
  margin-top: 2px;
}

.article-eyecatch-title {
  margin: 14px 0 8px;
  font-size: 15px;
  font-weight: 600;
}

.article-eyecatch {
  margin-bottom: 18px;
}

.article-body-title {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
}

.article-republish-title {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 0.35rem 0 0.75rem;
  color: var(--text);
}

.article-body-html {
  white-space: normal;
  line-height: 1.75;
  color: var(--text);
  max-width: 52rem;
}

.article-body-html .title-h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 1.35rem 0 0.55rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--line);
  color: #0a4b78;
}

.article-body-html .title-h2:first-child {
  margin-top: 0.35rem;
}

.article-body-html p {
  margin: 0 0 0.9rem;
  line-height: 1.8;
}

.source-excerpt {
  color: var(--muted);
}
