@font-face {
  font-family: 'Martian Mono';
  src: url('fonts/MartianMono-Light.woff2') format('woff2');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Martian Mono';
  src: url('fonts/MartianMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Martian Mono';
  src: url('fonts/MartianMono-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Martian Mono';
  src: url('fonts/MartianMono-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Martian Mono';
  src: url('fonts/MartianMono-ExtraBold.woff2') format('woff2');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg:     #081c10;   /* сплошной тёмно-зелёный фон */
  --card:   #10301d;
  --border: #1c3323;
  --accent: #4fbf7f;
  --yellow: #d1a54d;
  --green:  #a9c23f;
  --muted:  #5e7864;
  --text:   #eef6ee;
  --dim:    #9fc1a7;
}
body {
  font-family: 'Martian Mono', monospace;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow-x: hidden;
}

.wrap { width: 100%; max-width: 520px; padding: 20px 16px 60px; position: relative; z-index: 1; }

/* ── м'яка поява елементів при завантаженні ── */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in-1, .fade-in-2, .fade-in-3, .fade-in-4, .fade-in-5 {
  animation: fade-up 0.55s cubic-bezier(.2,.7,.3,1) both;
}
.fade-in-1 { animation-delay: 0s; }
.fade-in-2 { animation-delay: .07s; }
.fade-in-3 { animation-delay: .14s; }
.fade-in-4 { animation-delay: .21s; }
.fade-in-5 { animation-delay: .28s; }

/* ── коротка "пульсація" при живому оновленні ── */
@keyframes tick-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(79,191,127,0); }
  30%  { box-shadow: 0 0 0 4px rgba(79,191,127,0.06); }
  100% { box-shadow: 0 0 0 0 rgba(79,191,127,0); }
}
.tick-pulse { animation: tick-pulse 0.6s ease-out; }

/* ── header ── */
.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.clock {
  font-size: clamp(36px,9vw,52px); font-weight: 800; letter-spacing: -2px; line-height: 1;
  animation: clock-breathe 4s ease-in-out infinite;
}
@keyframes clock-breathe {
  0%,100% { text-shadow: 0 0 0px rgba(79,191,127,0); }
  50%     { text-shadow: 0 0 18px rgba(79,191,127,0.35); }
}
@media (prefers-reduced-motion: reduce) {
  .clock { animation: none; }
}
.meta { text-align: right; display: flex; flex-direction: column; gap: 4px; padding-top: 4px; }
.meta-date { font-size: 11px; color: var(--dim); font-weight: 300; }
.meta-day  { font-size: 12px; color: var(--muted); }
.tags-row { display: flex; gap: 8px; justify-content: center; margin-bottom: 16px; }
.tag {
  font-family: 'Martian Mono', monospace;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: default;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.tag.week-tag { border-color: rgba(79,191,127,0.3); color: var(--accent); }
.tag.grp-tag  { border-color: rgba(169,194,63,0.3);  color: var(--green); cursor: pointer; }
.tag.grp-tag:hover { background: rgba(169,194,63,0.1); transform: translateY(-1px); }
.tag.grp-tag:active { transform: translateY(0) scale(0.95); }
.tag.sound-tag { border-color: rgba(209,165,77,0.3); color: var(--yellow); cursor: pointer; }
.tag.sound-tag svg { width: 16px; height: 16px; stroke: currentColor; fill: none; }
.tag.sound-tag:hover { background: rgba(209,165,77,0.1); transform: translateY(-1px); }
.tag.sound-tag:active { transform: translateY(0) scale(0.95); }
.tag.sound-tag.muted { color: var(--muted); border-color: var(--border); }

/* alarm: red — тривога, як і раніше */
@keyframes alarm-pulse-red {
  0%,100% { background: #ff4f4f; box-shadow: 0 0 4px #ff0000; }
  50%      { background: #ff0000; box-shadow: 0 0 16px #ff0000, 0 0 25px rgba(255,0,0,.5); }
}
/* alarm: yellow — новий проміжний рівень */
@keyframes alarm-pulse-yellow {
  0%,100% { background: #e8c468; box-shadow: 0 0 4px #d1a54d; }
  50%      { background: #d1a54d; box-shadow: 0 0 16px #d1a54d, 0 0 25px rgba(209,165,77,.5); }
}
.header.is-alarm-red,
.header.is-alarm-yellow {
  border-bottom-color: transparent !important;
}
.header.is-alarm-red::after,
.header.is-alarm-yellow::after {
  content: ''; position: absolute; bottom: 0; left: 0; width: 100%; height: 4px;
  border-radius: 2px; z-index: 100;
}
.header.is-alarm-red::after {
  background: #ff0000;
  animation: alarm-pulse-red 1.2s infinite ease-in-out;
}
.header.is-alarm-yellow::after {
  background: #d1a54d;
  animation: alarm-pulse-yellow 1.2s infinite ease-in-out;
}

/* ── day nav ── */
.day-nav {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 16px;
}
.nav-btn {
  font-family: 'Martian Mono', monospace;
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); font-size: 14px; cursor: pointer;
  width: 32px; height: 32px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; flex-shrink: 0;
}
.nav-btn:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.nav-btn:active { transform: translateY(0) scale(0.94); }
.nav-btn:disabled { opacity: 0.2; cursor: default; pointer-events: none; }

.nav-days {
  display: flex; gap: 4px; flex: 1; overflow-x: auto;
  scrollbar-width: none;
}
.nav-days::-webkit-scrollbar { display: none; }

.nav-day {
  font-family: 'Martian Mono', monospace;
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); font-size: 9px; letter-spacing: 0.5px;
  cursor: pointer; padding: 5px 8px; border-radius: 6px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: all 0.15s; flex-shrink: 0; min-width: 44px;
}
.nav-day .nd-name { font-size: 8px; text-transform: uppercase; letter-spacing: 1px; }
.nav-day .nd-num  { font-size: 13px; font-weight: 600; }
.nav-day:hover    { border-color: rgba(79,191,127,0.4); color: var(--dim); transform: translateY(-1px); }
.nav-day.active   { border-color: var(--accent); color: var(--accent); background: rgba(79,191,127,0.08); }
.nav-day.today    { border-color: rgba(169,194,63,0.4); color: var(--green); }
.nav-day.today:not(.active) .nd-num { animation: today-glow 2.6s ease-in-out infinite; }
@keyframes today-glow {
  0%,100% { opacity: 1; }
  50%     { opacity: 0.55; }
}
.nav-day.today.active { background: rgba(169,194,63,0.08); }
.nav-day.weekend  { opacity: 0.35; }

/* ── toolbar row: view banner (left) + edit button (right) ── */
.day-toolbar {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 16px; min-height: 32px;
}

/* view-mode banner — only visible when browsing a day other than today */
.view-banner {
  display: none; align-items: center; justify-content: space-between;
  gap: 10px; padding: 7px 8px 7px 14px; flex: 1; min-width: 0;
  border: 1px solid rgba(209,165,77,0.2); border-radius: 8px;
  background: rgba(209,165,77,0.04); color: var(--yellow);
}
.view-banner.show { display: flex; }
.vb-text {
  font-size: 9px; letter-spacing: 1px; text-transform: uppercase;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.vb-today {
  font-family: 'Martian Mono', monospace;
  background: rgba(209,165,77,0.12); border: 1px solid rgba(209,165,77,0.35);
  color: var(--yellow); font-size: 9px; letter-spacing: 1px;
  cursor: pointer; padding: 6px 9px; border-radius: 6px;
  transition: all 0.15s; flex-shrink: 0; font-weight: 600;
}
.vb-today:hover { background: rgba(209,165,77,0.2); }

/* ── now card ── */
.now-card {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px; margin-bottom: 16px;
  position: relative; overflow: hidden; transition: border-color 0.3s;
}
.now-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 2px; transition: background 0.3s;
}
.now-card.lesson  { border-color: rgba(79,191,127,0.3); background: rgba(79,191,127,0.04); animation: glow-lesson 3.2s ease-in-out infinite; }
.now-card.lesson::before  { background: var(--accent); }
.now-card.break   { border-color: rgba(209,165,77,0.3); background: rgba(209,165,77,0.04); animation: glow-break 3.2s ease-in-out infinite; }
.now-card.break::before   { background: var(--yellow); }
.now-card.before  { border-color: rgba(169,194,63,0.2); background: rgba(169,194,63,0.03); }
.now-card.before::before  { background: var(--green); }
.now-card.other   { border-color: var(--border); }
@keyframes glow-lesson {
  0%,100% { box-shadow: 0 0 0 0 rgba(79,191,127,0); }
  50%     { box-shadow: 0 0 22px 0 rgba(79,191,127,0.10); }
}
@keyframes glow-break {
  0%,100% { box-shadow: 0 0 0 0 rgba(209,165,77,0); }
  50%     { box-shadow: 0 0 22px 0 rgba(209,165,77,0.10); }
}
@media (prefers-reduced-motion: reduce) {
  .now-card.lesson, .now-card.break { animation: none; }
}

.now-tag { font-size: 9px; letter-spacing: 3px; text-transform: uppercase; font-weight: 600; margin-bottom: 8px; }
.lesson .now-tag { color: var(--accent); }
.break  .now-tag { color: var(--yellow); }
.before .now-tag { color: var(--green); }
.other  .now-tag { color: var(--muted); }

.now-title { font-size: clamp(17px,4vw,22px); font-weight: 700; letter-spacing: -0.5px; margin-bottom: 4px; line-height: 1.25; }
.now-sub   { font-size: 11px; color: var(--dim); font-weight: 300; margin-bottom: 12px; }

.prog-wrap { background: rgba(255,255,255,0.05); border-radius: 2px; height: 3px; margin-bottom: 8px; overflow: hidden; }
.prog-bar  { height: 100%; border-radius: 2px; transition: width 1s linear; position: relative; overflow: hidden; }
.lesson .prog-bar { background: var(--accent); }
.break  .prog-bar { background: var(--yellow); }
.prog-bar::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: -60%; width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.55), transparent);
  animation: prog-shine 1.8s linear infinite;
}
@keyframes prog-shine {
  0%   { left: -60%; }
  100% { left: 140%; }
}
@media (prefers-reduced-motion: reduce) {
  .prog-bar::after { animation: none; display: none; }
}

.prog-meta { display: flex; justify-content: flex-end; font-size: 11px; color: var(--dim); }
.rem { font-weight: 600; font-size: 12px; }
.lesson .rem { color: var(--accent); }
.break  .rem { color: var(--yellow); }

.next-line { margin-top: 10px; font-size: 11px; color: var(--muted); padding-top: 8px; border-top: 1px solid var(--border); }
.next-line span { color: var(--text); font-weight: 600; }

/* ── lesson list ── */
.list-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.list-title  { font-size: 9px; letter-spacing: 3px; text-transform: uppercase; color: var(--muted); }

.lesson-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; margin-bottom: 2px;
  border: 1px solid transparent; transition: all 0.2s;
}
.lesson-row.past    { opacity: 0.3; }
.lesson-row.current { background: rgba(79,191,127,0.07); border-color: rgba(79,191,127,0.2); animation: row-current-glow 3.2s ease-in-out infinite; }
.lesson-row.future  { background: rgba(255,255,255,0.02); }
@keyframes row-current-glow {
  0%,100% { background: rgba(79,191,127,0.07); }
  50%     { background: rgba(79,191,127,0.13); }
}
@keyframes fade-row {
  from { opacity: 0; transform: translateX(-4px); }
  to   { opacity: 1; transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
  .lesson-row.current { animation: none; }
}

.l-slot { font-size: 10px; color: var(--muted); width: 14px; text-align: right; flex-shrink: 0; }
.lesson-row.current .l-slot { color: var(--accent); }
.l-time { font-size: 10px; color: var(--muted); flex-shrink: 0; min-width: 76px; font-weight: 300; }
.l-name { font-size: 13px; font-weight: 600; flex: 1; letter-spacing: -0.3px; }
.lesson-row.past .l-name { color: var(--dim); }
.l-now  { font-size: 8px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--accent); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.l-now::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
  animation: dot-pulse 1.4s ease-in-out infinite;
}
@keyframes dot-pulse {
  0%,100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 rgba(79,191,127,0.5); }
  50%     { opacity: 0.6; transform: scale(1.3); box-shadow: 0 0 0 3px rgba(79,191,127,0); }
}

