:root {
  --bg: #070707;
  --panel: #111111;
  --line: #2a2a2a;
  --text: #f4f4f4;
  --muted: #8a8a8a;
  --red: #c8102e;
  --gold: #d4a017;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; }

.app {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  grid-template-rows: 64px 1fr;
  min-height: calc(100dvh - 48px);
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.top {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: #000;
  min-width: 0;
  max-width: 100%;
}
.brand { display: flex; align-items: baseline; gap: 6px; flex: 0 0 auto; }
.mark { font-weight: 800; letter-spacing: -0.04em; font-size: 17px; }
.dot { color: var(--red); font-weight: 800; }
.badge {
  margin-left: 6px; font-size: 10px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--muted); border: 1px solid var(--line); padding: 3px 7px; border-radius: 99px;
}
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.year { border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px; font-size: 13px; }
#monthSelect {
  background: #161616; color: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 7px 10px; font-size: 13px;
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.left {
  border-right: 1px solid var(--line);
  padding: 16px 16px 24px;
  background: #0b0b0b;
  overflow: auto;
  min-width: 0;
}
.f-label {
  margin: 16px 0 8px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}
.f-label:first-child { margin-top: 0; }
.date-note {
  margin: 0 0 12px;
  max-width: 68ch;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.pick-hint { margin: -4px 0 14px; color: var(--muted); font-size: 13px; }
.month-list { display: flex; flex-direction: column; gap: 2px; }
.month-list button {
  text-align: left; background: none; border: 0; color: #ccc; padding: 7px 8px; border-radius: 8px; cursor: pointer;
}
.month-list button.on { background: #1a1a1a; color: #fff; box-shadow: inset 2px 0 0 var(--red); }
.left label {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: #ddd; margin: 6px 0; cursor: pointer;
}
.reset {
  margin-top: 18px; width: 100%; background: transparent; border: 1px solid var(--line);
  color: var(--muted); padding: 8px; border-radius: 10px; cursor: pointer;
}

.main { padding: 20px 20px 32px; min-width: 0; }
.month-head { display: flex; justify-content: space-between; align-items: end; flex-wrap: wrap; margin-bottom: 14px; gap: 12px; min-width: 0; }
.month-head h1 { margin: 0; font-size: 30px; letter-spacing: -0.04em; }
.legend { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 4px 8px; border-radius: 999px;
}
.chip.full { background: var(--red); }
.chip.half { background: var(--gold); color: #111; }
.chip.est { background: #222; color: #aaa; border: 1px dashed #444; }

.weekdays, .grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); min-width: 0; }
.weekdays { color: var(--muted); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; padding: 0 0 8px; gap: 6px; }
.grid { gap: 6px; }
.day {
  min-height: 96px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 4px;
  min-width: 0; overflow: hidden;
}
.day.out { opacity: .35; }
.day.has { cursor: pointer; }
.day.has:hover { border-color: #555; }
.day.selected { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
.num { font-size: 13px; font-weight: 700; color: #ccc; }
.day.has .num { color: #fff; }
.pills { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pill {
  font-size: 10px; line-height: 1.15; padding: 2px 4px; border-radius: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0; max-width: 100%;
}
.pill.full { background: #3a0b14; color: #ff6b7d; }
.pill.half { background: #2c2208; color: #e6c15a; }
.pill.est { outline: 1px dashed #555; }
.pill.more {
  appearance: none;
  border: 1px solid #3a3a3a;
  background: #1a1a1a;
  color: var(--gold);
  font-weight: 700;
  width: 100%;
  text-align: left;
  cursor: pointer;
  position: relative;
  overflow: visible;
}
.more-pop {
  display: none;
  position: absolute;
  z-index: 6;
  left: 0;
  top: calc(100% + 4px);
  width: max-content;
  max-width: min(240px, 70vw);
  padding: 8px 10px;
  background: #161616;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .55);
  white-space: normal;
}
.more-pop span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  padding: 2px 0;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}
.pill.more:hover .more-pop,
.pill.more:focus-visible .more-pop,
.pill.more.open .more-pop { display: block; }
.day:has(.pill.more:hover),
.day:has(.pill.more:focus-visible),
.day:has(.pill.more.open) { overflow: visible; z-index: 4; }
.day:nth-child(7n) .more-pop,
.day:nth-child(7n - 1) .more-pop { left: auto; right: 0; }

.overlay { display: none; }
.overlay.open {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 20;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, .62);
}
.right {
  display: flex;
  flex-direction: column;
  width: min(560px, 100%);
  max-height: min(88dvh, 920px);
  background: #0e0e0e;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .72);
  padding: 18px;
  overflow: hidden;
  min-width: 0;
}
.drawer-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 16px; flex: 0 0 auto; }
.kicker { margin: 0; color: var(--red); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; }
.drawer-head h2 { margin: 4px 0 0; font-size: 24px; }
.cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 0;
  flex: 1 1 auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.empty { color: var(--muted); font-size: 13px; }
.card {
  background: #161616; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
  min-width: 0; max-width: 100%;
}
.card h3 { margin: 0 0 6px; font-size: 16px; }
.meta { color: #bbb; font-size: 13px; line-height: 1.5; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.tag { font-size: 11px; background: #222; border-radius: 999px; padding: 3px 8px; color: #ccc; }
.wx {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0;
}
.wx div {
  background: #1b1b1b; border-radius: 10px; padding: 8px 10px;
}
.wx b { display: block; font-size: 16px; }
.wx span { color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.score { margin: 8px 0 4px; }
.score-top { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 2px 8px; font-size: 12px; color: #ccc; margin-bottom: 6px; }
.bar { height: 8px; background: #222; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #3d9b5f, var(--gold), var(--red)); }
.score p { margin: 6px 0 0; font-size: 12px; color: #aaa; line-height: 1.4; }
.go {
  display: inline-flex; align-items: center; justify-content: center; width: 100%;
  background: var(--red); color: #fff; text-decoration: none; font-weight: 700;
  padding: 10px; border-radius: 10px; margin-top: 8px;
}
.disclaimer { color: var(--muted); font-size: 11px; margin: 14px 0 0; flex: 0 0 auto; }

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

@media (max-width: 860px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    align-content: start;
  }
  .top { grid-row: 1; }
  .main { grid-row: 2; }
  .left { grid-row: 3; }

  .top {
    flex-wrap: wrap;
    height: auto;
    gap: 10px 12px;
    padding: 10px 12px;
  }
  .brand {
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: wrap;
    row-gap: 4px;
  }
  .top-actions {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    margin-left: 0;
    justify-content: flex-end;
  }
  #monthSelect {
    min-width: 0;
    max-width: 100%;
    min-height: 44px;
    font-size: 16px;
  }
  .year { min-height: 44px; display: inline-flex; align-items: center; }

  .left {
    display: flex; flex-wrap: wrap; gap: 8px 14px; border-right: 0; border-bottom: 0;
    border-top: 1px solid var(--line);
    padding: 12px 12px 20px;
    overflow-x: hidden;
  }
  .month-list { flex-direction: row; flex-wrap: wrap; width: 100%; min-width: 0; }
  .month-list button { min-height: 44px; padding: 10px 12px; }
  .f-label { width: 100%; margin: 8px 0 0; }
  .left label { min-height: 44px; }
  .reset { width: auto; margin-top: 0; min-height: 44px; padding: 10px 14px; }
  .main { padding: 14px 12px 28px; }
  .month-head h1 { font-size: 24px; }
  .date-note { max-width: none; font-size: 14px; line-height: 1.45; }
  .weekdays { font-size: 10px; letter-spacing: .04em; padding: 0 0 6px; gap: 4px; }
  .grid { gap: 4px; }
  .day { min-height: 64px; padding: 6px 3px; border-radius: 10px; }
  .num { font-size: 12px; }
  .pill { font-size: 9px; padding: 1px 3px; }
  .pills { gap: 1px; }
  .overlay.open {
    align-items: flex-end;
    padding: 0;
    background: rgba(0, 0, 0, .55);
  }
  .right {
    width: 100%;
    max-width: 100%;
    height: min(78dvh, 680px);
    max-height: min(78dvh, 680px);
    border-radius: 18px 18px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    border-top: 1px solid var(--line);
    box-shadow: none;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
  .go { min-height: 44px; }
  .wx { min-width: 0; }
}

html.sheet-open,
html.sheet-open body {
  overflow: hidden;
}

.sheet-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: #1a1a1a; font-size: 22px; line-height: 1; cursor: pointer;
}
.site-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 18px;
  padding: 12px 18px 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  background: #000;
}
.site-foot p { margin: 0; }
.foot-updated { color: #d0d0d0; }
@media (max-width: 860px) {
  .sheet-x { width: 44px; height: 44px; }
  .site-foot { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}
