:root {
  --bg: #0B0B10;
  --fg: #F8FAFC;
  --card: #1E1E23;
  --muted: #232328;
  --muted-fg: #A8B4C4;
  --border: #1E293B;
  --accent: #3B82F6;
  --accent-deep: #1D4ED8;
  --primary-blue: #2563EB;
  --on-primary: #0F172A;
  --ring: #F8FAFC;
  --debt: #DC2626;
  --on-debt: #FFFFFF;
  --love: #93C5FD;
  --font-display: "Orbitron", sans-serif;
  --font-body: "Noto Sans SC", "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "Noto Sans Mono CJK SC", ui-monospace, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background: #07070b;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, a { cursor: pointer; }
button { font-family: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 3px; }
img, svg { display: block; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

#app {
  height: 100%;
  max-height: 100%;
  max-width: 430px;
  margin: 0 auto;
  background: var(--bg);
  color: var(--fg);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.body { flex: 1; position: relative; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }

.tabbar {
  height: 76px; padding: 6px 12px 18px; display: flex;
  background: rgba(11,11,16,.92); border-top: 1px solid #1E293B; z-index: 10; flex-shrink: 0;
}
.tab {
  flex: 1; min-height: 44px; border: 0; background: transparent; color: var(--muted-fg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 500; cursor: pointer; transition: color 180ms ease;
}
.tab.active { color: var(--fg); }
.tab.active svg { stroke: #93C5FD; }
.tab svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.btn {
  min-height: 48px; padding: 0 18px; border-radius: 12px; font-size: 16px; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: none;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease;
}
.btn-white { background: #F8FAFC; color: #0F172A; }
.btn-white:hover { background: #E2E8F0; }
.btn-blue { background: #1D4ED8; color: #F8FAFC; }
.btn-blue:hover { background: #2563EB; }
.btn-ghost { background: transparent; color: #F8FAFC; border: 1px solid #334155; }
.btn-ghost:hover { border-color: #64748B; }
.btn svg { width: 18px; height: 18px; }
.btn:disabled { opacity: .55; cursor: default; }

.login { padding: 8px 28px 28px; height: 100%; display: flex; flex-direction: column; }
.space-abs { position: absolute; inset: 0; pointer-events: none; }
.login-brand { position: relative; z-index: 1; margin-top: 88px; text-align: center; }
.mark { width: 72px; height: 72px; margin: 0 auto 22px; }
.login-brand h1 { font-family: var(--font-display); font-size: 32px; font-weight: 700; letter-spacing: .16em; }
.login-brand p { margin-top: 10px; color: var(--muted-fg); font-size: 15px; }
.login-cta { position: relative; z-index: 1; margin-top: auto; display: flex; flex-direction: column; gap: 14px; }
.login-cta .legal { text-align: center; font-size: 12px; color: #94A3B8; line-height: 1.6; }
.login-error { text-align: center; color: #F87171; font-size: 13px; }

.app { padding: 16px 16px 0; height: 100%; display: flex; flex-direction: column; position: relative; z-index: 1; min-height: 0; }
.user-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; background: #1E293B; border: 1px solid #334155;
  overflow: hidden; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #BFDBFE;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-row .name { font-weight: 700; font-size: 16px; }
.user-row .handle { font-family: var(--font-mono); font-size: 12px; color: var(--muted-fg); }
.user-row .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.day-chip { font-family: var(--font-mono); font-size: 11px; color: #93C5FD; text-align: right; line-height: 1.35; }
.icon-btn {
  width: 44px; height: 44px; min-width: 44px; min-height: 44px; border-radius: 10px; border: 0;
  background: #1E293B; color: var(--fg); display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 180ms ease;
}
.icon-btn:hover { background: #334155; }
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.scroll { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 14px; padding-bottom: 8px; min-height: 0; }
.sec { display: flex; flex-direction: column; gap: 8px; }
.sec-hd { display: flex; align-items: center; gap: 8px; }
.sec-hd h2 { font-size: 15px; font-weight: 700; }
.count {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}
.count-debt { background: #DC2626; color: #FFFFFF; }
.count-owed { background: #1E293B; color: #93C5FD; border: 1px solid #334155; }
.count-love { background: rgba(29,78,216,.28); color: #93C5FD; border: 1px solid rgba(59,130,246,.45); }
.hint { font-size: 12px; color: var(--muted-fg); }

.item-card {
  background: #14141a; border: 1px solid var(--border); border-radius: 14px;
  padding: 12px; display: flex; flex-direction: column; gap: 8px;
}
.item-top { display: flex; align-items: flex-start; gap: 10px; }
.item-top .who { flex: 1; min-width: 0; }
.item-top .who .dn { font-weight: 700; font-size: 15px; }
.item-top .who .un { font-family: var(--font-mono); font-size: 12px; color: #93C5FD; }
.when { font-family: var(--font-mono); font-size: 11px; color: var(--muted-fg); white-space: nowrap; padding-top: 2px; }
.excerpt { font-size: 14px; color: #E2E8F0; line-height: 1.55; }
.item-actions { display: flex; gap: 8px; }
.item-actions .btn { flex: 1; min-height: 44px; font-size: 15px; }

.empty {
  border: 1px dashed #334155; border-radius: 14px; padding: 22px 16px;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
  color: var(--muted-fg); font-size: 14px; line-height: 1.6;
}
.empty.plain { border: 0; padding: 48px 16px; }
.empty svg { width: 36px; height: 36px; stroke: #64748B; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.love-tag { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-display); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: #93C5FD; }
.love-tag svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; }

.modal {
  position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal-backdrop { position: absolute; inset: 0; background: rgba(7,7,11,.72); }
.modal-card {
  position: relative; z-index: 1; width: 100%; background: #14141a; border: 1px solid #1E293B;
  border-radius: 16px; padding: 22px 20px 18px; display: flex; flex-direction: column; gap: 14px;
}
.modal-card h2 { font-size: 18px; font-weight: 700; }
.modal-card p { font-size: 16px; line-height: 1.7; color: #E2E8F0; }
.modal-card a { color: #93C5FD; text-underline-offset: 3px; }
.modal-card .btn { width: 100%; }

.status-msg { text-align: center; font-size: 13px; color: var(--muted-fg); padding: 8px; }
.toast { color: #F87171; }

@media (min-width: 768px) {
  body { background: #07070b; }
  #app { box-shadow: 0 0 0 1px #1E293B; }
}