.break-row {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 12px; margin-bottom: 2px; opacity: 0.35; transition: opacity 0.2s;
}
.break-row.active { opacity: 1; }
.break-line  { flex: 1; height: 1px; background: var(--border); }
.break-row.active .break-line { background: rgba(209,165,77,0.3); }
.break-label { font-size: 9px; color: var(--muted); white-space: nowrap; font-weight: 300; letter-spacing: 1px; }
.break-row.active .break-label { color: var(--yellow); }

/* ── group modal ── */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.88);
  backdrop-filter: blur(6px); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.overlay.open { opacity: 1; pointer-events: all; }
/* modals can be opened on top of one another (e.g. password prompt over the
   codes list, or a confirm dialog over the edit form) — layer by role so the
   topmost-intent one always wins regardless of DOM order */
#loginOverlay   { z-index: 200; }
#msgOverlay,
#confirmOverlay { z-index: 300; }
.modal {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 26px; width: 100%; max-width: 400px;
  transform: translateY(14px) scale(0.97); transition: transform 0.25s cubic-bezier(.2,.8,.3,1.2);
}
.overlay.open .modal { transform: translateY(0) scale(1); }
.modal-title { font-size: 13px; font-weight: 700; margin-bottom: 18px; letter-spacing: -0.3px; }
.grp-btns { display: flex; gap: 8px; }
.grp-btn {
  font-family: 'Martian Mono', monospace;
  flex: 1; padding: 14px; border-radius: 8px;
  border: 1px solid var(--border); background: transparent;
  color: var(--muted); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all 0.15s; letter-spacing: 1px;
}
.grp-btn:hover  { border-color: var(--green); color: var(--green); transform: translateY(-1px); }
.grp-btn:active { transform: translateY(0) scale(0.97); }
.grp-btn.active { background: rgba(169,194,63,0.1); border-color: var(--green); color: var(--green); }
.modal-close {
  font-family: 'Martian Mono', monospace;
  width: 100%; margin-top: 12px; padding: 11px;
  border: 1px solid var(--border); border-radius: 8px;
  background: transparent; color: var(--muted);
  font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  cursor: pointer; transition: all 0.15s; font-weight: 400;
}
.modal-close:hover { border-color: var(--muted); color: var(--text); }

