:root {
  --bg-sidebar: #131739;
  --bg-main: #0f2c58;
  --bg-card: #131739;
  --border-color: #235b8b;
  --bg-hover: #133868;
  --accent-cyan: #57c5ea;
  --accent-light: #c9eef8;
  --text-primary: #fafeff;
  --text-secondary: #ade5f2;
  --success: #4ade80;
  --danger: #ff6b6b;
  --shadow-soft: 0 4px 15px rgba(0, 0, 0, 0.2);
  --shadow-strong: 0 24px 48px rgba(0, 0, 0, 0.4);
}

body.light-mode {
  --bg-sidebar: #f4f8fc;
  --bg-main: #eaf4fb;
  --bg-card: #ffffff;
  --border-color: #b7d2e8;
  --bg-hover: #ddeefc;
  --accent-cyan: #2ca9d6;
  --accent-light: #d9f4fb;
  --text-primary: #16324f;
  --text-secondary: #4f6f8d;
  --success: #16a34a;
  --danger: #dc2626;
  --shadow-soft: 0 6px 18px rgba(22, 50, 79, 0.08);
  --shadow-strong: 0 24px 48px rgba(22, 50, 79, 0.16);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
}

html {
  overflow-x: hidden;
  overflow-y: scroll;
}

body {
  min-height: 100vh;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  display: flex;
  overflow-x: hidden;
  overflow-y: auto;
  transition: background-color 0.25s ease, color 0.25s ease;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}

.sidebar {
  width: 260px;
  min-width: 260px;
  min-height: 100vh;
  padding: 20px 16px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: background-color 0.25s ease, border-color 0.25s ease, left 0.3s ease;
}

.brand {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 52px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--accent-cyan);
  color: var(--bg-sidebar);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 17px;
  letter-spacing: 0;
}

.brand span {
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 13px;
}

.chat-list {
  flex: 1;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
}

.chat-item.active {
  background-color: rgba(87, 197, 234, 0.12);
  border-left: 3px solid var(--accent-cyan);
}

body.light-mode .chat-item.active {
  background-color: rgba(44, 169, 214, 0.12);
}

.chat-item i {
  color: var(--text-primary);
  font-size: 18px;
  flex-shrink: 0;
}

.chat-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.chat-date {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-secondary);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.sidebar-footer-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.sidebar-footer-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-footer-item i {
  font-size: 18px;
}

.main-content {
  flex: 1;
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-main);
}

.chat-header {
  display: flex;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-sidebar);
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.mobile-menu-btn {
  display: none;
  margin-right: 16px;
  color: var(--text-primary);
  font-size: 24px;
}

.assistant-info {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.assistant-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--bg-hover);
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.assistant-details {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.assistant-details .name {
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
}

.assistant-details .status {
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 12px;
}

.protocol-wrap {
  flex: 1 0 auto;
  padding: 24px;
  background: var(--bg-main);
}

body.light-mode .protocol-wrap {
  background:
    radial-gradient(circle at top center, rgba(44, 169, 214, 0.1), transparent 35%),
    linear-gradient(to bottom, #f6fbfe, var(--bg-main));
}

.protocol-card {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: var(--bg-card);
  box-shadow: var(--shadow-soft);
  transition: background-color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.protocol-title {
  color: var(--text-primary);
  font-size: 24px;
  font-weight: 600;
}

.protocol-subtitle {
  margin: 8px 0 24px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
}

.protocol-form {
  display: flex;
  flex-direction: column;
}

.field {
  margin-bottom: 16px;
}

.message-field {
  margin-top: 12px;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

body.light-mode label {
  color: var(--text-primary);
}

.input-dark-lite,
input,
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

body.light-mode .input-dark-lite,
body.light-mode input,
body.light-mode select,
body.light-mode textarea {
  background-color: #f9fcfe;
}

.input-dark-lite::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--text-secondary);
}

.input-dark-lite:hover,
input:hover,
select:hover,
textarea:hover {
  border-color: var(--accent-cyan);
}

.input-dark-lite:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(87, 197, 234, 0.15);
}

textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.5;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.btn-primary,
.btn-secondary {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.btn-primary {
  border: 1px solid var(--accent-cyan);
  background-color: var(--accent-cyan);
  color: var(--bg-sidebar);
}

body.light-mode .btn-primary {
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--accent-light);
  transform: translateY(-1px);
}

body.light-mode .btn-primary:hover {
  border-color: #3cb6df;
  background-color: #3cb6df;
}

.btn-secondary {
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-primary);
}

body.light-mode .btn-secondary {
  background: #ffffff;
}

.btn-secondary:hover {
  border-color: var(--accent-cyan);
  background-color: var(--bg-hover);
}

.result {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.result:not([hidden]) {
  display: flex;
  flex-direction: column;
}

.result[hidden],
.feedback[hidden] {
  display: none !important;
}

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(35, 91, 139, 0.45);
}

body.light-mode .result-row {
  border-bottom-color: #e3eef5;
}

.result-row .k {
  color: var(--text-secondary);
  font-size: 13px;
}

.result-row .v {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}

.protocol-number {
  font-size: 18px;
}

.feedback {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(74, 222, 128, 0.35);
  border-radius: 8px;
  background: rgba(74, 222, 128, 0.12);
  color: var(--success);
  font-size: 14px;
  line-height: 1.5;
}

.feedback.error {
  border-color: rgba(255, 107, 107, 0.35);
  background: rgba(255, 107, 107, 0.12);
  color: var(--danger);
}

@media (max-width: 768px) {
  body {
    position: relative;
    min-height: 100dvh;
    overflow-y: auto;
  }

  .main-content {
    min-height: 100dvh;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    z-index: 20;
    width: 280px;
    min-width: 280px;
    box-shadow: var(--shadow-strong);
  }

  body.sidebar-open .sidebar {
    left: 0;
  }

  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .chat-header {
    padding: 14px 16px;
  }

  .protocol-wrap {
    overflow: visible;
    padding: 16px;
    padding-bottom: 32px;
  }

  .protocol-card {
    padding: 20px 18px 18px;
  }

  .protocol-title {
    font-size: 20px;
  }

  .protocol-subtitle {
    margin-bottom: 18px;
    font-size: 13px;
  }

  .grid-2 {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .actions {
    flex-direction: column;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
  }

  .result-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .result-row .v {
    text-align: left;
  }
}

@media (max-width: 480px) {
  .sidebar {
    padding: 16px 12px;
  }

  .brand {
    margin-bottom: 36px;
  }

  .assistant-avatar {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }

  .assistant-details .name {
    font-size: 15px;
  }

  .protocol-wrap {
    padding: 12px;
  }
}
