@font-face {
  font-family: "Excalifont";
  src: url("fonts/Excalifont-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --bg: #f3f4f9;
  --panel: #111827;
  --panel-light: rgba(17, 24, 39, 0.65);
  --accent: #6366f1;
  --accent-strong: #4338ca;
  --danger: #ef4444;
  --text-light: #f9fafb;
  --text-muted: #9ca3af;
  --canvas-bg: #ffffff;
  --timeline-bg: #0f172a;
  --timeline-track: rgba(148, 163, 184, 0.45);
  --timeline-marker: #facc15;
  --ui-font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ui-font-size: 0.95rem;
  font-family: var(--ui-font-family);
  font-size: var(--ui-font-size);
}

* {
  box-sizing: border-box;
}

button,
input,
select,
textarea,
summary,
details {
  font-family: inherit;
  font-size: var(--ui-font-size);
  line-height: 1.2;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: radial-gradient(circle at top left, #111827, #0f172a 45%, #020617 100%);
  color: var(--text-light);
  min-height: 100vh;
  font-family: var(--ui-font-family);
  font-size: var(--ui-font-size);
}

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.5rem;
  gap: 1.5rem;
}

.app-brand {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
}

.app-brand img {
  display: block;
  max-width: 112px;
}

.app-header h1 {
  margin: 0;
  font-size: 1.75rem;
  text-align: left;
}

.app-header p {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

.export-menu {
  position: relative;
  min-width: 12rem;
}

.export-menu summary {
  list-style: none;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: white;
  padding: 0.55rem 1rem;
  border-radius: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  transition: background 120ms ease, transform 120ms ease;
  box-shadow: 0 12px 35px rgba(15, 23, 42, 0.3);
}

.export-menu summary::after {
  content: "▾";
  font-size: 0.8rem;
  opacity: 0.85;
}

.export-menu summary:focus-visible {
  outline: 2px solid rgba(99, 102, 241, 0.8);
  outline-offset: 2px;
}

.export-menu[open] summary {
  background: rgba(99, 102, 241, 0.9);
  border-color: rgba(99, 102, 241, 0.6);
  transform: translateY(-1px);
}

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

.export-menu .menu-list {
  position: absolute;
  right: 0;
  margin-top: 0.5rem;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 1rem;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: 0 20px 45px rgba(2, 6, 23, 0.35);
  min-width: 16rem;
  backdrop-filter: blur(14px);
  z-index: 10;
}

.export-menu .menu-list button {
  width: 100%;
  justify-content: flex-start;
  gap: 0.75rem;
}

.export-menu .menu-list p {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0.5rem;
  padding: 0 2rem 0.5rem;
}

.toolbar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.toolbar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(15, 23, 42, 0.35);
  color: rgba(226, 232, 240, 0.9);
  transition: background 120ms ease, color 120ms ease, transform 120ms ease;
}

.toolbar-toggle:hover {
  background: rgba(59, 130, 246, 0.3);
  color: white;
  transform: translateY(-1px);
}

.toolbar-toggle:focus-visible {
  outline: 2px solid rgba(96, 165, 250, 0.9);
  outline-offset: 2px;
}

.toolbar-toggle svg {
  width: 1.25rem;
  height: 1.25rem;
}

.toolbar-toggle.tool-menu-toggle svg {
  width: 1.1rem;
  height: 1.1rem;
}

.toolbar-toggle svg[data-icon="expand"] {
  display: none;
}

.toolbar-toggle[aria-pressed="true"] svg[data-icon="collapse"] {
  display: none;
}

.toolbar-toggle[aria-pressed="true"] svg[data-icon="expand"] {
  display: block;
}

.icon-only {
  padding: 0;
}

.app-shell.toolbar-collapsed .workspace {
  grid-template-columns: 1fr;
  gap: 0;
}

.app-shell.toolbar-collapsed .toolbar {
  display: none;
}

.app-shell.toolbar-collapsed .stage-area {
  grid-column: 1 / -1;
}

.toolbar {
  background: var(--panel-light);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 1.25rem;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  backdrop-filter: blur(16px);
}

.toolbar h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.8);
}