/* ── toolbar buttons ── */
.toolbar-btns { display: flex; gap: 8px; margin-left: auto; flex-shrink: 0; }
.edit-btn {
  font-family: 'Martian Mono', monospace;
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); font-size: 9px; letter-spacing: 1px; text-transform: uppercase;
  cursor: pointer; font-weight: 600;
  height: 32px; padding: 0 12px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: all 0.15s; flex-shrink: 0;
}
.edit-btn-icon  { font-size: 12px; line-height: 1; display: inline-flex; align-items: center; }
.edit-btn-icon svg { display: block; }
.edit-btn-label { white-space: nowrap; }
.edit-btn:hover:not(:disabled) { border-color: var(--yellow); color: var(--yellow); transform: translateY(-1px); }
.edit-btn:active:not(:disabled) { transform: translateY(0) scale(0.95); }
.edit-btn:disabled { opacity: 0.2; cursor: default; pointer-events: none; }
.codes-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.classes-btn:hover:not(:disabled) { border-color: var(--yellow); color: var(--yellow); }

/* the schedule-edit trigger is deliberately understated so casual visitors
   don't notice it — still reachable, but not advertised */
.edit-btn.ghost {
  width: 28px; height: 28px; padding: 0;
  opacity: 0.3; border-color: transparent; background: transparent;
}
.edit-btn.ghost:hover:not(:disabled) {
  opacity: 1; border-color: var(--yellow); color: var(--yellow); background: rgba(209,165,77,0.06);
}

