:root {
  color-scheme: light;
  --ink: #17292e;
  --muted: #61777d;
  --muted-2: #8aa0a4;
  --line: rgba(36, 60, 67, .12);
  --line-strong: rgba(36, 60, 67, .2);
  --bg: #e8f4f1;
  --panel: rgba(255, 255, 255, .72);
  --panel-strong: rgba(255, 255, 255, .92);
  --panel-soft: rgba(245, 252, 250, .78);
  --mint: #d9f2e9;
  --mint-strong: #86c73d;
  --mint-ink: #174f45;
  --accent: #079aa5;
  --accent-dark: #04727c;
  --aqua: #3db7e9;
  --violet: #4b25aa;
  --violet-soft: #ece7ff;
  --violet-deep: #39208a;
  --accent-2: #ff735d;
  --rose: #ee5f88;
  --amber: #f5ae36;
  --ok: #197b55;
  --shadow-soft: 0 22px 70px rgba(55, 91, 96, .18);
  --shadow-card: 0 12px 28px rgba(40, 67, 73, .1);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(203, 232, 226, .98) 0%, rgba(218, 235, 232, .95) 38%, rgba(220, 216, 246, .94) 100%),
    linear-gradient(90deg, rgba(7, 154, 165, .24), rgba(75, 37, 170, .18));
  color: var(--ink);
  font: 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .34), rgba(255, 255, 255, .02) 45%, rgba(255, 255, 255, .22)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .09) 0 1px, transparent 1px 120px);
  pointer-events: none;
}

a {
  color: var(--accent);
  text-decoration: none;
}

button,
.button {
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--violet), var(--violet-deep));
  box-shadow: 0 14px 26px rgba(75, 37, 170, .26);
  color: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  font: inherit;
}

button:disabled {
  opacity: .55;
  cursor: default;
}

.ghost {
  background: rgba(255, 255, 255, .7);
  border: 1px solid rgba(255, 255, 255, .72);
  color: var(--accent-dark);
  box-shadow: var(--shadow-card);
}

.nav {
  align-items: center;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .76), rgba(230, 247, 243, .68)),
    rgba(238, 248, 245, .82);
  border-bottom: 1px solid rgba(255, 255, 255, .7);
  display: flex;
  gap: 8px;
  min-height: 68px;
  padding: 0 28px;
  box-shadow: 0 10px 28px rgba(40, 67, 73, .08);
  backdrop-filter: blur(18px);
}

.brand {
  color: var(--ink);
  font-weight: 800;
  margin-right: 8px;
  padding: 8px 0;
}

.nav a:not(.brand) {
  align-items: center;
  background: rgba(255, 255, 255, .46);
  border: 1px solid rgba(255, 255, 255, .68);
  border-radius: 999px;
  color: var(--accent-dark);
  display: inline-flex;
  font-weight: 700;
  min-height: 38px;
  padding: 0 13px;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.nav a:not(.brand):hover {
  background: rgba(255, 255, 255, .72);
  border-color: rgba(255, 255, 255, .86);
  box-shadow: var(--shadow-card);
  color: var(--violet);
}

.spacer {
  flex: 1;
}

main {
  margin: 0 auto;
  max-width: 1160px;
  padding: 34px 28px;
}

.toolbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

h1,
h2 {
  line-height: 1.15;
  margin: 0 0 8px;
}

p {
  color: var(--muted);
  margin: 0;
}

.grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.card,
.panel,
.field-card {
  background: var(--panel-strong);
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(40, 67, 73, .13);
  padding: 20px;
  backdrop-filter: blur(18px);
}

.card {
  min-height: 172px;
  padding: 22px;
}

.card-head,
.actions,
.form-row {
  align-items: center;
  display: flex;
  gap: 12px;
}

.card-head {
  justify-content: space-between;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  margin-top: 22px;
}

.actions a {
  align-items: center;
  background: rgba(255, 255, 255, .72);
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 999px;
  color: var(--accent-dark);
  display: inline-flex;
  font-weight: 700;
  min-height: 34px;
  padding: 0 12px;
}

.actions a:hover {
  color: var(--violet);
  box-shadow: var(--shadow-card);
}

.badge {
  background: rgba(255, 255, 255, .72);
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .9);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
  min-height: 26px;
  padding: 3px 9px;
}

.badge-draft {
  background: rgba(61, 183, 233, .18);
  border-color: rgba(61, 183, 233, .34);
  color: #176a88;
}

.badge-published {
  background: rgba(238, 95, 136, .16);
  border-color: rgba(238, 95, 136, .32);
  color: #b3345f;
}

.badge-archived,
.badge-closed {
  background: rgba(97, 119, 125, .14);
  border-color: rgba(97, 119, 125, .26);
  color: #52666c;
}

.badge-new {
  background: rgba(238, 95, 136, .16);
  border-color: rgba(238, 95, 136, .32);
  color: #b3345f;
}

.badge-in_work {
  background: rgba(245, 174, 54, .2);
  border-color: rgba(245, 174, 54, .36);
  color: #94610d;
}

label {
  color: var(--muted);
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  width: 100%;
}

input,
select,
textarea {
  background: rgba(255, 255, 255, .78);
  border: 1px solid rgba(36, 60, 67, .15);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  min-height: 38px;
  padding: 8px 10px;
  width: 100%;
}

textarea {
  min-height: 80px;
  resize: vertical;
}

.check {
  align-items: center;
  display: flex;
  flex-direction: row;
  gap: 8px;
}

