:root {
  --bg: #161616;
  --panel: #1c1c1c;
  --line: #2a2a2a;
  --fg: #ececec;
  --muted: #8d8d8d;
  --soft: #b5b5b5;
  --fill: #242424;
  --fill-2: #2c2c2c;
  --urgent: #c9c9c9;
  --font: Inter, system-ui, sans-serif;
}

html[data-theme="light"] {
  --bg: #f3f3f3;
  --panel: #ffffff;
  --line: #e4e4e4;
  --fg: #161616;
  --muted: #6f6f6f;
  --soft: #3d3d3d;
  --fill: #f0f0f0;
  --fill-2: #e8e8e8;
  --urgent: #333333;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }

.app {
  min-height: 100vh;
  background: var(--bg);
}

.header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.brand-name {
  font-size: 14px;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chip {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
}

.lang-toggle {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.lang-btn {
  height: 32px;
  min-width: 36px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.lang-btn.active {
  background: var(--fill-2);
  color: var(--fg);
}

.theme-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.main {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 16px 0 32px;
}

.toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(280px, 100%);
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--fg);
  font: 500 13px/1 var(--font);
}

.search input::placeholder { color: var(--muted); }

.live {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.live-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--fg);
}

.live-count {
  margin-left: auto;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.live-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
}

.live-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--fill);
  text-align: left;
}

.live-bar {
  width: 3px;
  height: 28px;
  border-radius: 99px;
  flex-shrink: 0;
}

.live-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-cd {
  margin-top: 2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.cal-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  overflow: hidden;
}

.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.cal-nav-left,
.cal-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.month-label {
  min-width: 132px;
  text-align: center;
  font-size: 14px;
  font-weight: 650;
}

.nav-btn,
.today-btn,
.view-btn,
.modal-x {
  border: 1px solid var(--line);
  background: var(--fill);
  color: var(--soft);
}

.nav-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
}

.today-btn {
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
}

.today-btn.active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.view-toggle {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.view-btn {
  height: 32px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
}

.view-btn.active {
  background: var(--fill-2);
  color: var(--fg);
}

.dow-row,
.days,
.multi {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.dow-row { border-bottom: 1px solid var(--line); }

.dow {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 2px;
}

.week { border-bottom: 1px solid var(--line); }
.week:last-child { border-bottom: 0; }

.span {
  height: 20px;
  line-height: 20px;
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  padding: 0 6px;
  margin: 1px 0;
  border: 0;
  color: #f3f3f3;
}

html[data-theme="light"] .span,
html[data-theme="light"] .event {
  color: #ffffff;
}

.day {
  min-height: 76px;
  padding: 6px 4px;
  border-right: 1px solid var(--line);
  overflow: hidden;
}

.day:nth-child(7n) { border-right: 0; }
.day.today { background: var(--fill); }
.day.other { opacity: 0.38; }

.day-num {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 3px;
}

.day.today .day-num {
  background: var(--fg);
  color: var(--bg);
}

.event {
  display: block;
  width: 100%;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 5px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  border: 0;
  color: #f3f3f3;
}

.more {
  display: block;
  border: 0;
  background: none;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
}

.list { padding: 4px 0; }

.list-group {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--line);
}

.list-date {
  width: 64px;
  padding: 12px 10px 12px 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.list-dow {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
}

.list-day {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
}

.list-date.today .list-day { color: var(--fg); }

.list-sep {
  width: 1px;
  background: var(--line);
  margin: 10px 0;
}

.list-events {
  flex: 1;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.list-ev {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--fill);
  text-align: left;
  width: 100%;
}

.list-bar {
  width: 3px;
  border-radius: 99px;
  align-self: stretch;
}

.list-title { font-size: 13px; font-weight: 650; }
.list-time { font-size: 11px; color: var(--muted); margin-top: 2px; }

.today-view { padding: 12px; }

.today-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.today-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.today-clock {
  margin-top: 2px;
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.today-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.today-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--fill);
  text-align: left;
}

.today-card-top {
  display: flex;
  justify-content: space-between;
}

.today-status {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.today-card-title {
  font-size: 14px;
  font-weight: 650;
}

.today-card-range {
  font-size: 12px;
  color: var(--muted);
}

.today-card-cd {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.modal-title {
  flex: 1;
  font-size: 16px;
  font-weight: 650;
}

.modal-x {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

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

.modal-cd {
  margin-top: 10px;
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.hidden { display: none !important; }

@media (max-width: 900px) {
  .header-inner,
  .main {
    width: min(100% - 24px, 1080px);
  }

  .day { min-height: 68px; }
}

@media (max-width: 720px) {
  .header-inner,
  .main {
    width: calc(100% - 20px);
  }

  .header-inner { height: 52px; }
  .main { padding-top: 12px; }
  .search { width: 100%; }
  .toolbar { justify-content: stretch; }

  .cal-nav {
    flex-wrap: wrap;
  }

  .cal-nav-left,
  .cal-tools {
    width: 100%;
    justify-content: space-between;
  }

  .month-label { flex: 1; min-width: 0; }

  .day {
    min-height: 58px;
    padding: 4px 2px;
  }

  .span {
    font-size: 10px;
    height: 18px;
    line-height: 18px;
  }

  .event { font-size: 9px; }
  .today-grid { grid-template-columns: 1fr; }
  .live-list { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .brand-name { display: none; }
  .chip { display: none; }
  .view-btn { padding: 0 8px; }
}

@media (hover: hover) {
  .live-item:hover,
  .list-ev:hover,
  .today-card:hover,
  .nav-btn:hover,
  .theme-btn:hover {
    background: var(--fill-2);
  }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