/* on very narrow screens, collapse to icon-only to save space */
@media (max-width: 460px) {
  .edit-btn-label { display: none; }
  .edit-btn { padding: 0; width: 32px; }
}
@media (max-width: 360px) {
  .vb-prefix { display: none; }
}

/* ── login modal ── */
.login-input {
  font-family: 'Martian Mono', monospace;
  width: 100%; padding: 12px 14px; margin-bottom: 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: rgba(255,255,255,0.03); color: var(--text);
  font-size: 13px; outline: none; transition: border-color 0.15s;
}
.login-input:focus { border-color: var(--accent); }
.login-err { font-size: 10px; color: #ff6b6b; margin-bottom: 10px; min-height: 12px; letter-spacing: 0.3px; }
.login-submit {
  font-family: 'Martian Mono', monospace;
  width: 100%; padding: 12px; border-radius: 8px; border: 1px solid rgba(79,191,127,0.35);
  background: rgba(79,191,127,0.1); color: var(--accent);
  font-size: 11px; letter-spacing: 2px; text-transform: uppercase;
  cursor: pointer; transition: all 0.15s; font-weight: 600; margin-bottom: 8px;
}
.login-submit:hover { background: rgba(79,191,127,0.18); }

/* ── edit panel modal ── */
.edit-modal { max-width: 480px; max-height: 86vh; display: flex; flex-direction: column; }
.edit-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.edit-title { font-size: 13px; font-weight: 700; letter-spacing: -0.3px; }
.edit-sub   { font-size: 10px; color: var(--dim); font-weight: 300; margin-top: 2px; }

.edit-slots { overflow-y: auto; margin: 0 -4px; padding: 0 4px; flex: 1; }
.edit-slot {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; margin-bottom: 8px; background: rgba(255,255,255,0.015);
}
.es-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.es-num  { font-size: 11px; color: var(--muted); font-weight: 700; width: 14px; }
.es-time { font-size: 9px; color: var(--dim); font-weight: 300; min-width: 76px; }
.es-modes { display: flex; gap: 4px; margin-left: auto; }
.es-mode-btn {
  font-family: 'Martian Mono', monospace;
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); font-size: 8px; letter-spacing: 0.5px; text-transform: uppercase;
  cursor: pointer; padding: 5px 7px; border-radius: 5px; transition: all 0.15s; font-weight: 600;
}
.es-mode-btn:hover  { border-color: rgba(79,191,127,0.4); color: var(--dim); }
.es-mode-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(79,191,127,0.1); }

