* {
  box-sizing: border-box;
}

:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #172033;
  background: #cfd9e6;
  --page-bg-start: #d4deea;
  --page-bg-end: #c5d2e0;
  --surface: #e7eef6;
  --surface-soft: #f0f4f8;
  --surface-muted: #d2deea;
  --text: #172033;
  --text-soft: #52657b;
  --border: #9fb0c4;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger-bg: #fee2e2;
  --danger-text: #b91c1c;
  --success: #15803d;
  --shadow: rgba(30, 48, 72, 0.22);
  --overlay: rgba(15, 23, 42, 0.42);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --page-bg-start: #0f172a;
  --page-bg-end: #111827;
  --surface: #182235;
  --surface-soft: #111827;
  --surface-muted: #253247;
  --text: #e5edf8;
  --text-soft: #9fb0c6;
  --border: #334155;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --danger-bg: #4a2028;
  --danger-text: #fecaca;
  --success: #4ade80;
  --shadow: rgba(0, 0, 0, 0.38);
  --overlay: rgba(0, 0, 0, 0.62);
}

/* Text selection colors */
::selection {
  background: color-mix(in srgb, var(--primary) 24%, white 76%);
  color: #0f172a;
}

::-moz-selection {
  background: color-mix(in srgb, var(--primary) 24%, white 76%);
  color: #0f172a;
}

input::selection,
textarea::selection {
  background: color-mix(in srgb, var(--primary) 24%, white 76%);
  color: #0f172a;
}

input::-moz-selection,
textarea::-moz-selection {
  background: color-mix(in srgb, var(--primary) 24%, white 76%);
  color: #0f172a;
}

html[data-theme="dark"] ::selection {
  background: color-mix(in srgb, var(--primary) 52%, #0f172a 48%);
  color: #f8fafc;
}

html[data-theme="dark"] ::-moz-selection {
  background: color-mix(in srgb, var(--primary) 52%, #0f172a 48%);
  color: #f8fafc;
}

html[data-theme="dark"] input::selection,
html[data-theme="dark"] textarea::selection {
  background: color-mix(in srgb, var(--primary) 52%, #0f172a 48%);
  color: #f8fafc;
}

html[data-theme="dark"] input::-moz-selection,
html[data-theme="dark"] textarea::-moz-selection {
  background: color-mix(in srgb, var(--primary) 52%, #0f172a 48%);
  color: #f8fafc;
}


html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--page-bg-start);
}

body.menu-open {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button,
a,
input,
.chat-panel,
.content-card,
.site-header,
.chat-message {
  transition:
    background-color 0.22s ease,
    border-color 0.22s ease,
    color 0.22s ease,
    box-shadow 0.22s ease;
}

/* Header */
.site-header {
  min-height: 96px;
  display: grid;
  grid-template-columns: 158px 1fr auto;
  align-items: center;
  gap: 20px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 18px var(--shadow);
  position: relative;
  z-index: 50;
}

.header-left {
  display: flex;
  align-items: center;
  justify-self: start;
  gap: 10px;
}

.home-button,
.telegram-button {
  width: 64px;
  min-height: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 5px;
  border: none;
  border-radius: 13px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  text-decoration: none;
}

.home-button {
  background: var(--surface-muted);
  color: var(--text);
}

.home-button:hover,
.telegram-button:hover {
  transform: translateY(-2px);
}

.home-image {
  width: 48px;
  height: 38px;
  display: block;
  object-fit: contain;
  pointer-events: none;
}

.home-text {
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.telegram-button {
  background: #229ed9;
  color: #ffffff;
}

.telegram-button:hover {
  background: #168ac2;
}

.telegram-icon {
  width: 31px;
  height: 31px;
  display: block;
  fill: currentColor;
  pointer-events: none;
}

.main-nav {
  display: flex;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 12px;
  grid-column: 2;
}

.main-nav button {
  min-width: 118px;
  padding: 12px 18px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  z-index: 2;
}

.main-nav button:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
}

.main-nav button.active {
  background: #0f172a;
}

html[data-theme="dark"] .main-nav button.active {
  background: #64748b;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 8px;
}

.header-control {
  position: relative;
}

.icon-button,
.menu-toggle {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-muted);
  color: var(--text);
  cursor: pointer;
}

.icon-button:hover,
.menu-toggle:hover {
  background: var(--border);
}

.theme-icon {
  font-size: 21px;
}

.language-button {
  grid-template-columns: auto auto;
  gap: 3px;
  width: 58px;
  padding: 0 7px;
  font-size: 13px;
}

.language-button strong {
  font-size: 10px;
}

.control-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 90;
  min-width: 150px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 14px 34px var(--shadow);
}

.control-menu[hidden] {
  display: none;
}

.control-menu button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 11px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.control-menu button:hover,
.control-menu button.selected {
  background: var(--surface-muted);
}

.menu-toggle {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  line-height: 0;
}

.menu-toggle span {
  flex: 0 0 auto;
  display: block;
  width: 23px;
  height: 3px;
  margin: 0;
  border-radius: 999px;
  background: currentColor;
  transform-origin: center;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.site-header.compact-nav .menu-toggle {
  display: flex;
}

.site-header.compact-nav .main-nav {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 70;
  width: min(320px, 84vw);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  gap: 12px;
  padding: 92px 22px 24px;
  background: var(--surface);
  box-shadow: -12px 0 30px var(--shadow);
  transform: translateX(105%);
  transition: transform 0.28s ease;
}

.site-header.compact-nav.menu-open .main-nav {
  transform: translateX(0);
}

.site-header.compact-nav .main-nav button {
  width: 100%;
  min-width: 0;
  padding: 14px 18px;
}

.site-header.compact-nav.menu-open .menu-toggle {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 80;
}

.site-header.compact-nav.menu-open .menu-toggle span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.site-header.compact-nav.menu-open .menu-toggle span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.site-header.compact-nav.menu-open .menu-toggle span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--overlay);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.menu-overlay.visible {
  opacity: 1;
  visibility: visible;
}

/* Generic pages */
.page-content {
  height: calc(100vh - 96px);
  min-height: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background: linear-gradient(135deg, var(--page-bg-start), var(--page-bg-end));
}

.content-card {
  width: min(100%, 700px);
  padding: 56px 36px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 18px 45px var(--shadow);
}

.content-card h1 {
  margin: 0 0 16px;
  font-size: clamp(34px, 6vw, 58px);
}

.content-card p {
  margin: 0;
  font-size: 20px;
  color: var(--text-soft);
}


.calendar-column {
  min-width: 0;
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 70%) minmax(120px, 30%);
  gap: 12px;
  overflow: hidden;
}

.calendar-panel {
  min-width: 0;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(140px, 1fr) auto;
  overflow: hidden;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 18px 45px var(--shadow);
}

