.card {
  border: 1px solid var(--border);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.04), transparent 65%),
    var(--panel);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.28);
  animation: rise 0.4s ease;
}

.card-title {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.card-sub {
  color: var(--muted);
  font-size: 12px;
}

.stat {
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.04), transparent 70%),
    var(--panel-strong);
  border-radius: 14px;
  padding: 12px;
  border: 1px solid var(--border-strong);
}

.stat-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-value {
  font-size: 18px;
  margin-top: 6px;
}

.stat-value.ok {
  color: var(--ok);
}

.stat-value.warn {
  color: var(--warn);
}

.stat-card {
  display: grid;
  gap: 6px;
}

.note-title {
  font-weight: 600;
  letter-spacing: 0.2px;
}

.status-list {
  display: grid;
  gap: 8px;
}

.status-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.06);
}

.status-list div:last-child {
  border-bottom: none;
}

.label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-strong);
  padding: 6px 12px;
  border-radius: 999px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.06), transparent),
    var(--panel);
}

.theme-toggle {
  --theme-item: 28px;
  --theme-gap: 6px;
  --theme-pad: 6px;
  position: relative;
}

.theme-toggle__track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, var(--theme-item));
  gap: var(--theme-gap);
  padding: var(--theme-pad);
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
}

.theme-toggle__indicator {
  position: absolute;
  top: 50%;
  left: var(--theme-pad);
  width: var(--theme-item);
  height: var(--theme-item);
  border-radius: 999px;
  transform: translateY(-50%)
    translateX(calc(var(--theme-index, 0) * (var(--theme-item) + var(--theme-gap))));
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.12), transparent),
    var(--panel-strong);
  border: 1px solid var(--border-strong);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.25);
  transition: transform 180ms ease-out, background 180ms ease-out,
    box-shadow 180ms ease-out;
  z-index: 0;
}

.theme-toggle__button {
  height: var(--theme-item);
  width: var(--theme-item);
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: color 150ms ease-out, background 150ms ease-out;
}

.theme-toggle__button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.theme-toggle__button.active {
  color: var(--text);
}

.theme-icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pill.danger {
  border-color: rgba(255, 92, 92, 0.5);
  color: var(--danger);
}

.statusDot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--danger);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25);
}

.statusDot.ok {
  background: var(--ok);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25), 0 0 10px rgba(43, 217, 127, 0.4);
}

.btn {
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.btn.primary {
  border-color: rgba(245, 159, 74, 0.45);
  background: rgba(245, 159, 74, 0.2);
}

.btn.danger {
  border-color: rgba(255, 107, 107, 0.45);
  background: rgba(255, 107, 107, 0.18);
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.4px;
}

.field input,
.field textarea,
.field select {
  border: 1px solid var(--border-strong);
  background: rgba(0, 0, 0, 0.22);
  border-radius: 12px;
  padding: 9px 11px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease,
    background 150ms ease;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
  background: rgba(0, 0, 0, 0.28);
}

.field select {
  appearance: none;
  padding-right: 38px;
  background-color: var(--panel-strong);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%),
    linear-gradient(to right, transparent, transparent);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%,
    calc(100% - 38px) 50%;
  background-size: 6px 6px, 6px 6px, 1px 60%;
  background-repeat: no-repeat;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.field textarea {
  font-family: var(--mono);
  min-height: 180px;
  resize: vertical;
  white-space: pre;
}

.field textarea:focus {
  background: rgba(0, 0, 0, 0.32);
}

.field.checkbox {
  grid-template-columns: auto 1fr;
  align-items: center;
}

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

:root[data-theme="light"] .field input,
:root[data-theme="light"] .field textarea,
:root[data-theme="light"] .field select {
  background: rgba(255, 255, 255, 0.9);
  border-color: var(--border-strong);
}

:root[data-theme="light"] .field input:focus,
:root[data-theme="light"] .field textarea:focus,
:root[data-theme="light"] .field select:focus {
  background: #ffffff;
}

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

.mono {
  font-family: var(--mono);
}

.callout {
  padding: 10px 12px;
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.06), transparent),
    rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}

.callout.danger {
  border-color: rgba(255, 92, 92, 0.4);
  color: var(--danger);
}

.code-block {
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(0, 0, 0, 0.35);
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  max-height: 360px;
  overflow: auto;
}

:root[data-theme="light"] .code-block,
:root[data-theme="light"] .list-item,
:root[data-theme="light"] .table-row,
:root[data-theme="light"] .chip {
  background: rgba(255, 255, 255, 0.85);
}

.list {
  display: grid;
  gap: 12px;
}