.es-body { display: flex; flex-direction: column; gap: 8px; }
.es-group { }
.es-field { }
.es-label { font-size: 8px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; display: block; margin-bottom: 4px; }
.es-row { display: flex; gap: 6px; align-items: center; }
.es-input {
  font-family: 'Martian Mono', monospace;
  flex: 1; min-width: 0; padding: 9px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: rgba(255,255,255,0.03);
  color: var(--text); font-size: 12px; outline: none; transition: border-color 0.15s;
}
.es-input:focus { border-color: var(--accent); }
.es-week-toggle {
  display: flex; align-items: center; gap: 4px; flex-shrink: 0;
  font-size: 8px; color: var(--muted); letter-spacing: 0.5px; cursor: pointer; user-select: none;
}
.es-week-toggle input { accent-color: var(--accent); width: 12px; height: 12px; cursor: pointer; }

.edit-actions { display: flex; gap: 8px; margin-top: 14px; flex-shrink: 0; }
.edit-save {
  font-family: 'Martian Mono', monospace;
  flex: 1; padding: 12px; border-radius: 8px; border: 1px solid rgba(169,194,63,0.35);
  background: rgba(169,194,63,0.1); color: var(--green);
  font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  cursor: pointer; transition: all 0.15s; font-weight: 600;
}
.edit-save:hover { background: rgba(169,194,63,0.18); }
.edit-clear {
  font-family: 'Martian Mono', monospace;
  padding: 12px 14px; border-radius: 8px; border: 1px solid rgba(255,107,107,0.3);
  background: transparent; color: #ff6b6b;
  font-size: 10px; letter-spacing: 1px; text-transform: uppercase;
  cursor: pointer; transition: all 0.15s; font-weight: 600;
}
.edit-clear:hover { background: rgba(255,107,107,0.1); }
.edit-cancel-row { margin-top: 8px; flex-shrink: 0; }

