html {
  font-size: 16px;
  height: 100%;
}

@media (max-width: 1440px) {
  html {
    font-size: 14px;
  }
}

@media (max-width: 1024px) {
  html {
    font-size: 12px;
  }
}

@media (max-width: 768px) {
  html {
    font-size: 10px;
  }
}

:root {
  --bg: #f7f3ea;
  --panel: rgba(255, 251, 245, 0.92);
  --panel-strong: #fffdf8;
  --ink: #1d1b16;
  --muted: #6e6558;
  --line: rgba(61, 47, 32, 0.12);
  --accent: #d7612f;
  --accent-soft: rgba(215, 97, 47, 0.14);
  --shadow: 0 1.25rem 2.5rem rgba(54, 41, 25, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: "IBM Plex Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 225, 177, 0.55), transparent 28%),
    radial-gradient(circle at bottom right, rgba(212, 145, 115, 0.24), transparent 24%),
    linear-gradient(135deg, #f8f1e4, #f4efe9 55%, #efe7db);
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

.sidebar,
.toolbar {
  backdrop-filter: blur(1rem);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 15rem;
  flex-shrink: 0;
  min-height: 0;
  padding: 1.5rem 1rem;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 248, 237, 0.94), rgba(255, 252, 247, 0.82));
  border-right: 1px solid var(--line);
  transition:
    transform 380ms cubic-bezier(0.4, 0, 0.2, 1),
    margin-left 380ms cubic-bezier(0.4, 0, 0.2, 1),
    opacity 300ms ease;
}

body.is-presentation-mode .sidebar {
  transform: translateX(-100%);
  margin-left: -15rem;
  opacity: 0;
  pointer-events: none;
}

.workspace {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

h1,
h2 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  line-height: 1;
}

.sidebar__hint {
  margin: 0.75rem 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.component-palette {
  display: grid;
  gap: 0.75rem;
  min-height: 0;
  overflow: auto;
  padding-right: 0.25rem;
}

.component-palette.is-disabled {
  opacity: 0.5;
}

.component-card {
  display: grid;
  gap: 0.5rem;
  padding: 0.6rem;
  border: 1px solid transparent;
  border-radius: 1rem;
  background: var(--panel);
  box-shadow: var(--shadow);
  cursor: grab;
  text-align: center;
  justify-items: center;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

.component-card:hover {
  transform: translateY(-0.1rem);
  border-color: rgba(215, 97, 47, 0.25);
}

.component-card:disabled {
  cursor: not-allowed;
  transform: none;
}

.component-card strong {
  font-size: 0.85rem;
  color: var(--muted);
}

.component-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 5 / 3;
  border-radius: 0.65rem;
  background: rgba(61, 47, 32, 0.04);
  overflow: hidden;
}

.component-preview img,
.component-preview svg {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  height: 4rem;
  flex-shrink: 0;
  padding: 0 1rem;
  background: rgba(255, 251, 245, 0.72);
  border-bottom: 1px solid var(--line);
  transition:
    transform 380ms cubic-bezier(0.4, 0, 0.2, 1),
    margin-top 380ms cubic-bezier(0.4, 0, 0.2, 1),
    opacity 300ms ease;
}

body.is-presentation-mode .toolbar {
  transform: translateY(-100%);
  margin-top: -4rem;
  opacity: 0;
  pointer-events: none;
}

.toolbar__cluster {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toolbar__field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
}

.toolbar__field input:disabled,
.toolbar__field output:disabled {
  opacity: 0.45;
}

.toolbar__field--slider output {
  width: 2rem;
  text-align: right;
  color: var(--ink);
}

.tool-button,
.ghost-button {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
}

.tool-button,
.ghost-button {
  padding: 0.65rem 0.95rem;
  cursor: pointer;
}

.tool-button:disabled,
.ghost-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tool-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  background: rgba(65, 52, 39, 0.08);
}

.component-editor-modal[hidden] {
  display: none;
}

.component-editor-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
}

