:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --line: #e6e6e6;
  --line-strong: #111111;
  --text: #111111;
  --muted: #8a8a8a;
  --accent: #111111;
  --danger: #c0392b;
  --radius: 2px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 22px 28px 18px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: baseline; gap: 14px; }
.brand-mark {
  width: 18px;
  height: 1px;
  background: var(--line-strong);
  transform: translateY(-2px);
}
.brand h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  margin: 0;
  font-weight: 400;
  letter-spacing: -0.02em;
}

.topbar-info { display: flex; gap: 20px; align-items: baseline; }
.meta {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.meta-accent { color: var(--text); }

main { position: fixed; inset: 0; }

#mosaic {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
  background: #ffffff;
}
#mosaic.dragging { cursor: grabbing; }

.controls {
  position: fixed;
  right: 24px;
  bottom: 28px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ctrl-btn {
  width: 40px; height: 40px;
  border-radius: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.ctrl-btn:hover {
  border-color: var(--line-strong);
  background: #fafafa;
}
.ctrl-fit { font-size: 15px; letter-spacing: -0.05em; }

.hint {
  position: fixed;
  left: 28px;
  bottom: 28px;
  z-index: 10;
  max-width: min(72vw, 420px);
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
  transition: opacity .6s;
}
.hint.faded { opacity: 0; pointer-events: none; }

/* ---------- Модальное окно ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(10px);
  padding: 24px;
}
.modal.hidden { display: none; }

.modal-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 28px 28px 24px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.06);
}
.modal-card h2 {
  margin: 0 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  font-weight: 400;
  letter-spacing: -0.02em;
}
.modal-sub {
  margin: 0 0 22px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

.drop-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  border: 1px dashed var(--line);
  background: #fafafa;
  cursor: pointer;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  overflow: hidden;
  transition: border-color .15s, background .15s;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--line-strong);
  background: #f5f5f5;
}
.drop-zone small {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.crop-wrap {
  border: 1px dashed var(--line);
  background: #fafafa;
  padding: 12px;
}

.crop-wrap.hidden { display: none; }

#cropCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 320 / 360;
  touch-action: none;
  background: #f5f5f5;
}

.crop-hint {
  margin: 10px 0 0;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}

.editor-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
}

.editor-controls.hidden { display: none; }

.slider-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.slider-row input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
}

#dropText.hidden { display: none; }

.modal-error {
  margin: 14px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--danger);
}
.modal-error.hidden { display: none; }

.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
}

.btn {
  border-radius: 0;
  padding: 11px 18px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity .15s, background .15s, border-color .15s;
}
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  padding-left: 0;
}
.btn-ghost:hover { color: var(--text); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:not(:disabled):hover { background: #333; border-color: #333; }

@media (max-width: 600px) {
  .topbar { padding: 16px 18px 14px; }
  .brand h1 { font-size: 19px; }
  .topbar-info { gap: 12px; }
  .meta { font-size: 10px; }
  .hint { left: 18px; bottom: 96px; max-width: calc(100vw - 36px); }
  .controls { right: 18px; bottom: 18px; }
}
