*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 14px;
  background: #f5f6f8;
  color: #1a1a2e;
}

/* ── Navbar ── */
.navbar {
  background: #1a1a2e;
  color: #fff;
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-inner {
  display: flex;
  align-items: center;
  gap: 32px;
  width: 100%;
}
.nav-brand {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  letter-spacing: 0.05em;
}
.nav-links { display: flex; gap: 20px; }
.nav-links a {
  color: #aab0c6;
  text-decoration: none;
  font-size: 13px;
}
.nav-links a:hover { color: #fff; }

/* ── Main ── */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 24px 48px;
}

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.page-header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── Card ── */
.card {
  background: #fff;
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.card h2 {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 600;
}
.cards-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}
.stat-card { flex: 1; text-align: center; }
.stat-label { font-size: 12px; color: #666; margin-bottom: 8px; }
.stat-value { font-size: 36px; font-weight: 700; color: #1a1a2e; }

/* ── Form ── */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #555;
  margin-bottom: 4px;
}
input[type="text"],
input[type="url"],
input[type="email"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: #1a1a2e;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: #4f6ef7;
  box-shadow: 0 0 0 3px rgba(79,110,247,.1);
}
textarea { resize: vertical; }
.full-width { width: 100%; }
.input-row { display: flex; gap: 8px; align-items: center; }
.input-row input { flex: 1; }
.form-actions { text-align: right; margin-top: 8px; }
.hint { font-size: 12px; color: #888; margin: -8px 0 12px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, opacity .15s;
  font-family: inherit;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: #4f6ef7; color: #fff; }
.btn-primary:hover { background: #3d5ce0; }
.btn-secondary { background: #eef0f5; color: #333; }
.btn-secondary:hover { background: #dde0ea; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── Table ── */
.table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.table th, .table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid #f0f1f4;
  font-size: 13px;
}
.table th {
  background: #f8f9fc;
  font-weight: 600;
  font-size: 12px;
  color: #555;
}
.table tr:last-child td { border-bottom: none; }
.table a { color: #4f6ef7; text-decoration: none; }
.table a:hover { text-decoration: underline; }

/* ── Badge ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.badge-draft { background: #e5e7eb; color: #555; }
.badge-scheduled { background: #dbeafe; color: #1d4ed8; }
.badge-sent { background: #d1fae5; color: #065f46; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }

/* ── Preview layout ── */
.preview-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 16px;
  align-items: start;
}
.scheduled-time { font-size: 13px; color: #555; }
.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.preview-header h2 { margin: 0; }
.preview-meta {
  font-size: 12px;
  color: #555;
  line-height: 1.8;
  padding: 8px 10px;
  background: #f8f9fc;
  border-radius: 4px;
}

/* ── Section items ── */
.section-item {
  border-left: 3px solid #4f6ef7;
  padding-left: 20px;
  margin-bottom: 16px;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.section-header h3 { margin: 0; font-size: 14px; }

.section-edit-item {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 14px;
  margin-bottom: 12px;
}
.section-edit-header { margin-bottom: 10px; }

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-content {
  background: #fff;
  border-radius: 10px;
  padding: 28px 32px;
  min-width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
}
.modal-content h2 { margin: 0 0 20px; font-size: 17px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }

/* ── Misc ── */
.empty-state {
  text-align: center;
  color: #888;
  padding: 48px 0;
  font-size: 14px;
}
.empty-state a { color: #4f6ef7; }

.alert {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
}
.alert-success { background: #d1fae5; color: #065f46; }
.alert-error { background: #fee2e2; color: #991b1b; }

.image-actions { margin-top: 6px; }
.image-preview-area img { border-radius: 4px; border: 1px solid #e5e7eb; }

/* 画像候補グリッド */
.image-candidates-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.image-candidate-thumb {
  width: 100px;
  height: 70px;
  object-fit: cover;
  border-radius: 4px;
  border: 2px solid #e5e7eb;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
}
.image-candidate-thumb:hover { border-color: #4f6ef7; transform: scale(1.03); }
.image-candidate-thumb.selected { border-color: #4f6ef7; box-shadow: 0 0 0 3px rgba(79,110,247,.25); }

@media (max-width: 900px) {
  .preview-layout { grid-template-columns: 1fr; }
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.card-title-row h2,
.card-title-row label {
  margin-bottom: 0;
}
.btn-copy {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
  font-size: 12px;
  padding: 2px 10px;
  flex-shrink: 0;
}
.btn-copy:hover { background: #e5e7eb; }

.stock-dropdown {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  margin-top: 4px;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
}
.stock-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  gap: 8px;
}
.stock-item:hover { background: #f3f4f6; }
.stock-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  color: #374151;
}
.stock-delete-btn {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 14px;
  padding: 0 4px;
  flex-shrink: 0;
}
.stock-delete-btn:hover { color: #ef4444; }
