:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #e2e5ea;
  --text: #1f2430;
  --muted: #6b7280;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --danger: #e5484d;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}

body {
  min-height: 100vh;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  font-weight: 800;
  font-size: 16px;
}
.brand-name { font-weight: 700; font-size: 16px; }

.actions { display: flex; align-items: center; gap: 8px; }

.btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}
.btn:hover { border-color: #c7ccd6; }
.btn.ghost { background: #fff; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

select#theme, select#template {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
.icon-btn { padding: 8px 12px; font-size: 15px; }

/* ---------- Workspace ---------- */
.workspace {
  height: calc(100vh - 57px);
  display: flex;
  min-height: 0;
}

.pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.divider { width: 1px; background: var(--border); }

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
}
.hint { font-weight: 600; color: #16a34a; text-transform: none; letter-spacing: 0; }

.toolbar { display: flex; gap: 4px; }
.toolbar button {
  border: 1px solid transparent;
  background: transparent;
  width: 30px; height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  display: grid;
  place-items: center;
}
.toolbar button:hover { background: #eceef2; }
.toolbar button.danger:hover { background: #fde7e7; color: var(--danger); }

#editor {
  flex: 1;
  border: 0;
  outline: 0;
  resize: none;
  padding: 18px 20px;
  font-family: "Cascadia Code", Consolas, "Courier New", monospace;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  background: var(--panel);
}

.preview-scroll {
  flex: 1;
  overflow: auto;
  padding: 28px;
  background: #eef0f3;
}

/* ---------- Markdown rendering ---------- */
.markdown-body {
  max-width: 820px;
  margin: 0 auto;
  background: #fff;
  color: #1f2430;
  padding: 48px 56px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  line-height: 1.8;
  font-size: 15px;
}
.markdown-body h1 { font-size: 1.9em; border-bottom: 2px solid #eaecef; padding-bottom: .3em; margin-top: 0; }
.markdown-body h2 { font-size: 1.5em; border-bottom: 1px solid #eaecef; padding-bottom: .25em; }
.markdown-body h3 { font-size: 1.25em; }
.markdown-body p { margin: .8em 0; }
.markdown-body a { color: var(--accent); }
.markdown-body code {
  background: #f3f4f6;
  padding: .15em .4em;
  border-radius: 4px;
  font-size: .9em;
  font-family: "Cascadia Code", Consolas, monospace;
}
.markdown-body pre {
  background: #f6f8fa;
  padding: 16px;
  border-radius: 8px;
  overflow: auto;
}
.markdown-body pre code { background: transparent; padding: 0; }
.markdown-body blockquote {
  margin: 1em 0;
  padding: .4em 1em;
  color: var(--muted);
  border-left: 4px solid #d1d5db;
  background: #fafbfc;
}
.markdown-body table { border-collapse: collapse; width: 100%; margin: 1em 0; }
.markdown-body th, .markdown-body td { border: 1px solid #d1d5db; padding: 8px 12px; }
.markdown-body th { background: #f3f4f6; }
.markdown-body img { max-width: 100%; }
.markdown-body hr { border: 0; border-top: 1px solid #e5e7eb; margin: 2em 0; }

/* ---------- Themes ---------- */
.theme-serif { font-family: "Hiragino Mincho ProN", "Yu Mincho", "MS Mincho", serif; }
.theme-github { font-size: 14px; }
.theme-dark {
  background: #0d1117;
  color: #c9d1d9;
}
.theme-dark h1, .theme-dark h2 { border-color: #30363d; }
.theme-dark code { background: #161b22; }
.theme-dark pre { background: #161b22; }
.theme-dark th { background: #161b22; }
.theme-dark th, .theme-dark td { border-color: #30363d; }
.theme-dark blockquote { background: #161b22; border-color: #30363d; }

/* ---------- SEO / 解説コンテンツ ---------- */
.seo-content {
  border-top: 1px solid var(--border);
  padding: 0 24px 80px;
  background:
    radial-gradient(1200px 500px at 50% -150px, rgba(124, 58, 237, 0.10), transparent 60%),
    linear-gradient(180deg, #f7f8fc 0%, #eef1f8 100%);
}
.seo-inner {
  max-width: 880px;
  margin: 0 auto;
  line-height: 1.9;
  color: #374151;
}
.sec-title {
  font-size: 1.4em;
  margin: 2.4em 0 1em;
  text-align: center;
  background: linear-gradient(90deg, #4f46e5, #7c3aed);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Hero */
.hero {
  text-align: center;
  padding: 72px 16px 56px;
}
.hero-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #6d28d9;
  background: #ede9fe;
  border: 1px solid #ddd6fe;
}
.hero h1 {
  font-size: 2.2em;
  line-height: 1.4;
  margin: 18px 0 12px;
  background: linear-gradient(120deg, #4f46e5 0%, #7c3aed 50%, #0ea5e9 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-lead { font-size: 1.05em; color: #4b5563; max-width: 620px; margin: 0 auto 24px; }
.hero-cta {
  display: inline-block;
  padding: 12px 26px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.3);
  transition: transform .15s ease, box-shadow .15s ease;
}
.hero-cta:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(79, 70, 229, 0.38); }

/* Feature cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}
.feature-card {
  background: #fff;
  border: 1px solid var(--border);
  border-top: 4px solid var(--c, var(--accent));
  border-radius: 14px;
  padding: 22px 20px;
  box-shadow: 0 4px 14px rgba(16, 24, 40, 0.05);
  transition: transform .15s ease, box-shadow .15s ease;
}
.feature-card:hover { transform: translateY(-4px); box-shadow: 0 12px 26px rgba(16, 24, 40, 0.10); }
.feature-ico {
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  border-radius: 12px;
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--c, var(--accent));
  background: color-mix(in srgb, var(--c, var(--accent)) 14%, white);
}
.feature-card h3 { margin: 0 0 6px; font-size: 1.05em; }
.feature-card p { margin: 0; color: #6b7280; font-size: .92em; line-height: 1.7; }

/* Steps */
.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.step {
  position: relative;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 20px 20px;
  text-align: center;
  box-shadow: 0 4px 14px rgba(16, 24, 40, 0.05);
}
.step-num {
  display: inline-grid;
  place-items: center;
  width: 40px; height: 40px;
  margin-bottom: 12px;
  border-radius: 50%;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
}
.step p { margin: 0; color: #4b5563; font-size: .95em; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.chip {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: .92em;
  color: #374151;
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.04);
}

/* Info box */
.info-box {
  margin-top: 2.4em;
  background: #fff;
  border: 1px solid var(--border);
  border-left: 5px solid #7c3aed;
  border-radius: 14px;
  padding: 8px 28px 24px;
}
.info-box code { background: #f3f4f6; padding: .12em .4em; border-radius: 4px; font-size: .9em; }

/* FAQ */
.faq { display: flex; flex-direction: column; gap: 12px; }
.faq details {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px 18px;
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.04);
}
.faq summary {
  cursor: pointer;
  font-weight: 700;
  padding: 14px 24px 14px 0;
  list-style: none;
  position: relative;
  color: #1f2430;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  position: absolute;
  right: 2px; top: 50%;
  transform: translateY(-50%);
  font-size: 1.3em;
  color: var(--accent);
}
.faq details[open] summary::after { content: "−"; }
.faq details p { margin: 0 0 14px; color: #6b7280; }

.seo-footer {
  margin-top: 3.5em;
  padding-top: 1.6em;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .9em;
  text-align: center;
}
.footer-logo {
  display: inline-grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  font-weight: 800;
  margin-bottom: 8px;
}

/* ---------- Dark mode (サイト全体) ---------- */
body.dark {
  --bg: #0d1117;
  --panel: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #9198a1;
}
body.dark .btn { background: #21262d; color: var(--text); }
body.dark .btn:hover { border-color: #4b5563; }
body.dark .btn.primary { background: var(--accent); color: #fff; }
body.dark select#theme,
body.dark select#template { background: #21262d; }
body.dark .pane-head { background: #11151b; }
body.dark .toolbar button { color: var(--text); }
body.dark .toolbar button:hover { background: #30363d; }
body.dark .preview-scroll { background: #010409; }
body.dark .seo-content {
  background:
    radial-gradient(1200px 500px at 50% -150px, rgba(124, 58, 237, 0.18), transparent 60%),
    linear-gradient(180deg, #0d1117 0%, #010409 100%);
}
body.dark .seo-inner { color: #c9d1d9; }
body.dark .feature-card,
body.dark .step,
body.dark .chip,
body.dark .info-box,
body.dark .faq details { background: #161b22; }
body.dark .feature-card p,
body.dark .step p,
body.dark .faq details p { color: #9198a1; }
body.dark .faq summary,
body.dark .chip { color: #e6edf3; }
body.dark .hero-badge { background: #1f1b3a; color: #c4b5fd; border-color: #3b3170; }
body.dark .info-box code,
body.dark .seo-inner code { background: #0d1117; color: #e6edf3; }

/* ---------- Print area (hidden on screen) ---------- */
#printArea { display: none; }

/* ---------- Print / PDF ---------- */
@media print {
  .topbar, .workspace, .divider, .seo-content { display: none !important; }
  body { overflow: visible; height: auto; background: #fff; }
  #printArea {
    display: block !important;
    max-width: none;
    margin: 0;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
  }
  .markdown-body pre, .markdown-body table, .markdown-body img { page-break-inside: avoid; }
  .markdown-body h1, .markdown-body h2, .markdown-body h3 { page-break-after: avoid; }
}

@page {
  size: A4;
  margin: 18mm 16mm;
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .workspace { flex-direction: column; }
  .divider { width: auto; height: 1px; }
  .brand-name { display: none; }
}
