:root {
  color-scheme: light;
  --ink: #1b1b1f;
  --paper: #f6f2e9;
  --accent: #ff6b3d;
  --accent-dark: #d94a1f;
  --teal: #1e8c87;
  --line: #1b1b1f;
  --shadow: rgba(17, 16, 15, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", system-ui, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #fff7e1, #f4efe2 55%, #efe3d4 100%);
  min-height: 100vh;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.toolbar {
  display: grid;
  grid-template-columns: 1.2fr 2fr 1fr;
  gap: 1.5rem;
  padding: 1.5rem 2.5rem;
  align-items: center;
  background: linear-gradient(120deg, #fff7e8 0%, #f9ede0 55%, #f3e4d4 100%);
  border-bottom: 2px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
}

.menu-toggle {
  display: inline-flex;
  border: 2px solid var(--line);
  background: #fffaf2;
  padding: 0.35rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.brand {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.brand h1 {
  font-family: "Syne", sans-serif;
  font-size: 1.6rem;
  margin: 0;
  letter-spacing: 0.05em;
}

.brand p {
  margin: 0;
  font-size: 0.95rem;
  color: rgba(27, 27, 31, 0.7);
}

.logo-dot {
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(255, 107, 61, 0.2);
}

.controls,
.cast {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.cast {
  flex-direction: column;
  align-items: flex-end;
}

body.menu-collapsed .controls,
body.menu-collapsed .toolset,
body.menu-collapsed .brand {
  display: none;
}

body.menu-collapsed #screenCastBtn {
  display: none;
}

body.menu-collapsed .toolbar {
  gap: 0.6rem;
  padding: 0.5rem 0.7rem;
  border-radius: 14px;
  grid-template-columns: 1fr;
  justify-items: end;
}

body.menu-collapsed .menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.toolset {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.tool-buttons {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.tool {
  border: 2px solid var(--line);
  background: #fffaf2;
  color: var(--ink);
  padding: 0.35rem 0.55rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.tool svg {
  width: 20px;
  height: 20px;
  display: block;
}

.tool.active {
  background: var(--ink);
  color: #fff7ef;
}

.field {
  display: flex;
  flex-direction: column;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  gap: 0.3rem;
}

.field input[type="text"],
.field input[type="range"],
.field input[type="color"] {
  border: 2px solid var(--line);
  background: #fffaf2;
  padding: 0.35rem 0.6rem;
  font-size: 0.9rem;
}

.field input[type="text"] {
  min-width: 140px;
}

.field input[type="range"] {
  accent-color: var(--accent);
}

.controls button,
.cast button {
  border: 2px solid var(--line);
  background: var(--ink);
  color: #fdf7ef;
  padding: 0.6rem 1.2rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.controls button:hover,
.cast button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--shadow);
}

.controls button.ghost {
  background: transparent;
  color: var(--ink);
}

.cast button.primary {
  background: var(--accent);
  border-color: var(--accent-dark);
}

.cast button.active {
  background: var(--teal);
  border-color: #116d69;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.stage {
  position: relative;
  flex: 1;
  padding: 1.5rem 2.5rem 2.5rem;
}

canvas {
  width: 100%;
  height: 100%;
  background: #fffaf2;
  border: 2px solid var(--line);
  box-shadow: 0 24px 40px rgba(0, 0, 0, 0.08);
  cursor: crosshair;
  touch-action: none;
}

canvas.panning {
  cursor: grab;
}

.floating-text {
  position: absolute;
  min-width: 120px;
  max-width: 320px;
  border: 2px solid var(--line);
  background: #fffaf2;
  font-family: "Space Grotesk", system-ui, sans-serif;
  padding: 0.4rem 0.6rem;
  outline: none;
  resize: none;
  z-index: 3;
}

.hint {
  position: absolute;
  bottom: 2rem;
  left: 2.5rem;
  background: rgba(27, 27, 31, 0.9);
  color: #fdf7ef;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  display: flex;
  gap: 1.2rem;
  animation: float-in 0.7s ease;
}

.status {
  padding: 0.8rem 2.5rem 1.2rem;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  border-top: 2px solid var(--line);
  background: #f8f0e2;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(18, 17, 16, 0.5);
  display: grid;
  place-items: center;
  z-index: 6;
}

.modal.hidden {
  display: none;
}

.modal-card {
  background: #fffaf2;
  border: 2px solid var(--line);
  padding: 1.5rem 1.8rem;
  max-width: 420px;
  width: calc(100% - 3rem);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.16);
}

.modal-card h2 {
  margin: 0 0 0.6rem;
  font-family: "Syne", sans-serif;
  letter-spacing: 0.04em;
}

.modal-card p {
  margin: 0 0 1.4rem;
  line-height: 1.4;
  white-space: pre-line;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
}

@keyframes float-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .toolbar {
    grid-template-columns: 1fr;
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    left: auto;
    width: auto;
    padding: 0.75rem 0.9rem;
    border-radius: 18px;
    background: rgba(255, 247, 232, 0.92);
    backdrop-filter: blur(6px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
    display: inline-flex;
    flex-direction: column;
    align-items: stretch;
  }

  .controls,
  .cast {
    justify-content: flex-start;
  }

  .menu-toggle {
    align-items: center;
    justify-content: center;
  }

  body.menu-collapsed .toolbar {
    gap: 0.6rem;
    padding: 0.45rem;
    border-radius: 14px;
  }

  body.menu-collapsed .menu-toggle {
    padding: 0.35rem 0.6rem;
    font-size: 0.7rem;
  }

  .field {
    font-size: 0;
  }

  .field input {
    font-size: 0.85rem;
  }

  .field input[type="text"] {
    min-width: 110px;
  }

  .controls button,
  .cast button {
    padding: 0.45rem 0.75rem;
    font-size: 0.75rem;
  }

  .stage {
    padding: 0;
  }

  canvas {
    border-radius: 0;
  }

  .hint {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    flex-direction: column;
    align-items: flex-start;
    border-radius: 16px;
  }
}
