:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1e2329;
  --muted: #6a737d;
  --line: #d9dee5;
  --accent: #146b5c;
  --accent-dark: #0e5146;
  --danger: #b42318;
  --success: #12733d;
  --shadow: 0 14px 36px rgba(22, 28, 36, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

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

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  background: var(--accent);
  color: white;
  font-weight: 650;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

.button-link {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 0 16px;
  background: var(--accent);
  color: white;
  font-weight: 650;
  text-decoration: none;
}

.button-link:hover {
  background: var(--accent-dark);
}

button.ghost {
  background: #e8ecef;
  color: var(--text);
}

button.ghost:hover {
  background: #dce2e6;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  background: white;
  color: var(--text);
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 107, 92, 0.13);
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 17px;
  line-height: 1.25;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 32px auto;
}

.hidden {
  display: none !important;
}

.login-panel {
  width: min(460px, 100%);
  margin: 12vh auto 0;
  display: grid;
  gap: 28px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel p {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.6;
}

.download-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.stack {
  display: grid;
  gap: 16px;
}

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

.topbar p {
  margin-top: 8px;
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(22, 28, 36, 0.05);
}

.panel-title {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-title span {
  min-width: 34px;
  border-radius: 999px;
  padding: 4px 9px;
  background: #eef2f4;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.device-list,
.message-list {
  display: grid;
}

.device {
  display: grid;
  gap: 8px;
  width: 100%;
  min-height: 0;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.device:last-child {
  border-bottom: 0;
}

.device:hover {
  background: #f3f7fa;
}

.device.selected {
  background: #eaf2ff;
  border-left: 4px solid #2563eb;
  color: #173b7a;
}

.device.selected strong {
  color: #1d4ed8;
}

.device strong {
  font-size: 15px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 12px;
}

.status {
  color: var(--success);
  font-weight: 750;
}

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

.composer {
  padding-bottom: 18px;
}

.composer form {
  padding: 18px;
}

.selected-target {
  min-height: 48px;
  display: flex;
  align-items: center;
  border: 1px solid #b7cdfa;
  border-radius: 6px;
  padding: 12px 14px;
  background: #eef5ff;
  color: #1d4ed8;
  font-weight: 750;
}

.selected-target.empty {
  border-color: var(--line);
  background: #f7f8fa;
  color: var(--muted);
}

.send-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

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

.progress-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

progress {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: #e8ecef;
}

progress::-webkit-progress-bar {
  background: #e8ecef;
}

progress::-webkit-progress-value {
  background: var(--accent);
}

progress::-moz-progress-bar {
  background: var(--accent);
}

button:disabled {
  cursor: not-allowed;
  background: #aeb8c2;
}

.messages-panel {
  margin-top: 18px;
}

.message-group {
  border-bottom: 1px solid var(--line);
}

.message-group:last-child {
  border-bottom: 0;
}

.message-group-header {
  width: 100%;
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-radius: 0;
  padding: 14px 18px;
  background: #f8fafb;
  color: var(--text);
  text-align: left;
}

.message-group-header:hover {
  background: #eef3f6;
}

.message-group-header span {
  color: var(--accent);
  font-weight: 750;
}

.message-group.collapsed .message-group-body {
  display: none;
}

.message {
  display: grid;
  grid-template-columns: 180px 1fr 170px;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  align-items: start;
}

.message:last-child {
  border-bottom: 0;
}

.message-main {
  display: grid;
  gap: 8px;
}

.message-content {
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.media-link {
  display: inline-block;
  width: min(260px, 100%);
}

.media-link img {
  display: block;
  width: 100%;
  max-height: 220px;
  border-radius: 6px;
  object-fit: cover;
  background: #111;
}

.message-video {
  display: block;
  width: min(320px, 100%);
  max-height: 240px;
  border-radius: 6px;
  background: #111;
}

.error {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
}

.success {
  min-height: 18px;
  color: var(--success);
  font-size: 13px;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, 1180px);
    margin: 16px auto;
  }

  .topbar,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

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

  .message {
    grid-template-columns: 1fr;
  }

  .send-actions {
    grid-template-columns: 1fr;
  }
}