.check input {
  width: auto;
}

.field-card {
  margin-top: 14px;
}

.list {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 8px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.list-row {
  align-items: center;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  display: grid;
  gap: 12px;
  grid-template-columns: 1.2fr 1fr 1fr auto;
  padding: 14px 16px;
}

.list-row:last-child {
  border-bottom: 0;
}

dl {
  display: grid;
  grid-template-columns: 180px 1fr;
  margin: 0;
}

dt,
dd {
  border-bottom: 1px solid var(--line);
  margin: 0;
  padding: 10px 0;
}

dt {
  color: var(--muted);
}

.messages p {
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.chat-page {
  background:
    linear-gradient(135deg, rgba(223, 245, 240, .97) 0%, rgba(237, 246, 245, .92) 42%, rgba(236, 231, 255, .88) 100%),
    linear-gradient(90deg, rgba(7, 154, 165, .2), rgba(75, 37, 170, .16));
}

.chat-shell {
  align-content: start;
  display: grid;
  grid-template-rows: auto auto auto;
  margin: 0 auto;
  max-width: 820px;
  min-height: 100dvh;
  padding: 30px 18px;
}

.chat-header {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .82), rgba(217, 242, 233, .82)),
    rgba(255, 255, 255, .72);
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 8px 8px 0 0;
  box-shadow: 0 16px 42px rgba(40, 67, 73, .1);
  padding: 24px 26px;
  position: relative;
  overflow: hidden;
}

.chat-header::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 5px;
  content: "";
  background: linear-gradient(90deg, var(--accent), var(--aqua), var(--violet), var(--rose));
}

.chat-header h1 {
  font-size: clamp(25px, 3.2vw, 38px);
  margin-bottom: 0;
}

.chat-header p {
  color: var(--muted);
  font-size: 17px;
}

.chat-messages {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .74), rgba(245, 252, 250, .66)),
    rgba(255, 255, 255, .7);
  border-left: 1px solid rgba(255, 255, 255, .72);
  border-right: 1px solid rgba(255, 255, 255, .72);
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 190px;
  max-height: 46dvh;
  overflow-y: auto;
  padding: 22px 26px;
  backdrop-filter: blur(18px);
}

.chat-messages.is-summary-mode {
  max-height: none;
  overflow: visible;
}

.bubble {
  border-radius: 8px;
  max-width: 78%;
  padding: 13px 16px;
  position: relative;
  white-space: pre-wrap;
}

.bubble.assistant {
  align-self: flex-start;
  background:
    linear-gradient(135deg, rgba(217, 242, 233, .98), rgba(236, 231, 255, .88)),
    var(--mint);
  border: 1px solid rgba(75, 37, 170, .18);
  border-left: 5px solid var(--violet);
  color: var(--mint-ink);
  font-weight: 700;
  box-shadow: 0 14px 30px rgba(75, 37, 170, .12);
}

.bubble.assistant::before {
  display: block;
  margin-bottom: 4px;
  color: var(--violet);
  content: "Вопрос";
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.bubble.summary::before {
  display: none;
}

.bubble.final::before {
  display: none;
}

.bubble.summary {
  max-width: 88%;
  line-height: 1.5;
}

.bubble.final {
  font-size: 18px;
  max-width: 88%;
}

.summary-note {
  align-self: flex-start;
  background: rgba(255, 255, 255, .72);
  border: 1px solid rgba(75, 37, 170, .14);
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  max-width: 88%;
  padding: 11px 13px;
}

.bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--violet), var(--violet-deep));
  color: white;
  box-shadow: 0 14px 26px rgba(75, 37, 170, .26);
}

.quick-replies,
.choice-replies {
  align-self: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: -2px;
}

.quick-replies button,
.choice-replies button {
  min-height: 38px;
  padding: 0 14px;
}

.quick-replies button + button,
.choice-replies button + button {
  background: rgba(255, 255, 255, .82);
  border: 1px solid rgba(75, 37, 170, .18);
  box-shadow: var(--shadow-card);
  color: var(--violet);
}

.chat-input {
  align-items: center;
  background: rgba(255, 255, 255, .82);
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 0 0 8px 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
  padding: 14px 18px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.chat-input.is-hidden {
  display: none;
}

.chat-input input {
  border-color: rgba(36, 60, 67, .18);
  background: rgba(255, 255, 255, .86);
  height: 52px;
}

.chat-input button {
  height: 52px;
}

.chat-input input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(7, 154, 165, .16);
  outline: none;
}

.empty {
  padding: 18px;
}

.login-shell {
  display: grid;
  min-height: 100dvh;
  place-items: center;
}

.login-panel {
  width: min(440px, calc(100vw - 32px));
}

.login-panel h1 {
  margin-bottom: 10px;
}

.login-panel p {
  margin-bottom: 18px;
}

.form-error {
  background: rgba(238, 95, 136, .14);
  border: 1px solid rgba(238, 95, 136, .32);
  border-radius: 8px;
  color: #a82855;
  padding: 10px 12px;
}

@media (max-width: 720px) {
  .nav,
  .toolbar,
  .form-row {
    align-items: stretch;
    flex-direction: column;
  }

  .list-row,
  dl {
    grid-template-columns: 1fr;
  }

  main {
    padding: 16px;
  }

  .chat-shell {
    padding: 14px;
  }

  .chat-messages {
    min-height: 180px;
    max-height: 58dvh;
    padding: 16px;
  }

  .chat-input {
    grid-template-columns: 1fr;
  }
}
