:root {
  --cream: #f5efe6;
  --amber: #f2c48d;
  --ink: #1b1a16;
  --teal: #2c6e6f;
  --card: rgba(255, 255, 255, 0.9);
  --panel: rgba(255, 255, 255, 0.94);
  --shadow: 0 24px 60px rgba(27, 26, 22, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background: linear-gradient(130deg, #f7efe1 0%, #fcf7ef 45%, #e6f2f0 100%)
    fixed;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.2;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.18'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

.layout {
  max-width: 1240px;
  margin: 0 auto;
  padding: 32px;
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border-radius: 28px;
  padding: 28px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 24px;
  display: grid;
  gap: 22px;
}

.brand {
  display: grid;
  gap: 8px;
}

.tag {
  text-transform: uppercase;
  letter-spacing: 0.24em;
  font-size: 0.7rem;
  color: var(--teal);
  margin: 0;
}

h1 {
  font-family: "Fraunces", serif;
  font-size: clamp(2.2rem, 3.2vw, 3rem);
  margin: 0;
}

.subtitle {
  margin: 0;
  font-size: 1rem;
  color: #4a463b;
}

.status {
  padding: 12px 16px;
  border-radius: 16px;
  background: rgba(44, 110, 111, 0.08);
  color: #2b5b5a;
  font-size: 0.9rem;
}

.controls {
  display: grid;
  gap: 16px;
}

.panel-scroll {
  display: grid;
  gap: 18px;
  max-height: calc(100vh - 220px);
  overflow: auto;
  padding-right: 4px;
}

label {
  display: grid;
  gap: 8px;
  font-size: 0.92rem;
}

input[type="number"],
select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(27, 26, 22, 0.2);
  font-size: 0.98rem;
  background: rgba(255, 255, 255, 0.95);
}

input[type="range"] {
  width: 100%;
  accent-color: #2c6e6f;
}

.buttons {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

button {
  padding: 12px 18px;
  border-radius: 999px;
  border: none;
  font-weight: 600;
  font-size: 0.98rem;
  background: linear-gradient(135deg, var(--teal), #3a948e);
  color: #f9f6f0;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 12px 30px rgba(44, 110, 111, 0.24);
}

button.secondary {
  background: linear-gradient(135deg, #7a6b5a, #a6947d);
  box-shadow: 0 12px 26px rgba(27, 26, 22, 0.18);
}

button.ghost {
  background: transparent;
  color: #2b5b5a;
  border: 1px solid rgba(43, 91, 90, 0.4);
  box-shadow: none;
  padding: 8px 14px;
}

button:disabled {
  opacity: 0.5;
  cursor: wait;
  box-shadow: none;
}

button:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(44, 110, 111, 0.3);
}

.fitness {
  border-top: 1px solid rgba(27, 26, 22, 0.08);
  padding-top: 12px;
}

.fitness summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.fitness summary::-webkit-details-marker {
  display: none;
}

.summary-note {
  font-size: 0.78rem;
  color: #6b6154;
}

.fitness-body {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.sliders {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
}

.slider {
  display: grid;
  gap: 6px;
}

.slider-value {
  font-variant-numeric: tabular-nums;
  color: #5a5145;
}

.panel-hint {
  font-size: 0.85rem;
  color: #5a5145;
  margin: 0;
}

.gallery {
  display: grid;
  gap: 18px;
}

.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.gallery-header h2 {
  font-family: "Fraunces", serif;
  font-size: 1.6rem;
  margin: 0;
}

.gallery-header p {
  margin: 6px 0 0;
  color: #5a5145;
}

.gallery-card {
  background: var(--card);
  border-radius: 32px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.gallery-grid {
  --tile-size: 128px;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 16px;
  justify-content: start;
}

.tile {
  background: #f6f1e8;
  border-radius: 18px;
  border: 1px solid rgba(27, 26, 22, 0.12);
  box-shadow: 0 8px 18px rgba(27, 26, 22, 0.08);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tile:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 24px rgba(27, 26, 22, 0.12);
}

.tile canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 16px;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 10;
}

.modal.open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 20, 20, 0.5);
}

.modal-content {
  position: relative;
  background: #fff;
  border-radius: 24px;
  padding: 24px;
  max-width: 720px;
  width: min(90vw, 720px);
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
  z-index: 1;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-content canvas {
  width: 100%;
  height: auto;
  border-radius: 18px;
  border: 1px solid rgba(27, 26, 22, 0.12);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.detail-grid span {
  display: block;
  color: #6b6154;
  font-size: 0.85rem;
}

.detail-grid strong {
  font-size: 1.05rem;
}

.detail-summary {
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f6f1e8;
  border: 1px solid rgba(27, 26, 22, 0.1);
  max-height: 240px;
  overflow: auto;
  font-size: 0.85rem;
  line-height: 1.4;
  white-space: pre-wrap;
}

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

  .panel {
    position: static;
  }
}

@media (max-width: 1200px) {
  .gallery-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .gallery-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