.list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 260px);
  gap: 14px;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
}

.list-main {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.list-title {
  font-weight: 600;
}

.list-sub {
  color: var(--muted);
  font-size: 12px;
}

.list-meta {
  text-align: right;
  color: var(--muted);
  font-size: 11px;
  display: grid;
  gap: 4px;
  min-width: 220px;
}

.list-meta .field input,
.list-meta .field textarea,
.list-meta .field select {
  width: 100%;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.2);
}

.chip-ok {
  color: var(--ok);
  border-color: rgba(27, 217, 138, 0.4);
}

.chip-warn {
  color: var(--warn);
  border-color: rgba(242, 201, 76, 0.4);
}

.table {
  display: grid;
  gap: 8px;
}

.table-head,
.table-row {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 0.8fr 0.7fr 0.8fr 0.8fr;
  gap: 12px;
  align-items: center;
}

.table-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
}

.table-row {
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.chat-header__left {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.chat-header__right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-session {
  min-width: 240px;
}

.chat-thread {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 60vh;
  overflow: auto;
  padding: 14px 12px;
  min-width: 0;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.2) 0%,
    rgba(0, 0, 0, 0.3) 100%
  );
}

:root[data-theme="light"] .chat-thread {
  border-color: rgba(16, 24, 40, 0.12);
  background: linear-gradient(
    180deg,
    rgba(16, 24, 40, 0.03) 0%,
    rgba(16, 24, 40, 0.06) 100%
  );
}

.chat-line {
  display: flex;
}

.chat-line.user {
  justify-content: flex-end;
}

.chat-line.assistant,
.chat-line.other {
  justify-content: flex-start;
}

.chat-msg {
  display: grid;
  gap: 6px;
  max-width: min(720px, 82%);
}

.chat-line.user .chat-msg {
  justify-items: end;
}

.chat-bubble {
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.24);
  border-radius: 16px;
  padding: 10px 12px;
  min-width: 0;
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.24);
}

:root[data-theme="light"] .chat-bubble {
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 12px 26px rgba(16, 24, 40, 0.08);
}

.chat-line.user .chat-bubble {
  border-color: rgba(245, 159, 74, 0.45);
  background: linear-gradient(
    135deg,
    rgba(245, 159, 74, 0.26) 0%,
    rgba(245, 159, 74, 0.12) 100%
  );
}

.chat-line.assistant .chat-bubble {
  border-color: rgba(52, 199, 183, 0.2);
  background: linear-gradient(
    135deg,
    rgba(52, 199, 183, 0.12) 0%,
    rgba(0, 0, 0, 0.24) 100%
  );
}

:root[data-theme="light"] .chat-line.assistant .chat-bubble {
  background: linear-gradient(
    135deg,
    rgba(27, 185, 177, 0.12) 0%,
    rgba(255, 255, 255, 0.85) 100%
  );
}

@keyframes chatStreamPulse {
  0% {
    box-shadow: 0 12px 22px rgba(0, 0, 0, 0.24), 0 0 0 0 rgba(52, 199, 183, 0);
  }
  60% {
    box-shadow: 0 12px 22px rgba(0, 0, 0, 0.24), 0 0 0 6px rgba(52, 199, 183, 0.08);
  }
  100% {
    box-shadow: 0 12px 22px rgba(0, 0, 0, 0.24), 0 0 0 0 rgba(52, 199, 183, 0);
  }
}

.chat-bubble.streaming {
  border-color: rgba(52, 199, 183, 0.4);
  animation: chatStreamPulse 1.6s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .chat-bubble.streaming {
    animation: none;
  }
}

.chat-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  color: var(--chat-text);
}

.chat-stamp {
  font-size: 11px;
  color: var(--muted);
}

.chat-line.user .chat-stamp {
  text-align: right;
}

.chat-compose {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.chat-compose__field {
  gap: 4px;
}

.chat-compose__field textarea {
  min-height: 72px;
  padding: 10px 12px;
  border-radius: 16px;
  resize: vertical;
  white-space: pre-wrap;
  font-family: var(--font-body);
  line-height: 1.45;
}

.chat-compose__field textarea:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.chat-compose__actions {
  justify-content: flex-end;
  align-self: end;
}

@media (max-width: 900px) {
  .chat-session {
    min-width: 200px;
  }

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

.qr-wrap {
  margin-top: 12px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px dashed rgba(255, 255, 255, 0.18);
  padding: 12px;
  display: inline-flex;
}

.qr-wrap img {
  width: 180px;
  height: 180px;
  border-radius: 10px;
  image-rendering: pixelated;
}