.toolbar-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}


.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-light);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.tool-button:hover {
  transform: translateY(-1px);
  border-color: rgba(99, 102, 241, 0.55);
  background: rgba(99, 102, 241, 0.22);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.25);
}

.tool-button:focus-visible {
  outline: 2px solid rgba(99, 102, 241, 0.8);
  outline-offset: 2px;
}

.tool-button.selected {
  background: rgba(99, 102, 241, 0.95);
  border-color: rgba(99, 102, 241, 0.7);
  color: white;
  box-shadow: 0 10px 20px rgba(99, 102, 241, 0.35);
}


.floating-tool-menu {
  position: absolute;
  top: 0.0rem;
  left: 50%;
  transform: translate(-50%, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  width: calc(75% - 1.5rem);
  max-width: 56rem;
  padding: 0.85rem 1.25rem;
  border-radius: 1.25rem;
  background: rgba(17, 24, 39, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(18px);
  z-index: 4;
  pointer-events: auto;
  transition: opacity 160ms ease, transform 160ms ease;
}

.tool-cluster {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.tool-divider {
  width: 1px;
  height: 2.5rem;
  background: rgba(255, 255, 255, 0.18);
  opacity: 0.65;
  align-self: stretch;
}

.floating-tool-menu .tool-button {
  flex: 0 0 auto;
}

.floating-tool-menu .tool-button.selected {
  border-color: rgba(99, 102, 241, 0.8);
}

.tool-icon {
  width: 1.35rem;
  height: 1.35rem;
}

.tool-icon * {
  transition: stroke 120ms ease, fill 120ms ease;
}

.tool-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tool-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.tool-button:disabled:hover {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
}

@media (max-width: 760px) {
  .floating-tool-menu {
    left: 50%;
    transform: translate(-50%, 0);
    width: calc(100% - 1.5rem);
    max-width: 32rem;
    justify-content: center;
  }

  .tool-divider {
    display: none;
  }
}

.control {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.86);
}

.control-label {
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.65);
}

.color-controls {
  flex-direction: row;
  align-items: stretch;
  gap: 0.75rem;
}

.color-control {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.color-control span {
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.65);
}

.stage-surface {
  position: relative;
  display: inline-block;
  overflow: visible;
}

.stage-surface canvas {
  display: block;
}

.control.compact {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.control input[type="color"] {
  width: 100%;
  height: 2.25rem;
  border-radius: 0.75rem;
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.control select {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(15, 23, 42, 0.65);
  color: var(--text-light);
  font-size: 0.85rem;
}

.control input[type="range"] {
  width: 100%;
}

.control input[type="number"] {
  width: 4.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(15, 23, 42, 0.65);
  color: var(--text-light);
}

.control .value {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.icon-toggle-group {
  gap: 0.6rem;
}

.icon-toggle-row {
  display: flex;
  gap: 0.65rem;
  align-items: center;
}

.icon-toggle {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(15, 23, 42, 0.45);
  color: rgba(255, 255, 255, 0.85);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.icon-toggle svg {
  width: 1.2rem;
  height: 1.2rem;
}

.icon-toggle:hover {
  transform: translateY(-1px);
  border-color: rgba(99, 102, 241, 0.55);
  background: rgba(99, 102, 241, 0.18);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.25);
}

.icon-toggle:focus-visible {
  outline: 2px solid rgba(99, 102, 241, 0.8);
  outline-offset: 2px;
}

.icon-toggle[aria-pressed="true"] {
  background: rgba(99, 102, 241, 0.85);
  border-color: rgba(99, 102, 241, 0.6);
  color: white;
  box-shadow: 0 10px 24px rgba(99, 102, 241, 0.35);
}

.icon-toggle-group.is-disabled {
  opacity: 0.45;
}

.icon-toggle[disabled],
.icon-toggle.disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
  box-shadow: none;
  background: rgba(15, 23, 42, 0.3);
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.6);
}

.icon-toggle[disabled]:hover,
.icon-toggle.disabled:hover {
  transform: none;
  background: rgba(15, 23, 42, 0.3);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

.arrow-ending-control .icon-toggle {
  width: 2.8rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.is-hidden {
  display: none !important;
}

.arrow-ending-control {
  gap: 0.5rem;
}

.selection-info {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.selection-info p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

button {
  font-family: inherit;
}

button.primary {
  background: var(--accent);
  border: none;
  color: white;
  border-radius: 0.85rem;
  padding: 0.6rem 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, transform 120ms ease;
}

button.primary:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

button.ghost {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  border-radius: 0.85rem;
  padding: 0.55rem 1rem;
  cursor: pointer;
}

button.ghost:hover {
  background: rgba(255, 255, 255, 0.12);
}

button.ghost[aria-pressed="true"] {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.45);
}

button.danger {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 0.85rem;
  padding: 0.55rem 1rem;
  cursor: pointer;
}

button.danger:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.toolbar-section.tips {
  display: flex;
  flex-direction: column;
  max-height: 400px;
  overflow: hidden;
}

.tips-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-shrink: 0;
}

.tips ul {
  margin: 0;
  padding-left: 0;
  padding-right: 0.5rem;
  color: rgba(229, 231, 235, 0.85);
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.3) transparent;
}

.tips ul::-webkit-scrollbar {
  width: 6px;
}

.tips ul::-webkit-scrollbar-track {
  background: transparent;
}

.tips ul::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 3px;
}

.tips ul::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.5);
}