/* ── codes modal ── */
.codes-list { overflow-y: auto; margin: 10px -4px 0; padding: 0 4px; flex: 1; }
.code-row {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 6px; background: rgba(255,255,255,0.015);
  transition: all 0.15s;
}
.code-main { flex: 1; min-width: 0; cursor: pointer; }
.code-main:hover .code-value { color: var(--accent); }
.code-subject {
  font-size: 12px; font-weight: 600; letter-spacing: -0.2px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 3px;
}
.code-group {
  font-size: 8px; letter-spacing: 0.5px; text-transform: uppercase; font-weight: 600;
  color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 2px 5px;
}
.code-value { font-size: 12px; color: var(--dim); font-weight: 300; transition: color 0.15s; }
.code-value.empty { color: var(--muted); font-style: italic; }
.code-actions { display: flex; gap: 4px; flex-shrink: 0; }
.code-act-btn {
  font-family: 'Martian Mono', monospace;
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); font-size: 11px; cursor: pointer;
  width: 26px; height: 26px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; flex-shrink: 0;
}
.code-act-btn:hover { border-color: var(--accent); color: var(--accent); }
.code-act-btn.danger:hover { border-color: #ff6b6b; color: #ff6b6b; }
.codes-empty { font-size: 11px; color: var(--muted); text-align: center; padding: 20px 0; }
.codes-add-btn {
  font-family: 'Martian Mono', monospace;
  width: 100%; padding: 12px; border-radius: 8px; border: 1px solid rgba(79,191,127,0.35);
  background: rgba(79,191,127,0.1); color: var(--accent);
  font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  cursor: pointer; transition: all 0.15s; font-weight: 600; margin-top: 12px; flex-shrink: 0;
}
.codes-add-btn:hover { background: rgba(79,191,127,0.18); }

/* ── code add/edit form modal ── */
.code-form-field { margin-bottom: 12px; }
.code-form-field .es-label { margin-bottom: 5px; }
.code-form-field .es-input { width: 100%; }
.code-form-actions { display: flex; gap: 8px; margin-top: 4px; }

/* ── generic message / confirm modals ── */
.msg-text { font-size: 12px; color: var(--dim); line-height: 1.6; margin-bottom: 18px; }

/* ── пасхалка: листопад ── */
#confettiLayer { position: fixed; inset: 0; z-index: 500; pointer-events: none; overflow: hidden; }
.confetti-piece {
  position: absolute; top: -24px; opacity: 0.9;
  animation: leaf-fall linear forwards;
  will-change: transform;
}
.confetti-piece svg { display: block; width: 100%; height: 100%; }
@keyframes leaf-fall {
  0%   { transform: translate(0, 0) rotate(0deg); }
  100% { transform: translate(var(--drift, 40px), 110vh) rotate(var(--spin, 480deg)); opacity: 0.15; }
}
.egg-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--card); border: 1px solid var(--accent); color: var(--accent);
  font-size: 11px; letter-spacing: 1px; padding: 10px 16px; border-radius: 10px;
  z-index: 501; opacity: 0; transition: all 0.3s cubic-bezier(.2,.8,.3,1.2); pointer-events: none;
  white-space: nowrap;
}
.egg-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }


