:root {
  --desk: #23262d;
  --desk-2: #2d3139;
  --on-desk: #eceae3;
  --on-desk-2: #a9abb0;
  --paper: #f8f4e7;
  --paper-2: #f1ebd8;
  --line: #9eb0c4;
  --line-strong: #5f7186;
  --ink: #1e2b3c;
  --ink-soft: #55616f;
  --pen: #17315f;
  --mark-n: #b3261e;
  --mark-pp: #1f5fbf;
  --cover: #1d3557;
  --cover-2: #16294a;
  --accent: #1d3557;
  --today: #fbe9a8;
  --hand: 'Caveat', 'Segoe Print', cursive;
  --print: 'PT Sans', 'Segoe UI', Arial, sans-serif;
  --title: 'PT Serif', Georgia, serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; overscroll-behavior-x: none; background: var(--desk); -webkit-tap-highlight-color: transparent; }
body { margin: 0; font-family: var(--print); color: var(--ink); background: var(--desk); overscroll-behavior-x: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
input, textarea { user-select: text; -webkit-user-select: text; }
body.on-desk { min-height: 100dvh; background: var(--desk) radial-gradient(circle at 50% 0, var(--desk-2), var(--desk) 70%) fixed; }
body.locked { overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .4; }
:focus-visible { outline: 2px solid #e0a526; outline-offset: 1px; }

/* ====== Scrollbars ====== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { border: 2px solid transparent; border-radius: 6px; background: #5d6470 padding-box; }
@media (hover: hover) { ::-webkit-scrollbar-thumb:hover { background: #7b838f padding-box; } }
.dlg ::-webkit-scrollbar-thumb, .page.only::-webkit-scrollbar-thumb { background: #b9ad8e padding-box; }
@media (hover: hover) { .dlg ::-webkit-scrollbar-thumb:hover, .page.only::-webkit-scrollbar-thumb:hover { background: #958a6c padding-box; } }
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: #5d6470 transparent; }
  .dlg *, .page.only { scrollbar-color: #b9ad8e transparent; }
}

/* ====== Buttons ====== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--paper); color: var(--ink); font-weight: 700; font-size: 14px; text-decoration: none; }
@media (hover: hover) { .btn:hover:not(:disabled) { background: var(--paper-2); } }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (hover: hover) { .btn.primary:hover:not(:disabled) { background: var(--cover-2); } }
.btn.danger { background: var(--mark-n); border-color: var(--mark-n); color: #fff; }
@media (hover: hover) { .btn.danger:hover:not(:disabled) { background: #8f1d17; } }
.btn.small { min-height: 34px; padding: 5px 10px; font-size: 13px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; flex: none; border: 0; border-radius: 6px; background: transparent; color: inherit; text-decoration: none; }
@media (hover: hover) { .icon-btn:hover:not(:disabled) { background: rgba(127, 127, 127, .18); } }

/* ====== Login and shelf ====== */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.cover { position: relative; width: min(420px, 100%); min-height: 520px; display: grid; place-items: center; padding: 28px; border-radius: 4px 12px 12px 4px; background: linear-gradient(90deg, var(--cover-2) 0 18px, var(--cover) 18px); box-shadow: 0 24px 60px rgba(0, 0, 0, .5), inset -2px 0 0 rgba(255, 255, 255, .06); }
.cover-label { margin-left: 14px; padding: 26px 22px; border-radius: 4px; background: var(--paper); text-align: center; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); }
.cover-kicker { display: block; font-family: var(--title); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.cover-label strong { display: block; margin: 6px 0 12px; font-family: var(--title); font-size: 25px; }
.cover-label p { margin: 0 0 20px; color: var(--ink-soft); line-height: 1.45; font-size: 15px; }
.shelf { max-width: 1040px; margin: 0 auto; padding: 32px 20px 60px; color: var(--on-desk); }
.shelf-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.shelf-head h1 { margin: 0 0 24px; font-family: var(--title); font-size: 28px; }
.shelf-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 36px; }
.shelf-foot .btn { background: transparent; color: var(--on-desk); border-color: var(--on-desk-2); }
@media (hover: hover) { .shelf-foot .btn:hover:not(:disabled), .shelf-head .account-login:hover:not(:disabled) { background: rgba(127, 127, 127, .18); } }
.shelf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 22px; }
.mini-cover { position: relative; min-height: 260px; border-radius: 3px 9px 9px 3px; background: linear-gradient(90deg, var(--cover-2) 0 12px, var(--cover) 12px); box-shadow: 0 12px 26px rgba(0, 0, 0, .4); transition: transform .15s; }
@media (hover: hover) { .mini-cover:hover { transform: translateY(-3px); } }
.mini-link { position: absolute; inset: 44px 14px 54px 24px; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 12px; border-radius: 3px; background: var(--paper); color: var(--ink); text-align: center; text-decoration: none; overflow: hidden; }
.mini-link .cover-kicker { font-size: 10px; }
.mini-link strong { font-family: var(--title); font-size: 21px; overflow-wrap: anywhere; }
.mini-link span:not(.cover-kicker) { color: var(--ink-soft); font-size: 13px; }
.mini-link em { color: var(--mark-pp); font-size: 12px; font-style: normal; }
.mini-actions { position: absolute; right: 6px; bottom: 6px; display: flex; color: #fff; }
.mini-cover.new { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; border: 2px dashed var(--on-desk-2); background: transparent; color: var(--on-desk); box-shadow: none; font-weight: 700; }

/* ====== Top bar ====== */
.frame { min-height: 100dvh; display: flex; flex-direction: column; }
.bar { position: sticky; top: 0; z-index: 30; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 8px 14px; background: rgba(29, 32, 38, .94); color: var(--on-desk); backdrop-filter: blur(6px); }
.bar-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.bar-title strong { display: block; font-family: var(--title); font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-title span { display: block; color: var(--on-desk-2); font-size: 12px; }
.bar-title > div { min-width: 0; }
.bar-week { display: flex; align-items: center; gap: 4px; }
.week-pick { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border: 0; border-radius: 6px; background: transparent; font-weight: 700; white-space: nowrap; }
@media (hover: hover) { .week-pick:hover { background: rgba(127, 127, 127, .18); } }
.week-pick svg { opacity: .7; }
.today-btn { margin-left: 6px; background: transparent; color: var(--on-desk); border-color: var(--on-desk-2); }
@media (hover: hover) { .today-btn:hover:not(:disabled) { background: rgba(127, 127, 127, .18); } }
.bar-actions { display: flex; justify-content: flex-end; gap: 8px; }
.bar-actions .btn:not(.primary) { background: transparent; color: var(--on-desk); border-color: var(--on-desk-2); }
@media (hover: hover) { .bar-actions .btn:not(.primary):hover { background: rgba(127, 127, 127, .18); } }
.bar-actions .btn.primary { background: var(--paper); border-color: var(--paper); color: var(--ink); }
@media (hover: hover) { .bar-actions .btn.primary:hover:not(:disabled) { background: var(--paper-2); border-color: var(--paper-2); } }
.readonly { margin: 8px auto 0; padding: 3px 12px; border-radius: 12px; background: var(--desk-2); color: var(--on-desk-2); font-size: 13px; }
.legend { margin: 0 auto; padding: 4px 16px 18px; color: var(--on-desk-2); font-size: 13px; text-align: center; }
.ink-n, .ink-pp { font-family: var(--hand); font-size: 17px; }
.ink-n { color: #ff9c94; }
.ink-pp { color: #9cc3ff; }

/* ====== The book ====== */
.desk { position: relative; flex: 1; padding: 18px 8px 12px; overflow-x: clip; transition: opacity .15s; }
.desk.loading { opacity: .82; }
.book { position: relative; margin: 0 auto; }
.book.spread { display: grid; grid-template-columns: var(--page) 14px var(--page); width: max-content; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .45)); }
.page { position: relative; background: var(--paper); }
.page.left { padding: 14px 14px 26px 18px; border-radius: 6px 0 0 6px; background: linear-gradient(90deg, var(--paper) 92%, #e7dfc8); box-shadow: inset 0 0 0 1px #d9d0b6; }
.page.right { padding: 14px 18px 26px 14px; border-radius: 0 6px 6px 0; background: linear-gradient(270deg, var(--paper) 92%, #e7dfc8); box-shadow: inset 0 0 0 1px #d9d0b6; }
.book.spread { grid-template-columns: calc(var(--page) + 32px) 14px calc(var(--page) + 32px); }
.spine { background: linear-gradient(90deg, #bdb398, #efe8d3 40%, #efe8d3 60%, #bdb398); }
.turn { position: absolute; bottom: 0; width: 44px; height: 44px; display: grid; border: 0; color: var(--ink-soft); background: none; }
.turn svg { position: absolute; bottom: 5px; }
.turn.next { right: 0; border-radius: 0 0 6px 0; background: linear-gradient(315deg, #d9d0b6 0 48%, transparent 50%); }
.turn.next svg { right: 4px; }
.turn.prev { left: 0; border-radius: 0 0 0 6px; background: linear-gradient(45deg, #d9d0b6 0 48%, transparent 50%); }
.turn.prev svg { left: 4px; }
@media (hover: hover) { .turn:hover { color: var(--ink); filter: brightness(.95); } }
.turn:disabled { visibility: hidden; }

.sheet { width: 100%; table-layout: fixed; border-collapse: collapse; color: var(--ink); }
.sheet td { border: 1px solid var(--line); padding: 0; }
.r-date td { height: 26px; }
.r-subject td { height: 148px; }
.r-room td { height: 36px; }
.r-day td { height: 28px; }
.sheet tbody td { height: var(--cell); }
.day-edge { border-left: 2px solid var(--line-strong) !important; }

.block { padding: 8px 10px !important; vertical-align: top; text-align: center; }
.block-text h2 { margin: 0 0 8px; font-family: var(--title); font-size: 15px; line-height: 1.25; }
.block-text p { margin: 0 0 10px; color: var(--ink-soft); font-size: 13px; line-height: 1.3; overflow-wrap: anywhere; }
.date { font-family: var(--hand); font-weight: 700; font-size: 19px; line-height: 1; color: var(--pen); text-align: center; border-top-color: transparent !important; border-right-color: transparent !important; }
.date.today, .dayname.today { background: var(--today); }
.subject { position: relative; vertical-align: bottom; padding: 4px 0 !important; overflow: hidden; }
.subject span { display: block; margin: 0 auto; max-height: 138px; overflow: hidden; writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; text-overflow: ellipsis; font-family: var(--hand); font-size: 17px; font-weight: 500; line-height: 25px; color: var(--pen); text-align: left; }
.room { position: relative; font-family: var(--hand); font-size: 14px; font-weight: 700; line-height: 1; color: var(--pen); text-align: center; overflow: hidden; white-space: nowrap; }
.room.split { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cline x1='0' y1='78' x2='100' y2='22' stroke='%239eb0c4' stroke-width='1.2' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E") center / 100% 100% no-repeat; }
.room .r-a, .room .r-b { position: absolute; font-size: 12.5px; }
.room .r-a { left: 2px; top: 2px; }
.room .r-b { right: 2px; bottom: 2px; }
.dayname { font-size: 12.5px; text-align: left; padding-left: 5px !important; background: var(--paper-2); overflow: hidden; white-space: nowrap; }
.num-head { font-size: 11px; text-align: center; line-height: 1.1; }
.name-head { padding: 3px 5px !important; font-size: 11.5px; line-height: 1.15; text-align: center; }
.label { font-size: 10.5px; text-align: center; background: var(--paper-2); }
.num { font-size: 12px; text-align: center; color: var(--ink-soft); }
.num-blank { border: 0 !important; }
.name { padding: 0 6px !important; font-family: var(--hand); font-size: 19px; font-weight: 500; line-height: 1; color: var(--pen); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filler.plain { border-top-color: transparent; border-right-color: transparent; }

.tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; margin-top: 4px; }
.tool { display: inline-flex; align-items: center; gap: 3px; height: 22px; padding: 0 5px; border: 1px solid var(--line); border-radius: 4px; background: #fffdf5; color: var(--ink); font-family: var(--print); font-size: 10.5px; line-height: 1; }
.name-head .tools { flex-wrap: nowrap; }
.name-head .tool svg { display: none; }
@media (hover: hover) { .tool:hover { border-color: var(--line-strong); background: var(--paper-2); } }

.m { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; min-height: var(--cell); padding: 0; border: 0; background: transparent; font-family: var(--hand); font-weight: 700; font-size: 20px; line-height: 1; }
@media (hover: hover) { button.m:hover { background: rgba(29, 53, 87, .1); } }
.m.n { color: var(--mark-n); }
.m.pp { color: var(--mark-pp); font-size: 19px; letter-spacing: -.6px; }
tbody tr.hover .name, tbody tr.hover .num { background: rgba(29, 53, 87, .07); }
.num-btn, .name-btn { display: block; width: 100%; height: 100%; min-height: var(--cell); padding: 0; border: 0; background: transparent; color: inherit; font: inherit; }
@media (hover: hover) { .num-btn:hover { background: rgba(29, 53, 87, .12); } }
.name-btn { overflow: hidden; text-align: left; white-space: nowrap; text-overflow: ellipsis; }
@media (hover: hover) { .name-btn:hover { text-decoration: underline; text-decoration-thickness: 1px; } }
.sheet tbody tr.lit td { background-color: #fbeeb4; }
.page.only tbody tr.lit .num, .page.only tbody tr.lit .name { background-color: #fbeeb4; }
.sheet tbody tr.struck td { background-image: linear-gradient(transparent calc(50% - 1px), #33415a calc(50% - 1px), #33415a calc(50% + 1px), transparent calc(50% + 1px)); }
.sheet tbody tr.struck .name-btn, .sheet tbody tr.struck .num { color: var(--ink-soft); }

/* The table stays invisible so that a blank page keeps the size of a written one */
.page.blank .sheet { visibility: hidden; }
.page.only.blank { overflow: hidden; }
.add-week { position: absolute; left: 50%; top: 50%; z-index: 5; display: grid; justify-items: center; gap: 14px; width: min(280px, 88%); transform: translate(-50%, -50%); }
.add-plus { display: grid; place-items: center; width: 76px; height: 76px; border: 2px dashed var(--line-strong); border-radius: 50%; background: var(--paper); color: var(--ink-soft); }
@media (hover: hover) { .add-plus:hover { border-style: solid; background: var(--paper-2); color: var(--ink); } }

.note { position: absolute; left: 50%; top: 280px; z-index: 5; width: min(330px, 88%); transform: translateX(-50%) rotate(-1deg); padding: 16px 16px 14px; background: #fff7c2; box-shadow: 0 8px 20px rgba(0, 0, 0, .25); }
.note strong { font-family: var(--title); }
.note p { margin: 6px 0 12px; font-size: 14px; line-height: 1.4; }
.note div { display: flex; flex-wrap: wrap; gap: 8px; }

/* ====== Turning a page ====== */
.stage { position: absolute; inset: 0; z-index: 8; pointer-events: none; perspective: 2600px; }
.stage .under { position: absolute; margin: 0; }
.leaf { position: absolute; transform-style: preserve-3d; will-change: transform; }
.leaf .face { position: absolute; inset: 0; margin: 0; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.leaf .face.front { box-shadow: 0 0 22px rgba(0, 0, 0, .25); }
.leaf .face.back { transform: rotateY(180deg); box-shadow: 0 0 22px rgba(0, 0, 0, .25); }

.book.one-page { width: max-content; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .45)); }
.book.one-page .page.left, .book.one-page .page.right { border-radius: 6px; }
.stage-sheet { overflow-x: clip; perspective: 1300px; z-index: 12; }
.book.sheet-under { position: absolute; margin: 0; max-width: none; }
.book.sheet-leaf { position: absolute; margin: 0; max-width: none; background: var(--paper); backface-visibility: hidden; -webkit-backface-visibility: hidden; will-change: transform; }

/* ====== Phones and tablets: one long sheet ====== */
.book.single { max-width: 100%; width: max-content; padding: 8px; border-radius: 6px; background: var(--paper); filter: drop-shadow(0 12px 20px rgba(0, 0, 0, .4)); }
.page.only { max-width: calc(100vw - 32px); overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
/* Collapsed borders do not travel with sticky cells, and the columns behind would show through the gaps */
.book.single:not(.by-day) .sheet { border-collapse: separate; border-spacing: 0; }
.book.single:not(.by-day) .sheet td { border-width: 0 1px 1px 0; }
.book.single:not(.by-day) .sheet .r-date td { border-top-width: 1px; }
.book.single:not(.by-day) .sheet .block, .book.single:not(.by-day) .sheet .num, .book.single:not(.by-day) .sheet .num-head { border-left-width: 1px; }
.book.single:not(.by-day) .day-edge { border-left: 1px solid var(--line-strong) !important; }
.book.single:not(.by-day) .num, .book.single:not(.by-day) .num-head { position: sticky; left: 0; z-index: 2; background: var(--paper); }
.book.single:not(.by-day) .block { position: sticky; left: 0; z-index: 3; background: var(--paper); }
.book.single:not(.by-day) .name, .book.single:not(.by-day) .name-head { position: sticky; left: 30px; z-index: 2; background: var(--paper); }
.book.single:not(.by-day) .label { position: sticky; left: calc(30px + var(--name-w, 178px)); z-index: 2; }
.book.single:not(.by-day) .num-head { z-index: 3; }

/* ====== A phone: one day at a time ====== */
.book.by-day { --tabs: 50px; --safe-top: env(safe-area-inset-top, 0px); width: 100%; padding: 0 8px 8px; }
.book.by-day .page.only { max-width: none; overflow: visible; background: transparent; }
.book.by-day .page.blank { min-height: 70dvh; }
.day-title { padding: 12px 4px 10px; text-align: center; }
.day-title h2 { margin: 0 0 3px; font-family: var(--title); font-size: 16px; line-height: 1.25; }
.day-title p { margin: 0; color: var(--ink-soft); font-size: 13px; }
.day-title .tools { gap: 6px; margin-top: 10px; }
.day-title .tool { height: 34px; padding: 0 8px; font-size: 13px; }
.day-title .tool svg { display: none; }
.day-tabs { position: sticky; top: var(--safe-top); z-index: 6; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; height: var(--tabs); padding: 4px 0; background: var(--paper); }
.day-tab { display: grid; align-content: center; justify-items: center; gap: 1px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: #fffdf5; color: var(--ink); line-height: 1.1; }
.day-tab b { font-size: 14px; }
.day-tab span { color: var(--ink-soft); font-size: 11px; }
.day-tab.none { background: transparent; border-style: dashed; }
.day-tab.none b, .day-tab.none span { color: #a3a79f; }
.day-tab.today:not(.on) { background: var(--today); }
.day-tab.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.day-tab.on span { color: #d5dbe5; }
.day-sheet { width: 100%; border-collapse: separate; border-spacing: 0; }
.day-sheet td { border-width: 0 1px 1px 0; }
.day-sheet .num, .day-sheet .num-head { border-left-width: 1px; }
.day-sheet thead td { position: sticky; z-index: 4; background: var(--paper); }
.day-sheet .r-subject td { top: calc(var(--safe-top) + var(--tabs)); height: 100px; border-top-width: 1px; }
.day-sheet .r-room td { top: calc(var(--safe-top) + var(--tabs) + 100px); height: 26px; }
.day-sheet .subject { padding: 0 !important; }
.day-sheet .subject span { max-height: 92px; line-height: 22px; font-size: 16px; }
.day-sheet .room { font-size: 13px; }
.subject-btn { display: flex; align-items: flex-end; justify-content: center; width: 100%; height: 100%; padding: 4px 0; border: 0; background: transparent; color: inherit; }
.day-sheet .num-head { font-size: 11px; }
.day-sheet .name-head { font-size: 11px; }
.day-sheet .name { max-width: 0; padding: 0 6px !important; font-size: 19px; }

/* ====== The person's own account ====== */
.account-btn { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; overflow: hidden; border: 2px solid var(--on-desk-2); border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; }
.account-btn img, .account-face img { width: 100%; height: 100%; object-fit: cover; }
.bar-actions .account-login { background: transparent; color: var(--on-desk); border-color: var(--on-desk-2); width: auto; padding: 5px 12px; }
.shelf-head .account-login { background: transparent; color: var(--on-desk); border-color: var(--on-desk-2); }
.account-menu { position: fixed; z-index: 70; display: grid; gap: 8px; width: min(290px, calc(100vw - 16px)); padding: 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--paper); color: var(--ink); box-shadow: 0 14px 34px rgba(0, 0, 0, .4); }
.account-who { display: flex; align-items: center; gap: 10px; min-width: 0; margin-bottom: 4px; }
.account-who > div { min-width: 0; }
.account-who strong { display: block; font-family: var(--title); overflow-wrap: anywhere; }
.account-who span { color: var(--ink-soft); font-size: 13px; overflow-wrap: anywhere; }
.account-face { display: grid; place-items: center; flex: none; width: 42px; height: 42px; overflow: hidden; border-radius: 50%; background: var(--accent); color: #fff !important; font-size: 17px !important; font-weight: 700; }

/* ====== Who else is here ====== */
.peers { display: flex; align-items: center; }
.peer { display: grid; place-items: center; width: 32px; height: 32px; margin-left: -8px; padding: 0; overflow: hidden; border: 2px solid var(--desk); border-radius: 50%; background: var(--accent); color: #fff; font-size: 13px; font-weight: 700; }
.peer:first-child { margin-left: 0; }
.peer img { width: 100%; height: 100%; object-fit: cover; }
.peer.busy { border-color: #e0a526; }
.peer-edit { box-shadow: 0 0 0 2px #e0a526; }
.m.peer-edit { box-shadow: inset 0 0 0 2px #e0a526; }

/* ====== Dialogs ====== */
.dlg-overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(10, 12, 16, .6); }
.dlg { display: flex; flex-direction: column; width: min(480px, 100%); max-height: calc(100dvh - 32px); border-radius: 8px; background: var(--paper); box-shadow: 0 24px 60px rgba(0, 0, 0, .5); }
.dlg.wide { width: min(780px, 100%); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 12px 8px 18px; }
.dlg-head h2 { margin: 0; font-family: var(--title); font-size: 19px; }
.dlg-body { flex: 1; overflow-y: auto; padding: 4px 18px 14px; }
.dlg-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.dlg-text { margin: 0 0 6px; line-height: 1.45; }
.dlg-hint { margin: 0 0 12px; color: var(--ink-soft); font-size: 13.5px; line-height: 1.4; }
.form { display: grid; gap: 12px; }
.field { display: grid; gap: 4px; }
.field > span:first-child { color: var(--ink-soft); font-size: 13px; }
input, textarea { width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 5px; background: #fffdf6; font-size: 16px; }
textarea { resize: none; }

.people, .lessons { margin: 0 0 10px; padding: 0; list-style: none; display: grid; gap: 6px; }
.person { display: grid; grid-template-columns: 24px 1fr repeat(3, 34px); align-items: center; gap: 4px; }
.person .icon-btn, .lesson .icon-btn { width: 34px; height: 38px; }
.person-num, .lesson-num { color: var(--ink-soft); font-size: 13px; text-align: right; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.bulk { margin-top: 10px; display: grid; gap: 8px; justify-items: start; }
.bulk .field { width: 100%; }
.week-days { display: grid; gap: 14px; }
.sched-day { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.sched-day h3 { margin: 0 0 8px; font-family: var(--title); font-size: 15px; }
.lesson { display: grid; grid-template-columns: 20px minmax(0, 1fr) 62px 62px repeat(3, 34px); align-items: center; gap: 4px; }
.lesson .l-room, .lesson .l-building { padding: 8px 6px; text-align: center; }

.share-part { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; justify-items: start; }
.share-part > * { width: 100%; }
.share-part > .btn { width: auto; }
.share-part:last-child { border-bottom: 0; margin-bottom: 0; }
.share-part h3 { margin: 0; font-family: var(--title); font-size: 16px; }
.share-part .dlg-hint { margin: 0; }
.share-add, .link-row { display: flex; gap: 6px; }
.share-add input, .link-row input { flex: 1; min-width: 0; }
.link-row input { font-size: 13px; }
.editors { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.editors li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px 2px 10px; border-radius: 5px; background: var(--paper-2); overflow-wrap: anywhere; }
.switch-row:disabled { opacity: .8; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fffdf6; text-align: left; }
.switch-row small { display: block; margin-top: 3px; color: var(--ink-soft); font-size: 12.5px; line-height: 1.35; }
.switch { position: relative; flex: none; width: 42px; height: 24px; border-radius: 12px; background: #b9b6a8; transition: background .15s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch-row.on .switch { background: var(--accent); }
.switch-row.on .switch::after { transform: translateX(18px); }

.report-month { margin-bottom: 14px; }
.month-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.month-chip { min-height: 38px; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 19px; background: #fffdf6; font-size: 14px; }
.month-chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.report-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.f-university, .f-institute, .f-department { grid-column: 1 / -1; }
.report-sub { margin: 16px 0 8px; font-family: var(--title); font-size: 15px; }
.report-table-wrap { overflow-x: auto; }
.report-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.report-table th, .report-table td { padding: 4px 6px; border: 1px solid var(--line); text-align: left; }
.report-table th { font-size: 12px; font-weight: 700; background: var(--paper-2); }
.report-table td input { min-height: 32px; padding: 3px 6px; font-size: 14px; min-width: 96px; }
.report-table tfoot td { font-weight: 700; }
.report-table tfoot td:first-child { text-align: right; }
.report-signs { display: grid; grid-template-columns: 1fr 1.5fr; gap: 10px; margin-bottom: 12px; }

/* ====== Our own date field, calendar and suggestions ====== */
.date-field { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 5px; background: #fffdf6; font-size: 16px; text-align: left; }
@media (hover: hover) { .date-field:hover { background: var(--paper-2); } }
.date-field svg { flex: none; color: var(--ink-soft); }
.cal { position: fixed; z-index: 70; display: grid; gap: 8px; width: 276px; padding: 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--paper); color: var(--ink); box-shadow: 0 14px 34px rgba(0, 0, 0, .4); }
.cal-head { display: flex; align-items: center; justify-content: space-between; }
.cal-head strong { font-family: var(--title); font-size: 15px; }
.cal-head .icon-btn { width: 34px; height: 34px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-week { padding: 2px 0 4px; color: var(--ink-soft); font-size: 12px; text-align: center; }
.cal-day { height: 34px; padding: 0; border: 0; border-radius: 5px; background: transparent; font-size: 14px; }
@media (hover: hover) { .cal-day:hover { background: var(--paper-2); } }
.cal-day.other { color: #a3a79f; }
.cal-day.off { background: transparent; color: #c9c7bb; cursor: default; }
@media (hover: hover) { .cal-day.off:hover { background: transparent; color: #c9c7bb; cursor: default; } }
.cal-day.in-week { background: #e6dfc6; }
.cal-day.today { font-weight: 700; box-shadow: inset 0 0 0 1px var(--line-strong); }
.cal-day.picked { background: var(--accent); color: #fff; }
@media (hover: hover) { .cal-day.picked:hover { background: var(--accent); color: #fff; } }
.cal-today { justify-self: center; }
.suggest { position: fixed; z-index: 70; max-height: 200px; margin: 0; padding: 4px; overflow-y: auto; list-style: none; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--paper); box-shadow: 0 10px 24px rgba(0, 0, 0, .3); }
.suggest li { padding: 7px 9px; border-radius: 4px; cursor: pointer; font-size: 15px; }
.suggest li.on { background: var(--paper-2); }
@media (hover: hover) { .suggest li:hover { background: var(--paper-2); } }

.btn.danger-text { margin-right: auto; color: var(--mark-n); border-color: var(--mark-n); }
@media (hover: hover) { .btn.danger-text:hover:not(:disabled) { background: #f7dfdb; } }
.person-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; margin: 0 0 12px; }
.person-totals div { padding: 8px 10px; border-radius: 6px; background: var(--paper-2); }
.person-totals dt { color: var(--ink-soft); font-size: 12px; }
.person-totals dd { margin: 2px 0 0; font-family: var(--title); font-size: 22px; font-weight: 700; }
.ink-red { color: var(--mark-n); }
.ink-blue { color: var(--mark-pp); }
.person-top { margin: 0 0 4px; line-height: 1.4; }
.person-days, .person-subjects { margin: 0; padding: 0; list-style: none; display: grid; gap: 5px; font-size: 14px; }
.person-days li { display: grid; grid-template-columns: 84px 1fr 26px; align-items: center; gap: 8px; }
.person-days b { text-align: right; }
.bar-track { height: 9px; border-radius: 5px; background: var(--paper-2); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 5px; background: var(--accent); }
.person-subjects li { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 4px; border-bottom: 1px solid var(--paper-2); }
.toast { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 80; max-width: min(460px, calc(100vw - 24px)); padding: 10px 16px; border-radius: 8px; background: #11141a; color: #fff; font-size: 14px; line-height: 1.35; text-align: center; opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: #8f1d17; }

@media (max-width: 1079px) {
  .bar { grid-template-columns: 1fr auto; grid-template-areas: 'title actions' 'week week'; row-gap: 4px; }
  .bar-title { grid-area: title; }
  .bar-actions { grid-area: actions; }
  .bar-week { grid-area: week; justify-content: center; }
  .desk { padding: 10px 8px; }
}

@media (max-width: 640px) {
  body.on-desk { background: var(--desk); }
  .bar { position: static; padding: calc(6px + env(safe-area-inset-top, 0px)) 8px 6px; background: var(--desk); backdrop-filter: none; }
  .bar .icon-btn { width: 40px; height: 40px; }
  .bar-title { gap: 4px; }
  .bar-actions { align-items: center; }
  .bar-actions .btn span { display: none; }
  .bar-actions .btn:not(.account-login) { width: 40px; height: 40px; min-height: 40px; padding: 0; }
  .bar-actions .account-login { min-height: 40px; padding: 0 14px; }
  /* The arrows keep their place whatever the length of the dates between them */
  .bar-week { display: grid; grid-template-columns: 40px minmax(0, 1fr) 40px auto; width: 100%; gap: 2px; }
  .week-pick { justify-content: center; font-size: 14px; padding: 4px 2px; gap: 4px; }
  .today-btn { min-height: 40px; margin-left: 6px; padding: 0 10px; }
  .legend { padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
  input, textarea, .report-table td input, .link-row input { font-size: 16px; }
}

@media (max-width: 640px) {
  .dlg-overlay { padding: 0; align-items: flex-end; }
  .dlg, .dlg.wide { width: 100%; max-height: 92dvh; border-radius: 12px 12px 0 0; }
  .lesson { grid-template-columns: 18px 1fr 1fr 34px 34px 34px; }
  .lesson .l-subject { grid-column: 2 / -1; }
  .lesson .lesson-num { grid-row: 1; }
  .lesson .l-room { grid-column: 2; }
  .lesson .l-building { grid-column: 3; }
  .report-fields, .report-signs { grid-template-columns: 1fr; }
  .person { grid-template-columns: 20px 1fr 32px 32px 32px; }
  .person .icon-btn { width: 32px; }
}

/* ====== A touch screen has no pointer resting on anything ====== */
@media (hover: none) {
  :focus:not(:focus-visible), :focus-visible { outline: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Кнопка акаунта (спільна) по центру рядка з заголовком */
.shelf-head { align-items: center; }
#account { display: flex; align-items: center; }

/* Скелетон полиці журналів: пульсує лише прозорість */
.shelf-skel { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 18px; padding: 24px 0; }
.shelf-skel span { display: block; min-height: 220px; border-radius: 10px; background: rgba(255, 255, 255, 0.08); animation: shelf-pulse 1.2s ease-in-out infinite alternate; }
@keyframes shelf-pulse { from { opacity: 0.45; } to { opacity: 1; } }