.tip-item {
  list-style: none;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.tip-item span {
  flex: 1;
  line-height: 1.5;
}

.tip-dismiss {
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  width: 1.75rem;
  height: 1.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, transform 120ms ease;
  flex-shrink: 0;
}

.tip-dismiss:hover {
  background: rgba(239, 68, 68, 0.35);
  color: white;
  transform: scale(1.05);
}

.tip-dismiss:focus-visible {
  outline: 2px solid rgba(239, 68, 68, 0.65);
  outline-offset: 2px;
}

.stage-area {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
  overflow: visible;
}

.toolbar-toggle-floating {
  position: absolute;
  top: 0;
  left: -0.75rem;
  z-index: 10;
  display: none;
  opacity: 0;
  pointer-events: none;
}

.app-shell.toolbar-collapsed .toolbar-toggle-floating {
  display: inline-flex;
  opacity: 1;
  pointer-events: auto;
  left: 0.5rem;
  top: 0.5rem;
}

.canvas-wrapper {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03));
  border-radius: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.25rem;
  padding-top: 4rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  position: relative;
  overflow: visible;
}

.canvas-wrapper.tool-menu-collapsed {
  padding-top: 0.25rem;
}

.canvas-wrapper.tool-menu-collapsed .floating-tool-menu {
  transform: translate(-50%, -0.6rem);
}

.floating-tool-menu .tool-menu-toggle {
  margin-left: auto;
  flex-shrink: 0;
}

.floating-tool-menu[data-collapsed="true"] {
  width: auto;
  max-width: none;
  padding: 0.6rem 0.75rem;
  gap: 0.5rem;
  justify-content: center;
}

.floating-tool-menu[data-collapsed="true"] .tool-cluster,
.floating-tool-menu[data-collapsed="true"] .tool-divider {
  display: none;
}

.floating-tool-menu[data-collapsed="true"] .tool-menu-toggle {
  margin-left: 0;
}

.canvas-wrapper::after {
  content: "";
  position: absolute;
  inset: 0;
  background-size: 32px 32px;
  background-image: linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  opacity: 0.35;
  pointer-events: none;
  border-radius: inherit;
  z-index: 0;
}

