:root {
  color-scheme: light;
  --ink: #1d2722;
  --muted: #56655c;
  --line: #e3e9e3;
  --paper: #f7f9f6;
  --soft: #edf2eb;
  --lime: #d7edaf;
  --negative: #93453d;
  --widget-width: 332px;
  --card-shadow: 0 2px 3px #2138250b;
  font: 16px/1.45 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #fff;
}
* { box-sizing: border-box; }
body, h1, h2, h3, p, ul { margin: 0; }
body { min-height: 100svh; }
a { color: inherit; text-decoration: none; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid #486b40; outline-offset: 3px; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.icon-button { display: inline-grid; place-items: center; flex: none; width: 42px; height: 42px; padding: 0; border: 0; border-radius: 9px; background: transparent; }
.icon-button:hover, .icon-button[aria-current] { background: var(--soft); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 65px;
  width: min(var(--widget-width), calc(100% - 64px));
  margin-inline: auto;
}
.wordmark { display: inline-flex; align-items: center; gap: 8px; padding-block: 4px; font-size: 21px; font-weight: 760; letter-spacing: -.055em; }
.brand-mark { display: inline-grid; place-items: center; width: 23px; height: 23px; border-radius: 7px; background: var(--lime); }
.brand-mark::after { content: ''; width: 2px; height: 11px; border-radius: 2px; background: #45603b; box-shadow: -4px 2px #45603b, 4px -2px #45603b; }
.calendar-area {
  display: grid;
  place-items: start center;
  padding: clamp(36px, 8vh, 68px) 32px 60px;
}
.calendar-widget {
  position: relative;
  isolation: isolate;
  width: min(var(--widget-width), 100%);
  min-width: 0;
  filter: drop-shadow(0 2px 3px #26372107) drop-shadow(0 8px 15px #2637210c);
}
.calendar-widget::before {
  content: ''; position: absolute; z-index: -1;
  inset: 36px 0 0; background: white; border-radius: 16px;
  box-shadow: none;
}
.planner-bookmark { position: relative; z-index: -1; margin-bottom: -5px; padding-bottom: 15px; box-shadow: none; }
.planner-bookmarks { display: flex; padding-left: 13px; gap: 5px; }
.planner-bookmark {
  min-width: 70px;
  padding: 8px 13px 10px;
  border: 0;
  border-radius: 9px 9px 0 0;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-align: center;
}
.planner-bookmark:hover { background: var(--soft); }
.planner-bookmark[aria-current] { background: #fff; color: #233821; }
.calendar-head, #dates { border: 0; background: transparent; }
.calendar-head {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3px;
  padding: 8px 10px 8px 13px;
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
}
.calendar-head h1 { min-width: 0; font: inherit; }
.range-picker {
  border: 0;
  padding: 4px 0;
  border-radius: 5px;
  background: transparent;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 5px;
  text-align: left;
  min-height: 42px;
  align-content: center;
  font-size: clamp(15px, 4.65vw, 21px);
  font-weight: 750;
  line-height: 1.15;
  letter-spacing: -.04em;
}
.range-picker:hover #range { text-decoration: underline; text-underline-offset: 4px; }
.range-year { color: var(--muted); font-weight: 460; }
.range-year:empty { display: none; }
.picker-chevron { width: 14px; height: 14px; flex: none; align-self: center; }
.navigator { display: flex; flex: none; }
.navigator .icon-button { width: 30px; height: 39px; }
.navigator .icon { width: 18px; height: 18px; }
#dates { min-height: 90px; border-top: 0; border-radius: 0 0 12px 12px; box-shadow: none; padding: 0 11px 16px; }
.date-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekday { text-align: center; font-size: 12px; color: var(--muted); font-weight: 620; padding-block: 3px 8px; }
.week-row { position: relative; }
.week-row + .week-row { margin-top: 2px; }
.week-bookmark {
  display: grid;
  place-items: center;
  position: absolute;
  right: calc(100% + 10px);
  top: 14px;
  transform: translateY(-50%);
  width: 26px;
  min-height: 32px;
  background: var(--paper);
  color: var(--muted);
  border: 1px solid var(--line);
  border-right: 0;
  border-radius: 7px 0 0 7px;
  font-size: 11px;
  font-weight: 670;
  font-variant-numeric: tabular-nums;
}
.week-bookmark:hover { background: #e6efd9; color: var(--ink); }
.week-bookmark[aria-current] { background: #d7e8ba; color: #2b4020; }
.week-bookmark {
  z-index: -1;
  right: calc(100% + 5px);
  width: 27px;
  padding-right: 6px;
  border: 0;
  border-radius: 7px 0 0 7px;
  background: #fff;
  box-shadow: none;
}
.date {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  min-height: 43px;
  border-radius: 8px;
  padding: 5px 0 4px;
  font-variant-numeric: tabular-nums;
}
.date:hover { background: var(--soft); }
.panel-open .date.selected:not([aria-current]) { box-shadow: inset 0 0 0 1px #dce5d2; }
.date[aria-current] .date-num { color: #253817; }
.date[aria-current] { background: var(--lime); }
.date-num { font-size: 15px; font-weight: 670; line-height: 1.2; }
.date-points { font-size: 11px; color: var(--muted); line-height: 1.15; margin-top: 3px; }
.date-points.negative, .event-points.negative { color: var(--negative); }
.side-panel {
  background: white;
  position: fixed;
  inset: 0 auto 0 0;
  width: 100%;
  z-index: 1;
  overflow: auto;
  overscroll-behavior: contain;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 230ms ease, visibility 0s linear 230ms;
  padding: max(14px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
}
.panel-open .side-panel { transform: translateX(0); visibility: visible; transition-delay: 0s; }
.panel-top, .panel-content { width: min(460px, 100%); margin-inline: auto; }
.panel-top { margin-bottom: 12px; }
.panel-top .icon-button { margin-left: -9px; }
.panel-eyebrow { color: var(--muted); font-size: 14px; font-weight: 550; margin-bottom: 7px; }
.panel-title { font-size: clamp(25px, 5vw, 33px); line-height: 1.12; font-weight: 750; letter-spacing: -.05em; overflow-wrap: anywhere; }
.panel-note { color: var(--muted); margin-top: 15px; }
.event-list { list-style: none; padding: 0; margin-top: 18px; }
.event-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 54px; padding: 10px 0; border-top: 1px solid var(--line); }
.event-row:hover .event-title { text-decoration: underline; text-underline-offset: 3px; }
.event-time { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--muted); }
.event-title { font-weight: 630; line-height: 1.3; overflow-wrap: anywhere; }
.event-points { color: #36551c; font-weight: 740; font-variant-numeric: tabular-nums; }
.detail-points { display: inline-block; margin-top: 15px; padding: 3px 9px; border-radius: 8px; background: #eaf5d8; }
.detail-points.negative { background: #f9eeeb; }
.event-field { margin-top: 23px; }
.event-field h3 { font-size: 16px; }
.event-field p { margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.score { margin-top: 16px; font-size: 50px; line-height: 1; font-weight: 780; letter-spacing: -.07em; font-variant-numeric: tabular-nums; }
.score span { color: var(--muted); font-size: .64em; font-weight: 530; }
.slide-page { animation: slide-page 190ms ease both; }
@keyframes slide-page {
  from { transform: translateX(22px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

dialog {
  width: min(340px, calc(100% - 38px));
  padding: 22px;
  color: inherit;
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--card-shadow);
}
dialog::backdrop { background: #16251929; }
dialog h2 { font-size: 22px; letter-spacing: -.03em; }
.month-fields { display: grid; grid-template-columns: 1.45fr 1fr; gap: 9px; margin-top: 12px; }
.month-fields label { font-size: 13px; color: var(--muted); }
.month-fields select, .month-fields input { display: block; width: 100%; margin-top: 4px; padding: 6px; border: 1px solid var(--line); background: white; border-radius: 7px; color: var(--ink); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 15px; }
.dialog-actions button { padding: 7px 12px; border: 0; border-radius: 7px; background: var(--soft); }
.dialog-actions button[value="apply"] { background: var(--lime); }



.period-events-title { margin-top: 28px; font-size: 17px; }
.event-date { margin: 20px 0 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.event-list { margin-top: 8px; }
.week-figure { margin: 26px 0 0; }
.week-chart { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); gap: 7px; }
.chart-day { min-width: 0; text-align: center; border-radius: 5px; }
.chart-day:hover { background: #f3f6ee; }
.chart-plot { display: block; position: relative; height: 128px; }
.chart-plot::before { content: ''; position: absolute; left: -4px; right: -4px; bottom: var(--target-line); border-top: 1px dashed #b2bea7; }
.chart-plot::after { content: ''; position: absolute; left: -4px; right: -4px; bottom: var(--zero-line); border-top: 1px solid var(--line); }
.chart-bar { position: absolute; width: 65%; left: 17.5%; background: #b6d78e; border-radius: 5px 5px 0 0; min-height: 2px; }
.chart-bar.negative { background: #e5b3a5; border-radius: 0 0 5px 5px; }
.chart-weekday, .chart-value { display: block; margin-top: 7px; font-size: 12px; }
.chart-value { margin-top: 2px; font-weight: 650; }
.chart-caption { color: var(--muted); font-size: 12px; margin-top: 10px; }

@media (min-width: 761px) {
  html { scrollbar-gutter: stable; }
  body {
    display: grid;
    grid-template-areas: "header header" "calendar rail";
    grid-template-columns: minmax(0, 620px) minmax(280px, 360px);
    grid-template-rows: auto 1fr;
    column-gap: 48px;
    width: min(1050px, calc(100% - 80px));
    margin-inline: auto;
  }
  .calendar-screen { display: contents; }
  body::after {
    content: '';
    grid-area: rail;
    align-self: stretch;
    justify-self: start;
    width: 0;
    margin-top: 99px;
    margin-bottom: 24px;
    border-left: 1px solid var(--line);
    pointer-events: none;
    z-index: 2;
  }
  .topbar { grid-area: header; width: 100%; padding: 18px 0; border-bottom: 1px solid var(--line); }
  .calendar-area { grid-area: calendar; place-items: start stretch; min-width: 0; padding: 60px 0; }
  .calendar-widget { width: 100%; }
  .planner-bookmarks { padding-left: 18px; }
  .planner-bookmark { min-width: 90px; }
  .calendar-head { min-height: 91px; padding: 14px 18px 14px 24px; }
  .range-picker { column-gap: 8px; font-size: clamp(24px, 3vw, 35px); letter-spacing: -.05em; }
  .picker-chevron { width: 16px; height: 16px; }
  .navigator .icon-button { width: 36px; }
  #dates { padding: 0 20px 20px; box-shadow: none; }
  .week-bookmark { top: 20.8px; right: calc(100% + 13px); width: 40px; min-height: 40px; font-size: 12px; }
  .calendar-widget::before { top: 38px; }
  .weekday { font-size: 13px; padding-bottom: 14px; }
  .date { min-height: 67px; padding-top: 10px; }
  .date-num { font-size: 18px; font-weight: 580; }
  .date-points { font-size: 12px; margin-top: 6px; }
  .week-row + .week-row { margin-top: 3px; }
  .side-panel {
    grid-area: rail; align-self: start; margin-top: 99px;
    position: static; transform: none; transition: none;
    display: none; padding: 12px 20px 24px 28px;
    scrollbar-gutter: stable;
    border: 0; border-radius: 0; box-shadow: none;
    max-height: calc(100svh - 180px);
  }
  .panel-open .side-panel { display: block; }
  .panel-top { display: none; }
  .panel-title { font-size: 27px; }
  .score { font-size: 43px; }
  .slide-page { animation: none; }
}
@media (max-width: 760px) {
  body.panel-open { overflow: hidden; }
  .calendar-area { padding-left: 52px; padding-right: 24px; }
  .week-bookmark { top: 21px; width: 44px; min-height: 44px; font-size: 12px; }
  .date { min-height: 54px; padding-top: 12px; }
  .calendar-head, #dates { border-color: #edf0ea; }
  #dates { box-shadow: none; }
  .planner-bookmarks { padding-left: 15px; }
  .planner-bookmark { min-width: 76px; padding-top: 7px; padding-bottom: 15px; border-radius: 8px 8px 0 0; }
}
@media (max-width: 350px) {
  .calendar-area { padding-left: 48px; padding-right: 20px; }
  .topbar { width: calc(100% - 46px); }
  #dates { padding-inline: 8px; }
  .week-bookmark { right: calc(100% + 2px); width: 44px; }
  .navigator .icon-button { width: 25px; }
}
@media (prefers-reduced-motion: reduce) {
  .side-panel { transition: none; }
  .slide-page { animation: none; }
}

/* A single outline supplies the card surface. All controls sit above it. */
.calendar-widget { filter: none; }
.calendar-widget::before { content: none; }
.calendar-shape {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  z-index: -1;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px #25352412) drop-shadow(0 9px 14px #25352414);
}
.calendar-shape path { fill: #fff; stroke: #e2e8de; stroke-width: .8px; }
.planner-bookmark, .week-bookmark {
  z-index: auto;
  background: transparent;
  border: 0;
  box-shadow: none;
}
.planner-bookmark:hover, .planner-bookmark[aria-current],
.week-bookmark:hover, .week-bookmark[aria-current] {
  background: transparent;
  color: #355a23;
}
.week-bookmark:hover, .planner-bookmark:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.week-bookmark[aria-current] { font-weight: 800; }

#month-picker { overflow: visible; width: min(374px, calc(100% - 38px)); padding: 25px; border-radius: 20px; box-shadow: 0 18px 70px #1c302128; }
.month-fields { gap: 12px; margin-top: 21px; }
.select-field { position: relative; min-width: 0; }
.select-field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.select-trigger, .month-fields .year-control input {
  width: 100%; height: 45px; margin: 0; padding: 0 12px;
  border: 1px solid #dfe6dc; background: #fafbf9; border-radius: 10px;
  text-align: left; font-size: 15px; font-weight: 550; color: var(--ink);
}
.select-trigger { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.select-trigger .icon, .year-control .icon { width: 15px; height: 15px; color: #64705e; }
.select-trigger:hover, .month-fields .year-control input:hover { border-color: #b7c8ad; }
.select-trigger[aria-expanded="true"], .month-fields .year-control input[aria-expanded="true"] { border-color: #93af7e; background: white; }
.year-control { position: relative; }
.year-control .icon { position: absolute; right: 12px; top: 15px; pointer-events: none; }
.month-fields .year-control input { appearance: textfield; padding-right: 32px; }
.year-control input::-webkit-inner-spin-button, .year-control input::-webkit-outer-spin-button { appearance: none; margin: 0; }
.select-options {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 3;
  max-height: min(228px, 35svh); overflow-y: auto; overscroll-behavior: contain;
  padding: 5px; background: #fff; border: 1px solid #e0e7dc; border-radius: 12px;
  box-shadow: 0 6px 12px #20332110, 0 18px 36px #20332112; scrollbar-width: thin;
}
.select-options [role="option"] { padding: 8px 10px; min-height: 36px; border-radius: 7px; font-size: 14px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.select-options [aria-selected="true"]::after { content: '✓'; font-size: 13px; color: #4a6b30; }
.select-options [aria-selected="true"] { background: #edf4e3; font-weight: 650; }
.select-options .highlighted, .select-options [role="option"]:hover { background: #e7efdc; }
.dialog-actions { margin-top: 24px; gap: 8px; }
.dialog-actions button { padding: 9px 16px; border-radius: 9px; font-size: 14px; font-weight: 650; }

[hidden] { display: none !important; }
.connection-state { position: fixed; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 16px; background: white; z-index: 5; padding: 24px; }
.connection-state form { display: grid; width: min(300px, 100%); gap: 8px; }
.connection-state label { font-size: 14px; color: var(--muted); }
.connection-state input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; }
.connection-state button { padding: 9px 16px; background: var(--lime); border: 0; border-radius: 9px; }
.month-fields { grid-template-columns: minmax(0, 1fr); }
button:disabled { cursor: default; opacity: .4; }
.telegram-login { padding: 11px 20px; border-radius: 10px; background: var(--lime); font-weight: 650; }
.telegram-login:hover { background: #cce59e; }
.auth-note { max-width: 290px; text-align: center; font-size: 14px; color: var(--muted); }
.rubric-notes { margin-top: 20px; font-size: 15px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.rubric-rule { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 17px; }
.rubric-rule-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.rubric-rule h3 { font-size: 16px; }
.rubric-rule p { margin-top: 8px; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.rubric-rule .rubric-unit { color: var(--muted); margin-top: 3px; font-size: 13px; }
.rubric-version { font-size: 12px; margin-top: 24px; }