.component-editor-modal__backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top, rgba(255, 228, 181, 0.16), transparent 30%),
    rgba(29, 27, 22, 0.38);
  backdrop-filter: blur(0.6rem);
}

.component-editor-modal__dialog {
  position: relative;
  width: min(42rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
  padding: 1.4rem;
  border: 1px solid rgba(61, 47, 32, 0.12);
  border-radius: 1.5rem;
  background: linear-gradient(180deg, rgba(255, 252, 247, 0.98), rgba(255, 248, 239, 0.95));
  box-shadow: 0 2rem 5rem rgba(54, 41, 25, 0.24);
}

.component-editor-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.component-editor-modal__eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.component-editor-modal__title {
  margin: 0;
  font-size: 1.7rem;
}

.component-editor-modal__description {
  margin: 0.45rem 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.component-editor-modal__form,
.component-editor-modal__fields {
  display: grid;
  gap: 1rem;
}

.component-editor-modal__field {
  display: grid;
  gap: 0.45rem;
}

.component-editor-modal__field-label {
  font-weight: 600;
}

.component-editor-modal__field-description {
  color: var(--muted);
  font-size: 0.92rem;
}

.component-editor-modal__input {
  width: 100%;
  min-width: 0;
  padding: 0.8rem 0.9rem;
  border: 1px solid rgba(61, 47, 32, 0.14);
  border-radius: 0.95rem;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  outline: none;
}

.component-editor-modal__input:focus {
  border-color: rgba(215, 97, 47, 0.42);
  box-shadow: 0 0 0 0.2rem rgba(215, 97, 47, 0.12);
}

.component-editor-modal textarea.component-editor-modal__input {
  resize: vertical;
  min-height: 7rem;
}

.component-editor-modal input[type="color"].component-editor-modal__input {
  padding: 0.35rem;
  min-height: 3rem;
}

.component-editor-modal__file-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.component-editor-modal__file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.component-editor-modal__file-button {
  display: inline-block;
  padding: 0.65rem 1.15rem;
  border-radius: 999px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 140ms ease;
}

.component-editor-modal__file-button:hover {
  border-color: rgba(215, 97, 47, 0.42);
  background: white;
  color: var(--accent);
}

.component-editor-modal__file-name {
  font-size: 0.85rem;
  color: var(--muted);
}

.component-editor-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.component-editor-modal__submit {
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1.15rem;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

.tool-button svg {
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
}

.tool-button[aria-pressed="true"] {
  background: var(--accent);
  color: #fff6f0;
}

.ghost-button {
  background: rgba(65, 52, 39, 0.08);
}

.board-shell {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.canvas-container {
  width: 100%;
  height: 100%;
}

.canvas-container canvas {
  display: block;
}

.mode-toggle {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem 0.45rem 0.55rem;
  border-radius: 999px;
  background: var(--panel);
  box-shadow: var(--shadow);
  cursor: pointer;
  user-select: none;
  backdrop-filter: blur(1rem);
  border: 1px solid var(--line);
}

.mode-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.mode-toggle__track {
  position: relative;
  width: 2.4rem;
  height: 1.35rem;
  border-radius: 999px;
  background: rgba(65, 52, 39, 0.2);
  transition: background 250ms ease;
  flex-shrink: 0;
}

.mode-toggle input:checked ~ .mode-toggle__track {
  background: var(--accent);
}

.mode-toggle__thumb {
  position: absolute;
  top: 0.175rem;
  left: 0.175rem;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

.mode-toggle input:checked ~ .mode-toggle__track .mode-toggle__thumb {
  transform: translateX(1.05rem);
}

.mode-toggle__label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  line-height: 1;
  transition: color 250ms ease;
}

body.is-edit-mode .mode-toggle__label {
  color: var(--accent);
}

.is-drop-target {
  outline: 2px dashed rgba(215, 97, 47, 0.6);
  outline-offset: -0.8rem;
}

@media (max-width: 900px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    width: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  body.is-presentation-mode .sidebar {
    transform: translateY(-100%);
    margin-left: 0;
    margin-top: -15rem;
  }
}