#stage {
  background: var(--canvas-bg);
  border-radius: 1rem;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(15, 23, 42, 0.2);
  max-width: 100%;
  max-height: 100%;
}

.stage-dimensions {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: 0.03em;
  pointer-events: none;
  backdrop-filter: blur(6px);
}

.zoom-controls {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  z-index: 10;
}

.zoom-button {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(15, 23, 42, 0.6);
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  backdrop-filter: blur(6px);
}

.zoom-button:hover {
  background: rgba(15, 23, 42, 0.8);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
  transform: scale(1.05);
}

.zoom-button:active {
  transform: scale(0.95);
}

.zoom-button svg {
  width: 1.25rem;
  height: 1.25rem;
}

.zoom-reset {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0 0.5rem;
}

.zoom-reset .zoom-level {
  white-space: nowrap;
}

.stage-resize-handle {
  position: absolute;
  width: 2rem;
  height: 2rem;
  border-radius: 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(15, 23, 42, 0.6);
  color: rgba(255, 255, 255, 0.85);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.35);
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
  z-index: 5;
}

.stage-resize-handle--corner {
  bottom: 0.5rem;
  right: 0.5rem;
  cursor: nwse-resize;
}

.stage-resize-handle--right {
  top: 50%;
  right: 0.5rem;
  margin-top: -1rem;
  cursor: ew-resize;
}

.stage-resize-handle--bottom {
  left: 50%;
  bottom: 0.5rem;
  margin-left: -1rem;
  cursor: ns-resize;
}

.stage-resize-handle svg {
  width: 1.1rem;
  height: 1.1rem;
}

.stage-resize-handle:hover {
  transform: scale(1.05);
  background: rgba(99, 102, 241, 0.3);
  border-color: rgba(99, 102, 241, 0.6);
}

.stage-resize-handle:focus-visible {
  outline: 2px solid rgba(99, 102, 241, 0.8);
  outline-offset: 2px;
}

.canvas-wrapper.is-resizing .stage-resize-handle {
  background: rgba(99, 102, 241, 0.45);
  border-color: rgba(99, 102, 241, 0.75);
}

.canvas-text-editor {
  position: fixed;
  min-width: 220px;
  padding: 0.4rem 0.6rem;
  border-radius: 0.75rem;
  border: 2px solid var(--accent);
  background: rgba(15, 23, 42, 0.95);
  color: white;
  font-size: 1.2rem;
  line-height: 1.4;
  resize: none;
  outline: none;
  z-index: 4;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.45);
  transition: border-color 160ms ease;
  white-space: pre-wrap;
  overflow: hidden;
  font-family: inherit;
}

.canvas-text-editor:focus {
  border-color: rgba(99, 102, 241, 0.8);
}

.marquee-overlay {
  position: absolute;
  border: 1px dashed rgba(15, 23, 42, 0.5);
  background-color: rgba(99, 102, 241, 0.12);
  pointer-events: none;
  border-radius: 0.35rem;
  backdrop-filter: blur(2px);
  mix-blend-mode: multiply;
}

.context-menu {
  position: fixed;
  min-width: 180px;
  padding: 0.5rem 0;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 0.75rem;
  box-shadow: 0 20px 55px rgba(2, 6, 23, 0.5);
  z-index: 4000;
  color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
}

.context-menu[hidden] {
  display: none;
}

.context-menu__section {
  padding: 0 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.context-menu__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(226, 232, 240, 0.75);
}

.context-menu input[type="color"] {
  width: 100%;
  height: 2rem;
  border-radius: 0.5rem;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
}

.context-menu button {
  display: block;
  width: 100%;
  padding: 0.55rem 1rem;
  background: none;
  border: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.context-menu button:hover,
.context-menu button:focus-visible {
  background-color: rgba(99, 102, 241, 0.18);
  outline: none;
}

.context-menu__divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0.5rem 0;
}

