:root {
  --bg: #f6f3ee;
  --card: #fff;
  --text: #24211d;
  --muted: #7a736a;
  --line: #e4ded5;
  --accent: #c2603a;
  --accent-dark: #a24d2c;
  --accent-soft: #f7e6dd;
  --danger: #c0392b;
  --ok: #2e8b57;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(40, 30, 20, 0.08);
  --topbar: 60px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: 28px; }
h3 { font-size: 16px; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: .3em 0 0; }
.center { text-align: center; }

.container { max-width: 1140px; margin: 0 auto; padding: 32px 20px; }
.container.narrow { max-width: 880px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }

/* кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--text); font: inherit; font-weight: 500;
  cursor: pointer; text-decoration: none; transition: .15s;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-large { padding: 14px 28px; font-size: 16px; }

/* шапка */
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar);
  display: flex; align-items: center; gap: 24px; padding: 0 20px;
  background: rgba(255, 255, 255, .95); border-bottom: 1px solid var(--line); backdrop-filter: blur(6px);
}
.logo { font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; white-space: nowrap; }
.steps { display: flex; gap: 4px; margin: 0 auto; }
.steps button {
  border: 0; background: none; font: inherit; color: var(--muted); padding: 8px 14px;
  border-radius: 20px; cursor: pointer;
}
.steps button b {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--line); color: var(--text); font-size: 12px; margin-right: 4px;
}
.steps button.is-active { color: var(--text); background: var(--accent-soft); }
.steps button.is-active b { background: var(--accent); color: #fff; }
.steps button:disabled { cursor: default; }
.topbar-price { white-space: nowrap; }
.topbar-price strong { color: var(--accent); font-size: 18px; }
.topnav { display: flex; gap: 20px; margin-left: auto; align-items: center; }
.topnav a { color: var(--text); text-decoration: none; }

/* шаг 1 */
.opt-group { margin-bottom: 28px; }
.opt-row { display: flex; gap: 48px; flex-wrap: wrap; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.opt-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left;
  padding: 16px; border-radius: var(--radius); border: 2px solid var(--line); background: #fff;
  font: inherit; color: inherit; cursor: pointer; transition: .15s;
}
.opt-card:hover { border-color: #d9b8a8; }
.opt-card.is-active { border-color: var(--accent); background: var(--accent-soft); }
.opt-card .muted { font-size: 13px; }
.opt-card .price { color: var(--accent); font-weight: 600; margin-top: auto; padding-top: 4px; }
.format-shape { display: block; height: 54px; max-width: 80px; background: #d8cfc3; border-radius: 3px; margin-bottom: 8px; box-shadow: 2px 2px 0 #bfb3a4; }
.opt-card.is-active .format-shape { background: var(--accent); box-shadow: 2px 2px 0 var(--accent-dark); }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.stepper button { width: 44px; height: 44px; border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--accent); }
.stepper button:disabled { color: var(--line); cursor: default; }
.stepper output { min-width: 50px; text-align: center; font-size: 18px; font-weight: 600; }
.step-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 24px; }

/* редактор */
body.is-editor { overflow: hidden; }
.editor { display: grid; grid-template-columns: 280px 1fr; height: calc(100vh - var(--topbar)); }
.library { display: flex; flex-direction: column; background: #fff; border-right: 1px solid var(--line); min-height: 0; }
.library.is-drop { outline: 3px dashed var(--accent); outline-offset: -6px; }
.library-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.library-head h3 { margin: 0; }
.library-grid {
  flex: 1; overflow-y: auto; padding: 12px; display: grid;
  grid-template-columns: repeat(3, 1fr); gap: 6px; align-content: start;
}
.dropzone { grid-column: 1 / -1; border: 2px dashed var(--line); border-radius: var(--radius); padding: 28px 16px; text-align: center; color: var(--muted); }
.lib-item { position: relative; aspect-ratio: 1; border-radius: 6px; overflow: hidden; cursor: grab; background: #eee; outline: 2px solid transparent; }
.lib-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-item.is-used img { opacity: .55; }
.lib-item.is-pending { outline-color: var(--accent); }
.lib-item .badge {
  position: absolute; left: 4px; bottom: 4px; background: var(--ok); color: #fff;
  font-size: 11px; border-radius: 9px; padding: 0 6px; line-height: 18px;
}
.lib-del {
  position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, .55); color: #fff; cursor: pointer; display: none; line-height: 1;
}
.lib-item:hover .lib-del { display: block; }
.library-foot { padding: 12px 16px; border-top: 1px solid var(--line); }

.workspace { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.toolbar {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap; min-height: 58px;
  padding: 8px 16px; background: #fff; border-bottom: 1px solid var(--line);
}
.tb-group { display: flex; align-items: center; gap: 6px; }
.tb-label { font-weight: 600; margin-right: 4px; }
.layout-btn { padding: 4px; border: 2px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; width: 42px; }
.layout-btn.is-active { border-color: var(--accent); }
.layout-preview { position: relative; width: 100%; background: #f1ece5; }
.layout-preview div { position: absolute; background: #b9ad9e; border-radius: 1px; }
.layout-preview .lp-text { background: repeating-linear-gradient(#b9ad9e 0 2px, transparent 2px 4px); opacity: .7; }
.layout-preview .lp-overlay { background: rgba(255, 255, 255, .8); }
.layout-btn.is-active .layout-preview div:not(.lp-text):not(.lp-overlay) { background: var(--accent); }
.tb-zoom { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.tb-zoom input { width: 120px; accent-color: var(--accent); }

.stage { flex: 1; display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 0; padding: 12px; }
.nav-btn {
  flex: none; width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line);
  background: #fff; font-size: 26px; cursor: pointer; color: var(--accent);
}
.nav-btn:disabled { opacity: .3; cursor: default; }
.spread-wrap { display: flex; flex-direction: column; align-items: center; }
.spread-title { font-weight: 600; margin-bottom: 8px; color: var(--muted); }
.spread { display: flex; filter: drop-shadow(0 6px 18px rgba(40, 30, 20, .18)); }
.spread .page-box { flex: 1; min-width: 0; }
.spread:not(.is-single) .page-box:first-child .page { box-shadow: inset -14px 0 18px -14px rgba(0, 0, 0, .35); }
.spread:not(.is-single) .page-box:last-child .page { box-shadow: inset 14px 0 18px -14px rgba(0, 0, 0, .35); }
.page-label { text-align: center; color: var(--muted); font-size: 12px; margin-top: 6px; }

.strip { display: flex; gap: 10px; overflow-x: auto; padding: 10px 16px; background: #fff; border-top: 1px solid var(--line); }
.strip-item { flex: none; border: 2px solid transparent; border-radius: 6px; background: none; padding: 3px; cursor: pointer; font: inherit; font-size: 11px; color: var(--muted); }
.strip-item.is-active { border-color: var(--accent); color: var(--text); }
.strip-spread { display: flex; height: 56px; margin-bottom: 2px; box-shadow: 0 1px 4px rgba(0, 0, 0, .15); }
.strip-spread .page { height: 100%; width: auto; }
.editor-actions { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: #fff; border-top: 1px solid var(--line); }

/* страница альбома */
.page { position: relative; width: 100%; background: #fff; overflow: hidden; container-type: inline-size; user-select: none; }
.page.is-selected { outline: 2px solid rgba(194, 96, 58, .5); outline-offset: 2px; }
.slot { position: absolute; overflow: hidden; }
.slot img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.slot--photo { cursor: pointer; touch-action: none; }
.slot--empty { background: #eee8e0; }
.slot-plus { position: absolute; inset: 0; display: grid; place-items: center; color: #b3a797; font-size: 8cqw; }
.slot--photo.is-selected { outline: 3px solid var(--accent); outline-offset: -3px; }
.slot--photo.is-drop { outline: 3px dashed var(--accent); outline-offset: -3px; background: var(--accent-soft); }
.slot--photo.is-panning { cursor: grabbing; }
.slot-text {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; text-align: center;
  font-family: Georgia, 'Times New Roman', serif; font-size: 4.2cqw; line-height: 1.25; white-space: pre-wrap;
  overflow: hidden; outline: none; color: #3a332c; word-break: break-word;
}
.page--cover .slot-text { font-size: 7cqw; }
.slot-text[contenteditable]:empty::before { content: attr(data-placeholder); color: #c5bbae; }
.slot--text.is-selected, .slot-text[contenteditable]:focus { outline: 2px dashed var(--accent); outline-offset: -2px; }
.slot--overlay .slot-text { color: #fff; text-shadow: 0 1px 8px rgba(0, 0, 0, .6); }
.slot--overlay .slot-text[contenteditable]:empty::before { color: rgba(255, 255, 255, .8); }
.dpi-warn {
  position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%;
  background: #e67e22; color: #fff; font-weight: 700; display: grid; place-items: center; font-size: 13px;
}

/* шаг 3 */
.checkout { display: grid; grid-template-columns: 1fr 360px; gap: 24px; align-items: start; }
.field { margin-bottom: 16px; flex: 1; }
.field-row { display: flex; gap: 16px; }
.field > label { display: block; font-weight: 500; margin-bottom: 6px; }
input:not([type=checkbox]):not([type=radio]):not([type=range]), textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.radio-list { display: grid; gap: 8px; }
.radio { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.radio span { flex: 1; }
.radio:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio input, .check input { accent-color: var(--accent); }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.form-error { color: var(--danger); background: #fdecea; padding: 10px 12px; border-radius: 8px; }
.summary { position: sticky; top: calc(var(--topbar) + 20px); }
.summary-cover { width: 140px; margin: 0 auto 16px; box-shadow: var(--shadow); }
.sum-list { list-style: none; padding: 0; margin: 0 0 12px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.sum-list li { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; font-size: 14px; }
.sum-list span { color: var(--muted); }
.sum-total { display: flex; justify-content: space-between; font-size: 20px; font-weight: 700; }
.sum-total b { color: var(--accent); }
.warn { color: #b9770e; background: #fef5e7; padding: 8px 10px; border-radius: 8px; font-size: 13px; }

.done-card { padding: 48px; }
.done-icon { width: 72px; height: 72px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 40px; display: grid; place-items: center; margin: 0 auto 16px; }
.order-no { font-size: 22px; color: var(--accent); letter-spacing: 1px; }

/* модальное окно и уведомления */
.modal { position: fixed; inset: 0; background: rgba(30, 25, 20, .5); display: grid; place-items: center; z-index: 50; }
.modal-box { background: #fff; border-radius: var(--radius); padding: 28px; width: min(460px, 92vw); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.progress { height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; margin: 16px 0 8px; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  background: #2b2621; color: #fff; padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow);
  max-width: 90vw; font-size: 14px; pointer-events: none;
}

/* режим «собирает дизайнер» */
.d-card { margin-bottom: 20px; }
.d-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.d-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.d-grid .lib-item { cursor: default; }

/* редактор дизайнера (constructor?edit=…) */
.edit-bar { display: flex; align-items: center; gap: 12px; margin: 0 auto; flex-wrap: wrap; }
.edit-title { font-size: 14px; }
.edit-pages { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.edit-pages .btn { padding: 2px 10px; }
.is-edit .lib-del, .is-edit .library-head label, .is-edit .editor-actions .btn { display: none !important; }
.edit-wishes { margin: 0 12px 10px; padding: 10px 12px; background: var(--accent-soft); border-radius: 8px; font-size: 13px; max-height: 180px; overflow-y: auto; }
.edit-wishes p { margin: 0 0 6px; }
.edit-wishes p:last-child { margin: 0; }

/* главная */
.hero { padding: 72px 20px; text-align: center; background: linear-gradient(160deg, #f6e3d6, #f6f3ee 60%); }
.hero h1 { font-size: clamp(30px, 5vw, 48px); max-width: 760px; margin: 0 auto 16px; }
.hero p { font-size: 18px; color: var(--muted); max-width: 620px; margin: 0 auto 28px; }
.section { padding: 56px 0; }
.section h2 { font-size: 28px; text-align: center; margin-bottom: 32px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.how-num { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; margin-bottom: 12px; }
.format-card { text-align: center; text-decoration: none; color: inherit; transition: .15s; }
.format-card:hover { transform: translateY(-3px); }
.format-card .format-shape { margin: 0 auto 14px; height: 80px; max-width: 120px; }
.format-card .price { color: var(--accent); font-weight: 700; font-size: 18px; }
.status-form { display: flex; gap: 10px; flex-wrap: wrap; max-width: 620px; margin: 0 auto; }
.status-form input { flex: 1; min-width: 180px; }
.status-result { text-align: center; margin-top: 16px; }
.footer { padding: 32px 20px; text-align: center; color: var(--muted); border-top: 1px solid var(--line); }

/* админка */
.admin-layout { display: grid; grid-template-columns: minmax(420px, 1fr) 1.4fr; gap: 20px; padding: 20px; align-items: start; }
.filters { display: flex; gap: 10px; margin-bottom: 12px; }
.filters select { width: auto; }
table.orders { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); font-size: 14px; }
.orders th, .orders td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.orders th { background: #faf7f3; font-weight: 600; font-size: 13px; color: var(--muted); }
.orders tbody tr { cursor: pointer; }
.orders tbody tr:hover { background: #fcf8f4; }
.orders tbody tr.is-active { background: var(--accent-soft); }
.status { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; background: #eee; white-space: nowrap; }
.status-new { background: #fdebd0; color: #a04000; }
.status-confirmed, .status-printing { background: #d6eaf8; color: #1b4f72; }
.status-ready, .status-shipped { background: #e8daef; color: #5b2c6f; }
.status-done { background: #d5f5e3; color: #1d6b3f; }
.status-cancelled, .status-uploading { background: #eee; color: #777; }
.status[class*="design-"] { margin-left: 4px; margin-top: 4px; }
.design-todo, .design-changes { background: #fadbd8; color: #922b21; }
.design-draft { background: #fdebd0; color: #a04000; }
.design-sent { background: #d6eaf8; color: #1b4f72; }
.design-approved { background: #d5f5e3; color: #1d6b3f; }
.design-box { background: #faf7f3; border-radius: 10px; padding: 12px 14px; margin-bottom: 20px; font-size: 14px; }
.design-box p { margin: 0 0 8px; }
.design-quote { background: #fff; border-left: 3px solid var(--accent); padding: 8px 10px; margin-bottom: 8px; white-space: pre-wrap; }
.design-status { display: inline-flex; align-items: center; gap: 8px; }
.design-status select { width: auto; padding: 6px 10px; }
.design-link input { font-size: 13px; background: #fff; }
.design-feedback { margin-top: 10px; display: grid; gap: 6px; }
.fb-item { background: #fff; border-radius: 8px; padding: 8px 10px; border-left: 3px solid #ccc; white-space: pre-wrap; }
.fb-item span { color: var(--muted); font-size: 12px; }
.fb-item.fb-approved { border-left-color: var(--ok); }
.fb-item.fb-changes { border-left-color: #e67e22; }
.detail { position: sticky; top: calc(var(--topbar) + 20px); max-height: calc(100vh - var(--topbar) - 40px); overflow-y: auto; }
.detail-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 4px 12px; margin: 12px 0 20px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.preview-grid figure { margin: 0; }
.preview-grid figcaption { font-size: 12px; color: var(--muted); text-align: center; margin-top: 4px; }
.preview-spread { display: flex; box-shadow: 0 1px 6px rgba(0, 0, 0, .15); }
.preview-spread.is-single { width: 50%; margin: 0 auto; }
.photo-list { font-size: 13px; columns: 2; padding-left: 18px; }
.actions-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }

@media (max-width: 900px) {
  .checkout, .admin-layout { grid-template-columns: 1fr; }
  .summary, .detail { position: static; max-height: none; }
  .editor { grid-template-columns: 1fr; grid-template-rows: 200px 1fr; }
  .library-grid { grid-template-columns: repeat(6, 1fr); }
  .library-foot .hint { display: none; }
  .steps button { padding: 6px 8px; font-size: 13px; }
  .topbar { gap: 10px; }
  .logo .studio-name { display: none; }
  .field-row { flex-direction: column; gap: 0; }
}
