:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --ink: #16181d;
  --muted: #687181;
  --line: #dfe4ec;
  --accent: #0bb0ad;
  --accent-dark: #087e7d;
  --hot: #ff375f;
  --warning: #b87800;
  --success: #147d45;
  --shadow: 0 18px 45px rgba(23, 31, 45, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  background: #11141a;
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: #202631;
  color: #62f2ea;
  font-weight: 800;
}

.brand span,
.account-card p,
.metric-card small,
.setting-row small {
  color: var(--muted);
}

.brand span {
  display: block;
  margin-top: 2px;
  color: #9da6b7;
  font-size: 12px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  background: transparent;
  color: #cbd2df;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: #242b37;
  color: #fff;
}

.icon {
  display: grid;
  width: 22px;
  place-items: center;
  color: #62f2ea;
  font-size: 16px;
}

.account-card {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 16px;
  background: #1a202a;
}

.account-card .label {
  color: #9da6b7;
  font-size: 12px;
}

.account-card strong {
  display: block;
  margin: 4px 0 14px;
  font-size: 20px;
}

.account-card p {
  margin: 12px 0 0;
  color: #9da6b7;
  font-size: 12px;
  line-height: 1.55;
}

.main-panel {
  min-width: 0;
  padding: 28px;
}

.topbar,
.panel-heading,
.setting-row,
.comment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar {
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.18;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

.top-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-button,
.ghost-button,
.icon-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 700;
}

.primary-button {
  background: var(--accent);
  color: #041717;
}

.primary-button:hover {
  background: #15c8c4;
}

.ghost-button {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.icon-button {
  display: grid;
  width: 40px;
  padding: 0;
  place-items: center;
  background: #eef4f6;
  color: var(--accent-dark);
}

.full {
  width: 100%;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 18px;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin: 9px 0 4px;
  font-size: 28px;
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.left-column,
.right-column {
  display: grid;
  align-content: start;
  gap: 18px;
}

.panel {
  padding: 18px;
}

.panel-heading {
  margin-bottom: 16px;
}

.panel-heading.compact {
  align-items: flex-start;
}

.status-pill {
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.idle {
  background: #f1f3f6;
  color: #56606f;
}

.status-pill.live {
  background: #e5f9ef;
  color: var(--success);
}

.connection-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 18px;
}

.phone-preview {
  border: 10px solid #191d25;
  border-radius: 26px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 18px 35px rgba(10, 15, 25, 0.18);
}

.phone-top {
  width: 76px;
  height: 6px;
  margin: 10px auto;
  border-radius: 999px;
  background: #303846;
}

.video-frame {
  position: relative;
  min-height: 320px;
}

.video-frame img {
  display: block;
  width: 100%;
  height: 320px;
  object-fit: cover;
}

.video-overlay {
  position: absolute;
  inset: auto 12px 14px;
  color: #fff;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
}

.video-overlay span {
  display: block;
  margin-top: 4px;
  font-size: 12px;
}

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

.setting-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfe;
}

.setting-row strong,
.setting-row small {
  display: block;
}

.setting-row small {
  margin-top: 4px;
  line-height: 1.5;
}

input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.rate-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfe;
}

.rate-box input {
  grid-column: 1 / -1;
  accent-color: var(--accent);
}

.rate-box output {
  color: var(--accent-dark);
  font-weight: 800;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
  background: #f3f6f9;
}

.segmented button {
  min-width: 54px;
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.segmented button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(20, 28, 40, 0.08);
}

.comment-list,
.rules,
.activity-list {
  display: grid;
  gap: 10px;
}

.comment-item {
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.avatar {
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: #e8f7f7;
  color: var(--accent-dark);
  font-weight: 800;
}

.comment-body {
  min-width: 0;
  flex: 1;
}

.comment-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.comment-meta strong {
  font-size: 14px;
}

.comment-meta span {
  color: var(--muted);
  font-size: 12px;
}

.comment-body p {
  margin: 0 0 8px;
  line-height: 1.55;
}

.reply-preview {
  border-left: 3px solid var(--accent);
  padding: 8px 10px;
  background: #eefafa;
  color: #115958;
  font-size: 13px;
  line-height: 1.5;
}

.badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 800;
}

.badge.auto {
  background: #e5f9ef;
  color: var(--success);
}

.badge.review {
  background: #fff3d9;
  color: var(--warning);
}

.badge.blocked {
  background: #ffe8ee;
  color: var(--hot);
}

.badge.replied {
  background: #eef3ff;
  color: #3157a4;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.rule-form {
  display: grid;
  gap: 12px;
}

.rule-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.rule-form input,
.rule-form textarea,
.rule-form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.rule-form textarea {
  resize: vertical;
}

.rule-form input:focus,
.rule-form textarea:focus,
.rule-form select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 176, 173, 0.15);
}

.rules {
  margin-top: 16px;
}

.rule-chip {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
}

.rule-chip strong {
  display: block;
  margin-bottom: 5px;
}

.rule-chip span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.tag-box {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-box span {
  border: 1px solid #f0d8ac;
  border-radius: 999px;
  padding: 7px 10px;
  background: #fff8eb;
  color: #8a5c00;
  font-size: 12px;
  font-weight: 800;
}

.activity-list {
  margin: 0;
  padding-left: 20px;
}

.activity-list li {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.activity-list strong {
  color: var(--ink);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100vw - 44px));
  transform: translateY(18px);
  border-radius: 8px;
  padding: 12px 14px;
  background: #11141a;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.2);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 88px minmax(0, 1fr);
  }

  .brand div:not(.brand-mark),
  .nav-item:not(.active),
  .nav-item.active,
  .account-card p,
  .account-card .label,
  .account-card strong {
    font-size: 0;
  }

  .sidebar {
    padding: 20px 14px;
  }

  .brand {
    justify-content: center;
  }

  .nav-item {
    justify-content: center;
    padding: 0;
  }

  .account-card {
    padding: 10px;
  }

  .account-card .primary-button {
    min-width: 0;
    padding: 0;
    font-size: 0;
  }

  .account-card .primary-button::before {
    content: "登录";
    font-size: 13px;
  }

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

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    overflow-x: auto;
  }

  .brand {
    min-width: 48px;
  }

  .nav-list {
    display: flex;
    min-width: max-content;
  }

  .account-card {
    min-width: 132px;
    margin-top: 0;
  }

  .main-panel {
    padding: 20px;
  }

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

  h1 {
    font-size: 24px;
  }

  .status-grid,
  .connection-layout {
    grid-template-columns: 1fr;
  }

  .phone-preview {
    max-width: 260px;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .comment-item {
    display: grid;
    grid-template-columns: auto 1fr;
  }

  .comment-item .badge {
    grid-column: 2;
    justify-self: start;
  }
}