.context-menu__icon {
  display: inline-block;
  margin-right: 0.5rem;
  opacity: 0.85;
}

.timeline {
  background: var(--timeline-bg);
  border-radius: 1.2rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1.25rem 1.5rem 1.5rem;
  color: rgba(226, 232, 240, 0.9);
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  width: 100%;
  overflow: hidden;
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.timeline-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.timeline-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.time-display {
  font-family: "JetBrains Mono", "SFMono-Regular", Menlo, monospace;
  font-size: 0.95rem;
}

.timeline-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#timelineRange {
  width: 100%;
}

.timeline-track {
  position: relative;
  width: 100%;
  height: 40px;
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 0.75rem;
}

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

  .toolbar {
    order: 2;
  }

  .stage-area {
    order: 1;
  }

  .floating-tool-menu {
    max-width: 90%;
    justify-content: center;
    row-gap: 0.65rem;
  }
}

.timeline-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--timeline-marker);
}

.timeline-key {
  position: absolute;
  top: 8px;
  bottom: 8px;
  width: 4px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.65);
  transform: translateX(-50%);
  pointer-events: auto;
  cursor: grab;
  box-shadow: 0 0 6px rgba(99, 102, 241, 0.75);
  transition: width 120ms ease, background 120ms ease;
}

.timeline-key:hover {
  width: 6px;
  background: rgba(99, 102, 241, 0.85);
}

.timeline-key.dragging {
  cursor: grabbing;
  width: 6px;
  background: rgba(99, 102, 241, 0.95);
  z-index: 10;
}

.timeline-key.selected {
  background: #fbbf24;
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.35);
}

.timeline-key.selected:hover,
.timeline-key.selected.dragging {
  background: #f59e0b;
}

