:root {
  color-scheme: light;
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --ink: #20233b;
  --muted: #545b72;
  --accent: #3d48a3;
  --line: rgba(255, 255, 255, .84);
  color: var(--ink);
  background: #e4e9fb;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  padding: clamp(16px, 4vw, 58px);
  background:
    radial-gradient(ellipse at 12% 8%, #d5ccff 0%, transparent 52%),
    radial-gradient(ellipse at 84% 86%, #c2eae9 0%, transparent 55%),
    linear-gradient(145deg, #ecedfb, #d9e7f6);
  background-attachment: fixed;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid #4858c0; outline-offset: 3px; }
.shell, .login-card {
  border: 1px solid var(--line);
  background: rgba(250, 251, 255, .62);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  backdrop-filter: blur(24px) saturate(140%);
  box-shadow: 0 25px 80px #4b58912b, 0 2px 10px #4b589111;
}
.shell { margin: 0 auto; max-width: 1280px; min-height: calc(100vh - 116px); border-radius: 23px; overflow: hidden; }
.brand-icon { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; color: white; background: linear-gradient(140deg, #7a82e7, #474eaa); font-size: 22px; box-shadow: 0 3px 8px #525eb338; }
main { min-width: 0; padding: clamp(22px, 4vw, 50px); }
.heading, .list-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(27px, 4vw, 38px); letter-spacing: -.04em; }
h2, h3 { font-size: 18px; }
h3 { overflow-wrap: anywhere; }
.secondary, .primary, .copy { border-radius: 10px; padding: 8px 13px; min-height: 44px; font-weight: 600; }
.secondary, input, select { background: #ffffffbd; border: 1px solid #525d912e; color: var(--ink); }
.primary { background: var(--accent); border: 1px solid var(--accent); color: white; }
.toolbar { margin: 24px 0; display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
label { display: grid; gap: 5px; min-width: 0; font-size: 14px; font-weight: 650; color: var(--muted); }
input, select { font-size: 16px; padding: 9px 10px; width: 100%; min-width: 0; min-height: 44px; border-radius: 10px; }
.list-heading { margin-bottom: 10px; }
#count { color: var(--muted); font-size: 14px; }
.message-heading {
  display: grid;
  grid-template-columns: minmax(0, max-content) minmax(0, max-content) minmax(max-content, 1fr);
  grid-template-areas: "sender metadata time";
  align-items: center;
  gap: 8px 12px;
}
.message-heading .sender { grid-area: sender; min-width: 0; }
.message-heading time { grid-area: time; justify-self: end; padding: 4px 9px; border: 1px solid #cdd4ef; border-radius: 8px; background: #e8edff; color: #353e78; font-size: 18px; line-height: 1.35; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.messages { display: grid; gap: 12px; }
.message, .empty { border: 1px solid var(--line); border-radius: 15px; background: #ffffff94; box-shadow: 0 3px 12px #4b58910c; }
.message { padding: 17px 19px; }
.metadata { grid-area: metadata; display: flex; flex-wrap: wrap; align-items: center; gap: 7px; min-width: 0; overflow-wrap: anywhere; }
.tag {
  --tag-hue: 220;
  padding: 3px 9px;
  border: 1px solid hsl(var(--tag-hue) 60% 71%);
  border-radius: 7px;
  color: hsl(var(--tag-hue) 62% 27%);
  background: hsl(var(--tag-hue) 72% 93%);
  font-weight: 700;
}
.number-tag { font-size: 17px; font-variant-numeric: tabular-nums; }
.number-tag.unmapped { font-size: 15px; border-color: #c4c7d4; color: #4d5368; background: #edf0f6; }
.slot-tag { font-size: 14px; color: var(--muted); padding-inline: 3px; }
.heading-actions, .sender { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.heading-actions { justify-content: flex-end; }
.sender-address { border: 1px solid #d8dbef; border-radius: 7px; background: #eff1fb; padding: 2px 8px; color: #414a77; font-size: 15px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.refresh-status { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.refresh-status:empty { margin: 0; }
.message-content { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.body { flex: 1 1 min(100%, 180px); min-width: 0; border: 1px solid #d9dfef; border-radius: 10px; background: #f5f7ffcc; padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
mark { color: #343d88; background: #e3e5ff; padding: 1px 5px; border-radius: 4px; font-weight: 750; }
.copy { background: #eef0ff; border: 1px solid #d8dcfa; color: #343d88; }
.empty { text-align: center; color: var(--muted); padding: 30px 12px; }
.feedback, .login p { margin-top: 8px; color: var(--muted); }
.login { min-height: calc(100vh - 116px); display: grid; place-items: center; }
.login-card { width: min(100%, 420px); padding: 28px; border-radius: 23px; }
.login h1 { margin-top: 15px; font-size: 26px; }
.login form { display: grid; gap: 10px; margin-top: 22px; }
.password-field { display: flex; gap: 8px; }
.password-field button { flex: none; }
@media (max-width: 720px) {
  body { padding: 10px; }
  .shell { display: block; border-radius: 16px; min-height: calc(100vh - 20px); }
  main { padding: 18px 12px 24px; }
  .heading { flex-wrap: wrap; }
  .heading .secondary { font-size: 14px; }
  .toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 16px 0; }
  .search { grid-column: 1 / -1; }
  .message { padding: 13px; }
  .message-heading {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "sender time" "metadata metadata";
  }
}

.tone-0 { --tag-hue: 226; }
.tone-1 { --tag-hue: 156; }
.tone-2 { --tag-hue: 283; }
.tone-3 { --tag-hue: 33; }
.tone-4 { --tag-hue: 330; }
.tone-5 { --tag-hue: 194; }
.heading-actions a { display: inline-flex; align-items: center; text-decoration: none; }
.toolbar > button { align-self: end; justify-self: start; }

.filter-select { display: grid; align-content: start; gap: 5px; min-width: 0; }
.filter-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid #525d9138;
  border-radius: 11px;
  background: linear-gradient(155deg, #fff, #eef1fcbd);
  box-shadow: 0 2px 5px #4b58910d, inset 0 1px 0 #fff;
  color: var(--ink);
  font-weight: 650;
  text-align: left;
}
.filter-trigger span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-trigger::after {
  content: '';
  flex: 0 0 7px;
  height: 7px;
  margin: -4px 2px 0 0;
  border: solid var(--accent);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.filter-trigger:hover, .filter-trigger[aria-expanded="true"] { border-color: #727fc1; }
.filter-trigger[aria-expanded="true"]::after { margin-top: 4px; transform: rotate(225deg); }
.filter-options {
  position: fixed;
  inset: auto;
  margin: 0;
  padding: 5px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #bac4e7;
  border-radius: 12px;
  background: #f4f6ffeb;
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 0 12px 32px #36447838;
}
.filter-options button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  min-height: 40px;
  padding: 7px 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-size: 15px;
  overflow-wrap: anywhere;
}
.filter-options button:hover, .filter-options button:focus-visible { background: #e9edfc; }
.filter-options button:focus-visible { outline-offset: -2px; }
.filter-options button[aria-selected="true"] { background: #dee5fc; color: #343f89; font-weight: 700; }
.filter-options button[aria-selected="true"]::after { content: '✓'; }

.preview-view-nav { display: flex; flex-wrap: wrap; gap: 8px; }
.preview-view-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 4px 12px;
  border: 1px solid #525d912e;
  border-radius: 10px;
  background: #ffffff70;
  color: var(--muted);
  font-size: clamp(20px, 2.5vw, 30px);
  line-height: 1.35;
  font-weight: 700;
  text-decoration: none;
}
.preview-view-nav a:hover { background: #ffffffbd; color: var(--accent); }
.preview-view-nav a[aria-current="page"] { background: #fff; color: var(--accent); box-shadow: 0 2px 8px #4b58911c; }
.page-heading { margin-bottom: 16px; }
.device-summary { color: var(--muted); font-size: 14px; white-space: nowrap; }
.device-table-wrap { border: 1px solid var(--line); background: #ffffff94; border-radius: 16px; overflow: hidden; }
.device-table { width: 100%; border-collapse: collapse; text-align: left; }
.device-table th, .device-table td { padding: 13px 14px; vertical-align: top; }
.device-table thead { color: var(--muted); font-size: 14px; background: #eff1fbbd; }
.device-table tbody tr + tr { border-top: 1px solid #cfd5e895; }
.device-table tbody tr:hover { background: #ffffff72; }
.device-table tbody th { white-space: nowrap; }
.device-table .device-sms, .device-action { white-space: nowrap; font-variant-numeric: tabular-nums; }
.device-table .device-action { text-align: right; }
.line-items { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 7px; }
.phone-line { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 2px 8px; border: 1px solid #d8dbef; border-radius: 7px; background: #eff1fb; overflow-wrap: anywhere; }
.phone-line span, .line-muted { color: var(--muted); font-size: 13px; }
.phone-line strong { font-variant-numeric: tabular-nums; }
.detail-link { color: var(--accent); text-decoration: none; font-weight: 650; }
.detail-link:hover { text-decoration: underline; }
#detail-lines { margin-top: 6px; }
.detail-list-title { margin-bottom: 9px; }
@media (max-width: 680px) {
  .device-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .device-table, .device-table tbody { display: block; }
  .device-table tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: 12px; gap: 7px 8px; }
  .device-table th, .device-table td { padding: 0; }
  .device-table .device-lines { grid-column: 1 / -1; grid-row: 2; }
  .device-table .device-sms { grid-column: 1; grid-row: 3; }
  .device-table .device-action { grid-column: 2; grid-row: 1; }
}

body:has(.detail-dialog[open]) { overflow: hidden; }
.detail-dialog { width: min(820px, calc(100% - 28px)); max-width: none; max-height: 86vh; max-height: 86dvh; padding: 0; border: 1px solid #ffffffd9; border-radius: 20px; color: var(--ink); background: #f2f4fc; box-shadow: 0 24px 85px #252c6447; overflow: auto; overscroll-behavior: contain; }
.detail-dialog::backdrop { background: #21274455; backdrop-filter: blur(3px); }
.detail-dialog-content { padding: 0 clamp(14px, 4vw, 28px) 18px; }
.detail-dialog-header { position: sticky; top: 0; background: #f2f4fc; box-shadow: 0 1px #dce0f0; z-index: 1; margin-bottom: 14px; padding: 16px 0 12px; }
.detail-dialog-header h1 { font-size: clamp(22px, 4vw, 30px); }
.detail-dialog-header .heading-actions { flex: none; }
@media (max-width: 540px) {
  .detail-dialog-header { align-items: flex-start; }
  .detail-dialog-header .heading-actions { margin-left: auto; }
}

.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 14px 0 2px; }
.pagination span { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.pagination a { display: inline-flex; align-items: center; text-decoration: none; }
.pagination button:disabled { color: var(--muted); opacity: .52; cursor: default; }

.heading-actions [aria-current="page"] { background: #fff; color: var(--accent); border-color: #9ba6df; box-shadow: 0 2px 8px #4b58911c; }
.settings-stack { display: grid; gap: 16px; }
.settings-card { border: 1px solid var(--line); border-radius: 15px; background: #ffffff94; box-shadow: 0 3px 12px #4b58910c; padding: 18px 20px; display: grid; gap: 12px; }
.settings-card h2 { font-size: 18px; }
.settings-form { display: grid; gap: 10px; max-width: 520px; }
.settings-form button { justify-self: start; }
.key-field { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.key-field input { flex: 1 1 280px; }
.mono-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }
.keyword-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; max-width: 560px; }
.keyword-form input { flex: 1 1 220px; }
.keyword-list { display: flex; flex-wrap: wrap; gap: 8px; }
.keyword-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 12px; border: 1px solid #c3cbe8; border-radius: 999px; background: #eef1ff; color: #2f3878; font-weight: 650; }
.keyword-chip button { min-height: 26px; min-width: 26px; padding: 0 6px; border: 0; border-radius: 999px; background: transparent; color: #5b6497; font-size: 18px; line-height: 1; }
.keyword-chip button:hover { background: #dce2fb; color: #222a66; }
.inline-list { display: grid; gap: 8px; }
.inline-item { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border: 1px solid #d9dfef; border-radius: 10px; background: #f5f7ffcc; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
