:root {
  --bg: #FAFAFA; /* Off-white background */
  --panel: #FFFFFF;
  --text-main: #18181B; /* Zinc-900 */
  --text-muted: #71717A; /* Zinc-500 */
  --border: #E4E4E7; /* Zinc-200 */
  --accent: #2563EB; /* Blue-600 */
  --accent-hover: #1D4ED8;
  --danger: #EF4444;
  --radius: 12px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Typography */
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 700; letter-spacing: -0.025em; }
p { margin: 0; }

/* Navbar */
.site-header {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.site-header .inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-main);
  font-weight: 700;
  font-size: 18px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: white;
  font-size: 16px;
}

.nav-links {
  display: flex;
  gap: 24px;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14px;
  transition: color 0.15s;
}

.nav-links a:hover { color: var(--accent); }

/* Layout */
.main-layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 24px;
  min-height: calc(100vh - 64px - 80px); /* Minus header & footer */
}

@media (max-width: 1024px) {
  .main-layout { grid-template-columns: 1fr; }
}

/* Sidebar / Controls */
.controls-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  /* overflow: hidden; Removed to allow dropdowns */
}

/* Accordion Sections */
.section { border-bottom: 1px solid var(--border); }
.section:last-child { border-bottom: none; }

.panel > .section:first-child .section-header {
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}
.panel > .section:last-child:not(.collapsed) .section-content {
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}
.panel > .section:last-child.collapsed .section-header {
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

.section-header {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  background: #F4F4F5; /* darker header */
  transition: background 0.15s;
}

.section-header:hover { background: #E4E4E7; }

.section-title h3 { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.section-chevron { color: var(--text-muted); font-size: 12px; transition: transform 0.2s; }
.section.collapsed .section-chevron { transform: rotate(-90deg); }

.section-content {
  padding: 16px;
  background: #FFFFFF; /* white body */
  /* Use JS to toggle display/height if needed, or CSS max-height */
  display: block;
  border-top: 1px solid var(--border); /* separator */
}
.section.collapsed .section-content { display: none; }

/* Control inputs */
.control-group { margin-bottom: 16px; }
.control-group:last-child { margin-bottom: 0; }
.control-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.row { display: grid; gap: 8px; margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text-main);
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="text"]:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

input[type="color"] {
  width: 100%;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

/* Buttons */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s;
}

button:hover { background: #F4F4F5; }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.3);
}
button.primary:hover { background: var(--accent-hover); }

button.danger {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
  background: #FEF2F2;
}
button.danger:hover { background: #FEE2E2; }

/* Canvas Area */
.preview-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 24px;
}

.canvas-wrapper {
  background: #fff;
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  line-height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

canvas {
  max-width: 100%;
  max-height: 80vh; /* Limit height to 80% of viewport to avoid scrolling */
  width: auto;      /* Allow width to adjust based on height constraint */
  height: auto;     /* Maintain aspect ratio */
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.preview-controls {
  margin-top: 24px;
  display: flex;
  gap: 12px;
  align-items: center;
}

/* Lists (Photos, Blocks) */
.item-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: #F9FAFB;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  height: 32px;
}

.list-item.active {
  background: #EFF6FF;
  border-color: var(--accent);
  color: var(--accent);
}

.list-item-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0; /* Enable flex child truncation */
}

.list-item-title { 
  font-weight: 600; 
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item-meta { display: none; } /* Hide meta for compactness */

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: #fff;
  padding: 32px 24px;
  margin-top: auto;
}

.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-muted);
  font-size: 13px;
}

.footer-links {
  display: flex;
  gap: 24px;
}
.footer-links a {
  text-decoration: none;
  color: var(--text-muted);
  transition: color 0.15s;
}
.footer-links a:hover { color: var(--text-main); }

/* Utilities */
.hidden { display: none; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #18181B;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* Custom Font Dropdown */
.custom-select-wrapper {
  position: relative;
  user-select: none;
  width: 100%;
}

.custom-select-trigger {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: 13px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.custom-select-trigger:hover { border-color: var(--accent); }

.custom-select-trigger span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.custom-select-trigger::after {
  content: "▼";
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 8px;
}

.custom-options {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow-md);
  margin-top: 4px;
  z-index: 100;
  max-height: 300px;
  overflow-y: auto;
  display: none;
}

.custom-options.open { display: block; }

.custom-option {
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text-main);
  cursor: pointer;
  border-bottom: 1px solid #f4f4f5;
  transition: background 0.1s;
}
.custom-option:last-child { border-bottom: none; }
.custom-option:hover { background: #f4f4f5; color: var(--accent); }
.custom-option.selected { background: #eff6ff; color: var(--accent); font-weight: 600; }

.option-group-label {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  background: #fafafa;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  pointer-events: none;
}

/* Text Page Layout */
.text-content {
  max-width: 800px;
  margin: 48px auto;
  padding: 0 24px;
}

.text-content h1 {
  font-size: 2.25rem;
  margin-bottom: 2rem;
  color: var(--text-main);
}

.text-content h2 {
  font-size: 1.5rem;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  color: var(--text-main);
}

.text-content p, .text-content li {
  color: #374151;
  margin-bottom: 1.25rem;
  font-size: 1.05rem;
}

.text-content a {
  color: var(--accent);
  text-decoration: none;
}

.text-content a:hover {
  text-decoration: underline;
}

/* FAQ Section */
.faq-section {
  grid-column: 1 / -1;
  max-width: 800px;
  margin: 64px auto;
  padding: 0 24px;
}

.faq-title {
  text-align: center;
  margin-bottom: 32px;
  font-size: 2rem;
}

.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
  background: white;
}

.faq-question {
  padding: 16px 20px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #F4F4F5;
  transition: background 0.2s;
}

.faq-question:hover {
  background: #E4E4E7;
}

.faq-answer {
  padding: 0 20px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out, padding 0.3s ease;
  color: var(--text-muted);
  line-height: 1.6;
}

.faq-item.active .faq-answer {
  padding: 16px 20px;
  max-height: 500px; /* Arbitrary large height */
  border-top: 1px solid var(--border);
}

.faq-chevron {
  transition: transform 0.3s;
}

.faq-item.active .faq-chevron {
  transform: rotate(180deg);
}