.calendar-header {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 56px;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.calendar-title {
  margin: 0;
  color: var(--text);
  font-size: clamp(26px, 3vw, 42px);
  font-weight: 750;
  text-align: center;
}

.calendar-nav-button {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.calendar-nav-button:hover {
  background: var(--border);
  transform: translateY(-1px);
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekdays {
  gap: 8px;
  margin-bottom: 8px;
}

.calendar-weekday {
  padding: 10px 4px;
  color: var(--text-soft);
  font-size: clamp(11px, 1.1vw, 14px);
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.calendar-grid {
  min-height: 0;
  grid-template-rows: repeat(var(--calendar-row-count, 6), minmax(58px, 1fr));
  gap: 8px;
}

.calendar-day {
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--text);
}

.calendar-day:hover,
.calendar-day:focus-within {
  border-color: var(--primary);
  background: var(--surface-muted);
}

.calendar-day-select {
  appearance: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.calendar-day-number {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: clamp(14px, 1.4vw, 18px);
  font-weight: 700;
  z-index: 3;
  text-shadow: 0 1px 2px rgba(15, 23, 42, 0.55);
}

.calendar-day-marks {
  position: absolute;
  inset: 0;
  display: block;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

.calendar-day-mark {
  position: absolute;
  left: 0;
  right: 0;
  height: 20%;
  display: block;
  background: var(--marker-color);
  opacity: 0.95;
  bottom: calc(var(--marker-index, 0) * 20%);
}


.calendar-start-time {
  position: absolute;
  left: 6px;
  bottom: 5px;
  z-index: 4;
  width: 24px;
  display: grid;
  grid-template-rows: 18px 5px 18px;
  align-items: center;
  justify-items: center;
}

.calendar-time-part {
  width: 24px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font-size: 9px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
}

.calendar-time-part:focus {
  border-color: var(--primary);
  outline: 2px solid #93c5fd;
  outline-offset: 1px;
}

.calendar-time-separator {
  color: var(--text-soft);
  font-size: 9px;
  font-weight: 800;
  line-height: 5px;
}


.calendar-labels-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  padding: 12px 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 10px 28px var(--shadow);
}

.calendar-labels-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.calendar-labels-heading h2 {
  margin: 0;
  font-size: 16px;
}

.calendar-labels-heading p {
  margin: 0;
  color: var(--text-soft);
  font-size: 11px;
  text-align: right;
}

.calendar-labels {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(105px, 1fr));
  gap: 7px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.calendar-label-item {
  min-width: 0;
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 6px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: var(--label-color);
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.24);
}

.calendar-label-item.selected {
  border-color: #ffffff;
  box-shadow:
    0 0 0 3px var(--primary),
    0 4px 10px rgba(15, 23, 42, 0.32);
}

.calendar-label-input {
  width: 100%;
  min-width: 0;
  padding: 6px 7px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 7px;
  background: rgba(15, 23, 42, 0.22);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.48);
}

.calendar-label-input::selection {
  background: rgba(255, 255, 255, 0.35);
}

.calendar-label-input:focus {
  border-color: #ffffff;
  background: rgba(15, 23, 42, 0.32);
  outline: none;
}

.calendar-label-select:focus-visible,
.calendar-label-input:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
}


.calendar-day.weekend {
  background: color-mix(in srgb, var(--surface-muted) 82%, #94a3b8 18%);
  color: var(--text-soft);
  border-color: color-mix(in srgb, var(--border) 78%, #94a3b8 22%);
}

.calendar-day.weekend:hover {
  background: color-mix(in srgb, var(--surface-muted) 72%, #94a3b8 28%);
  border-color: var(--text-soft);
}

.calendar-day.weekend .calendar-day-number {
  color: var(--text-soft);
}

.calendar-day.weekend.today .calendar-day-number {
  color: #ffffff;
}

html[data-theme="dark"] .calendar-day.weekend {
  background: color-mix(in srgb, var(--surface-muted) 72%, #64748b 28%);
  border-color: color-mix(in srgb, var(--border) 70%, #64748b 30%);
}

.calendar-day.outside-month {
  color: var(--text-soft);
  opacity: 0.42;
}

.calendar-day.today {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.calendar-day.today .calendar-day-number {
  background: var(--primary);
  color: #ffffff;
}

.calendar-nav-button:focus-visible,
.calendar-day-select:focus-visible,
.calendar-time-part:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 3px;
}

/* Chat */
.home-dashboard {
  height: calc(100vh - 96px);
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 30%);
  align-items: start;
  gap: 18px;
  padding: 18px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--page-bg-start), var(--page-bg-end));
}

.chat-panel {
  width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 18px 45px var(--shadow);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.chat-heading {
  min-width: 0;
}

.chat-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-header h1 {
  margin: 0;
  font-size: 26px;
}

.chat-header p {
  margin: 4px 0 0;
  color: var(--text-soft);
  font-size: 14px;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 700;
}

.mode-badge.online {
  color: var(--success);
}

.clear-chat-button {
  flex: 0 0 auto;
  padding: 10px 14px;
  border: none;
  border-radius: 9px;
  background: var(--surface-muted);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.clear-chat-button:hover {
  filter: brightness(0.96);
}

.chat-messages {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 22px;
  background: var(--surface-soft);
}

.chat-placeholder {
  margin: auto;
  color: var(--text-soft);
  text-align: center;
}

.chat-message {
  width: 100%;
  align-self: flex-start;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 14px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 4px 12px var(--shadow);
}

.chat-message.own-message {
  border-left: 3px solid var(--primary);
}

.chat-message-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.chat-author {
  font-size: 14px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.chat-time {
  color: var(--text-soft);
  font-size: 12px;
}

.chat-text {
  grid-column: 1;
  color: var(--text);
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.delete-message-button {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger-text);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.delete-message-button:hover {
  transform: scale(1.05);
}

.chat-date-divider {
  align-self: center;
  margin: 5px 0 1px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 3px 8px var(--shadow);
}

.chat-status {
  display: none;
  min-height: 34px;
  margin: 0;
  padding: 7px 20px;
  border-top: 1px solid var(--border);
  font-size: 14px;
}

.chat-status:not(:empty) {
  display: block;
}

.chat-status.error {
  color: #dc2626;
  font-weight: 700;
}

.chat-status.success {
  color: var(--success);
}

.chat-form {
  display: grid;
  gap: 12px;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.message-composer {
  position: relative;
}

.message-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
}

.message-row input,
.name-field input {
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}

.message-row > button:last-child {
  padding: 12px 18px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

.message-row > button:last-child:hover {
  background: var(--primary-hover);
}

.emoji-toggle {
  width: 44px;
  min-width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-muted);
  color: var(--text);
  line-height: 1;
  text-align: center;
  cursor: pointer;
}

.emoji-toggle-icon {
  display: block;
  width: 24px;
  height: 24px;
  font-size: 22px;
  line-height: 24px;
  text-align: center;
  transform: translateY(1px);
  pointer-events: none;
}

.emoji-toggle:hover,
.emoji-toggle[aria-expanded="true"] {
  background: var(--border);
}

.emoji-picker {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  z-index: 25;
  width: min(292px, calc(100vw - 56px));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 14px 34px var(--shadow);
}

.emoji-picker[hidden] {
  display: none;
}

.emoji-picker button {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 4px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.emoji-picker button:hover {
  background: var(--surface-muted);
  transform: scale(1.08);
}

.user-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  align-items: end;
  gap: 12px;
}

.name-field,
.color-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 700;
}

.color-field input {
  width: 58px;
  height: 44px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}

/* Focus */
.home-button:focus-visible,
.telegram-button:focus-visible,
.main-nav button:focus-visible,
.icon-button:focus-visible,
.menu-toggle:focus-visible,
.clear-chat-button:focus-visible,
.delete-message-button:focus-visible,
.message-row button:focus-visible,
.emoji-toggle:focus-visible,
.emoji-picker button:focus-visible,
.chat-form input:focus-visible,
.control-menu button:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 3px;
}

@media (orientation: landscape) and (max-width: 1200px) {
  .home-dashboard {
    grid-template-columns: minmax(0, 1fr) minmax(340px, 50%);
  }
}

@media (max-width: 760px) {
  .calendar-title {
    font-size: clamp(16px, 4.2vw, 22px);
    font-weight: 740;
  }

  .calendar-weekdays {
    gap: 5px;
    margin-bottom: 5px;
  }

  .calendar-weekday {
    padding: 4px 2px;
    font-size: 8px;
  }

  .chat-panel {
    grid-template-rows: 1fr auto auto;
  }

  .chat-header {
    display: none;
  }

  .chat-messages {
    padding: 14px 12px;
  }

  .name-field > span,
  .color-field > span {
    display: none;
  }

  .user-row {
    align-items: end;
  }

  .site-header {
    grid-template-columns: 148px 1fr auto;
    padding: 12px 14px;
    gap: 10px;
  }

  .header-actions {
    gap: 5px;
  }

  .icon-button,
  .menu-toggle {
    width: 40px;
    height: 40px;
  }

  .language-button {
    width: 52px;
  }

  .home-dashboard {
    height: calc(100vh - 96px);
    min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    align-items: stretch;
    padding: 10px;
    overflow: hidden;
  }

  .calendar-column {
    height: auto;
    min-height: 0;
    grid-template-rows: auto auto;
    align-content: start;
    gap: 7px;
  }

  .calendar-panel {
    height: auto;
    min-height: 0;
    padding: 5px;
  }

  .calendar-labels-panel {
    min-height: 44px;
    padding: 4px 6px;
    gap: 3px;
  }

  .calendar-labels-heading {
    display: none;
  }

  .calendar-labels {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .calendar-label-item {
    flex: 0 0 112px;
    min-height: 28px;
    padding: 2px;
  }
}

@media (max-width: 520px) {
  .site-header {
    grid-template-columns: 138px 1fr auto;
  }

  .home-button,
  .telegram-button {
    width: 59px;
  }

  .header-left {
    gap: 6px;
  }

  .language-button {
    width: 44px;
  }

  .language-button strong {
    display: none;
  }

  .calendar-header {
    grid-template-columns: 46px minmax(0, 1fr) 46px;
    gap: 6px;
    margin-bottom: 5px;
  }

  .calendar-nav-button {
    width: 46px;
    height: 46px;
    font-size: 24px;
  }

  .calendar-grid {
    gap: 2px;
  }

  .calendar-weekdays {
    gap: 2px;
  }

  .calendar-day {
    border-radius: 9px;
  }

  .calendar-day-number {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }

  .calendar-start-time {
    left: 2px;
    bottom: 2px;
    width: 18px;
    grid-template-rows: 14px 3px 14px;
  }

  .calendar-time-part {
    width: 18px;
    height: 14px;
    font-size: 7px;
    line-height: 14px;
  }

  .calendar-time-separator {
    font-size: 7px;
    line-height: 3px;
  }

  .calendar-day-mark {
    opacity: 0.95;
  }

}


@media (max-height: 720px) {
  .calendar-panel {
    min-height: 0;
    padding: 10px;
  }

  .calendar-header {
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    gap: 4px;
    margin-bottom: 4px;
  }

  .calendar-nav-button {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  .calendar-title {
    font-size: clamp(20px, 3vw, 28px);
  }

  .calendar-weekday {
    padding: 2px;
    font-size: 9px;
  }

  .calendar-grid {
    gap: 1.5px;
  }

  .calendar-day {
    padding: 2px;
  }

  .calendar-day-number {
    top: 2px;
    right: 2px;
    width: 21px;
    height: 21px;
    font-size: 11px;
  }
  .calendar-start-time {
    left: 1px;
    bottom: 1px;
    width: 17px;
    grid-template-rows: 13px 3px 13px;
  }

  .chat-form {
    padding: 10px 12px 12px;
    gap: 8px;
  }

  .chat-messages {
    padding: 14px;
  }
}




@media (max-height: 720px) and (max-width: 760px) {
  .home-dashboard {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .calendar-column {
    gap: 4px;
  }

  .calendar-labels-panel {
    min-height: 38px;
    padding: 3px 5px;
  }

  .calendar-label-item {
    flex: 0 0 108px;
    min-height: 26px;
  }

  .calendar-label-input {
    padding: 2px 4px;
    font-size: 8px;
  }
}



@media (max-width: 760px) {
  .name-field > span,
  .color-field > span {
    display: none !important;
  }

  .name-field,
  .color-field {
    gap: 0;
  }

  .user-row {
    align-items: center;
    gap: 10px;
  }
}


@media (max-width: 760px) {
  .message-row input,
  .name-field input {
    padding: 9px 12px;
  }

  .message-row > button:last-child {
    padding: 9px 16px;
  }

  .emoji-toggle {
    width: 38px;
    min-width: 38px;
    height: 38px;
  }

  .emoji-toggle-icon {
    width: 20px;
    height: 20px;
    font-size: 18px;
    line-height: 20px;
  }

  .color-field input {
    height: 38px;
  }
}


@media (max-width: 760px) {
  .chat-messages {
    gap: 6px;
  }

  .chat-message {
    padding: 6px 14px;
  }
}


/* Special calendar action: opens the selected day's record page. */
.calendar-record-label {
  width: 100%;
  justify-content: center;
  color: #ffffff;
  font: inherit;
  text-align: center;
}

.calendar-record-label-text {
  width: 100%;
  padding: 6px 7px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 7px;
  background: rgba(15, 23, 42, 0.22);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.48);
}

.calendar-record-label:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
}

.day-record-page {
  min-height: calc(100vh - 96px);
  padding: 18px;
  background: linear-gradient(135deg, var(--page-bg-start), var(--page-bg-end));
}

.day-record-panel {
  width: min(100%, 1600px);
  min-height: calc(100vh - 132px);
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 18px 45px var(--shadow);
}

.day-record-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.day-record-header::after {
  width: 124px;
  content: "";
}

.day-record-header h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(20px, 2.6vw, 34px);
  text-align: center;
}

.day-record-back {
  min-width: 124px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-muted);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.day-record-workspace {
  min-height: 0;
  margin: 18px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}


.day-record-voice {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 88%, var(--primary) 12%);
}

.day-record-voice-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.day-record-voice-heading h2 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
}

.day-record-voice-heading p,
.day-record-voice-example {
  margin: 3px 0 0;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.35;
}

.day-record-voice-toggle,
.day-record-voice-apply,
.day-record-voice-clear {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.day-record-voice-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--surface);
  box-shadow: 0 3px 0 color-mix(in srgb, var(--border) 65%, #000000 35%);
}

.day-record-voice-toggle.listening {
  border-color: #dc2626;
  background: color-mix(in srgb, #ef4444 14%, var(--surface) 86%);
  color: #b91c1c;
  box-shadow: 0 0 0 3px color-mix(in srgb, #ef4444 22%, transparent);
}

.day-record-voice-toggle:disabled,
.day-record-voice-apply:disabled,
.day-record-voice-clear:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  box-shadow: none;
}

.day-record-voice-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.day-record-voice-transcript-field {
  min-width: 0;
  display: grid;
  gap: 5px;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 800;
}

.day-record-voice-transcript-field textarea {
  width: 100%;
  min-height: 58px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  line-height: 1.35;
  resize: vertical;
  box-sizing: border-box;
}

.day-record-voice-transcript-field textarea:focus {
  border-color: var(--primary);
  outline: 2px solid color-mix(in srgb, var(--primary) 30%, transparent);
}

.day-record-voice-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.day-record-voice-apply {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.day-record-voice-clear {
  background: var(--surface-muted);
}

.day-record-voice-status {
  min-height: 16px;
  margin: 0;
  color: var(--success);
  font-size: 11px;
  font-weight: 750;
}

.day-record-voice-status.error {
  color: #dc2626;
}

.day-record-toolbar {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 14px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.day-record-save-status {
  min-width: 110px;
  margin: 0 auto 0 0;
  color: var(--success);
  font-size: 13px;
  font-weight: 700;
}

.day-record-save-status.error {
  color: #dc2626;
}

.day-record-photo-select,
.day-record-add-rows {
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--primary);
  color: #ffffff;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 3px 0 color-mix(in srgb, var(--primary) 55%, #000000 45%);
}

.day-record-add-rows:hover {
  background: var(--primary-hover);
}

.day-record-photo-select {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-muted);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 3px 0 color-mix(in srgb, var(--border) 65%, #000000 35%);
}

.day-record-photo-select:hover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--surface-muted) 82%, var(--primary) 18%);
}

.day-record-photo-select:disabled,
.day-record-photo-replace:disabled,
.day-record-photo-delete:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.day-record-add-rows:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--primary) 55%, #000000 45%);
}

