@font-face { font-family: "CalSerif"; src: local("Minion Pro"), local("MinionPro-Regular"), url("fonts/crimson-pro-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: block; }
@font-face { font-family: "CalSerif"; src: local("Minion Pro Bold"), local("MinionPro-Bold"), url("fonts/crimson-pro-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: block; }

:root {
  --ui-font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --ui-bg: #e8e8ec;
  --ui-panel: #ffffff;
  --ui-line: #d6d6dc;
  --ui-text: #1d1d22;
  --ui-muted: #6b6b75;
  --ui-accent: #2f6fed;
  --ui-accent-soft: #e8efff;
  --ui-warn: #e8860c;
  --ui-danger: #c93636;
  --side-w: 340px;
  --tb-h: 54px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--ui-font); color: var(--ui-text); background: var(--ui-bg); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- toolbar ---------- */
#toolbar { position: fixed; inset: 0 0 auto 0; min-height: 54px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 9px 14px; background: var(--ui-panel); border-bottom: 1px solid var(--ui-line); z-index: 20; font-size: 13px; }
.tb-group { display: flex; align-items: center; gap: 4px; }
.tb-spacer { flex: 1; }
.app-name { font-weight: 650; font-size: 14px; white-space: nowrap; }
.icon-btn { border: 1px solid transparent; background: transparent; border-radius: 6px; width: 28px; height: 28px; cursor: pointer; font-size: 17px; line-height: 1; display: inline-grid; place-items: center; }
.icon-btn:hover:not(:disabled) { background: #f0f0f3; border-color: var(--ui-line); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.btn { border: 1px solid var(--ui-line); background: #fff; border-radius: 7px; padding: 6px 11px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f6f6f8; }
.btn.primary { background: var(--ui-accent); border-color: var(--ui-accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn.danger { color: var(--ui-danger); }
#yearInput { width: 66px; text-align: center; font-size: 16px; font-weight: 650; border: 1px solid var(--ui-line); border-radius: 6px; padding: 3px 2px; -moz-appearance: textfield; }
#yearInput::-webkit-inner-spin-button, #yearInput::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
#monthNav { gap: 1px; }
#monthNav button { border: 0; background: transparent; padding: 4px 5px; border-radius: 5px; cursor: pointer; color: var(--ui-muted); font-size: 12px; }
#monthNav button:hover { background: #f0f0f3; color: var(--ui-text); }
#monthNav button.current { color: var(--ui-accent); font-weight: 650; }
#search { width: 150px; border: 1px solid var(--ui-line); border-radius: 7px; padding: 5px 8px; }
#searchCount { color: var(--ui-muted); font-size: 12px; min-width: 44px; }
#zoomLabel { width: 42px; text-align: center; color: var(--ui-muted); font-variant-numeric: tabular-nums; }
.save-status { font-size: 12px; color: var(--ui-muted); min-width: 64px; text-align: right; white-space: nowrap; }
.save-status.saving { color: var(--ui-muted); }
.save-status.error { color: var(--ui-danger); font-weight: 600; }
@media (max-width: 1500px) { #monthNav { display: none; } }
@media (max-width: 1100px) { .app-name { display: none; } }

.tabs { gap: 2px; background: #f0f0f3; border-radius: 8px; padding: 2px; }
.tabs a { text-decoration: none; color: var(--ui-muted); padding: 4px 11px; border-radius: 6px; font-size: 13px; }
.tabs a:hover { color: var(--ui-text); }
.tabs a.active { background: #fff; color: var(--ui-text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.12); }


/* ---------- shared version: account + history ---------- */
.who { font-size: 12px; color: var(--ui-muted); white-space: nowrap; }
.who a { color: var(--ui-accent); text-decoration: none; }
.hist-day { font-weight: 650; margin: 14px 0 6px; color: var(--ui-text); }
.hist-day:first-child { margin-top: 0; }
.hist-row { padding: 4px 0; border-bottom: 1px solid #f0f0f2; }
.hist-time { display: inline-block; width: 72px; color: var(--ui-muted); font-variant-numeric: tabular-nums; }

/* ---------- layout ---------- */
#main { position: fixed; inset: var(--tb-h) 0 0 0; display: flex; }
#scroller { flex: 1; overflow: auto; padding: 24px 28px 80px; }
#pages { width: max-content; margin: 0 auto; }
#sidebar { width: var(--side-w); flex: none; background: var(--ui-panel); border-left: 1px solid var(--ui-line); overflow-y: auto; font-size: 13px; }

.page-caption { font: 600 11px var(--ui-font); color: var(--ui-muted); letter-spacing: .04em; text-transform: uppercase; margin: 0 0 6px 2px; }
.page-caption.month-start { margin-top: 10px; }
.page-wrap { margin-bottom: 22px; }

/* ---------- calendar page (all units are printer points) ---------- */
.page { position: relative; width: 792pt; height: 612pt; background: #fff; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 6px 22px rgba(0,0,0,.08);
  font-family: "CalSerif", "Minion Pro", Georgia, serif; color: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; font-kerning: normal; font-synthesis: small-caps; }
.page * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.p-title { position: absolute; right: 36.5pt; white-space: nowrap; color: #808080; line-height: 1; }
.p-title .m { font-size: 34pt; }
.p-title .y { font-size: 27pt; margin-left: 7pt; }
.hbar { position: absolute; background: #808080; }
.wday { position: absolute; color: #fff; font-size: 14pt; text-align: center; line-height: 1; white-space: nowrap; }
.ln { position: absolute; background: #000; }
.line-svg { position: absolute; left: 0; top: 0; width: 792pt; height: 612pt; pointer-events: none; overflow: visible; }
.notes-label { position: absolute; font-size: 12pt; line-height: 1; }
.notes-label.bold { font-weight: 700; }

.cell { position: absolute; }
.cell.in { cursor: pointer; }
.dnum { position: absolute; font-weight: 700; font-size: 14pt; line-height: 1.111; white-space: nowrap; }
.dnum.grey { color: #b3b3b3; }
.moon { position: absolute; overflow: visible; }
.content { position: absolute; transform-origin: 50% 100%; }
.entry { text-align: center; white-space: pre-wrap; overflow-wrap: break-word; }
.entry .ico { display: inline-block; vertical-align: baseline; height: 1em; fill: #000; }
.entry .t { outline: none; }
.entry .t[contenteditable] { background: #fff8d6; box-shadow: 0 0 0 1.5pt #f2c94c; border-radius: 1pt; cursor: text; }
.content.al-top, .content.al-center, .content.al-spread { display: flex; flex-direction: column; }
.content.al-top { justify-content: flex-start; }
.content.al-center { justify-content: center; }
.content.al-spread { justify-content: flex-end; }
.content.al-spread > .entry { margin-top: auto !important; }
.entry { position: relative; }
.gap-h { position: absolute; left: 50%; width: 40pt; margin-left: -20pt; height: 8pt; cursor: ns-resize; display: none; z-index: 4; }
.gap-h span { position: absolute; left: 0; right: 0; top: 3pt; height: 2pt; border-radius: 2pt; background: var(--ui-accent); opacity: .55; }
.gap-h:hover span, .cell.dragging .gap-h span { opacity: 1; height: 2.5pt; }
.cell.selected .gap-h { display: block; }
.drag-tip { position: fixed; z-index: 70; background: #26262c; color: #fff; font: 12px var(--ui-font); padding: 4px 8px; border-radius: 6px; pointer-events: none; }
.pos-row { margin-bottom: 10px; }
.pos-row label { display: block; font-size: 11px; color: var(--ui-muted); margin-bottom: 3px; }
.pos-row .seg { display: flex; }
.pos-row .seg button { flex: 1; padding: 5px 4px; }
.auto-note { height: 28px; display: flex; align-items: center; justify-content: center; border: 1px dashed var(--ui-line); border-radius: 7px; color: var(--ui-muted); font-size: 11.5px; }
.tip { color: var(--ui-muted); font-size: 12px; line-height: 1.4; margin-top: 12px; }
.tag { position: absolute; background: #cccccc; text-align: center; font-variant: small-caps; white-space: pre; overflow: hidden; }

/* editor-only overlays */
.cell.in:hover::after { content: ""; position: absolute; inset: 1pt; background: rgba(47,111,237,.04); pointer-events: none; }
.cell.selected::after, .cell.selected:hover::after { content: ""; position: absolute; inset: 1pt; border: 2pt solid var(--ui-accent); background: rgba(47,111,237,.035); pointer-events: none; z-index: 3; }
.cell.shrunk::before { content: ""; position: absolute; right: 1pt; bottom: 1pt; border: 6pt solid transparent; border-right-color: var(--ui-warn); border-bottom-color: var(--ui-warn); z-index: 2; pointer-events: none; }
.entry.hit .t { background: #ffe58a; }
.entry.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: #ffe58a; } to { background: transparent; } }

/* ---------- sidebar ---------- */
.side-empty { padding: 22px 20px; color: var(--ui-muted); line-height: 1.5; }
.side-empty h2 { color: var(--ui-text); font-size: 16px; margin: 0 0 8px; }
.hint-list { padding-left: 18px; margin: 14px 0; }
.hint-list li { margin-bottom: 6px; }
#overflowList .ov-title { color: var(--ui-text); font-weight: 600; margin-top: 18px; }
#overflowList button { display: block; width: 100%; text-align: left; border: 0; background: #fff6ea; color: #8a4b00; border-radius: 6px; padding: 6px 9px; margin-top: 5px; cursor: pointer; }
#overflowList button:hover { background: #ffecd2; }

.dp-head { padding: 16px 18px 12px; border-bottom: 1px solid var(--ui-line); position: sticky; top: 0; background: #fff; z-index: 2; }
.dp-date { font-size: 18px; font-weight: 650; }
.dp-sub { color: var(--ui-muted); margin-top: 3px; }
.dp-close { position: absolute; right: 12px; top: 13px; }
.dp-note { margin: 10px 18px 0; padding: 8px 10px; border-radius: 7px; background: #f4f4f6; color: var(--ui-muted); line-height: 1.4; }
.dp-note.warn { background: #fff6ea; color: #8a4b00; }
.dp-section { padding: 12px 18px; }
.dp-section h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ui-muted); margin: 4px 0 10px; }
.entry-card { border: 1px solid var(--ui-line); border-radius: 9px; padding: 10px; margin-bottom: 10px; background: #fff; }
.entry-card.focus { border-color: var(--ui-accent); box-shadow: 0 0 0 3px var(--ui-accent-soft); }
.ec-top { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.seg { display: inline-flex; border: 1px solid var(--ui-line); border-radius: 7px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 4px 8px; cursor: pointer; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.seg button + button { border-left: 1px solid var(--ui-line); }
.seg button.on { background: var(--ui-accent-soft); color: var(--ui-accent); font-weight: 600; }
.seg svg { width: 13px; height: 13px; fill: currentColor; }
.ec-top .grow { flex: 1; }
.entry-card textarea { width: 100%; min-height: 54px; resize: vertical; border: 1px solid var(--ui-line); border-radius: 7px; padding: 6px 8px; font-family: "CalSerif", Georgia, serif; font-size: 15px; line-height: 1.3; text-align: center; }
.entry-card textarea:focus { outline: none; border-color: var(--ui-accent); }
.ec-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.stepper { display: flex; flex-direction: column; align-items: stretch; }
.stepper label { font-size: 11px; color: var(--ui-muted); margin-bottom: 2px; }
.stepper .row { display: flex; align-items: center; border: 1px solid var(--ui-line); border-radius: 7px; overflow: hidden; }
.stepper button { border: 0; background: #f6f6f8; width: 24px; height: 26px; cursor: pointer; font-size: 15px; }
.stepper button:hover { background: #ececf0; }
.stepper input { width: 100%; min-width: 0; border: 0; text-align: center; font-size: 12px; padding: 0; height: 26px; font-variant-numeric: tabular-nums; }
.hl-size { display: flex; align-items: center; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.hl-size .hl-label { font-size: 11px; color: var(--ui-muted); }
.hl-size .btn.small { padding: 2px 8px; font-family: Georgia, serif; }
.hl-note { font-size: 11px; color: var(--ui-muted); margin-left: 4px; }
.mini-link { border: 0; background: none; color: var(--ui-accent); cursor: pointer; font-size: 11.5px; padding: 0; }
.inline-bar { position: fixed; z-index: 40; display: flex; align-items: center; gap: 4px; background: #26262c; color: #fff; padding: 4px 6px 4px 10px; border-radius: 8px; font: 12px var(--ui-font); box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.inline-bar button { border: 0; background: #3a3a42; color: #fff; border-radius: 5px; padding: 3px 9px; cursor: pointer; font: 13px Georgia, serif; }
.inline-bar button:hover { background: #50505a; }
.add-row { display: flex; gap: 6px; flex-wrap: wrap; }
.add-row .btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.add-row svg { width: 13px; height: 13px; }
.cell-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.empty-day { color: var(--ui-muted); padding: 6px 0 12px; }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(20,20,28,.35); display: grid; place-items: center; z-index: 50; }
.modal { background: #fff; border-radius: 12px; width: min(760px, calc(100vw - 40px)); max-height: calc(100vh - 60px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); font-size: 13px; }
.modal.narrow { width: min(460px, calc(100vw - 40px)); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--ui-line); display: flex; align-items: center; }
.modal-head h2 { margin: 0; font-size: 16px; flex: 1; }
.modal-body { padding: 16px 20px; overflow-y: auto; line-height: 1.45; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--ui-line); display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.modal-foot .left { margin-right: auto; color: var(--ui-muted); display: flex; gap: 6px; align-items: center; }
.hol-table { width: 100%; border-collapse: collapse; }
.hol-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ui-muted); padding: 6px 6px; border-bottom: 1px solid var(--ui-line); position: sticky; top: -16px; background: #fff; }
.hol-table td { padding: 5px 6px; border-bottom: 1px solid #f0f0f2; vertical-align: middle; }
.hol-table input[type=text] { width: 100%; border: 1px solid transparent; border-radius: 5px; padding: 3px 5px; }
.hol-table input[type=text]:hover, .hol-table input[type=text]:focus { border-color: var(--ui-line); outline: none; }
.hol-table .rule { color: var(--ui-muted); }
.hol-table tr.off td { opacity: .45; }
.add-hol { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 14px; padding: 10px; background: #f6f6f8; border-radius: 8px; }
.add-hol select, .add-hol input { border: 1px solid var(--ui-line); border-radius: 6px; padding: 4px 6px; background: #fff; }
.setting-row { display: flex; align-items: center; gap: 10px; padding: 12px 0 4px; border-top: 1px solid var(--ui-line); margin-top: 16px; }
.setting-row select { border: 1px solid var(--ui-line); border-radius: 6px; padding: 4px 6px; }
.steps { margin: 6px 0 0; padding-left: 20px; }
.steps li { margin-bottom: 6px; }

#toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: #26262c; color: #fff; padding: 9px 14px; border-radius: 8px; font-size: 13px; z-index: 60; box-shadow: 0 6px 20px rgba(0,0,0,.2); }

/* ---------- print ---------- */
@page { size: 11in 8.5in; margin: 0; }
@media print {
  html, body { height: auto; overflow: visible; background: #fff; }
  .no-print, .page-caption { display: none !important; }
  #main { position: static; display: block; }
  #scroller { overflow: visible; padding: 0; }
  #pages { zoom: 1 !important; margin: 0; }
  .page-wrap { margin: 0; break-after: page; page-break-after: always; }
  .page-wrap:last-child { break-after: auto; page-break-after: auto; }
  .page { box-shadow: none; }
  .line-svg { shape-rendering: geometricPrecision; }
  .cell.selected::after, .cell.in:hover::after, .cell.shrunk::before, .gap-h { display: none !important; }
  .entry.hit .t, .entry .t[contenteditable] { background: none !important; box-shadow: none !important; }
}
