:root {
  --bg: #FAF9F7;
  --surface: #FFFFFF;
  --text-primary: #1C1917;
  --text-secondary: #78716C;
  --accent: #C45C2C;
  --accent-hover: #A84D22;
  --border: #E7E5E4;
  --radius: 1.25rem;
  --shadow: 0 4px 24px rgba(28,25,23,0.08);
}
.fotobudka-page * { box-sizing: border-box; }
.fotobudka-page {
  font-family: 'Outfit', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1rem 2rem;
  line-height: 1.5;
}
.app-header { text-align: center; margin-bottom: 1.5rem; max-width: 640px; width: 100%; }
  font-family: 'Outfit', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1rem 2rem;
  line-height: 1.5;
}
.app-header { text-align: center; margin-bottom: 1.5rem; max-width: 640px; width: 100%; }
.app-header h1 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 0.375rem;
}
.app-header p {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 45ch;
  margin: 0 auto;
}
.app-main {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.canvas-area {
  position: relative;
  width: 100%;
  border-radius: var(--radius);
  overflow: visible;
  background: var(--surface);
  box-shadow: var(--shadow);
  user-select: none;
  touch-action: none;
}
.canvas-area img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}
.canvas-hint {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(28,25,23,0.75);
  color: #fff;
  padding: 0.5rem 1.25rem;
  border-radius: 100px;
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.3s ease;
  z-index: 5;
}
.canvas-hint.hidden { opacity: 0; }
.sticker {
  position: absolute;
  left: 0;
  top: 0;
  cursor: grab;
  touch-action: none;
  user-select: none;
  z-index: 10;
}
.sticker:active { cursor: grabbing; }
.sticker-wrap {
  width: 100%;
  height: 100%;
  position: relative;
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.sticker-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.12));
}
.bubble-text {
  position: absolute;
  top: 18%;
  left: 10%;
  right: 10%;
  bottom: 24%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 20px;
  line-height: 1.25;
  color: #1C1917;
  outline: none;
  cursor: text;
  overflow: hidden;
  word-break: break-word;
  z-index: 2;
  padding: 4px;
}
.bubble-text:empty::before {
  content: 'Мяу!';
  opacity: 0.35;
}
.text-content {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 28px;
  line-height: 1.2;
  white-space: nowrap;
  padding: 8px 18px;
  border-radius: 14px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  display: inline-block;
  text-align: center;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.selection-ring {
  position: absolute;
  inset: -10px;
  border: 2px dashed var(--accent);
  border-radius: 14px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.sticker.selected .selection-ring { opacity: 1; }
.delete-btn {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: 2.5px solid #fff;
  font-size: 18px;
  font-family: 'Outfit', sans-serif;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 0 2px 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  z-index: 20;
  transition: transform 0.15s ease, background 0.15s ease;
}
.delete-btn:hover { background: var(--accent-hover); transform: scale(1.1); }
.delete-btn:active { transform: scale(0.95); }
.sticker.selected .delete-btn { display: flex; }
.edit-btn {
  position: absolute;
  top: -12px;
  left: -12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  border: 2.5px solid var(--accent);
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  transition: all 0.15s ease;
}
.edit-btn:hover { background: var(--accent); color: #fff; transform: scale(1.1); }
.edit-btn:active { transform: scale(0.95); }
.sticker.selected .edit-btn { display: flex; }
.rotate-handle {
  position: absolute;
  top: -36px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-primary);
  border: 2.5px solid var(--accent);
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 13px;
  cursor: grab;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  touch-action: none;
}
.rotate-handle:active { cursor: grabbing; }
.rotate-handle::before {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 14px;
  background: var(--accent);
}
.sticker.selected .rotate-handle { display: flex; }
.resize-handle {
  position: absolute;
  bottom: -10px;
  right: -10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 2.5px solid #fff;
  cursor: nwse-resize;
  display: none;
  z-index: 20;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  touch-action: none;
}
.resize-handle::before {
  content: '';
  position: absolute;
  inset: 4px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  border-radius: 0 0 4px 0;
}
.sticker.selected .resize-handle { display: block; }
.font-plus {
  position: absolute;
  bottom: -12px;
  left: 28px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-primary);
  border: 2px solid var(--border);
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
  transition: all 0.15s ease;
}
.font-plus:hover { border-color: var(--accent); transform: scale(1.1); }
.font-minus {
  position: absolute;
  bottom: -12px;
  left: -12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-primary);
  border: 2px solid var(--border);
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
  transition: all 0.15s ease;
}
.font-minus:hover { border-color: var(--accent); transform: scale(1.1); }
.sticker.selected .font-plus, .sticker.selected .font-minus { display: flex; }
@keyframes popIn {
  0% { transform: scale(0) rotate(-8deg); opacity: 0; }
  65% { transform: scale(1.12) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
.controls {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.875rem;
  flex-wrap: wrap;
}
.tab {
  padding: 0.5rem 1.125rem;
  border-radius: 100px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-weight: 500;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-height: 44px;
}
.tab:hover { color: var(--text-primary); background: var(--bg); }
.tab.active { background: var(--accent); color: #fff; }
.tab.active:hover { background: var(--accent-hover); }
.palette-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.palette {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding: 0.25rem 0.125rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex: 1;
}
.palette::-webkit-scrollbar { display: none; }
.scroll-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
  min-height: 36px;
}
.scroll-btn:hover { border-color: var(--accent); color: var(--accent); transform: scale(1.1); }
.scroll-btn:active { transform: scale(0.95); }
.sticker-thumb {
  flex-shrink: 0;
  width: 76px;
  height: 76px;
  border: 2px solid var(--border);
  border-radius: 1rem;
  background: var(--bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-height: 44px;
}
.sticker-thumb:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.sticker-thumb:active { transform: translateY(1px); }
.sticker-thumb svg { max-width: 100%; max-height: 100%; }
.text-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.text-input-row {
  display: flex;
  gap: 0.5rem;
}
.text-input-row input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: 100px;
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s ease;
  min-height: 44px;
}
.text-input-row input:focus { border-color: var(--accent); }
.text-input-row button {
  padding: 0.75rem 1.5rem;
  border-radius: 100px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
  white-space: nowrap;
}
.text-input-row button:hover { background: var(--accent-hover); }
.text-input-row button:active { transform: translateY(1px); }
.color-palette {
  display: flex;
  gap: 0.625rem;
  flex-wrap: wrap;
}
.color-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--border);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-height: 36px;
}
.color-swatch:hover { transform: scale(1.15); border-color: var(--text-secondary); }
.color-swatch.active { border-color: var(--accent); transform: scale(1.15); box-shadow: 0 0 0 3px rgba(196,92,44,0.2); }
.actions {
  display: flex;
  gap: 0.875rem;
  justify-content: center;
  flex-wrap: wrap;
}
.btn {
  padding: 0.875rem 1.75rem;
  border-radius: 100px;
  border: none;
  font-family: inherit;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(196,92,44,0.25); }
.btn-primary:active { transform: translateY(1px); }
.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 2px solid var(--border);
}
.btn-secondary:hover { border-color: var(--text-secondary); transform: translateY(-2px); }
.btn-secondary:active { transform: translateY(1px); }
.tip {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
}
.app-footer {
  margin-top: 2rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
}
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-primary);
  color: #fff;
  padding: 0.875rem 1.75rem;
  border-radius: 100px;
  font-size: 0.9375rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 100;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (max-width: 480px) {
  body { padding: 1rem 0.75rem 1.5rem; }
  .app-header h1 { font-size: 1.625rem; }
  .btn { padding: 0.75rem 1.5rem; font-size: 0.9375rem; }
  .actions { flex-direction: column; }
  .controls { padding: 0.875rem; }
  .text-content { font-size: 22px; max-width: 220px; }
  .bubble-text { font-size: 16px; }
  .scroll-btn { display: none; }
}
</style>