.day-record-main-content {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(360px, 2fr);
  overflow: hidden;
}

.day-record-table-scroll {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border-right: 1px solid var(--border);
}

.day-record-photo-column {
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  background: transparent;
}

.day-record-table {
  width: 100%;
  min-width: 1280px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  color: var(--text);
}

.day-record-table th,
.day-record-table td {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.day-record-table thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  height: 46px;
  padding: 7px 6px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.15;
  text-align: center;
}

.day-record-table thead th:first-child,
.day-record-row-number {
  position: sticky;
  left: 0;
  z-index: 5;
}

.day-record-row-number {
  width: 44px;
  padding: 6px;
  background: var(--surface-muted);
  font-size: 13px;
  text-align: center;
}

.day-record-table tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--surface-soft) 85%, var(--surface-muted) 15%);
}

.day-record-table td {
  height: 76px;
  padding: 5px;
  background: var(--surface);
  vertical-align: top;
}

.day-record-table input,
.day-record-table textarea,
.day-record-table select {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  line-height: 1.3;
  box-sizing: border-box;
}

.day-record-table textarea {
  min-height: 64px;
  resize: vertical;
}

.day-record-table input:focus,
.day-record-table textarea:focus,
.day-record-table select:focus {
  border-color: var(--primary);
  outline: 2px solid color-mix(in srgb, var(--primary) 34%, transparent);
  outline-offset: 0;
}