/* ══════════════════════════════════════════════════════
   MOBILE-FIRST PATCH — накладається поверх базових стилів
   ══════════════════════════════════════════════════════ */

/* 1. КОНТРАСТ */
:root {
  --border:      #2b4d36;
  --muted:       #85a58c;
  --dim:         #c3dcc8;
  --muted-faint: #6a8a72;   /* лише для декору, не для тексту */
  --accent:      #5ecb8c;
  --yellow:      #e0b45f;
  --green:       #bcd44e;
}

/* 2. КОМПАКТНИЙ ХЕДЕР */
.wrap { padding: 14px 14px 48px; }
.header { margin-bottom: 14px; padding-bottom: 12px; align-items: center; }
.clock { font-size: clamp(30px, 8.5vw, 46px); letter-spacing: -1.5px; }
.meta-date { font-size: 12px; }
.meta-day  { font-size: 12px; color: var(--dim); }

/* 3. ТАПАБЕЛЬНІ ЗОНИ ≥44px */
.tags-row { gap: 10px; margin-bottom: 14px; }
.tag      { width: 44px; height: 44px; font-size: 14px; border-radius: 10px; }
.tag.sound-tag svg { width: 19px; height: 19px; }

.nav-btn  { width: 44px; height: 44px; border-radius: 10px; font-size: 16px; }
.nav-day  { min-width: 52px; min-height: 48px; padding: 6px 8px; border-radius: 10px; }
.nav-day .nd-name { font-size: 9px; }
.nav-day .nd-num  { font-size: 15px; }
.nav-day.weekend  { opacity: 0.5; }

/* 4. СТРІЧКА ДНІВ */
.nav-days {
  gap: 6px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scroll-padding-inline: 8px;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
          mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
}
.nav-day { scroll-snap-align: center; }

@media (max-width: 520px) {
  #prevWeek, #nextWeek { display: none; }
  .day-nav { gap: 6px; }
}

/* 5. ПАНЕЛЬ КНОПОК */
@media (max-width: 460px) {
  .edit-btn-label { display: inline; font-size: 9px; }
  .edit-btn { width: auto; padding: 0 10px; height: 40px; gap: 5px; }
}
.edit-btn { height: 40px; border-radius: 10px; }
.edit-btn.ghost {
  width: 40px; height: 40px; opacity: 0.5;
  border-color: var(--border);
}

/* 6. КАРТКА «ЗАРАЗ» */
.now-card { padding: 16px 16px 14px; border-radius: 14px; }
.now-tag  { font-size: 10px; letter-spacing: 2.5px; }
.now-title { font-size: clamp(20px, 6vw, 26px); }
.now-sub  { font-size: 12px; }
.prog-wrap { height: 5px; border-radius: 3px; margin-bottom: 10px; }
.prog-meta { justify-content: space-between; align-items: baseline; font-size: 12px; }
.prog-meta::before {
  content: 'Залишилось'; font-size: 9px; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--muted);
}
.rem { font-size: 15px; font-variant-numeric: tabular-nums; }
.next-line { font-size: 12px; padding-top: 10px; margin-top: 12px; }

/* 7. СПИСОК УРОКІВ */
.list-title { font-size: 10px; color: var(--dim); }
.lesson-row { padding: 12px; gap: 10px; border-radius: 10px; }
.l-slot { font-size: 12px; width: 16px; color: var(--muted); }
.l-time { font-size: 12px; min-width: 88px; color: var(--muted); }
.l-name { font-size: 15px; line-height: 1.3; letter-spacing: -0.2px; }

