:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --text: #1f1d1b;
  --muted: #7a756e;
  --line: #e8e5df;
  --accent: #6d4b63;
  --accent-hover: #5b3d52;
  --accent-soft: #f3edf1;
  --critical: #c2553a;
  --critical-soft: #fbefea;
  --normal: #4f8a5b;
  --normal-soft: #edf5ee;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 29, 27, .04), 0 4px 16px rgba(31, 29, 27, .04);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
h1 { font-size: 22px; line-height: 1.25; margin: 0 0 6px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0; font-weight: 600; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
button, input, textarea { font: inherit; color: inherit; }

/* кнопки */
.btn {
  border: 1px solid transparent; border-radius: 10px; padding: 9px 16px; cursor: pointer;
  font-weight: 550; background: transparent; transition: background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-outline { border-color: var(--line); background: var(--card); }
.btn-outline:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-ghost { color: var(--muted); padding: 7px 10px; }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: #f1efeb; }
.btn-danger { color: var(--critical); }
.btn-sm { padding: 7px 12px; font-size: 14px; }
.btn-lg { padding: 13px 22px; font-size: 15px; }
.btn-block { width: 100%; }

/* поля */
input:not([type=checkbox]):not([type=file]), textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; line-height: 1.5; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
label input, label textarea { margin-top: 6px; color: var(--text); font-size: 15px; }
.check { display: inline-flex; align-items: center; gap: 6px; margin: 0; white-space: nowrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 28px 24px; box-shadow: var(--shadow); }
.login-card .muted { margin: 2px 0 22px; font-size: 14px; }
.form-error { color: var(--critical); font-size: 14px; min-height: 20px; margin-bottom: 8px; }

/* шапка */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.brand-lg { font-size: 20px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.top { position: sticky; top: 0; z-index: 10; background: rgba(246, 245, 242, .9); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); }
.top-inner { max-width: 960px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: none; padding: 8px 12px; border-radius: 8px; cursor: pointer; color: var(--muted);
  font-weight: 500; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.user { position: relative; }
.user-btn { display: flex; align-items: center; gap: 6px; border: 0; background: none; cursor: pointer; color: var(--muted);
  padding: 8px; font-weight: 500; }
.menu { position: absolute; right: 0; top: 100%; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); padding: 4px; min-width: 170px; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 12px;
  border-radius: 8px; cursor: pointer; }
.menu button:hover { background: var(--bg); }

.wrap { max-width: 960px; margin: 0 auto; padding: 24px 16px 80px; }
.page-title { margin-bottom: 4px; }
section > .muted { margin-bottom: 18px; max-width: 720px; }

/* hero */
.hero { padding: 22px; display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.progress { height: 6px; background: var(--line); border-radius: 6px; overflow: hidden; margin-top: 12px; max-width: 380px; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* блоки */
.block { margin-bottom: 36px; }
.block-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.block-head .muted { margin-top: 4px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-critical { background: var(--critical); }
.dot-normal { background: var(--normal); }
.count { color: var(--muted); font-weight: 500; }
.list { display: flex; flex-direction: column; gap: 12px; }

/* карточка вопроса */
.q { padding: 18px; transition: opacity .3s, transform .3s; }
.q.leaving { opacity: 0; transform: translateY(-6px); }
.q-meta { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); }
.q-product { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-date { white-space: nowrap; }
.q-author { font-size: 13px; color: var(--muted); margin-top: 2px; }
.q-author:empty { display: none; }
.q-text { font-size: 16px; font-weight: 550; margin: 10px 0 10px; white-space: pre-wrap; word-break: break-word; }
.q-reason { display: inline-block; font-size: 12.5px; padding: 3px 9px; border-radius: 20px; margin-bottom: 10px;
  background: var(--critical-soft); color: var(--critical); }
.q-reason:empty { display: none; }
.q.normal .q-reason { background: var(--normal-soft); color: var(--normal); }
.q-error { color: var(--critical); font-size: 13px; margin-bottom: 8px; }
.q-error:empty { display: none; }
.q-answer { min-height: 84px; background: #fcfbf9; }
.q-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.q-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
.q.edited .q-answer { border-color: #d9c7d3; }

/* история и прочее */
.h-item { padding: 16px 18px; }
.h-item .q-text { margin: 6px 0 8px; font-size: 15px; }
.h-answer { white-space: pre-wrap; font-size: 14.5px; }
.h-orig { margin-top: 8px; font-size: 13px; color: var(--muted); white-space: pre-wrap; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 20px; background: var(--bg); color: var(--muted); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; }
.row-main { min-width: 0; }
.form-inline { display: flex; gap: 10px; align-items: center; padding: 14px; margin: 14px 0 8px; }
.form-inline input[name=username] { flex: 1; }

/* настройки */
.settings .card { padding: 18px; margin-bottom: 14px; }
.settings details { margin-top: 6px; }
.settings summary { cursor: pointer; color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.hint { font-size: 13px; color: var(--normal); margin: -6px 0 12px; }
.hint:empty { display: none; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.check-result { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.ok { color: var(--normal); }
.bad { color: var(--critical); }

/* модалка и тост */
.modal { position: fixed; inset: 0; background: rgba(31, 29, 27, .35); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal-card { background: var(--card); border-radius: 16px; padding: 22px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.15); }
.modal-card p { margin-bottom: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.secret { font-family: ui-monospace, Menlo, monospace; background: var(--bg); border-radius: 8px; padding: 10px 12px;
  user-select: all; word-break: break-all; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 60; max-width: calc(100% - 32px); }
.toast.bad { background: var(--critical); }

@media (max-width: 720px) {
  .top-inner { flex-wrap: wrap; gap: 6px 10px; padding: 10px 12px 6px; }
  .tabs { order: 3; flex-basis: 100%; }
  .user { margin-left: auto; }
  .wrap { padding: 18px 12px 80px; }
  .hero { flex-direction: column; align-items: stretch; padding: 18px; }
  .hero .btn { width: 100%; }
  .block-head { flex-direction: column; align-items: stretch; }
  .block-head .btn { width: 100%; }
  .q { padding: 14px; }
  .q-actions { width: 100%; }
  .q-actions [data-act=send] { flex: 1 1 100%; order: -1; padding: 11px; }
  .q-actions .btn-ghost { flex: 1; }
  .form-inline { flex-wrap: wrap; }
  .form-inline .btn { width: 100%; }
}

.q-research { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.q-research summary { cursor: pointer; }
.q-research p { white-space: pre-wrap; margin-top: 6px; padding: 10px 12px; background: var(--bg); border-radius: 10px; }