.day-record-table select.status-ok {
  border-color: #16a34a;
  background: color-mix(in srgb, #22c55e 14%, var(--surface) 86%);
  color: #15803d;
  font-weight: 800;
}

.day-record-table select.status-not-ok {
  border-color: #dc2626;
  background: color-mix(in srgb, #ef4444 13%, var(--surface) 87%);
  color: #b91c1c;
  font-weight: 800;
}

.day-record-table .row-number-column {
  width: 44px;
}

.day-record-table .short-column {
  width: 112px;
}

.day-record-table .text-column {
  width: 245px;
}

.day-record-table .status-column {
  width: 110px;
}

.day-record-table .note-column {
  width: 220px;
}


.day-record-photo-dropzone {
  min-height: 66px;
  margin: 10px 12px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 11px 16px;
  border: 2px dashed color-mix(in srgb, var(--primary) 58%, var(--border) 42%);
  border-radius: 11px;
  background: color-mix(in srgb, var(--surface) 90%, var(--primary) 10%);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.day-record-photo-dropzone:hover,
.day-record-photo-dropzone:focus-visible {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--surface) 80%, var(--primary) 20%);
  outline: none;
}

.day-record-photo-dropzone.is-dragging {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--surface) 68%, var(--primary) 32%);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 24%, transparent 76%);
  transform: translateY(-1px);
}

.day-record-photo-dropzone.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.day-record-photo-dropzone.has-photo {
  min-height: 54px;
  margin-bottom: 0;
}

.day-record-photo-dropzone-icon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--primary);
  color: #ffffff;
  font-size: 25px;
  font-weight: 900;
  line-height: 1;
}

.day-record-photo-dropzone-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.day-record-photo-dropzone-copy strong {
  font-size: 13px;
  line-height: 1.2;
}

.day-record-photo-dropzone-copy span {
  color: var(--text-soft);
  font-size: 11px;
  line-height: 1.25;
}

.day-record-photo-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto;
  gap: 12px;
  padding: 14px 12px 20px;
  overflow: visible;
  border-top: 1px solid var(--border);
  background: transparent;
}

.day-record-photo-panel[hidden] {
  display: none;
}

.day-record-photo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.day-record-photo-header h2 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
}

.day-record-photo-header p {
  margin: 3px 0 0;
  color: var(--text-soft);
  font-size: 11px;
}

.day-record-photo-status {
  min-height: 14px;
  color: var(--success) !important;
  font-weight: 750;
}

.day-record-photo-status.error {
  color: #dc2626 !important;
}

.day-record-photo-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
}

