/* GridLoom Precision Design System */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --text: #0f172a;
  --text-muted: #475569;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --desk-bg: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.10);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111827;
  --surface-alt: #1e293b;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #273449;
  --accent: #38bdf8;
  --accent-hover: #0ea5e9;
  --accent-soft: rgba(56, 189, 248, 0.12);
  --desk-bg: #1e293b;
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.45);
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.gl-container {
  max-width: 1220px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Language Hint Banner */
.gl-lang-banner {
  background: #1e293b;
  color: #f8fafc;
  padding: 8px 16px;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.gl-lang-banner-btn {
  background: #38bdf8;
  color: #0f172a;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 0.82rem;
}
.gl-lang-banner-close {
  background: none;
  border: none;
  color: #cbd5e1;
  font-size: 1.1rem;
  cursor: pointer;
}

/* Header */
.gl-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.gl-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  gap: 16px;
}
.gl-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text);
  letter-spacing: -0.02em;
}
.gl-logo:hover { text-decoration: none; }
.gl-logo img { width: 28px; height: 28px; }
.gl-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.gl-nav a {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
}
.gl-nav a:hover { color: var(--text); text-decoration: none; }
.gl-lang-switch, .gl-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.gl-lang-switch:hover, .gl-icon-btn:hover { border-color: var(--accent); text-decoration: none; }

/* Breadcrumb */
.gl-breadcrumb {
  padding: 14px 0 6px;
  font-size: 0.84rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Hero */
.gl-hero {
  padding: 36px 0 24px;
}
.gl-hero-home {
  padding: 48px 0 36px;
  text-align: center;
}
.gl-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.78rem;
  margin-bottom: 12px;
}
h1 {
  margin: 0 0 10px;
  font-size: clamp(1.55rem, 3vw, 2.25rem);
  line-height: 1.25;
  letter-spacing: -0.025em;
}
.gl-lead {
  margin: 0;
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 780px;
}
.gl-hero-home .gl-lead { margin: 0 auto 24px; }

/* Studio 2-Column Layout */
.gl-studio {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 24px;
  align-items: start;
  margin: 18px 0 32px;
}
@media (max-width: 900px) {
  .gl-studio { grid-template-columns: 1fr; }
}

.gl-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.gl-ctrl-group {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.gl-ctrl-group:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.gl-ctrl-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 12px;
}

.gl-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
  font-size: 0.87rem;
}
.gl-field span {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  color: var(--text);
}
.gl-field b { color: var(--accent); font-weight: 700; }
.gl-field select, .gl-field input[type="number"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}
.gl-field input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}
.gl-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.is-hidden { display: none !important; }

.gl-seg-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}
.gl-seg-btn {
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}
.gl-seg-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.gl-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  margin-bottom: 8px;
  cursor: pointer;
}
.gl-check input { accent-color: var(--accent); width: 16px; height: 16px; }

.gl-swatches {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.gl-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12);
}
.gl-swatch.is-active {
  border-color: var(--text);
  transform: scale(1.1);
}
.gl-color-picker {
  width: 30px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px;
  background: var(--surface);
  cursor: pointer;
}

/* Preview Workspace */
.gl-stage-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.gl-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.gl-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.gl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}
.gl-btn:hover { border-color: var(--accent); }
.gl-btn:active { transform: translateY(1px); }
.gl-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}
.gl-btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.gl-zoom-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.gl-zoom-bar button {
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}

.gl-desk {
  background: var(--desk-bg);
  background-image: radial-gradient(rgba(100, 116, 139, 0.18) 1px, transparent 1px);
  background-size: 16px 16px;
  padding: 24px;
  min-height: 520px;
  max-height: 78vh;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.gl-sheet-frame {
  width: 100%;
  max-width: 560px;
  background: #ffffff;
  box-shadow: var(--shadow-md);
  line-height: 0;
  border-radius: 2px;
}
.gl-sheet-frame svg {
  display: block;
  width: 100%;
  height: auto;
}
.gl-stage-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.gl-badge-local {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #059669;
  font-weight: 700;
}

/* Cards & Grids */
.gl-grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin: 20px 0 36px;
}
.gl-card {
  display: flex;
  flex-direction: column;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.gl-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}
.gl-card-tag {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.gl-card h3 { margin: 0 0 6px; font-size: 1.05rem; }
.gl-card p { margin: 0; font-size: 0.88rem; color: var(--text-muted); }

/* Preset Chips */
.gl-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 24px;
}
.gl-chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
}
.gl-chip:hover, .gl-chip.is-current {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
}

/* Rich Content Sections (SEO & Helpful Guides) */
.gl-content-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 24px;
}
.gl-content-section h2 {
  margin: 0 0 14px;
  font-size: 1.3rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.gl-content-section h3 {
  margin: 20px 0 8px;
  font-size: 1.05rem;
}
.gl-spec-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.92rem;
}
.gl-spec-table th, .gl-spec-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.gl-spec-table th {
  width: 34%;
  color: var(--text-muted);
  font-weight: 600;
  background: var(--surface-alt);
}

.gl-faq-item {
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}
.gl-faq-item:last-child { border-bottom: none; }
.gl-faq-item summary {
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.gl-faq-item p {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 0.94rem;
}

/* CLS-Safe AdSense Slots (Hidden cleanly until active) */
.gl-ad-slot {
  display: none;
  margin: 20px auto;
  text-align: center;
  min-height: 100px;
  overflow: hidden;
}
.gl-ad-slot.is-active {
  display: block;
}

/* Footer */
.gl-footer {
  margin-top: 48px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 36px 0 28px;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.gl-footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 24px;
  margin-bottom: 24px;
}
.gl-footer h4 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 0.92rem;
}
.gl-footer ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.gl-footer li { margin-bottom: 6px; }
.gl-footer a { color: var(--text-muted); }
.gl-footer a:hover { color: var(--accent); }
.gl-footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.82rem;
}

/* Toast Notification */
.gl-toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: #0f172a;
  color: #f8fafc;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
}
.gl-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media print {
  .gl-header, .gl-footer, .gl-panel, .gl-toolbar, .gl-stage-footer, .gl-breadcrumb, .gl-hero, .gl-content-section, .gl-ad-slot {
    display: none !important;
  }
  .gl-desk { padding: 0; background: #fff; max-height: none; overflow: visible; }
  .gl-sheet-frame { max-width: none; box-shadow: none; }
}
