:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #d97706;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --good-bg: #dcfce7;
  --good-border: #86efac;
  --good-text: #15803d;
  --defective-bg: #fee2e2;
  --defective-border: #fca5a5;
  --defective-text: #b91c1c;
  --borderline-bg: #fef3c7;
  --borderline-border: #fcd34d;
  --borderline-text: #b45309;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Hiragino Sans', 'Meiryo', 'Yu Gothic', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
}

/* ── Header ─────────────────────────── */
.header {
  background: var(--primary);
  color: white;
  padding: 0 1rem;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}
.admin-page .header-inner {
  max-width: none;
  padding: 0 1.5rem;
  justify-content: space-between;
}
.admin-page .header-inner .logo {
  margin-right: auto;
}
.logo {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge {
  font-size: 0.65rem;
  background: rgba(255,255,255,0.2);
  padding: 2px 8px;
  border-radius: 10px;
  vertical-align: middle;
  font-weight: 400;
}

/* ── Search bar ─────────────────────── */
.search-wrap {
  flex: 0 0 auto;
  width: 600px;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.search-wrap input {
  flex: 1;
  padding: 0.45rem 0.85rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  min-width: 0;
}
#searchInput {
  height: 32px !important;
  padding: 0 0.85rem !important;
  box-sizing: border-box !important;
  vertical-align: middle !important;
}
.search-wrap input:focus { outline: 2px solid rgba(255,255,255,0.6); }

/* ── Buttons ────────────────────────── */
button, a.btn-admin, a.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.45rem 1rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-family: inherit;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn-primary, #searchBtn { background: var(--primary); color: white; }
.btn-primary:hover, #searchBtn:hover { background: var(--primary-hover); }
#searchBtn {
  padding: 0.45rem 1rem !important;
  height: 32px !important;
  align-self: center;
  flex-shrink: 0;
  font-size: 0.875rem !important;
  line-height: 1 !important;
  box-sizing: border-box;
}
.btn-secondary, #clearBtn {
  background: rgba(255,255,255,0.15);
  color: white;
}
.btn-secondary:hover, #clearBtn:hover { background: rgba(255,255,255,0.28); }
.btn-admin {
  background: rgba(255,255,255,0.15);
  color: white;
}
.btn-admin:hover { background: rgba(255,255,255,0.28); }
.btn-print-access { background: #16a34a !important; }
.btn-print-access:hover { background: #15803d !important; }
.btn-back {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-back:hover { background: var(--primary); color: white; }
.btn-print { background: var(--success); color: white; }
.btn-print:hover { background: #15803d; }
.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger:hover { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

/* ── Viewer main ────────────────────── */
.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* ── Product cards ──────────────────── */
.product-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.875rem;
}
.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.1s;
}
.product-card:hover {
  border-color: var(--primary);
  box-shadow: 0 3px 10px rgba(37,99,235,0.12);
  transform: translateY(-1px);
}
.card-sku {
  font-size: 0.75rem;
  font-family: monospace;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 7px;
  border-radius: 4px;
  display: inline-block;
}
.card-skus {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 0.4rem;
}
.card-parent-sku {
  font-size: 0.75rem;
  font-family: monospace;
  color: var(--primary);
  background: #eff6ff;
  padding: 2px 7px;
  border-radius: 4px;
}
.card-sku-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.card-name {
  font-size: 0.975rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}
.card-category { font-size: 0.8rem; color: var(--text-muted); }
.card-category-inline { font-size: 0.82rem; color: var(--text-muted); font-weight: 400; }

/* ── Empty state ────────────────────── */
.empty-state {
  grid-column: 1/-1;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}

/* ── Product detail ─────────────────── */
.product-detail { max-width: 900px; }
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

/* print title */
.print-only { display: none; }

.detail-meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}
.detail-parent-sku {
  font-family: monospace;
  font-size: 0.95rem;
  color: var(--primary);
  background: #eff6ff;
  padding: 2px 10px;
  border-radius: 4px;
}
.detail-child-skus {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
}
.sku-list-toggle {
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
}
.sku-list-toggle:hover { border-color: var(--primary); color: var(--primary); }
.sku-list-wrap {
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.sku-list-table {
  width: auto;
  min-width: 360px;
  border-collapse: collapse;
  font-size: 0.85rem;
  table-layout: fixed;
}
.sku-list-table colgroup col:nth-child(1) { width: 100px; }
.sku-list-table colgroup col:nth-child(2) { width: auto; }
.sku-list-table colgroup col:nth-child(3) { width: 100px; }
.sku-list-table colgroup col:nth-child(4) { width: 100px; }
.sku-list-table th {
  background: var(--bg);
  padding: 0.4rem 0.75rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.sku-list-table th:last-child { text-align: right; }
.sku-list-table td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sku-list-table tr:last-child td { border-bottom: none; }
.sku-list-table tr:hover td { background: var(--bg); }
.sku-list-code { font-family: monospace; color: var(--text-muted); }
.sku-list-num { text-align: right; color: var(--text-muted); }
.detail-child-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}
.detail-child-codes {
  font-family: monospace;
  color: var(--text-muted);
  line-height: 1.7;
}
.detail-name { font-size: 1.5rem; font-weight: 700; }
.detail-category { font-size: 0.85rem; color: var(--text-muted); }
.detail-updated-at { font-size: 0.78rem; color: var(--text-muted); margin-left: auto; }

.detail-overview-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.detail-overview-row .detail-overview,
.detail-overview-row .detail-notes {
  margin-top: 0;
  margin-bottom: 0;
}
.detail-overview-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}
.detail-overview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  margin-bottom: 1.5rem;
  white-space: pre-wrap;
  font-size: 0.9rem;
}

/* ── Example groups ─────────────────── */
.examples-group { margin-bottom: 1.25rem; }
.examples-group-title {
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.55rem 1rem;
  border-radius: 6px 6px 0 0;
  border: 1px solid;
  border-bottom: none;
}
.title-good    { background: var(--good-bg);       border-color: var(--good-border);       color: var(--good-text); }
.title-defective { background: var(--defective-bg); border-color: var(--defective-border); color: var(--defective-text); }
.title-borderline { background: var(--borderline-bg); border-color: var(--borderline-border); color: var(--borderline-text); }

.examples-list {
  border: 1px solid var(--border);
  border-radius: 0 0 6px 6px;
  background: var(--surface);
}
.example-item {
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.example-item:last-child { border-bottom: none; }
.example-title { font-weight: 600; margin-bottom: 0.5rem; }
.example-bullets {
  margin: 0 0 0.75rem 1.2rem;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1.8;
}
.example-bullets li { margin-bottom: 0.1rem; }
.example-images-section {
  border-top: 1px dashed var(--border);
  padding-top: 0.75rem;
  margin-top: 0.25rem;
}
.example-images {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.example-image-wrap { text-align: center; }
.example-image-wrap img {
  max-width: 200px;
  max-height: 200px;
  border: 1px solid var(--border);
  border-radius: 4px;
  display: block;
  cursor: zoom-in;
  transition: opacity 0.15s;
}
.example-image-wrap img:hover { opacity: 0.85; }
.example-image-wrap .caption {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  max-width: 200px;
}

.detail-notes {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  margin-top: 1.5rem;
}
.detail-notes h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}
.detail-notes p { white-space: pre-wrap; font-size: 0.9rem; }

/* ── Lightbox ───────────────────────── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.lightbox.active { display: flex; }
.lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 4px;
}
.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  font-size: 1.25rem;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-close:hover { background: rgba(255,255,255,0.3); }

/* ══════════════════════════════════════
   ADMIN
══════════════════════════════════════ */
.admin-page { background: var(--bg); }

.admin-layout {
  display: flex;
  height: calc(100vh - 52px);
  overflow: hidden;
}

/* ── Sidebar ────────────────────────── */
.sidebar {
  width: 340px;
  min-width: 340px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-header h2 { font-size: 0.875rem; color: var(--text-muted); }
.sidebar-import {
  display: flex;
  gap: 0.4rem;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.btn-import {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem 0.6rem;
  background: var(--success);
  color: white;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-import:hover { background: #15803d; }
.btn-import.loading { opacity: 0.6; pointer-events: none; }
.btn-import input[type="file"] { display: none; }
.btn-import-sku { background: var(--warn); }
.btn-import-sku:hover { background: #b45309; }
.btn-template {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem 0.6rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.15s;
}
.btn-template:hover { border-color: var(--primary); color: var(--primary); }

.sidebar-tools-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
  transition: background 0.1s;
  flex-shrink: 0;
}
.sidebar-tools-toggle:hover { background: var(--bg); }
.sidebar-tools-toggle span:last-child { font-size: 0.65rem; }

.sidebar-search {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-search input {
  width: 100%;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: inherit;
}
.sidebar-search input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

.side-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
}
.side-list li {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  border-left: 3px solid transparent;
}
.side-list li:hover { background: var(--bg); }
.side-list li.active {
  background: #eff6ff;
  border-left-color: var(--primary);
}
.side-row1 { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.1rem; }
.side-parent-sku { font-size: 0.75rem; font-family: monospace; color: var(--primary); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-child-count { font-size: 0.68rem; color: var(--text-muted); background: var(--bg); padding: 1px 5px; border-radius: 8px; border: 1px solid var(--border); }
.side-name { font-size: 0.875rem; font-weight: 500; }
.search-hint { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.3rem; padding: 0 0.2rem; }
.content-icons { display: flex; gap: 2px; flex-shrink: 0; margin-left: auto; }
.ci {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}
.ci-empty { background: #f1f5f9; color: #cbd5e1; }
.ci-ov { background: #dbeafe; color: #1d4ed8; }
.ci-nt { background: #fef3c7; color: #b45309; }
.ci-gd { background: #dcfce7; color: #15803d; }
.ci-df { background: #fee2e2; color: #b91c1c; }
.ci-ref .ci:not(.ci-empty) { opacity: 0.75; outline: 1px dashed currentColor; }

/* ── Admin main ─────────────────────── */
.admin-main {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem;
}
.welcome-msg {
  max-width: 960px;
  margin: 0 auto;
}
.welcome-msg {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.8;
}
.form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.form-header h2 { font-size: 1.15rem; }

#productForm { max-width: 1200px; }

.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.form-section > h3 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.section-updated-at {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.875rem;
  margin-bottom: 0.875rem;
}
.form-group { display: flex; flex-direction: column; gap: 0.25rem; }
.form-group label { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); }
.label-hint { font-size: 0.72rem; font-weight: 400; color: var(--text-muted); margin-left: 0.25rem; }
.required { color: var(--danger); }
.form-group input, .form-group textarea {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
}
.form-group input:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-group textarea { resize: vertical; }

/* ── Tabs ───────────────────────────── */
.tab-bar { display: flex; gap: 0; margin-bottom: 1.25rem; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.tab {
  flex: 1;
  padding: 0.75rem 1rem;
  border: none;
  border-right: 1px solid var(--border);
  border-radius: 0;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.tab:last-child { border-right: none; }
.tab:hover { filter: brightness(0.97); }
.tab[data-type="good"]       { border-bottom: 3px solid transparent; }
.tab[data-type="defective"]  { border-bottom: 3px solid transparent; }
.tab[data-type="borderline"] { border-bottom: 3px solid transparent; }
.tab[data-type="good"].active {
  background: var(--good-bg);
  color: var(--good-text);
  border-bottom-color: var(--good-text);
}
.tab[data-type="defective"].active {
  background: var(--defective-bg);
  color: var(--defective-text);
  border-bottom-color: var(--defective-text);
}
.tab[data-type="borderline"].active {
  background: var(--borderline-bg);
  color: var(--borderline-text);
  border-bottom-color: var(--borderline-text);
}

/* ── Example editor ─────────────────── */
.example-editor {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 0.75rem;
}
.example-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.example-editor-header span { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }
.example-section-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}
.label-required {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--danger);
  text-transform: none;
  letter-spacing: 0;
  margin-left: 0.4rem;
}
.ex-block {
  border-radius: 6px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.6rem;
}
.ex-block-text    { background: #f8fafc;           border: 1px solid var(--border); }
.ex-block-images  { background: var(--surface);    border: 1px solid var(--border); }
.ex-block-good        { background: var(--good-bg);       border-color: var(--good-border); }
.ex-block-defective   { background: var(--defective-bg);  border-color: var(--defective-border); }
.ex-block-borderline  { background: var(--borderline-bg); border-color: var(--borderline-border); }
.ex-block textarea {
  width: 100%;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--surface);
  margin-bottom: 0.5rem;
  resize: vertical;
  line-height: 1.7;
  box-sizing: border-box;
}
.ex-block textarea:focus { outline: none; border-color: var(--primary); }
.ex-title-area { line-height: 1.7; overflow: hidden; resize: none; }
/* 閲覧画面 事例ブロック */
.ex-view-block { border-radius: 6px; padding: 0.75rem 1rem; margin-bottom: 0.5rem; }
.ex-view-text { background: #f8fafc; border: 1px solid var(--border); }
.ex-view-images { background: var(--surface); border: 1px solid var(--border); }
.ex-view-images-label {
  font-size: 0.72rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.6rem;
}
.caption-missing { color: var(--danger); font-style: italic; }

/* ── Image upload ───────────────────── */
.uploaded-images {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 0.65rem;
}
.uploaded-image-wrap { position: relative; width: 250px; flex-shrink: 0; }
.uploaded-image-wrap img {
  width: 100%;
  height: 250px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 6px;
  display: block;
}
.del-img-btn {
  display: none;
  position: absolute;
  top: -7px;
  right: -7px;
  width: 20px;
  height: 20px;
  background: var(--danger);
  color: white;
  border: 2px solid white;
  border-radius: 50%;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.uploaded-images.delete-mode .del-img-btn { display: flex; }
.btn-delete-mode {
  margin-left: auto;
  font-size: 0.7rem;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  color: var(--text);
}
.btn-delete-mode-active {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.img-caption {
  width: 100%;
  font-size: 0.7rem;
  padding: 3px 4px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 3px;
  margin-top: 3px;
  font-family: inherit;
  background: var(--surface);
  resize: none;
  line-height: 1.4;
}
.img-caption:focus { outline: none; border-color: var(--primary); }
.img-caption-empty { border-color: var(--danger); background: #fff5f5; }
.img-caption-empty::placeholder { color: var(--danger); opacity: 0.7; }

.image-upload-area {
  display: block;
  border: 2px dashed var(--border);
  border-radius: 6px;
  padding: 0.9rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}
.image-upload-area:hover, .image-upload-area.dragover {
  border-color: var(--primary);
  background: #eff6ff;
}
.image-upload-area input[type="file"] { display: none; }
.image-upload-area p { font-size: 0.8rem; color: var(--text-muted); pointer-events: none; }

.imgs-upload-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 0.65rem;
}
.imgs-upload-wrap .uploaded-images {
  display: contents;
}
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  width: 250px;
  height: 250px;
  position: relative;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #f8fafc;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  outline: none;
  user-select: none;
  flex-shrink: 0;
}
.upload-zone:hover { border-color: #93c5fd; background: #f0f6ff; }
.upload-zone.paste-active {
  border-color: var(--primary);
  border-width: 2px;
  background: #dbeafe;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.22);
}
.upload-zone.paste-active .dz-text { display: none; }
.dz-paste-msg {
  display: none;
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 700;
  margin: 0;
  animation: dz-blink 1.1s ease-in-out infinite;
}
.upload-zone.paste-active .dz-paste-msg { display: block; }
@keyframes dz-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.upload-zone.dragover { border-color: var(--primary); background: #dbeafe; }
.dz-icon { flex-shrink: 0; margin-top: 2px; }
.dz-text { font-size: 0.8rem; color: #94a3b8; line-height: 1.6; margin: 0; text-align: center; }
.dz-file-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  color: #64748b;
  transition: all 0.15s;
}
.dz-file-btn:hover { background: #e2e8f0; border-color: #cbd5e1; color: #334155; }

.feature-images-section { margin-top: 1rem; }
.feature-images-view {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.25rem;
}
.feature-images-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

/* ── 参照リンク ─────────────────────── */
.ref-sku-group { margin-bottom: 0.875rem; }
.ref-sku-input-wrap { display: flex; gap: 0.5rem; align-items: center; }
.ref-sku-input-wrap input { flex: 1; }
.btn-clear-ref {
  padding: 0.35rem 0.75rem;
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.btn-clear-ref:hover { background: var(--danger); color: white; }
.ref-sku-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.ref-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  background: #dbeafe;
  color: var(--primary);
  white-space: nowrap;
}
.ref-badge-warn { background: #fef3c7; color: var(--warn); }
.ref-status-active {
  background: #dbeafe;
  border: 1px solid #93c5fd;
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-top: 0.5rem;
}
.ref-status-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}
.ref-badge-lg {
  background: var(--primary);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 10px;
  white-space: nowrap;
}
.ref-status-action {
  font-size: 0.82rem;
  color: #1e40af;
  padding-left: 0.25rem;
}
.referrers-banner {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-left: 4px solid var(--warn);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-top: 0.75rem;
}
.referrers-header {
  font-size: 0.85rem;
  font-weight: 700;
  color: #92400e;
  margin-bottom: 0.5rem;
}
.referrers-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.referrer-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.75rem;
  background: white;
  border: 1px solid #fed7aa;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.referrer-item:hover { background: #fff7ed; border-color: var(--warn); }
.referrer-sku { font-family: monospace; font-weight: 700; color: #92400e; }
.referrer-name { color: var(--text-muted); }
.ref-link {
  display: inline;
  background: none;
  border: none;
  padding: 0;
  color: var(--primary);
  font-size: inherit;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  font-weight: 600;
}
.ref-link:hover { color: var(--primary-hover); }
.ref-banner {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}
.ref-banner-title { font-weight: 700; color: var(--primary); font-size: 0.9rem; margin-bottom: 0.3rem; }
.ref-banner-desc { font-size: 0.82rem; color: var(--text-muted); }
.readonly-area {
  background: #cbd5e1 !important;
  color: #475569 !important;
  cursor: not-allowed !important;
  border-color: #94a3b8 !important;
  opacity: 1;
}
.ref-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  margin-bottom: 0.75rem;
}

/* ── Quill editor (admin) ───────────── */
.quill-editor {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
}
.quill-editor .ql-toolbar {
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 4px 8px;
  background: var(--bg);
}
.quill-editor .ql-container {
  border: none;
  font-size: 0.9rem;
  font-family: 'Hiragino Sans', 'Meiryo', 'Yu Gothic', sans-serif;
  min-height: 100px;
}
.quill-editor .ql-editor {
  min-height: 100px;
  padding: 0.5rem 0.75rem;
  line-height: 1.7;
}
.quill-editor .ql-editor.ql-blank::before {
  color: #94a3b8;
  font-style: normal;
}
.quill-editor:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.ql-readonly .ql-toolbar { opacity: 0.5; pointer-events: none; }
.ql-readonly .ql-editor  { background: #f1f5f9; cursor: not-allowed; color: #475569; }

/* ── rich-content (viewer) ──────────── */
.rich-content { font-size: 0.9rem; line-height: 1.7; }
.rich-content p { margin-bottom: 0.35rem; }
.rich-content p:last-child { margin-bottom: 0; }
.rich-content ul { margin: 0.25rem 0 0.35rem 1.4rem; padding: 0; }
.rich-content li { margin-bottom: 0.1rem; }

.parent-sku-warning {
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: var(--danger);
  background: #fff5f5;
  border: 1px solid #fca5a5;
  border-radius: 4px;
  padding: 0.3rem 0.65rem;
}

.autosave-status {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  min-height: 1.2em;
}
.autosave-saving  { color: var(--text-muted); }
.autosave-saved   { color: var(--success); }
.autosave-error   { color: var(--danger); }
.autosave-pending { color: var(--warn); }

.child-sku-section { margin-bottom: 0.875rem; }
.child-sku-inline-display {
  margin: 0 0 0.75rem 0;
  flex-wrap: wrap;
  row-gap: 0.1rem;
}
.child-sku-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  user-select: none;
}
.toggle-arrow { font-size: 0.7rem; color: var(--primary); }
.toggle-count { font-size: 0.78rem; color: var(--text-muted); background: var(--bg); padding: 1px 7px; border-radius: 10px; border: 1px solid var(--border); }
.child-sku-table-wrap {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  max-width: 820px;
}
.child-sku-edit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  table-layout: fixed;
}
.child-sku-edit-table colgroup col:nth-child(1) { width: 130px; }
.child-sku-edit-table colgroup col:nth-child(2) { }
.child-sku-edit-table colgroup col:nth-child(3) { width: 90px; }
.child-sku-edit-table colgroup col:nth-child(4) { width: 90px; }
.child-sku-edit-table colgroup col:nth-child(5) { width: 60px; }
.child-sku-edit-table th {
  background: var(--bg);
  padding: 0.4rem 0.6rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
}
.child-sku-edit-table th:nth-child(n+3) { text-align: right; }
.child-sku-edit-table td {
  padding: 0.3rem 0.4rem;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.child-sku-edit-table tr:last-child td { border-bottom: none; }
.child-sku-edit-table tr.row-pending-delete { background: #fff5f5; }
.child-sku-edit-table input {
  width: 100%;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
  font-family: inherit;
  background: #f8fafc;
  box-sizing: border-box;
  color: var(--text);
}
.child-sku-edit-table input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.1);
}
.csku-num { text-align: right; }
.btn-del-row {
  padding: 0.25rem 0.5rem;
  font-size: 0.78rem;
  font-family: inherit;
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.btn-del-row:hover { background: var(--danger); color: white; }
.btn-del-confirm { background: var(--danger); color: white; }
.add-row-btn {
  width: 100%;
  padding: 0.55rem;
  border: none;
  border-top: 1px solid var(--border);
  background: var(--bg);
  color: var(--primary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}
.add-row-btn:hover { background: #eff6ff; }

.add-example-btn {
  width: 100%;
  padding: 0.75rem;
  border: 2px dashed var(--border);
  background: transparent;
  color: var(--primary);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.15s;
}
.add-example-btn:hover { border-color: var(--primary); background: #eff6ff; }

/* ── Confirm modal ──────────────────── */
.confirm-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.confirm-modal-box {
  background: white;
  border-radius: 12px;
  padding: 2rem;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  border-top: 5px solid var(--warn);
  animation: modal-in 0.15s ease;
}
@keyframes modal-in {
  from { transform: scale(0.93); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
.confirm-modal-icon { font-size: 2.5rem; text-align: center; margin-bottom: 0.75rem; }
.confirm-modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #92400e;
  text-align: center;
  margin-bottom: 1rem;
}
.confirm-modal-body {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.75;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin-bottom: 1.5rem;
}
.confirm-modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}
.confirm-btn-cancel {
  padding: 0.55rem 1.25rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
}
.confirm-btn-cancel:hover { background: var(--bg); }
.confirm-btn-ok {
  padding: 0.55rem 1.25rem;
  background: var(--warn);
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.confirm-btn-ok:hover { background: #b45309; }

/* ── Help button ────────────────────── */
.btn-help {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.2);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  line-height: 1;
}
.btn-help:hover { background: rgba(255,255,255,0.4); }

/* ── Import help popup ───────────────── */
.import-help-popup {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.import-help-box {
  background: white;
  border-radius: 10px;
  width: 420px;
  max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  overflow: hidden;
}
.import-help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  font-weight: 700;
}
.import-help-body {
  padding: 1rem 1.25rem;
  font-size: 0.85rem;
  line-height: 1.6;
}
.import-help-body p { margin-bottom: 0.75rem; }
.help-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.75rem;
  font-size: 0.82rem;
}
.help-table th, .help-table td {
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  text-align: left;
}
.help-table th { background: var(--bg); font-weight: 700; color: var(--text-muted); }
.help-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0 !important;
}

/* ── Export / Full import ───────────── */
.btn-import-export {
  background: #7c3aed;
  flex: 1;
}
.btn-import-export:hover { background: #6d28d9; }
.btn-import-full {
  flex-shrink: 0;
  cursor: pointer;
}
.btn-import-full input[type="file"] { display: none; }

/* ── Memo ───────────────────────────── */
.memo-section { margin-bottom: 0.875rem; }

/* ── バックアップモーダル ────────────── */
.backup-modal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  flex-shrink: 0;
}
.backup-status-text { font-size: 0.82rem; color: var(--text-muted); }
.backup-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1.25rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}
.backup-item:last-child { border-bottom: none; }
.backup-item-info { display: flex; flex-direction: column; gap: 0.15rem; }
.backup-item-name { font-size: 0.85rem; font-weight: 600; display: flex; align-items: center; gap: 0.4rem; }
.backup-item-meta { font-size: 0.75rem; color: var(--text-muted); }
.badge-auto   { background: #e0f2fe; color: #0369a1; font-size: 0.68rem; font-weight: 700; padding: 1px 7px; border-radius: 99px; white-space: nowrap; }
.badge-manual { background: #fef3c7; color: #92400e; font-size: 0.68rem; font-weight: 700; padding: 1px 7px; border-radius: 99px; white-space: nowrap; }
.btn-del-backup {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  transition: all 0.15s;
}
.btn-del-backup:hover { background: #fee2e2; border-color: #fca5a5; color: var(--danger); }

/* ── 更新履歴モーダル ────────────────── */
.history-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.history-modal-box {
  background: white;
  border-radius: 10px;
  width: 680px;
  max-width: 95vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  overflow: hidden;
}
.history-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.history-modal-header h2 { font-size: 1rem; }
.history-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}
.history-close:hover { background: var(--bg); }
.history-list { overflow-y: auto; flex: 1; }
.history-item {
  padding: 0.7rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: none; }
.history-item-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.history-badge {
  font-size: 0.7rem;
  font-weight: 700;
  color: white;
  padding: 1px 8px;
  border-radius: 99px;
  flex-shrink: 0;
}
.history-sku { font-family: monospace; font-size: 0.82rem; color: var(--primary); font-weight: 600; }
.history-name { font-size: 0.85rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-time { font-size: 0.78rem; color: var(--text-muted); flex-shrink: 0; margin-left: auto; }
.history-changed { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.2rem; padding-left: 0.25rem; }

/* ── Toast ──────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: #1e293b;
  color: white;
  padding: 0.7rem 1.1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  z-index: 9999;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ── Print ──────────────────────────── */
@media print {
  .no-print { display: none !important; }
  .print-only { display: block !important; }
  body { background: white; font-size: 10.5pt; }
  .main { padding: 0; }
  .product-detail { max-width: 100%; }
  .detail-name { font-size: 15pt; }
  .detail-sku { font-size: 9pt; }
  .examples-group { page-break-inside: avoid; }
  .example-item { page-break-inside: avoid; }
  .example-image-wrap img { max-width: 130px; max-height: 130px; }
  .detail-overview-row { grid-template-columns: 1fr 1fr; }
  .rich-content ul { margin-left: 1.2rem; }
  .rich-content li { margin-bottom: 0.05rem; }
  .rich-content p  { margin-bottom: 0.2rem; }
}