.day-record-photo-replace,
.day-record-photo-delete {
  min-height: 32px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.day-record-photo-replace {
  background: var(--surface-muted);
}

.day-record-photo-delete {
  border-color: color-mix(in srgb, #dc2626 45%, var(--border) 55%);
  background: color-mix(in srgb, #ef4444 12%, var(--surface) 88%);
  color: var(--danger-text);
}

.day-record-photo-preview {
  min-height: 0;
  width: 100%;
  max-width: 100%;
  justify-self: center;
  display: grid;
  place-items: center;
  padding: 0;
  overflow: visible;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  cursor: zoom-in;
}

.day-record-photo-preview[hidden] {
  display: none;
}

.day-record-photo-preview img {
  width: 100%;
  height: auto;
  max-height: none;
  display: block;
  object-fit: contain;
  background: transparent;
}

.day-record-photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 56px 24px 24px;
  background: rgba(2, 6, 23, 0.92);
}

.day-record-photo-lightbox[hidden] {
  display: none;
}

.day-record-photo-lightbox img {
  max-width: 96vw;
  max-height: 90vh;
  display: block;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
}

.day-record-photo-lightbox-close {
  position: fixed;
  top: 14px;
  right: 18px;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.82);
  color: #ffffff;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}

body.photo-lightbox-open {
  overflow: hidden;
}


@media (max-width: 900px) {
  .day-record-main-content {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(280px, 52vh) auto;
    align-content: start;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .day-record-table-scroll {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .day-record-photo-column {
    min-height: auto;
    overflow: visible;
  }
}

@media (max-width: 760px) {
  .calendar-record-label-text {
    padding: 3px 5px;
    font-size: 9px;
  }

  .day-record-page {
    min-height: calc(100vh - 96px);
    padding: 10px;
  }

  .day-record-panel {
    min-height: calc(100vh - 116px);
    border-radius: 16px;
  }

  .day-record-header {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }

  .day-record-header::after {
    display: none;
  }

  .day-record-header h1 {
    grid-row: 1;
    font-size: 18px;
  }

  .day-record-back {
    grid-row: 2;
    min-width: 0;
    justify-self: start;
    padding: 8px 11px;
  }

  .day-record-workspace {
    margin: 10px;
    grid-template-rows: auto auto minmax(0, 1fr);
    border-radius: 10px;
  }


  .day-record-voice {
    gap: 8px;
    padding: 9px;
  }

  .day-record-voice-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .day-record-voice-toggle {
    width: 100%;
  }

  .day-record-voice-editor {
    grid-template-columns: 1fr;
  }

  .day-record-voice-actions {
    grid-template-columns: 1fr 1fr;
  }

  .day-record-voice-example {
    font-size: 10px;
  }

  .day-record-toolbar {
    min-height: 46px;
    gap: 8px;
    padding: 6px 8px;
  }

  .day-record-save-status {
    min-width: 0;
    font-size: 11px;
  }

  .day-record-add-rows {
    padding: 7px 9px;
    font-size: 11px;
  }

  .day-record-photo-select {
    min-height: 32px;
    padding: 7px 9px;
    font-size: 11px;
  }

  .day-record-photo-dropzone {
    min-height: 56px;
    margin: 7px 8px 0;
    gap: 9px;
    padding: 9px 10px;
  }

  .day-record-photo-dropzone-icon {
    width: 32px;
    height: 32px;
    font-size: 21px;
  }

  .day-record-photo-dropzone-copy strong {
    font-size: 11px;
  }

  .day-record-photo-dropzone-copy span {
    font-size: 10px;
  }

  .day-record-photo-panel {
    gap: 8px;
    padding: 10px 8px 16px;
  }

  .day-record-photo-header {
    align-items: stretch;
    flex-direction: column;
    gap: 7px;
  }

  .day-record-photo-actions {
    width: 100%;
  }

  .day-record-photo-replace,
  .day-record-photo-delete {
    flex: 1 1 0;
  }

  .day-record-photo-preview {
    width: 100%;
  }

  .day-record-photo-preview img {
    width: 100%;
    height: auto;
    max-height: none;
  }

  .day-record-table {
    min-width: 1180px;
  }

  .day-record-table thead th {
    height: 40px;
    padding: 5px 4px;
    font-size: 10px;
  }

  .day-record-table td {
    height: 68px;
    padding: 4px;
  }

  .day-record-table input,
  .day-record-table textarea,
  .day-record-table select {
    padding: 6px;
    font-size: 12px;
  }
}


/* Calendar labels styled as keyboard-like buttons on the large web layout. */
@media screen and (min-width: 761px) {
  .calendar-labels-panel .calendar-labels {
    display: grid;
    grid-template-columns: repeat(auto-fill, 144px);
    grid-auto-rows: 32px;
    justify-content: start;
    align-content: start;
    gap: 9px 10px;
    padding: 2px 0 6px;
    overflow-y: auto;
  }

  .calendar-labels-panel .calendar-label-item,
  .calendar-labels-panel .calendar-record-label {
    width: 144px;
    min-width: 144px;
    max-width: 144px;
    min-height: 32px;
    height: 32px;
    padding: 3px;
    border: 1px solid rgba(255, 255, 255, 0.34);
    border-bottom-color: rgba(15, 23, 42, 0.58);
    border-radius: 8px;
    box-sizing: border-box;
    box-shadow:
      0 4px 0 rgba(15, 23, 42, 0.52),
      0 6px 10px rgba(15, 23, 42, 0.24),
      inset 0 1px 0 rgba(255, 255, 255, 0.34);
    transform: translateY(0);
    transition:
      transform 120ms ease,
      box-shadow 120ms ease,
      filter 120ms ease;
  }

  .calendar-labels-panel .calendar-label-item:hover,
  .calendar-labels-panel .calendar-record-label:hover {
    filter: brightness(1.07);
    transform: translateY(-1px);
    box-shadow:
      0 5px 0 rgba(15, 23, 42, 0.52),
      0 8px 12px rgba(15, 23, 42, 0.26),
      inset 0 1px 0 rgba(255, 255, 255, 0.38);
  }

  .calendar-labels-panel .calendar-label-item.selected,
  .calendar-labels-panel .calendar-record-label.selected,
  .calendar-labels-panel .calendar-label-item:active,
  .calendar-labels-panel .calendar-record-label:active {
    transform: translateY(3px);
    border-color: rgba(255, 255, 255, 0.72);
    box-shadow:
      0 1px 0 rgba(15, 23, 42, 0.54),
      0 2px 5px rgba(15, 23, 42, 0.22),
      inset 0 2px 5px rgba(15, 23, 42, 0.24);
  }

  .calendar-labels-panel .calendar-label-item.selected {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
  }

  .calendar-labels-panel .calendar-label-input,
  .calendar-labels-panel .calendar-record-label-text {
    width: 100%;
    height: 24px;
    min-height: 24px;
    padding: 2px 6px;
    border-radius: 5px;
    box-sizing: border-box;
    font-size: 11px;
    line-height: 18px;
  }

  .calendar-labels-panel .calendar-record-label {
    display: grid;
    place-items: center;
    text-align: center;
  }

  .calendar-labels-panel .calendar-record-label-text {
    display: grid;
    place-items: center;
    text-align: center;
    margin: 0;
  }
}


/* Dictation into one selected daily-record field. */
.day-record-field-voice {
  gap: 10px;
}

.day-record-field-voice-state {
  display: grid;
  grid-template-columns: minmax(220px, auto) minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.day-record-voice-target {
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.day-record-voice-toggle.armed {
  background: #a16207;
  color: #ffffff;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.22);
}

.day-record-table input.voice-target-active,
.day-record-table textarea.voice-target-active,
.day-record-table select.voice-target-active {
  border-color: #f59e0b;
  outline: 3px solid rgba(245, 158, 11, 0.28);
  background: color-mix(in srgb, var(--surface) 88%, #f59e0b 12%);
}

@media (max-width: 760px) {
  .day-record-field-voice-state {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .day-record-voice-target {
    padding: 7px 9px;
    font-size: 12px;
  }
}


/* A green date number indicates that the day contains saved work records. */
.calendar-day.has-day-record .calendar-day-number,
.calendar-day.weekend.has-day-record .calendar-day-number,
.calendar-day.today.has-day-record .calendar-day-number,
.calendar-day.weekend.today.has-day-record .calendar-day-number {
  color: #4ade80;
  font-weight: 900;
  text-shadow:
    0 0 6px rgba(34, 197, 94, 0.72),
    0 1px 2px rgba(15, 23, 42, 0.72);
}


/* Keep the daily-record page inside the viewport and scroll long tables vertically. */
body[data-current-page="day.html"] .day-record-page {
  height: calc(100vh - 96px);
  height: calc(100dvh - 96px);
  min-height: 0;
  overflow: hidden;
}

body[data-current-page="day.html"] .day-record-panel {
  height: 100%;
  min-height: 0;
}

body[data-current-page="day.html"] .day-record-workspace {
  min-height: 0;
}

body[data-current-page="day.html"] .day-record-table-scroll {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow-x: auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}

@media (max-width: 760px) {
  body[data-current-page="day.html"] .day-record-page {
    height: calc(100vh - 96px);
    height: calc(100dvh - 96px);
  }

  body[data-current-page="day.html"] .day-record-panel {
    height: 100%;
    min-height: 0;
  }

  body[data-current-page="day.html"] .day-record-table-scroll {
    touch-action: pan-x pan-y;
  }
}


/* Protected calendar-label names: editing is enabled only by the Edit button. */
.calendar-label-input[readonly] {
  pointer-events: none;
  user-select: none;
  caret-color: transparent;
  cursor: pointer;
}

.calendar-labels.label-edit-mode .calendar-label-input:not([readonly]) {
  cursor: text;
  caret-color: currentColor;
  border-color: #fbbf24;
  background: rgba(15, 23, 42, 0.38);
  box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.28);
}

.calendar-label-edit-button {
  min-width: 0;
  min-height: 48px;
  display: grid;
  place-items: center;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow:
    0 3px 0 rgba(15, 23, 42, 0.44),
    0 5px 9px rgba(15, 23, 42, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    background 120ms ease;
}

.calendar-label-edit-button:hover {
  background: var(--border);
  transform: translateY(-1px);
}

.calendar-label-edit-button.edit-active,
.calendar-label-edit-button:active {
  transform: translateY(2px);
  background: #d97706;
  color: #ffffff;
  border-color: #fbbf24;
  box-shadow:
    0 1px 0 rgba(15, 23, 42, 0.48),
    inset 0 2px 5px rgba(15, 23, 42, 0.28);
}

.calendar-label-edit-button:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
}

@media screen and (min-width: 761px) {
  .calendar-labels-panel .calendar-label-edit-button {
    width: 96px;
    min-width: 96px;
    max-width: 96px;
    min-height: 32px;
    height: 32px;
    margin-left: 12px;
    padding: 3px 10px;
    border-radius: 8px;
  }
}

@media (max-width: 760px) {
  .calendar-label-edit-button {
    flex: 0 0 78px;
    min-height: 28px;
    height: 28px;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 10px;
  }
}


/* Week, month and label-filtered work record summaries. */
.records-summary-page {
  height: calc(100vh - 96px);
  height: calc(100dvh - 96px);
  min-height: 0;
  padding: 18px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--page-bg-start), var(--page-bg-end));
}

.records-summary-panel {
  width: min(100%, 1700px);
  height: 100%;
  min-height: 0;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 18px 45px var(--shadow);
}

.records-summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.records-summary-heading {
  min-width: 0;
}

.records-summary-heading h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(22px, 2.5vw, 34px);
}

.records-summary-heading p {
  margin: 5px 0 0;
  color: var(--text-soft);
  font-size: 13px;
}

.records-summary-back,
.records-summary-load-more,
.records-summary-open-selected {
  flex: 0 0 auto;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-muted);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.records-summary-load-more {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.records-summary-open-selected {
  border-color: #0f766e;
  background: #0f766e;
  color: #ffffff;
}

.records-summary-open-selected:disabled {
  border-color: var(--border);
  background: var(--surface-muted);
  color: var(--text-soft);
  cursor: not-allowed;
  opacity: 0.72;
}

.records-summary-back:hover,
.records-summary-load-more:hover,
.records-summary-open-selected:not(:disabled):hover,
.records-summary-label-button:hover {
  filter: brightness(1.07);
}

.records-summary-prototype {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 7px 20px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 90%, #f59e0b 10%);
  color: var(--text-soft);
  font-size: 11px;
}

.records-summary-prototype strong {
  flex: 0 0 auto;
  color: #d97706;
}

.records-summary-label-filter {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}

.records-summary-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.records-summary-label-button {
  min-width: 130px;
  min-height: 34px;
  padding: 6px 12px;
  border: 2px solid transparent;
  border-radius: 9px;
  background: var(--summary-label-color);
  color: #ffffff;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  box-shadow:
    0 4px 0 rgba(15, 23, 42, 0.45),
    0 6px 10px rgba(15, 23, 42, 0.2);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.records-summary-label-button.selected {
  border-color: #ffffff;
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  transform: translateY(3px);
  box-shadow:
    0 1px 0 rgba(15, 23, 42, 0.48),
    inset 0 2px 4px rgba(15, 23, 42, 0.22);
}

.records-summary-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 8px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.records-summary-stat {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}

.records-summary-stat strong,
.records-summary-stat span {
  display: block;
}

.records-summary-stat strong {
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.records-summary-stat span {
  margin-top: 2px;
  color: var(--text-soft);
  font-size: 10px;
}

.records-summary-content {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 14px 20px 22px;
  background: var(--surface-soft);
}

.records-summary-message {
  min-height: 180px;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--text-soft);
  font-size: 15px;
  text-align: center;
}

.records-summary-message.error {
  color: #dc2626;
}

.records-summary-day {
  overflow: hidden;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: 0 5px 14px var(--shadow);
}

.records-summary-day:last-child {
  margin-bottom: 0;
}

.records-summary-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

.records-summary-day-header h2 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  text-transform: capitalize;
}

.records-summary-day-header button {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.records-summary-marked-empty {
  margin: 0;
  padding: 16px 12px;
  color: var(--text-soft);
  font-size: 13px;
}

.records-summary-table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.records-summary-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
  table-layout: fixed;
  color: var(--text);
  font-size: 12px;
}

.records-summary-table th,
.records-summary-table td {
  padding: 8px 9px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  overflow-wrap: anywhere;
}

.records-summary-table th:last-child,
.records-summary-table td:last-child {
  border-right: none;
}

.records-summary-table tbody tr:last-child td {
  border-bottom: none;
}

.records-summary-table th {
  background: color-mix(in srgb, var(--surface-muted) 88%, var(--primary) 12%);
  font-size: 10px;
  text-align: left;
}

.records-summary-table th:nth-child(1),
.records-summary-table td:nth-child(1) {
  width: 42px;
  text-align: center;
}

.records-summary-table th:nth-child(2),
.records-summary-table td:nth-child(2),
.records-summary-table th:nth-child(3),
.records-summary-table td:nth-child(3),
.records-summary-table th:nth-child(4),
.records-summary-table td:nth-child(4),
.records-summary-table th:nth-child(5),
.records-summary-table td:nth-child(5) {
  width: 105px;
}

.records-summary-table th:nth-child(6),
.records-summary-table td:nth-child(6),
.records-summary-table th:nth-child(7),
.records-summary-table td:nth-child(7) {
  width: 220px;
}

.records-summary-table th:nth-child(8),
.records-summary-table td:nth-child(8) {
  width: 90px;
}

.records-summary-table th:nth-child(9),
.records-summary-table td:nth-child(9) {
  width: 190px;
}

.records-summary-status-ok {
  color: #16a34a;
  font-weight: 900;
}

.records-summary-status-not-ok {
  color: #dc2626;
  font-weight: 900;
}

.records-summary-footer {
  min-height: 0;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.records-summary-footer:has(.records-summary-load-more[hidden]) {
  display: none;
}

@media (max-width: 900px) {
  .records-summary-page {
    padding: 10px;
  }

  .records-summary-header {
    align-items: flex-start;
    padding: 12px;
  }

  .records-summary-heading h1 {
    font-size: 22px;
  }

  .records-summary-prototype {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
    padding: 6px 12px;
  }

  .records-summary-label-filter,
  .records-summary-stats,
  .records-summary-content {
    padding-left: 12px;
    padding-right: 12px;
  }

  .records-summary-labels {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 3px 2px 7px;
  }

  .records-summary-label-button {
    flex: 0 0 118px;
    min-width: 118px;
  }

  .records-summary-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .records-summary-stat:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .records-summary-page {
    height: calc(100vh - 96px);
    height: calc(100dvh - 96px);
    padding: 6px;
  }

  .records-summary-panel {
    border-radius: 14px;
  }

  .records-summary-header {
    gap: 8px;
    padding: 10px;
  }

  .records-summary-heading h1 {
    font-size: 18px;
  }

  .records-summary-heading p {
    font-size: 11px;
  }

  .records-summary-back {
    padding: 7px 9px;
    font-size: 10px;
  }

  .records-summary-content {
    padding-top: 9px;
    padding-bottom: 12px;
  }

  .records-summary-day-header {
    padding: 7px 9px;
  }

  .records-summary-day-header h2 {
    font-size: 12px;
  }

  .records-summary-day-header button {
    padding: 5px 7px;
    font-size: 9px;
  }

  .records-summary-table {
    font-size: 11px;
  }
}


/* Mobile containment fixes for week/month/label summary pages. */
.records-summary-panel,
.records-summary-header,
.records-summary-prototype,
.records-summary-label-filter,
.records-summary-labels,
.records-summary-stats,
.records-summary-content,
.records-summary-day,
.records-summary-table-scroll,
.records-summary-footer {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.records-summary-table-scroll {
  display: block;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  padding-bottom: 6px;
}

.records-summary-footer {
  width: 100%;
  justify-content: center;
  overflow: hidden;
}

.records-summary-load-more {
  max-width: 100%;
  margin: 0 auto;
  white-space: normal;
  text-align: center;
}

@media (max-width: 520px) {
  .records-summary-label-filter {
    overflow: hidden;
  }

  .records-summary-labels {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    padding: 3px 0 6px;
    overflow: visible;
  }

  .records-summary-label-button {
    width: 100%;
    min-width: 0;
    min-height: 36px;
    padding: 6px 7px;
    font-size: 10px;
  }

  .records-summary-content {
    width: 100%;
    overflow-x: hidden;
  }

  .records-summary-day {
    width: 100%;
  }

  .records-summary-table-scroll {
    width: 100%;
    max-width: 100%;
    touch-action: pan-x pan-y;
  }

  .records-summary-table {
    width: 1180px;
    min-width: 1180px;
    max-width: none;
  }

  .records-summary-footer {
    padding: 9px 10px 11px;
  }

  .records-summary-load-more {
    display: block;
    width: min(100%, 230px);
    min-height: 38px;
    padding: 8px 12px;
  }
}


/* Correct summary grid rows when the label filter is hidden on week/month pages. */
body[data-summary-mode="week"] .records-summary-panel,
body[data-summary-mode="month"] .records-summary-panel {
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
}

body[data-summary-mode="labels"] .records-summary-panel {
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
}

.records-summary-footer {
  align-items: center;
}

.records-summary-load-more {
  width: auto;
  height: auto;
  min-height: 38px;
  align-self: center;
  flex: 0 0 auto;
}


/* More contrasted light theme. Dark theme remains unchanged. */
html:not([data-theme="dark"]) .site-header {
  background: #e1e9f3;
  border-bottom-color: #91a4bb;
  box-shadow: 0 5px 18px rgba(41, 59, 84, 0.2);
}

html:not([data-theme="dark"]) .home-dashboard,
html:not([data-theme="dark"]) .page-content,
html:not([data-theme="dark"]) .day-record-page,
html:not([data-theme="dark"]) .records-summary-page {
  background: linear-gradient(135deg, #d6e0eb, #c7d4e2);
}

html:not([data-theme="dark"]) .calendar-panel,
html:not([data-theme="dark"]) .calendar-labels-panel,
html:not([data-theme="dark"]) .chat-panel,
html:not([data-theme="dark"]) .content-card,
html:not([data-theme="dark"]) .day-record-panel,
html:not([data-theme="dark"]) .records-summary-panel {
  background: #e3ebf4;
  border-color: #8fa3ba;
  box-shadow:
    0 14px 34px rgba(48, 66, 91, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

html:not([data-theme="dark"]) .calendar-day {
  background: #f1f5f9;
  border-color: #aab9ca;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 2px 5px rgba(60, 78, 103, 0.12);
}

html:not([data-theme="dark"]) .calendar-day:hover,
html:not([data-theme="dark"]) .calendar-day:focus-within {
  background: #e2eaf3;
  border-color: #5d7ea8;
}

html:not([data-theme="dark"]) .calendar-day-number {
  text-shadow: none;
}

html:not([data-theme="dark"]) .calendar-nav-button,
html:not([data-theme="dark"]) .icon-button,
html:not([data-theme="dark"]) .menu-toggle,
html:not([data-theme="dark"]) .clear-chat-button,
html:not([data-theme="dark"]) .emoji-toggle {
  background: #cedae7;
  border-color: #93a7bd;
  box-shadow:
    0 3px 7px rgba(51, 68, 92, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.66);
}

html:not([data-theme="dark"]) .calendar-nav-button:hover,
html:not([data-theme="dark"]) .icon-button:hover,
html:not([data-theme="dark"]) .menu-toggle:hover,
html:not([data-theme="dark"]) .clear-chat-button:hover,
html:not([data-theme="dark"]) .emoji-toggle:hover {
  background: #bccbdc;
}

html:not([data-theme="dark"]) .chat-header,
html:not([data-theme="dark"]) .chat-form {
  background: #e0e8f2;
  border-color: #9aadc1;
}

html:not([data-theme="dark"]) .chat-messages {
  background: #d2dde9;
}

html:not([data-theme="dark"]) .chat-message {
  background: #f3f7fb;
  border-color: #a5b5c7;
  box-shadow:
    0 4px 10px rgba(48, 64, 86, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

html:not([data-theme="dark"]) .chat-date-divider,
html:not([data-theme="dark"]) .mode-badge {
  background: #c7d4e2;
  border-color: #93a7bd;
  color: #42566d;
}

html:not([data-theme="dark"]) .message-row input,
html:not([data-theme="dark"]) .name-field input,
html:not([data-theme="dark"]) .calendar-time-part,
html:not([data-theme="dark"]) .color-field input,
html:not([data-theme="dark"]) .day-record-table input,
html:not([data-theme="dark"]) .day-record-table textarea,
html:not([data-theme="dark"]) .day-record-table select {
  background: #f7f9fc;
  border-color: #9eafc2;
}

html:not([data-theme="dark"]) .main-nav button.active {
  background: #40556f;
}

html:not([data-theme="dark"]) .calendar-labels-panel {
  background: #dfe8f2;
}

html:not([data-theme="dark"]) .calendar-day.weekend {
  background: #cbd7e4;
  border-color: #92a5bb;
}

html:not([data-theme="dark"]) .calendar-day.weekend:hover {
  background: #becddd;
}

html:not([data-theme="dark"]) .calendar-day.outside-month {
  opacity: 0.5;
}


/* Emoji and sticker picker. */
.emoji-picker {
  width: min(340px, calc(100vw - 56px));
  display: block;
}

.chat-picker-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 9px;
}

.emoji-picker .chat-picker-tab {
  width: 100%;
  min-height: 34px;
  aspect-ratio: auto;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-muted);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  transform: none;
}

.emoji-picker .chat-picker-tab:hover {
  background: var(--border);
  transform: none;
}

.emoji-picker .chat-picker-tab.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.chat-picker-panel {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
}

.chat-picker-panel[hidden] {
  display: none;
}

.sticker-panel {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  max-height: 278px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 3px;
  -webkit-overflow-scrolling: touch;
}

.emoji-picker .sticker-button {
  aspect-ratio: 1;
  padding: 3px;
  border: 1px solid transparent;
  background: var(--surface-muted);
  overflow: hidden;
}

.emoji-picker .sticker-button:hover {
  border-color: var(--primary);
  background: var(--border);
  transform: scale(1.04);
}

.sticker-button img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  pointer-events: none;
}

.chat-sticker-image {
  grid-column: 1;
  width: min(180px, 100%);
  max-height: 180px;
  display: block;
  object-fit: contain;
  object-position: left center;
  user-select: none;
}

.chat-message.sticker-message {
  min-height: 120px;
}

@media (max-width: 760px) {
  .emoji-picker {
    width: min(320px, calc(100vw - 36px));
  }

  .sticker-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-height: 240px;
  }

  .chat-sticker-image {
    width: min(138px, 100%);
    max-height: 138px;
  }

  .chat-message.sticker-message {
    min-height: 92px;
  }
}

html:not([data-theme="dark"]) .emoji-picker .chat-picker-tab {
  background: #cedae7;
  border-color: #93a7bd;
}

html:not([data-theme="dark"]) .emoji-picker .chat-picker-tab.active {
  background: var(--primary);
  border-color: var(--primary);
}

html:not([data-theme="dark"]) .emoji-picker .sticker-button {
  background: #e2eaf3;
  border-color: #b5c4d4;
}


/* Compact delete controls and improved sticker messages. */
.delete-message-button {
  width: 14px;
  height: 14px;
  min-width: 14px;
  min-height: 14px;
  border-radius: 4px;
  font-size: 7px;
  line-height: 1;
  padding: 0;
  box-shadow: none;
}

.delete-message-button:hover {
  transform: scale(1.08);
}

.chat-message.sticker-message,
html:not([data-theme="dark"]) .chat-message.sticker-message {
  width: 100%;
  max-width: 100%;
  min-height: 0;
  padding: 4px 6px 8px;
  border: 0;
  border-left: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  grid-template-columns: minmax(0, 1fr) 14px;
  gap: 6px 10px;
  align-items: start;
}

.chat-message.sticker-message.own-message {
  border-left: 0;
}

.chat-message.sticker-message .chat-message-header {
  grid-column: 1;
  grid-row: 1;
  padding-left: 0;
  padding-right: 6px;
  min-height: 16px;
  position: relative;
  z-index: 1;
}

.chat-message.sticker-message .chat-sticker-image {
  grid-column: 1;
  grid-row: 2;
  justify-self: center;
  width: min(112px, 100%);
  max-height: 112px;
  object-position: center;
}

.chat-message.sticker-message .delete-message-button {
  grid-column: 2;
  grid-row: 1 / span 2;
  justify-self: end;
  align-self: center;
}

@media (max-width: 760px) {
  .delete-message-button {
    width: 13px;
    height: 13px;
    min-width: 13px;
    min-height: 13px;
    font-size: 7px;
  }

  .chat-message.sticker-message,
  html:not([data-theme="dark"]) .chat-message.sticker-message {
    min-height: 0;
    padding: 3px 2px 6px;
    grid-template-columns: minmax(0, 1fr) 13px;
    gap: 4px 6px;
  }

  .chat-message.sticker-message .chat-sticker-image {
    width: min(94px, 100%);
    max-height: 94px;
  }
}


/* Month row selection and selected-items window controls. */
.records-summary-table.selectable {
  min-width: 1225px;
}

.records-summary-table.selectable th:nth-child(1),
.records-summary-table.selectable td:nth-child(1) {
  width: 44px;
  text-align: center;
  vertical-align: middle;
}

.records-summary-table.selectable th:nth-child(2),
.records-summary-table.selectable td:nth-child(2) {
  width: 42px;
  text-align: center;
}

.records-summary-table.selectable th:nth-child(3),
.records-summary-table.selectable td:nth-child(3),
.records-summary-table.selectable th:nth-child(4),
.records-summary-table.selectable td:nth-child(4),
.records-summary-table.selectable th:nth-child(5),
.records-summary-table.selectable td:nth-child(5),
.records-summary-table.selectable th:nth-child(6),
.records-summary-table.selectable td:nth-child(6) {
  width: 105px;
  text-align: left;
}

.records-summary-table.selectable th:nth-child(7),
.records-summary-table.selectable td:nth-child(7),
.records-summary-table.selectable th:nth-child(8),
.records-summary-table.selectable td:nth-child(8) {
  width: 220px;
}

.records-summary-table.selectable th:nth-child(9),
.records-summary-table.selectable td:nth-child(9) {
  width: 90px;
}

.records-summary-table.selectable th:nth-child(10),
.records-summary-table.selectable td:nth-child(10) {
  width: 190px;
}

.records-summary-select-checkbox {
  -webkit-appearance: none;
  appearance: none;
  width: 19px;
  height: 19px;
  margin: 0;
  border: 2px solid #52657b;
  border-radius: 5px;
  background-color: #f8fafc;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 13px 13px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.65);
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.records-summary-select-checkbox:hover {
  border-color: #1d4ed8;
}

.records-summary-select-checkbox:checked {
  border-color: #1d4ed8;
  background-color: #2563eb;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='white' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round' d='M3 8.4 6.4 12 13 4.5'/%3E%3C/svg%3E");
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
}

.records-summary-select-checkbox:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: 2px;
}

html[data-theme="dark"] .records-summary-select-checkbox {
  border-color: #94a3b8;
  background-color: #111827;
  box-shadow: none;
}

html[data-theme="dark"] .records-summary-select-checkbox:checked {
  border-color: #60a5fa;
  background-color: #2563eb;
}

.records-summary-open-selected[hidden] {
  display: none;
}

@media (max-width: 520px) {
  .records-summary-table.selectable {
    width: 1225px;
    min-width: 1225px;
  }

  .records-summary-open-selected,
  .records-summary-load-more {
    width: min(100%, 230px);
  }
}

/* Wide desktop day workspace: use the available screen width instead of keeping a narrow centered card. */
@media (min-width: 901px) {
  body[data-current-page="day.html"] .day-record-page {
    padding: 8px 12px;
  }

  body[data-current-page="day.html"] .day-record-panel {
    width: calc(100vw - 24px);
    max-width: none;
    min-height: 0;
  }

  body[data-current-page="day.html"] .day-record-workspace {
    margin: 10px 12px 12px;
  }

  body[data-current-page="day.html"] .day-record-main-content {
    grid-template-columns: minmax(0, 13fr) minmax(360px, 5fr);
  }

  body[data-current-page="day.html"] .day-record-table {
    min-width: 1150px;
  }

  body[data-current-page="day.html"] .day-record-table .row-number-column,
  body[data-current-page="day.html"] .day-record-row-number {
    width: 44px;
  }

  body[data-current-page="day.html"] .day-record-table .short-column {
    width: 94px;
  }

  body[data-current-page="day.html"] .day-record-table .text-column {
    width: 215px;
  }

  body[data-current-page="day.html"] .day-record-table .status-column {
    width: 100px;
  }

  body[data-current-page="day.html"] .day-record-table .note-column {
    width: 200px;
  }
}
