:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #3b82f6;
  --accent-weak: #eff6ff;
  --radius: 12px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: "Noto Sans JP", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
}

/* ===== ヘッダー ===== */
header {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: #fff;
  padding: 24px 24px 22px;
}
.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  position: relative;
}
header h1 {
  margin: 0 0 8px;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
header h1 .accent {
  color: #93c5fd;
}
header p {
  margin: 0;
  color: #cbd5e1;
  font-size: 1.05rem;
  max-width: 760px;
}
.lang-switch {
  position: absolute;
  top: 0;
  right: 0;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.95rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 6px 14px;
  border-radius: 999px;
  transition: all 0.2s;
}
.lang-switch:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

/* ===== レイアウト ===== */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 8px;
}

/* ===== ライブラリタブ ===== */
.lib-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.lib-tab {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  padding: 12px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}
.lib-tab small {
  display: block;
  font-weight: 400;
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 2px;
}
.lib-tab:hover {
  border-color: var(--accent);
}
.lib-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.lib-tab.active small {
  color: #dbeafe;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  align-items: start;
}

/* ===== プレビュー ===== */
.stage {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
#preview-host {
  height: 260px;
  max-width: 620px;
  margin: 0 auto;
  border-radius: 8px;
  overflow: hidden;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
}
#preview-host .my-slider {
  width: 100%;
  height: 100%;
}
#preview-host img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* Splide/Slick はスライドの高さが画像依存で、プレビュー高に追従しないため明示的に通す（縦モードは除外） */
#preview-host .splide,
#preview-host .splide__track,
#preview-host .splide__list {
  height: 100%;
}
#preview-host .splide:not(.splide--ttb) .splide__slide {
  height: 100%;
}
#preview-host .slick-list,
#preview-host .slick-track {
  height: 100%;
}
#preview-host .slick-slider:not(.slick-vertical) .slick-track {
  display: flex;
}
#preview-host .slick-slider:not(.slick-vertical) .slick-slide {
  height: auto;
}
#preview-host .slick-slide > div {
  height: 100%;
  line-height: 0;
}
/* Slickのドットは既定でスライド下に出て固定高プレビューで見切れるため、内側下部へ配置 */
#preview-host .slick-slider {
  margin-bottom: 0;
}
#preview-host .slick-dots {
  bottom: 8px;
}
#preview-host .slick-dots li button::before {
  color: #fff;
  opacity: 0.75;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
#preview-host .slick-dots li.slick-active button::before {
  opacity: 1;
}
/* サムネイル連動ギャラリー（プレビュー） */
#preview-host .gallery {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  gap: 8px;
}
#preview-host .gallery .main-slider,
#preview-host .gallery .thumb-slider {
  overflow: hidden;
  min-width: 0;
}
#preview-host .gallery .main-slider {
  flex: 1;
  min-height: 0;
  width: 100%;
}
#preview-host .gallery .thumb-slider {
  height: 56px;
  flex: 0 0 56px;
  width: 100%;
}
#preview-host .gallery .thumb-slider .swiper-slide,
#preview-host .gallery .thumb-slider .splide__slide,
#preview-host .gallery .thumb-slider .slick-slide {
  opacity: 0.45;
  cursor: pointer;
}
#preview-host .gallery .thumb-slider .swiper-slide-thumb-active,
#preview-host .gallery .thumb-slider .splide__slide.is-active,
#preview-host .gallery .thumb-slider .slick-current {
  opacity: 1;
}

.preview-loading,
.preview-error {
  color: var(--muted);
  font-size: 0.95rem;
}
.preview-error {
  color: #dc2626;
}
.drag-hint {
  margin: 16px 0 0;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}

