:root {
  --ink: #1a1a1a;
  --muted: #6b6b6b;
  --line: #e2e2e0;
  --ground: #fbfbf9;
  --surface: #fff;
  --accent: #14594a;
  --warn: #8a5a12;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--ground);
  color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", sans-serif;
}

a { color: var(--accent); }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 24px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.topbar__nav { display: flex; align-items: baseline; gap: 20px; }
.topbar__brand { font-weight: 600; text-decoration: none; }
.topbar__right { display: flex; align-items: center; gap: 14px; }

.switch { margin: 0; }
.switch__btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 5px 12px; border-radius: 4px; font: inherit; font-size: 14px; cursor: pointer;
}
.switch__btn:hover { border-color: var(--accent); color: var(--accent); }

main { padding: 32px 24px 64px; }
.page { max-width: 940px; margin: 0 auto; }
.page__head { margin-bottom: 28px; }
h1 { font-size: 32px; margin: 0 0 8px; }
h2 { font-size: 18px; margin: 32px 0 12px; }
.lede { font-size: 18px; color: var(--muted); margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.crumbs { font-size: 14px; color: var(--muted); margin: 0 0 8px; }

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px;
         grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; }
.card__title { font-weight: 500; text-decoration: none; display: block; }
.card__meta { margin: 8px 0 0; font-size: 14px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.price { font-variant-numeric: tabular-nums; color: var(--ink); }
.price--missing { color: var(--muted); font-style: italic; }

.chip { font-size: 12px; padding: 2px 8px; border-radius: 3px; background: #f0ece2; color: var(--warn); }

.offers { width: 100%; border-collapse: collapse; margin: 20px 0; background: var(--surface); }
.offers th, .offers td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.offers thead th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.offers .num { text-align: right; font-variant-numeric: tabular-nums; }

.btn { display: inline-block; padding: 8px 16px; border-radius: 4px;
       background: var(--accent); color: #fff; text-decoration: none; font-size: 15px; }
.btn--soon { background: var(--line); color: var(--muted); cursor: default; }
.linkish { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }

.notice { background: #f0ece2; border-left: 3px solid var(--warn); padding: 10px 14px; font-size: 15px; }
.flash { max-width: 940px; margin: 0 auto 20px; padding: 10px 14px; border-radius: 4px; background: #eef3f0; }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  .offers thead { display: none; }
  .offers td { display: block; border: 0; padding: 4px 14px; }
  .offers tr { display: block; border-bottom: 1px solid var(--line); padding: 10px 0; }
  .offers .num { text-align: left; }
}

.narrow { max-width: 460px; }
.form { display: grid; gap: 8px; margin: 20px 0; }
.form label { font-size: 14px; color: var(--muted); }
.form input[type="email"], .form input[type="text"] {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px;
  font: inherit; background: var(--surface);
}
.form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.form input[type="submit"] { justify-self: start; margin-top: 6px; border: 0; cursor: pointer; }
.flash--alert { background: #f6e9e7; }

.form--inline { max-width: 460px; }
.choices { border: 0; padding: 0; margin: 8px 0 0; display: flex; gap: 16px; align-items: center; }
.choices legend { font-size: 14px; color: var(--muted); padding: 0; }
.offers button.btn { border: 0; cursor: pointer; font: inherit; font-size: 14px; }
.status { display: inline-block; padding: 5px 12px; border-radius: 3px; background: #f0ece2; color: var(--warn); font-size: 14px; }
.status--paid { background: #e4efe9; color: var(--accent); }

.errors { margin: 0 0 12px; padding: 10px 14px 10px 30px; background: #f6e9e7; border-left: 3px solid #9e2e22; }
.errors li { font-size: 14px; }
.hint { margin: -2px 0 6px; font-size: 13px; color: var(--muted); }
.form select, .form input[type="tel"] {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px; font: inherit; background: var(--surface);
}
.filters { display: flex; flex-wrap: wrap; gap: 14px; font-size: 14px; margin-bottom: 18px; }
.filters .on { font-weight: 600; color: var(--ink); text-decoration: none; }
.row-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.row-form input[type="text"] { padding: 5px 8px; border: 1px solid var(--line); border-radius: 3px; font: inherit; font-size: 13px; }
.block { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); }
.block h2 { margin-top: 0; }
.status--shipped { background: #e7eef4; color: #2a5670; }
.status--delivered { background: #e4efe9; color: var(--accent); }
.status--returned, .status--canceled { background: #f6e9e7; color: #9e2e22; }

.plain { list-style: none; margin: 0 0 8px; padding: 0; }
.plain li { padding: 3px 0; }

/* ---- чат: как в мессенджере ---- */
.topbar__chat { display: inline-flex; align-items: center; gap: 6px; }
.badge { min-width: 18px; padding: 1px 6px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 600; text-align: center; }

.chat { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; height: calc(100vh - 120px); min-height: 420px; }
.chat__head { padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.chat__head h1 { font-size: 20px; margin: 0; }
.chat__push { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.chat__push[hidden] { display: none; }
.btn.small { padding: 5px 10px; font-size: 13px; }

.chat__scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 8px; background: #e9efe9; border-radius: 0 0 10px 10px; }
.chat__older { display: block; text-align: center; padding: 6px; font-size: 13px; }
.chat__messages { display: flex; flex-direction: column; gap: 2px; }
.chat__date { align-self: center; margin: 12px 0 6px; padding: 3px 10px; border-radius: 10px; background: rgba(20, 89, 74, .12); color: var(--accent); font-size: 12px; font-weight: 600; }

/* сообщение: аватар + пузырь; своё — зеркально и справа */
.msg { display: flex; align-items: flex-end; gap: 8px; max-width: 78%; margin-top: 8px; position: relative; }
.msg--continued { margin-top: 0; }
.msg--mine { align-self: flex-end; flex-direction: row-reverse; }
.msg__avatar { flex: 0 0 32px; width: 32px; height: 32px; }
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; object-fit: cover; vertical-align: middle; flex: none; }
.avatar--initial { background: hsl(var(--hue) 45% 45%); color: #fff; font-weight: 700; }
.topbar__me { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.avatar-block { display: flex; align-items: center; gap: 18px; margin: 12px 0 26px; }
.form--avatar { flex-direction: row; align-items: center; gap: 12px; margin: 0 0 6px; }
.form--avatar label.btn { cursor: pointer; }
.msg:not(.msg--group-end) .msg__avatar { visibility: hidden; }
.msg--mine .msg__avatar { display: none; }

.msg__bubble {
  position: relative; min-width: 80px; padding: 6px 10px 18px;
  background: #fff; border-radius: 14px;
  box-shadow: 0 1px 1px rgba(0,0,0,.06);
}
.msg--group-end:not(.msg--mine) .msg__bubble { border-bottom-left-radius: 4px; }
.msg--continued .msg__bubble { border-top-left-radius: 8px; }
.msg--mine .msg__bubble { background: #dcf3d0; border-radius: 14px; }
.msg--mine.msg--group-end .msg__bubble { border-bottom-right-radius: 4px; }
.msg--deleted .msg__bubble { background: var(--ground); box-shadow: none; border: 1px dashed var(--line-strong, #b5bcb2); }

.msg__author { display: block; font-size: 13px; font-weight: 600; color: hsl(var(--hue, 160) 45% 38%); margin-bottom: 2px; }
.msg--continued .msg__author, .msg--mine .msg__author { display: none; }
.msg__body { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 15px; line-height: 1.4; }
.msg__body--deleted { color: var(--muted); font-style: italic; }
.msg__time { position: absolute; right: 10px; bottom: 4px; font-size: 11px; color: rgba(0,0,0,.45); }
.msg--mine .msg__time { color: rgba(20, 89, 74, .7); }
.msg__ticks { display: none; margin-left: 3px; letter-spacing: -2px; }
.msg--mine .msg__ticks { display: inline; }
.msg__ticks--read { color: var(--accent); }

.msg__quote { display: block; margin: 2px 0 6px; padding: 3px 8px; border-left: 3px solid var(--accent); background: rgba(20, 89, 74, .07); border-radius: 4px; font-size: 13px; color: var(--ink); text-decoration: none; }
.msg--mine .msg__quote { background: rgba(20, 89, 74, .1); }
.msg__quote-author { display: block; font-weight: 600; color: var(--accent); }
.msg__quote-text { color: var(--muted); }
.msg__voice { display: block; width: 240px; max-width: 100%; margin: 4px 0; height: 36px; }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reactions:empty { display: none; }
.reactions__chip { border: 1px solid transparent; background: rgba(20, 89, 74, .08); border-radius: 12px; padding: 1px 8px; font: inherit; font-size: 13px; cursor: pointer; }
.reactions__chip--mine { border-color: var(--accent); background: #fff; }
.msg--mine .reactions__chip--mine { background: #fff; }
.reactions__count { color: var(--muted); font-size: 12px; }

/* инструменты: появляются при наведении, на тачскрине — всегда, но неброско */
.msg__tools { position: absolute; top: -6px; display: flex; gap: 2px; padding: 2px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.08); opacity: 0; transition: opacity .12s; }
.msg:not(.msg--mine) .msg__tools { right: -4px; }
.msg--mine .msg__tools { left: -4px; }
.msg:hover .msg__tools, .msg:focus-within .msg__tools, .msg__tools:has(details[open]) { opacity: 1; }
@media (hover: none) {
  .msg__tools { display: none; top: auto; bottom: -30px; z-index: 4; opacity: 1; }
  .msg--tools-open .msg__tools { display: flex; }
  .msg--tools-open { margin-bottom: 26px; }
}
.msg__tool { border: 0; background: none; font: inherit; font-size: 14px; line-height: 1; padding: 4px 6px; border-radius: 6px; cursor: pointer; color: var(--ink-2, #59615a); }
.msg__tool:hover { background: var(--ground); }
.msg__mod { display: none; }
.chat--moderator .msg__mod { display: inline-flex; }
.msg__mod form { display: inline; }
.react { display: inline; position: relative; }
.react summary { list-style: none; cursor: pointer; }
.react summary::-webkit-details-marker { display: none; }
.react__picker { position: absolute; z-index: 5; left: 0; display: flex; gap: 2px; padding: 4px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.1); }
.react__pick { border: 0; background: none; font-size: 20px; cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.react__pick:hover { background: var(--ground); }
.msg--mine .react__picker { left: auto; right: 0; }

/* композер */
.chat__form { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; }
.chat__row { display: flex; gap: 6px; align-items: flex-end; }
.chat__form textarea { flex: 1; resize: none; padding: 10px 14px; border: 1px solid var(--line); border-radius: 20px; font: inherit; font-size: 15px; background: var(--surface); min-height: 42px; max-height: 160px; line-height: 1.4; }
.chat__form textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.chat__icon { flex: 0 0 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.chat__icon--send { background: var(--accent); color: #fff; border-color: var(--accent); }
.chat__icon--send:hover { background: var(--accent-2, #0e4438); }
.chat__form--muted { align-items: center; }
.chat__error { width: 100%; margin: 0; color: #9e2e22; font-size: 14px; }
.chat__reply { display: flex; gap: 8px; align-items: center; font-size: 13px; padding: 4px 10px; border-left: 3px solid var(--accent); background: var(--ground); border-radius: 4px; }
.chat__reply[hidden], .chat__recording[hidden] { display: none; }
.chat__nudge { margin: 8px 0 0; padding: 8px 12px; background: #f0ece2; border-left: 3px solid var(--warn); border-radius: 4px; font-size: 14px; }
.hidden-input { display: none; }
.btn--recording { background: #f6e9e7 !important; border-color: #9e2e22 !important; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .btn--recording { animation: none; } }
@media (max-width: 640px) { .msg { max-width: 92%; } .chat { height: calc(100vh - 100px); } }