.lesson-row.past { opacity: 1; }
.lesson-row.past .l-name { color: var(--muted); }
.lesson-row.past .l-time,
.lesson-row.past .l-slot { color: var(--muted-faint); }
.lesson-row.future .l-name { color: var(--text); }
.lesson-row.future { background: rgba(255,255,255,0.035); }
.lesson-row.current .l-name { color: var(--text); }

.break-row { opacity: 1; padding: 6px 12px; }
.break-line { background: rgba(255,255,255,0.05); }
.break-label { font-size: 10px; color: var(--muted-faint); }
.break-row.active .break-label { color: var(--yellow); font-weight: 600; }
.break-row.active .break-line { background: rgba(224,180,95,0.28); }

/* 8. ПРОПУСК У НУМЕРАЦІЇ */
.lesson-row + .lesson-row { margin-top: 2px; }

/* 9. МОДАЛКИ на телефоні — знизу */
@media (max-width: 520px) {
  .overlay { align-items: flex-end; padding: 0; }
  .modal {
    max-width: none; border-radius: 18px 18px 0 0;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    max-height: 88vh; transform: translateY(100%);
  }
  .overlay.open .modal { transform: translateY(0); }
  .edit-modal { max-height: 88vh; }
  .login-input, .es-input { font-size: 16px; }  /* <16px = iOS зумить сторінку */
  .grp-btn, .edit-save, .edit-clear, .modal-close, .codes-add-btn { min-height: 48px; }
}

/* 10. ПРОДУКТИВНІСТЬ / БАТАРЕЯ */
@media (max-width: 640px) {
  .clock { animation: none; }
  .prog-bar::after { animation-duration: 2.6s; }
}

/* 11. ДЕСКТОП: ширина сторінки = природна ширина рядка з днями тижня
   (--wrap-w рахує JS у measureWrapWidth()) */
@media (min-width: 900px) {
  .wrap { max-width: var(--wrap-w, 620px); padding-top: 32px; }
  .l-name { font-size: 16px; }
  .l-time, .l-slot { font-size: 13px; }
}

/* 14. Коли всі 7 днів влазять без скролу — прибираємо затухання і snap */
.nav-days.fits {
  -webkit-mask-image: none;
          mask-image: none;
  scroll-snap-type: none;
  cursor: default;
}
.nav-days.fits .nav-day { scroll-snap-align: none; }

/* 12. ДОСТУПНІСТЬ: фокус із клавіатури */
:where(button, [tabindex], input):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}
.tag.grp-tag, .tag.sound-tag { -webkit-tap-highlight-color: transparent; }

/* 13. УЩІЛЬНЕННЯ ШАПКИ — теги і тулбар в одному ряду */
.day-toolbar {
  flex-wrap: wrap;
  gap: 8px;
  min-height: 40px;
  margin-bottom: 12px;
}
.tags-row {
  margin-bottom: 0;
  gap: 8px;
  justify-content: flex-start;
}
.toolbar-btns { margin-left: auto; }

.view-banner.show { order: 5; flex: 0 0 100%; }

.tag,
.edit-btn,
.edit-btn.ghost { width: auto; height: 40px; }
.tag { width: 40px; border-radius: 9px; }
.edit-btn.ghost { width: 40px; }

.header    { margin-bottom: 12px; padding-bottom: 10px; }
.day-nav   { margin-bottom: 10px; }
.nav-day   { min-height: 44px; }
.nav-btn   { width: 40px; height: 44px; }
.now-card  { margin-bottom: 12px; }
.list-header { margin-bottom: 6px; }

@media (max-width: 380px) {
  .edit-btn-label { display: none; }
  .edit-btn { width: 40px; padding: 0; }
}