.keyframe-panel {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.keyframe-panel h3 {
  margin: 0;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(248, 250, 252, 0.6);
}

.keyframe-list {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-height: 32px;
}

.keyframe-chip {
  background: rgba(99, 102, 241, 0.18);
  border: 1px solid rgba(99, 102, 241, 0.5);
  color: rgba(224, 231, 255, 0.85);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.78rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.keyframe-chip.selected {
  background: rgba(99, 102, 241, 0.38);
  border-color: rgba(129, 140, 248, 0.85);
  color: #ffffff;
  box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.25);
}

.keyframe-chip:focus-visible {
  outline: 2px solid rgba(129, 140, 248, 0.8);
  outline-offset: 3px;
}

.keyframe-chip span {
  pointer-events: none;
}

.keyframe-chip button {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.keyframe-chip button:hover {
  color: rgba(255, 255, 255, 0.9);
}

.app-footer {
  padding: 1rem 2rem 2rem;
  color: rgba(148, 163, 184, 0.8);
  font-size: 0.9rem;
}

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

  .toolbar {
    flex-direction: row;
    overflow-x: auto;
    gap: 1.5rem;
  }

  .stage-area {
    order: -1;
  }
}

/* Mobile optimizations */
@media (max-width: 768px) {
  body {
    font-size: 14px;
  }

  .app-header {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .app-title {
    font-size: 1.1rem;
  }

  .toolbar-toggle-floating {
    top: 0.5rem;
    left: 0.5rem;
  }

  .workspace {
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .toolbar {
    padding: 1rem;
    gap: 1rem;
  }

  .control-group {
    gap: 0.75rem;
  }

  .control {
    gap: 0.3rem;
  }

  .canvas-wrapper {
    padding: 0.5rem;
    padding-top: 3.5rem;
    border-radius: 1rem;
  }

  .floating-tool-menu {
    width: calc(100% - 1rem);
    max-width: none;
    padding: 0.6rem 0.75rem;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
  }

  .tool-cluster {
    gap: 0.3rem;
  }

  .tool-button {
    width: 2.5rem;
    height: 2.5rem;
  }

  .stage-dimensions {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
  }

  .timeline {
    gap: 0.75rem;
  }

  .timeline-header {
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
  }

  .timeline-controls {
    justify-content: center;
    flex-wrap: wrap;
  }

  .timeline-controls button {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }

  .timeline-info {
    justify-content: center;
    flex-wrap: wrap;
  }

  .timeline-track {
    height: 50px;
  }

  .keyframe-panel {
    gap: 0.4rem;
  }

  .keyframe-panel h3 {
    font-size: 0.85rem;
  }

  .keyframe-chip {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
  }

  .app-footer {
    padding: 1rem;
    font-size: 0.85rem;
  }

  /* Make stage resize handles larger for touch */
  .stage-resize-handle {
    width: 2.5rem;
    height: 2.5rem;
  }

  .stage-resize-handle--corner {
    bottom: 0.25rem;
    right: 0.25rem;
  }

  .stage-resize-handle--right {
    right: 0.25rem;
  }

  .stage-resize-handle--bottom {
    bottom: 0.25rem;
  }

  /* Make timeline markers easier to tap */
  .timeline-key {
    width: 6px;
  }

  .timeline-key:hover,
  .timeline-key.dragging {
    width: 8px;
  }
}

/* Very small mobile devices */
@media (max-width: 480px) {
  .app-header {
    padding: 0.5rem 0.75rem;
  }

  .app-title {
    font-size: 1rem;
  }

  .workspace {
    padding: 0.5rem;
    gap: 0.5rem;
  }

  .canvas-wrapper {
    padding: 0.35rem;
    padding-top: 3rem;
  }

  .floating-tool-menu {
    padding: 0.5rem;
    gap: 0.35rem;
  }

  .tool-button {
    width: 2.25rem;
    height: 2.25rem;
  }

  .tool-icon {
    width: 1.1rem;
    height: 1.1rem;
  }

  .timeline-controls button {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
  }

  .control input[type="number"] {
    width: 3.5rem;
    padding: 0.3rem 0.4rem;
  }

  /* Simplify toolbar on very small screens */
  .toolbar {
    padding: 0.75rem;
  }

  .control-group {
    gap: 0.5rem;
  }

  /* Stack controls vertically on tiny screens */
  .color-controls {
    flex-direction: column;
  }
}

/* Landscape mobile optimization */
@media (max-width: 900px) and (orientation: landscape) {
  .workspace {
    display: flex;
    flex-direction: row;
    height: 100vh;
    padding: 0.5rem;
    gap: 0.5rem;
  }

  .toolbar {
    width: 280px;
    max-height: 100%;
    overflow-y: auto;
    flex-shrink: 0;
  }

  .stage-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
  }

  .canvas-wrapper {
    flex: 1;
  }

  .timeline {
    min-height: 150px;
  }
}

/* Touch-friendly improvements for all mobile */
@media (hover: none) and (pointer: coarse) {
  .tool-button,
  .icon-toggle,
  button {
    min-height: 44px;
    min-width: 44px;
  }

  .timeline-key {
    width: 8px;
    cursor: default;
  }

  .timeline-key::before {
    content: '';
    position: absolute;
    top: -8px;
    bottom: -8px;
    left: -12px;
    right: -12px;
  }

  .stage-resize-handle {
    width: 3rem;
    height: 3rem;
  }

  /* Prevent text selection on touch */
  .tool-button,
  .timeline-key,
  .keyframe-chip,
  button {
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }
}

/* Keyboard visible optimization */
body.keyboard-visible {
  height: 100vh;
  overflow: hidden;
}

body.keyboard-visible .timeline {
  min-height: 120px;
}

body.keyboard-visible .app-footer {
  display: none;
}

/* Improve scrolling performance on mobile */
@supports (-webkit-overflow-scrolling: touch) {
  .toolbar,
  .timeline,
  .keyframe-list {
    -webkit-overflow-scrolling: touch;
  }
}
