:root {
  --bg: #ffffff;
  --surface: #f6f7f9;
  --text: #0e2340;
  --muted: #55627a;
  --line: #dde2ea;
  --accent: #b8872a;
  --accent-strong: #e0b043;
  --head: #0e2340;
  --head-text: #f4f1e8;
  --link: #16325a;
  --warn-bg: #fff6e0;
  --err-bg: #fdecec;
  --err-text: #8a1f1f;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1a30;
    --surface: #12264a;
    --text: #eef1f6;
    --muted: #a9b4c6;
    --line: #233a5f;
    --accent: #e0b043;
    --accent-strong: #e0b043;
    --head: #071225;
    --head-text: #f4f1e8;
    --link: #f0cf7a;
    --warn-bg: #3a2f12;
    --err-bg: #3d1717;
    --err-text: #ffb4b4;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  overflow-wrap: anywhere;
}

.header { background: var(--head); color: var(--head-text); border-bottom: 3px solid var(--accent-strong); }

.header-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
}

.logo { display: flex; align-items: center; gap: 10px; color: var(--head-text); text-decoration: none; font-weight: 600; }
.logo-icon { border-radius: 50%; }
.logo-text { font-size: 18px; letter-spacing: .2px; }

.nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
.nav-link { color: var(--head-text); text-decoration: none; opacity: .88; }
.nav-link:hover { opacity: 1; text-decoration: underline; text-decoration-color: var(--accent-strong); }

.logout-form, .inline-form { display: inline; margin: 0; }

.btn-link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent-strong);
  font: inherit;
  cursor: pointer;
}

.content { max-width: 860px; margin: 0 auto; padding: 24px 16px 48px; }

h1 { font-size: 26px; line-height: 1.25; margin: 0 0 16px; }
h2 { font-size: 20px; margin: 28px 0 10px; }

a, .link { color: var(--link); }
code { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; font-size: 14px; }
.invite-link { display: block; padding: 10px; word-break: break-all; }

.hint, .empty-hint, .act-meta, .act-organ, .act-pub, .qdate, .expert-date { color: var(--muted); font-size: 14px; }

.qlist { list-style: none; margin: 0; padding: 0; }
.qitem { border-bottom: 1px solid var(--line); }
.qlink { display: block; padding: 12px 4px; color: var(--text); text-decoration: none; }
.qlink:hover { background: var(--surface); }
.qtext { display: block; font-weight: 500; }
.qstatus { display: inline-block; font-size: 13px; padding: 1px 8px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); margin-left: 6px; }
.status-answered { border-color: #2f7d4f; color: #2f7d4f; }
.status-not_found { border-color: var(--muted); }
.status-to_experts { border-color: var(--accent); color: var(--accent); }
.status-expert_answered { border-color: var(--link); color: var(--link); }

.acts { display: grid; gap: 16px; margin-top: 16px; }
.act { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.act-title { font-weight: 600; margin: 0 0 2px; }
.act-name { font-style: italic; margin: 0 0 6px; }
.act-changes { color: var(--accent); font-size: 14px; }
.fragment { margin: 10px 0 0; }
.frag-label { font-size: 14px; color: var(--muted); margin-bottom: 2px; }

blockquote {
  margin: 4px 0 0;
  padding: 6px 12px;
  border-left: 3px solid var(--accent-strong);
  background: var(--bg);
}

.expert-answer { margin-top: 20px; padding: 14px 16px; border: 1px solid var(--accent); border-radius: 8px; }

.search-form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.search-input, select, input[type="text"] {
  flex: 1 1 260px;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.btn-primary, .btn-small {
  background: var(--head);
  color: var(--head-text);
  border: 1px solid var(--accent-strong);
  border-radius: 6px;
  padding: 9px 16px;
  font: inherit;
  cursor: pointer;
}
.btn-small { padding: 3px 10px; font-size: 14px; }
.btn-primary:hover, .btn-small:hover { background: var(--accent-strong); color: #0e2340; }

.warning-msg { background: var(--warn-bg); border-left: 3px solid var(--accent-strong); padding: 8px 12px; border-radius: 4px; }
.error-msg { background: var(--err-bg); color: var(--err-text); padding: 8px 12px; border-radius: 4px; }

.table { width: 100%; border-collapse: collapse; font-size: 15px; display: block; overflow-x: auto; }
.table th, .table td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: 13px; }

.invite-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.invite-form select { flex: 0 1 200px; }

@media (max-width: 520px) {
  h1 { font-size: 22px; }
  .header-inner { padding: 8px 16px; }
  .logo-text { font-size: 16px; }
}
