
/* Safe-area + sticky offset fixes (iOS Dynamic Island / notch) */
:root{
  --topbar-base-h: 56px; /* used for sticky offset of weekbar */
}

/* Ref-style mobile calendar UI (red header, big day, small lunar/festival) */
:root{
  --bg:#f3f4f6;
  --card:#ffffff;
  --line:#e5e7eb;
  --text:#111827;
  --muted:#6b7280;
  --muted2:#9ca3af;
  --red:#e53935;
  --green:#16a34a;
  --sel:#e53935;
}
*{box-sizing:border-box}
body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,"PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;
  -webkit-text-size-adjust:100%;
  touch-action:manipulation;
}
.container{
  max-width:980px;
  margin:0 auto;
  background:var(--card);
  min-height:100vh;
}
.topbar{
  position:sticky; top:0; z-index:10;
  background:var(--red);
  color:#fff;
  padding:12px 12px 10px;
  display:flex; align-items:center; justify-content:space-between; gap:10px;
padding-top:calc(12px + env(safe-area-inset-top));min-height:calc(var(--topbar-base-h) + env(safe-area-inset-top));}

.topbar .nav-btn{
  color:#fff; text-decoration:none;
  font-size:14px;
  padding:6px 10px;
  border-radius:10px;
  background:rgba(255,255,255,.18);
  white-space:nowrap;
}
.topbar h1{
  margin:0;
  font-size:18px;
  font-weight:800;
  letter-spacing:.5px;
}
.weekbar{
  display:grid;
  grid-template-columns:repeat(7,1fr);
  padding:8px 8px 6px;
  border-bottom:1px solid var(--line);
  background:#fff;
  position:sticky;
  top:calc(var(--topbar-base-h) + env(safe-area-inset-top)); /* height of header approx */
  z-index:9;
}
.weekbar div{
  text-align:center;
  font-size:13px;
  font-weight:700;
  color:#111827;
}
.weekbar .sun, .weekbar .sat{ color:var(--red); }

.calgrid{
  display:grid;
  grid-template-columns:repeat(7,1fr);
  gap:0;
}
.daycell{
  border-right:1px solid var(--line);
  border-bottom:1px solid var(--line);
  min-height:74px;
  padding:8px 6px 6px;
  position:relative;
}
/* left border */
.daycell:nth-child(7n+1){ border-left:1px solid var(--line); }

.daylink{ display:block; height:100%; color:inherit; text-decoration:none; }
.daytop{
  display:flex; align-items:flex-start; justify-content:center;
  font-size:34px;
  font-weight:800;
  line-height:1;
}
/* weekend red number */
.weekend .daytop{ color:var(--red); }

.sub{
  margin-top:6px;
  text-align:center;
  font-size:14px;
  color:var(--muted);
  line-height:1.1;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.sub.festival{ color:var(--red); font-weight:700; }
.sub.term{ color:var(--green); font-weight:700; }

/* other month */
.other .daytop, .other .sub{ color:#c7c9cf; }
.other .daytop{ font-weight:700; }

/* selected day border like screenshot */
.selected{
  outline:3px solid var(--sel);
  outline-offset:-3px;
  border-radius:10px;
}
/* today subtle */
.today{
  background:#f3f4f6;
  border-radius:10px;
}

/* Detail panel */
.side{
  padding:12px 12px 20px;
  border-top:10px solid var(--bg);
}
.section{ margin-bottom:14px; }
.section h2{ margin:0 0 8px; font-size:15px; }
.kv{ display:grid; grid-template-columns:88px 1fr; gap:6px 10px; font-size:13px; }
.k{ color:var(--muted); }
.v{ color:var(--text); }
.tags{ display:flex; flex-wrap:wrap; gap:8px; }
.tag{ font-size:12px; border-radius:999px; padding:6px 10px; background:#f1f5f9; color:var(--text); }
.tag.good{ background:#ecfdf5; color:#065f46; }
.tag.bad{ background:#fef2f2; color:#991b1b; }
.note{ font-size:12px; color:var(--muted); line-height:1.45; }

.footer{
  padding:12px;
  border-top:1px solid var(--line);
  background:#fff;
}
.footer form{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
input,button{
  font-size:14px;
  padding:8px 10px;
  border-radius:10px;
  border:1px solid #d1d5db;
}
button{
  background:var(--red);
  color:#fff;
  border:0;
}
@media (max-width:520px){
  .footer form input[type="url"]{ flex:1 1 100%; width:100%; min-width:0 !important; }
  .footer form input[type="number"]{ flex:1 1 30%; }
}
@media (min-width:900px){
  .container{ border-left:1px solid var(--line); border-right:1px solid var(--line); }
  .main{ display:grid; grid-template-columns:1.2fr .8fr; align-items:start; }
  .side{ border-top:none; border-left:1px solid var(--line); min-height:calc(100vh - 52px); }
}


/* iOS Safe Area */
.topbar{padding-top:calc(12px + env(safe-area-inset-top));}
.footer{padding-bottom:calc(12px + env(safe-area-inset-bottom));}


/* ===== 禁止左右滑动 / 横向滚动 ===== */
html, body {
  overflow-x: hidden !important;
  overscroll-behavior-x: none;
  touch-action: pan-y; /* 只允许上下滑动 */
}
.calgrid {
  overflow-x: hidden;
}
