:root {
  --bg: #080b10;
  --bg-elev: #11161f;
  --bg-elev-2: #161d28;
  --line: #232b38;
  --text: #e7edf6;
  --muted: #8492a8;
  --accent: #5ee1a4;
  --accent-soft: rgba(94, 225, 164, 0.14);
  --danger: #ff7a7a;
  --radius: 18px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  line-height: 1.5;
}

body {
  min-height: 100vh;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.glow {
  position: fixed;
  inset: -30% -10% auto -10%;
  height: 380px;
  background: radial-gradient(circle at 30% 20%, rgba(94, 225, 164, 0.18), transparent 60%),
              radial-gradient(circle at 75% 5%, rgba(88, 130, 255, 0.16), transparent 55%);
  filter: blur(40px);
  pointer-events: none;
  z-index: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 10px;
  background: linear-gradient(180deg, rgba(8, 11, 16, 0.96), rgba(8, 11, 16, 0.7));
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 4px rgba(132, 146, 168, 0.12);
}
.dot.live {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.ttl {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-variant-numeric: tabular-nums;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
}
.ttl-label { color: var(--muted); font-size: 12px; }
.ttl-value { font-weight: 650; color: var(--accent); font-size: 14px; }
.ttl.warn .ttl-value { color: var(--danger); }

.view {
  position: relative;
  z-index: 1;
  padding: 6px 16px 40px;
  max-width: 620px;
  margin: 0 auto;
}

.hero { padding: 18px 4px 6px; }
.hero h1 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
.hero .accent {
  display: inline-block;
  margin-top: 6px;
  font-size: 15px;
  font-weight: 500;
  color: var(--accent);
}

.muted { color: var(--muted); }
.small { font-size: 13px; }

.card {
  background: linear-gradient(180deg, var(--bg-elev), var(--bg-elev-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.create-card { margin-top: 18px; display: grid; gap: 14px; }

.field { display: grid; gap: 6px; }
.field-label { font-size: 13px; color: var(--muted); }

input, select {
  width: 100%;
  padding: 13px 14px;
  font-size: 16px;
  color: var(--text);
  background: #0c1118;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  font-family: inherit;
}
input:focus, select:focus { border-color: var(--accent); }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  padding: 12px 16px;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.08s ease, background 0.2s ease, opacity 0.2s ease;
}
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.55; cursor: default; }
.btn.block { width: 100%; }
.btn.primary {
  background: linear-gradient(135deg, #5ee1a4, #37c98c);
  border-color: transparent;
  color: #04231a;
}
.btn.ghost { background: #0e131b; }
.btn.danger { color: var(--danger); }

.address-card { margin-top: 16px; }
.address-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.address {
  flex: 1;
  min-width: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0.01em;
  word-break: break-all;
}
.icon-btn {
  border: 1px solid var(--line);
  background: #0c1118;
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 17px;
  cursor: pointer;
  flex: 0 0 auto;
}
.icon-btn.danger { color: var(--danger); }

.address-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.address-actions .btn { flex: 1; padding: 10px 8px; font-size: 14px; }

.metrics {
  display: flex;
  gap: 14px;
  align-items: baseline;
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
}
.metrics b { color: var(--text); font-size: 15px; }
.metrics .muted { margin-left: auto; }

.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 22px 4px 10px;
}
.list-head h2 { margin: 0; font-size: 15px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

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

.msg {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  padding: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  animation: pop 0.22s ease;
}
.msg:active { background: var(--bg-elev-2); }
.msg.unread { border-color: rgba(94, 225, 164, 0.35); }
.msg .from { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.msg .subject { color: var(--text); font-size: 14px; grid-column: 1 / -1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .intro { color: var(--muted); font-size: 13px; grid-column: 1 / -1; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.msg .tags { grid-column: 1 / -1; display: flex; gap: 8px; font-size: 12px; color: var(--muted); }
.tag { border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.tag.new { color: var(--accent); border-color: rgba(94, 225, 164, 0.4); }

@keyframes pop {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.empty { text-align: center; padding: 46px 18px; color: var(--muted); }
.empty-icon { font-size: 40px; opacity: 0.5; margin-bottom: 6px; }
.empty p { margin: 4px 0; }

.sheet { position: fixed; inset: 0; z-index: 40; display: flex; }
.sheet[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); }
.sheet-panel {
  position: relative;
  margin: auto auto 0;
  width: 100%;
  max-width: 680px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.6);
  animation: slide 0.22s ease;
}
@keyframes slide {
  from { transform: translateY(24px); opacity: 0.6; }
  to { transform: none; opacity: 1; }
}
.sheet-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.sheet-title { flex: 1; min-width: 0; }
.sheet-title h3 { margin: 0; font-size: 16px; word-break: break-word; }
.sheet-title p { margin: 2px 0 0; word-break: break-all; }
.sheet-body { padding: 14px 16px 28px; overflow: auto; }

.detail-body { font-size: 15px; word-break: break-word; }
.detail-body pre {
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  color: #d7e2f2;
  margin: 0;
}
.detail-body iframe {
  width: 100%;
  min-height: 320px;
  border: 0;
  border-radius: 12px;
  background: #fff;
}

.attachments { margin-top: 18px; display: grid; gap: 8px; }
.attachments h4 { margin: 0; font-size: 13px; color: var(--muted); letter-spacing: 0.05em; }
.attach {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0c1118;
  cursor: pointer;
  font-size: 14px;
}
.attach .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach .size { color: var(--muted); font-size: 12px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #1b2432;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 60;
  box-shadow: var(--shadow);
}
.toast[hidden] { display: none; }

@media (min-width: 640px) {
  .hero h1 { font-size: 32px; }
  .sheet-panel { margin-bottom: 24px; border-radius: 20px; border-bottom: 1px solid var(--line); }
}