/* ===== コントロールパネル ===== */
.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 12px;
}
.type-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.type-row.effect-row {
  grid-template-columns: repeat(3, 1fr);
}
.type-row.effect-row .type-btn {
  font-size: 0.85rem;
  padding: 8px 2px;
}
.type-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  padding: 8px 0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.type-btn:hover {
  border-color: var(--accent);
}
.type-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.slider-row {
  display: block;
  margin-bottom: 14px;
}
.slider-row:last-child {
  margin-bottom: 0;
}
.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.slider-label em {
  font-style: normal;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  cursor: pointer;
}
.check-row + .check-row {
  margin-top: 12px;
}
.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}
.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}
.hint-text {
  margin: 10px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.hidden {
  display: none !important;
}

/* ===== 出力 ===== */
.output-section {
  margin-top: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.output-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 12px;
}
.output-head h2 {
  margin: 0;
  font-size: 1.15rem;
}
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  font: inherit;
  font-size: 0.95rem;
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}
.copy-btn:hover {
  background: #2563eb;
}
.copy-btn.copied {
  background: #16a34a;
}
.slick-warn {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 4px solid #f59e0b;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 14px;
  font-size: 0.9rem;
  color: #92400e;
}
.slick-warn a {
  color: #b45309;
  font-weight: 700;
}
.output-section textarea {
  width: 100%;
  min-height: 320px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 0.95rem;
  line-height: 1.6;
  color: #e2e8f0;
  background: #0f172a;
  border: none;
  border-radius: 8px;
  padding: 16px;
}
.output-note {
  margin: 12px 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}
.output-note code {
  font-family: var(--mono);
  background: var(--accent-weak);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 4px;
}

/* ===== プリセットページ ===== */
.preset-demo {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}
.preset-demo #preview-host {
  margin: 0 auto;
}
.code-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 22px 0 8px;
  gap: 12px;
}
.code-head h3 {
  margin: 0;
  font-size: 1.05rem;
}
pre.code-block {
  margin: 0;
  width: 100%;
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.6;
  color: #e2e8f0;
  background: #0f172a;
  border-radius: 8px;
  padding: 16px;
  white-space: pre;
  overflow-x: auto;
}
.copy-btn.small {
  padding: 6px 12px;
  font-size: 0.88rem;
}

/* ===== 記事・解説 ===== */
.article {
  max-width: 820px;
  margin: 48px auto 0;
  padding: 0 24px;
}
.article h2 {
  font-size: 1.4rem;
  letter-spacing: -0.01em;
  margin: 40px 0 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}
.article h3 {
  font-size: 1.15rem;
  margin: 28px 0 10px;
}
.article p {
  margin: 0 0 14px;
}
.article ul,
.article ol {
  margin: 0 0 16px;
  padding-left: 1.4em;
}
.article li {
  margin-bottom: 6px;
}
.article code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
}
.answer-box {
  background: var(--accent-weak);
  border: 1px solid #bfdbfe;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 18px 20px;
  margin-bottom: 8px;
}
.answer-box p {
  margin: 0;
}
.compare-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 16px;
  font-size: 0.95rem;
}
.compare-table th,
.compare-table td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
}
.compare-table thead th {
  background: #f1f5f9;
}
.faq-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 12px;
  background: var(--surface);
}
.faq-item h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}
.faq-item p {
  margin: 0;
  color: #334155;
}
.related {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 12px 0 8px;
}
.related a {
  display: block;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  transition: all 0.2s;
}
.related a:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.12);
}
.related a strong {
  display: block;
  color: var(--accent);
  margin-bottom: 4px;
}
.related a span {
  font-size: 0.9rem;
  color: var(--muted);
}

/* ===== フッター ===== */
footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 40px;
  color: #64748b;
  font-size: 1rem;
  border-top: 1px solid #e2e8f0;
  background: #fff;
  margin-top: 48px;
}
footer a {
  color: #1e293b;
  text-decoration: none;
  transition: color 0.2s;
}
footer a:hover {
  color: #3b82f6;
}
.footer-links {
  display: flex;
  gap: 16px;
}
.footer-links a {
  border: 1px solid #e2e8f0;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 1rem;
  transition: all 0.2s;
}
.footer-links a:hover {
  border-color: #3b82f6;
  color: #3b82f6;
}

/* 2カラム時、プレビューを上部に固定し、サイドバーをスクロールさせて連動 */
@media (min-width: 901px) {
  .stage {
    position: sticky;
    top: 24px;
  }
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .panel {
    order: 2;
  }
}
@media (max-width: 768px) {
  header {
    padding: 18px 20px 16px;
  }
  header h1 {
    font-size: 1.5rem;
  }
  .lang-switch {
    position: static;
    display: inline-block;
    margin-bottom: 16px;
  }
  .lib-tab small {
    display: none;
  }
  footer {
    flex-direction: column;
    gap: 16px;
    padding: 24px 16px;
    text-align: center;
  }
  .footer-links {
    flex-wrap: wrap;
    justify-content: center;
  }
}
