:root {
  color-scheme: light;
  --bg: #f1f1f1;
  --surface: #ffffff;
  --surface-2: #f7f7f7;
  --text: #303030;
  --muted: #616161;
  --disabled: #8a8a8a;
  --border: #e3e3e3;
  --input-border: #8a8a8a;
  --focus: #005bd3;
  --link: #005bd3;
  --primary: #303030;
  --primary-hover: #1a1a1a;
  --critical: #8e0b21;
  --critical-bg: #fee8eb;
  --warning-bg: #fff1e3;
  --success: #014b40;
  --success-bg: #cdfed4;
  --info-bg: #eaf4ff;
  --shadow: 0 1px 0 rgba(0, 0, 0, .05), 0 1px 3px rgba(0, 0, 0, .12);
  --radius: 8px;
}

* { box-sizing: border-box; }
html { font-size: 16px; background: var(--bg); }
body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
  font-family: system-ui, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
button, input, textarea, select { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--link); text-underline-offset: 3px; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: 24px; line-height: 1.35; letter-spacing: -.2px; }
h2 { margin-bottom: 12px; font-size: 20px; line-height: 1.4; }
h3 { margin-bottom: 8px; font-size: 17px; line-height: 1.4; }
p:last-child { margin-bottom: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { color: var(--text); font-weight: 700; text-decoration: none; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.shop-label { display: none; color: var(--muted); font-size: 14px; }
.page {
  width: 100%;
  max-width: 702px;
  margin: 0 auto;
  padding: 20px;
}
.page-wide { max-width: 1120px; }
.page-head { margin-bottom: 16px; }
.page-head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-head-row h1 { margin-bottom: 0; }
.page-banner { margin-bottom: 16px; }
.eyebrow, .note { color: var(--muted); font-size: 14px; line-height: 1.5; }
.eyebrow { margin-bottom: 4px; }
.back-link { display: inline-block; margin-bottom: 12px; color: var(--text); text-decoration: none; }
.back-link::before { content: "‹"; margin-right: 6px; font-size: 22px; vertical-align: -1px; }

.stack { display: grid; gap: 16px; }
.compact-stack { display: grid; gap: 8px; }
.card {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.card-flat { box-shadow: none; }
.card-head, .row-between {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.divider { height: 1px; margin: 16px 0; background: var(--border); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions-right { justify-content: flex-end; }
.action-stack { display: grid; gap: 8px; }

.btn {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid #c9cccf;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  font-weight: 650;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { border-color: var(--primary); background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { border-color: #c70a24; color: var(--critical); }
.btn-plain { border-color: transparent; background: transparent; color: var(--link); box-shadow: none; }
.btn-wide { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { border-color: var(--border); background: #ebebeb; color: var(--disabled); cursor: not-allowed; }
.icon-btn { min-width: 36px; padding: 6px; }

.field { display: grid; gap: 6px; }
.field label, .field-label { font-weight: 650; }
.input, .textarea, .select {
  width: 100%;
  min-height: 40px;
  padding: 7px 12px;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 16px;
  line-height: 1.5;
}
.textarea { min-height: 112px; resize: vertical; }
.textarea-tall { min-height: 320px; }
.input[aria-invalid="true"] { border-color: #c70a24; }
.field-error { color: var(--critical); font-size: 14px; }
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.check-row input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--primary); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 2px 10px;
  border-radius: 9999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
}
.badge::before { content: "●"; font-size: 14px; }
.badge-success { color: var(--success); background: var(--success-bg); }
.badge-warning { color: #704000; background: var(--warning-bg); }
.badge-muted { color: var(--muted); }
.badge-lock::before { content: "🔒"; font-size: 14px; }

.banner {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 16px;
  border: 1px solid transparent;
  border-radius: 12px;
}
.banner::before { content: "i"; width: 24px; height: 24px; display: grid; place-items: center; border: 2px solid currentColor; border-radius: 50%; font-weight: 700; }
.banner-danger { color: var(--critical); background: var(--critical-bg); border-color: #f3b7c0; }
.banner-danger::before { content: "!"; }
.banner-warning { color: #704000; background: var(--warning-bg); border-color: #f0c795; }
.banner-info { color: #003a5a; background: var(--info-bg); border-color: #b5d7f2; }
.banner-success { color: var(--success); background: var(--success-bg); border-color: #9fe6aa; }
.banner-title { margin-bottom: 2px; font-weight: 700; }
.banner .btn { margin-top: 10px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 16px;
  border-radius: 8px;
  background: #303030;
  color: #fff;
  font-size: 16px;
  opacity: 0;
  pointer-events: none;
  transition: .18s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.metric-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.metric-value { margin-bottom: 8px; font-size: 20px; font-weight: 700; }
.progress { height: 8px; overflow: hidden; border-radius: 9999px; background: #dedede; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: #616161; }

.entry-card { display: grid; gap: 12px; }
.entry-card.locked { background: #f7f7f7; color: var(--muted); }
.entry-card.locked .btn { pointer-events: none; }
.status-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.meta-list { display: grid; gap: 6px; color: var(--muted); font-size: 14px; }

.login-page { min-height: 100vh; display: grid; place-items: start center; padding: 64px 20px 24px; background: var(--surface); }
.login-box { width: min(100%, 440px); text-align: center; }
.login-mark { width: 48px; height: 48px; margin: 0 auto 20px; display: grid; place-items: center; border-radius: 12px; background: #5d386a; color: white; font-weight: 800; }
.login-box h1 { font-size: 28px; }
.login-box .field { margin-top: 24px; text-align: left; }
.login-box #login-form { display: grid; gap: 8px; }
.login-help { margin-top: 20px; color: var(--muted); font-size: 14px; }
.code-form { display: grid; gap: 8px; margin-top: 12px; text-align: left; }
.code-form .field { margin-top: 0; }

.editor-toolbar {
  position: sticky;
  top: 56px;
  z-index: 15;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.editor-toolbar .btn { padding-left: 6px; padding-right: 6px; }
.editor-toolbar .toolbar-secondary { display: none; }
.editor-layout { display: grid; gap: 16px; }
.site-canvas { overflow: hidden; padding: 0; }
.site-hero { position: relative; min-height: 250px; display: grid; align-items: end; background: #4d3457; }
.site-hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .58; }
.site-copy { position: relative; z-index: 1; padding: 24px 20px; color: white; background: linear-gradient(transparent, rgba(0,0,0,.66)); }
.site-copy .eyebrow { width: max-content; padding: 2px 6px; border-radius: 4px; background: #303030; color: #ffffff; font-size: 14px; font-weight: 700; }
.site-copy h2 { font-size: 28px; }
.editable { display: grid; gap: 8px; padding: 8px; border-radius: 6px; outline: 2px dashed rgba(255,255,255,.72); outline-offset: 2px; }
.editable + .editable { margin-top: 12px; }
.editable.dark { outline-color: #8a8a8a; }
.editable > :not(.edit-label) { margin-bottom: 0; }
.edit-label { min-height: 32px; justify-self: end; padding: 6px 10px; border: 1px solid #c9cccf; border-radius: 6px; background: #fff; color: #303030; font-size: 16px; font-weight: 700; line-height: 1; cursor: pointer; }
.site-section { padding: 28px 20px; background: white; }
.inline-editor { margin-top: 12px; padding: 12px; border: 2px solid var(--focus); border-radius: 8px; background: white; color: var(--text); }
.inline-editor .actions { margin-top: 8px; }

.media-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.media-item { overflow: hidden; padding: 0; border: 2px solid transparent; border-radius: 8px; background: white; cursor: pointer; }
.media-item img { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.media-item.selected { border-color: var(--focus); }
.media-item span { display: block; padding: 8px; font-size: 14px; }
.upload-box { padding: 20px; text-align: center; border: 2px dashed #8a8a8a; border-radius: 8px; background: var(--surface-2); }

.segmented { display: inline-flex; flex-shrink: 0; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.segmented button { height: 36px; min-height: 36px; padding: 6px 8px; border: 0; border-radius: 6px; background: transparent; font-size: 16px; white-space: nowrap; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: white; box-shadow: var(--shadow); font-weight: 700; }
.preview-controls .note { min-width: 0; margin-bottom: 0; }
.preview-stage { width: 100%; overflow-x: auto; padding: 4px; }
.preview-frame { width: 100%; min-height: 520px; border: 1px solid var(--border); border-radius: 8px; background: white; }
.preview-frame.desktop { width: 960px; max-width: none; }
.preview-frame.mobile { width: min(100%, 375px); margin: 0 auto; }

.timeline { display: grid; gap: 0; }
.version-row { display: grid; grid-template-columns: 24px 1fr; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.version-row:last-child { border-bottom: 0; }
.timeline-dot { width: 12px; height: 12px; margin: 7px auto 0; border-radius: 50%; background: #6d4b78; box-shadow: 0 0 0 4px #eee5f1; }
.version-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.post-row { display: grid; gap: 10px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.post-row:last-child { border-bottom: 0; }
.post-title { margin-bottom: 2px; font-weight: 700; }
.article-topbar { position: sticky; top: 0; z-index: 20; min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 20px; background: white; border-bottom: 1px solid var(--border); }
.article-page { max-width: 702px; margin: 0 auto; padding: 20px; }
.cover-picker { width: 100%; min-height: 150px; display: grid; place-items: center; border: 1px dashed #8a8a8a; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 16px; cursor: pointer; }
.cover-picker:hover { background: #eeeeee; }
.title-input { width: 100%; min-height: 96px; overflow: hidden; resize: none; padding: 12px 0; border: 0; border-bottom: 1px solid var(--border); background: transparent; font-size: 28px; font-weight: 700; line-height: 1.35; }
.body-input { width: 100%; min-height: 420px; padding: 16px 0; border: 0; background: transparent; font-size: 16px; line-height: 1.7; resize: vertical; }
.title-input:focus, .body-input:focus { outline: none; border-color: var(--focus); }

.version-site-preview { overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: white; }
.version-site-hero { position: relative; min-height: 240px; display: grid; align-items: end; padding: 24px; overflow: hidden; background: #4d3457; color: white; }
.version-site-hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .5; }
.version-site-hero > div { position: relative; }
.version-site-shop-name { display: inline-block; width: max-content; padding: 2px 6px; border-radius: 4px; background: #303030; color: #ffffff; font-size: 14px; font-weight: 700; }
.version-site-body { padding: 24px; }
.link-look { color: var(--link); text-decoration: underline; }
.version-confirm { margin-top: 16px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 80; display: grid; align-items: end; background: rgba(0,0,0,.42); }
.modal { width: 100%; max-height: 90vh; overflow: auto; padding: 20px; border-radius: 16px 16px 0 0; background: white; }
.modal-inner { max-width: 662px; margin: 0 auto; }
.modal-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 16px; }
.modal-head h2 { margin: 0; }
.loading { min-height: 180px; display: grid; place-items: center; text-align: center; color: var(--muted); }
.spinner { width: 32px; height: 32px; margin: 0 auto 12px; border: 3px solid #d8d8d8; border-top-color: #303030; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.hidden { display: none !important; }

@media (min-width: 600px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .action-stack { display: flex; flex-wrap: wrap; }
  .media-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 768px) {
  .page { padding: 24px 32px 48px; }
  .shop-label { display: inline; }
  .editor-toolbar { grid-template-columns: repeat(4, auto); justify-content: center; }
  .editor-toolbar .toolbar-secondary { display: inline-flex; }
  .side-editor-actions { display: none; }
  .editor-layout { grid-template-columns: minmax(0, 662px) minmax(280px, 360px); align-items: start; justify-content: center; }
  .editor-side { position: sticky; top: 132px; }
  .modal-backdrop { align-items: center; padding: 24px; }
  .modal { max-width: 720px; margin: auto; border-radius: 16px; }
  .post-row { grid-template-columns: 1fr auto; align-items: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
