* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #0b1224;
  color: #e2e8f0;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #1f2937;
  background: linear-gradient(135deg, #111827, #0ea5e9);
}
.brand {
  font-weight: 800;
  font-size: 18px;
}
.muted {
  color: #94a3b8;
  font-size: 13px;
}
.container {
  padding: 16px;
  max-width: 1100px;
  margin: 0 auto;
}
.card {
  border: 1px solid #1f2937;
  background: #111827;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
.card.inner {
  margin-bottom: 12px;
  padding: 12px;
}
.grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
}
.row.wrap {
  justify-content: flex-start;
  flex-wrap: wrap;
}
.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 12px;
  align-items: start;
}
.sidebar {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 80px);
  overflow: auto;
  padding-right: 4px;
}
.chat {
  border: 1px solid #1f2937;
  background: #111827;
  border-radius: 10px;
  overflow: hidden;
  height: clamp(520px, calc(100vh - 240px), 860px);
  display: flex;
  flex-direction: column;
}
.chat-header {
  padding: 10px 12px;
  border-bottom: 1px solid #1f2937;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.chat-title {
  font-weight: 800;
}
.msg-list {
  flex: 1;
  padding: 12px;
  overflow: auto;
  background: #0b1224;
  min-height: 0;
}
.msg {
  max-width: 78%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #1f2937;
  margin-bottom: 10px;
  white-space: pre-wrap;
}
.msg.in {
  background: #111827;
}
.msg.out {
  background: #0a3d5a;
  margin-left: auto;
}
.msg .meta {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 6px;
}
.composer {
  display: flex;
  gap: 10px;
  padding: 10px;
  border-top: 1px solid #1f2937;
  background: #111827;
}
.composer input {
  flex: 1;
}
.select {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #1f2937;
  background: #0b1224;
  color: #e2e8f0;
}
.form {
  display: grid;
  gap: 10px;
}
label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}
input {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #1f2937;
  background: #0b1224;
  color: #e2e8f0;
}
.textarea {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #1f2937;
  background: #0b1224;
  color: #e2e8f0;
  resize: vertical;
  min-height: 90px;
  font-family: inherit;
}
.btn {
  padding: 10px 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: 700;
  background: #38bdf8;
  color: #0b1224;
}
.btn:hover {
  background: #7dd3fc;
}
.btn.secondary {
  background: #0ea5e9;
}
.btn.secondary:hover {
  background: #38bdf8;
}
.btn.small {
  padding: 8px 10px;
  font-size: 12px;
}
.unread-badge {
  background: #ef4444;
  color: #fff;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 18px;
}
.trash-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid #1f2937;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.trash-btn:hover {
  border-color: #ef4444;
  color: #ef4444;
}
.trash-btn svg {
  width: 16px;
  height: 16px;
}
.item.unread {
  border-color: rgba(239, 68, 68, 0.8);
}
.item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.tagbar {
  padding: 8px 12px;
  border-bottom: 1px solid #1f2937;
  background: #0b1224;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.tag-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.tag-pill {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid #1f2937;
  background: rgba(15, 23, 42, 0.35);
}
.tags-panel {
  padding: 10px 12px;
  border-bottom: 1px solid #1f2937;
  background: #0b1224;
}
.tags-list {
  display: grid;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
  padding-right: 2px;
}
.tag-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid #1f2937;
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.7);
}
.tag-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.tag-left span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tag-color {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  border: 1px solid #1f2937;
  flex: 0 0 auto;
}
.icon-btn {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #1f2937;
  background: transparent;
  color: #e2e8f0;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
}
.icon-btn:hover {
  border-color: #ef4444;
  color: #ef4444;
}
.tag-create {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}
.tag-create input[type='color'] {
  width: 46px;
  height: 38px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid #1f2937;
  background: #0b1224;
}
.tag-create input[name='name'] {
  flex: 1;
}
.status {
  margin: 8px 0 16px 0;
}
.list {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}
.item {
  padding: 10px;
  border: 1px solid #1f2937;
  border-radius: 8px;
  background: #0b1224;
}
.item.clickable {
  cursor: pointer;
}
.item.clickable:hover {
  border-color: #38bdf8;
}
.item .small {
  font-size: 12px;
  color: #94a3b8;
}
.qr {
  margin-top: 10px;
  width: 100%;
  border-radius: 10px;
  border: 1px solid #1f2937;
  background: #0b1224;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th,
.table td {
  padding: 8px;
  border-bottom: 1px solid #1f2937;
  text-align: left;
}
.table th {
  color: #cbd5e1;
}
.badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.35);
  border: 1px solid rgba(15, 23, 42, 0.6);
  font-weight: 700;
}
.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.hidden {
  display: none !important;
}
h2, h3 {
  margin: 0 0 10px 0;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    max-height: none;
  }
}
