:root {
  --bg: #ffffff;
  --bg-soft: #fafafa;
  --fg: #0a0a0a;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #0a0a0a;
  --primary-fg: #ffffff;
  --panel: rgba(255, 255, 255, 0.95);
  --panel-soft: #f5f5f7;
  --canvas-bg: #ffffff;
}

body.theme-dark {
  --bg: #0a0a0a;
  --bg-soft: #111113;
  --fg: #f5f5f7;
  --muted: #9ca3af;
  --line: #2a2a2e;
  --primary: #f5f5f7;
  --primary-fg: #0a0a0a;
  --panel: rgba(20, 20, 22, 0.95);
  --panel-soft: #1c1c1f;
  --canvas-bg: #000000;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  transition: background 0.25s ease, color 0.25s ease;
}

.toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  transition: background 0.25s ease, border-color 0.25s ease;
}

.toolbar__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
}

.toolbar__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4DE2F6, #7685FA, #A85CE6);
}

.toolbar__title {
  font-weight: 700;
}

.toolbar__sub {
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.toolbar__group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  background: var(--panel-soft);
  border-radius: 10px;
  transition: background 0.25s ease;
}

.ratio-btn {
  border: none;
  background: transparent;
  color: var(--fg);
  padding: 6px 12px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ratio-btn:hover {
  background: rgba(127, 127, 127, 0.15);
}

.ratio-btn.is-active {
  background: var(--primary);
  color: var(--primary-fg);
}

.slider-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  padding: 0 10px;
}

.slider-label span:first-child {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.slider-label input[type="range"] {
  width: 80px;
  accent-color: var(--primary);
}

.slider-value {
  font-family: 'SF Mono', 'Monaco', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg);
  min-width: 22px;
  text-align: right;
}

.toolbar__actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  padding: 0;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  background: var(--panel-soft);
  border-color: var(--muted);
}

.format-btn {
  width: 56px;
  font-size: 11px;
  letter-spacing: 0.05em;
}

.icon-light,
.icon-dark {
  display: none;
}

body.theme-light .icon-light { display: inline; }
body.theme-dark .icon-dark { display: inline; }

.action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  padding: 8px 14px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.action:hover {
  background: var(--panel-soft);
  border-color: var(--muted);
}

.action--primary {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: var(--primary);
}

.action--primary:hover {
  opacity: 0.85;
}

.stage {
  position: absolute;
  top: 64px;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: var(--bg-soft);
  overflow: hidden;
  transition: background 0.25s ease;
}

.stage__canvas {
  background: var(--canvas-bg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.25s ease, box-shadow 0.25s ease;
}

.stage__canvas canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.stage__meta {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--panel);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  font-family: 'SF Mono', 'Monaco', monospace;
  z-index: 5;
  transition: background 0.25s ease, border-color 0.25s ease;
}

.stage__meta .dot {
  color: var(--line);
}

#ratioLabel {
  color: var(--fg);
}
