/* The family's look (mod's): true black with Ghastly's purple for what matters (the title, the
   selected day, what's on now), rounded panels, and the dotted Doto lettering of a departure
   board for times and event names. */
:root {
  --bg: #000;
  --surface: #0b0910;
  --surface-2: #15111c;
  --text: #f1edf6;
  --muted: #8b8396;
  --line: #1b1622;
  --line-2: #2a2234;
  --accent: #b163ff;        /* Ghastly's body */
  --accent-2: #7d449e;      /* his shading */
  --accent-soft: rgba(177, 99, 255, .14);
  --on-accent: #fff;
  --danger: #ff6b8b;
  --soon: #ff8a65;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --dots: "Doto", var(--mono);
  color-scheme: dark;
}

/* The page is exactly the screen, like mod: --app-h follows the visible area (/fit.js), so
   nothing slides under the iPhone keyboard; only the agenda and the week scroll. */
* { box-sizing: border-box; }
html, body { position: fixed; inset: 0; width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: 260px; z-index: -1; pointer-events: none; background: radial-gradient(90% 100% at 50% 0, rgba(177, 99, 255, .11), transparent 70%); }
/* an explicit display would otherwise override the hidden attribute */
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
/* form fields at 16px so iPhone Safari doesn't zoom when one is tapped */
input, select, textarea { font: 16px/1.3 var(--font); letter-spacing: 0; outline: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button {
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 9px 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s, transform .1s;
}
button:active { transform: scale(.97); }
button.primary { background: linear-gradient(145deg, var(--accent), var(--accent-2)); border-color: transparent; color: var(--on-accent); font-weight: 600; box-shadow: 0 4px 14px rgba(177, 99, 255, .28); }
button.danger { background: transparent; border-color: transparent; color: var(--danger); }
button.icon { background: transparent; border-color: transparent; font-size: 26px; line-height: 1; padding: 6px 10px; color: var(--muted); }
h1, h2 { margin: 0; font-weight: 700; }

/* Sign-in */
#signin {
  height: var(--app-h, 100dvh);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
}
#signin img { border-radius: 22px; }
#signin h1 { font: 700 28px/1 var(--dots); color: var(--text); }
#signin h1::after { content: "."; color: var(--accent); }
#signin p { color: var(--muted); margin: 0; max-width: 32ch; }
#signin a { color: var(--accent); font-size: 13px; }
#keyForm { display: flex; flex-direction: column; gap: 10px; width: min(100%, 320px); }
#keyForm input { padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--surface); text-align: center; }

/* Board */
#app {
  position: relative;
  height: var(--app-h, 100dvh);
  display: flex;
  flex-direction: column;
  max-width: 640px;
  margin: 0 auto;
  padding: max(8px, calc(env(safe-area-inset-top) + 8px)) env(safe-area-inset-right) 0 env(safe-area-inset-left);   /* clear of iOS's fade under the status bar */
}
header { padding: 10px 14px 12px; }
.board-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.board-top h1 { font: 700 26px/1 var(--dots); letter-spacing: .02em; color: var(--text); }
.board-top h1::after, #signin h1::after, dialog h2::after { font-family: var(--font); }   /* Doto's full stop is a cross */
.board-top h1::after { content: "."; color: var(--accent); }
#clock { font: 500 18px/1 var(--dots); font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--muted); }
.board-nav { display: flex; align-items: center; gap: 4px; margin-top: 12px; }
/* the dot font's own colon reads as a dagger, so colons use the plain font */
.sep { font: 700 .8em/1 var(--mono); font-style: normal; margin: 0 1px; vertical-align: .08em; }
#dayBtn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface);
  border-color: var(--line);
  font-weight: 600;
  white-space: nowrap;
}
#dayBtn .chevron { font-size: 12px; color: var(--muted); transition: transform .15s; }
#dayBtn[aria-expanded="true"] { border-color: rgba(177, 99, 255, .45); }
#dayBtn[aria-expanded="true"] .chevron { transform: rotate(180deg); }
#menuBtn { width: 42px; height: 42px; padding: 0; font-size: 20px; background: var(--surface); border-color: var(--line); border-radius: 50%; }
#today { font-size: 13px; padding: 6px 14px; }
.board-views { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
/* Day / Week: a segmented pill */
.views { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; }
.views button { border: 0; border-radius: 999px; padding: 6px 16px; font-size: 13px; background: transparent; color: var(--muted); }
.views button[aria-pressed="true"] { background: var(--accent-soft); color: var(--text); font-weight: 600; box-shadow: inset 0 0 0 1px rgba(177, 99, 255, .45); }

/* Month picker, shown from the date button: a rounded card under the header */
#monthPanel { margin: 0 10px 8px; padding: 8px 8px 10px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.month-nav { display: flex; align-items: center; }
.month-nav h2 { flex: 1; text-align: center; font-size: 15px; font-weight: 600; }
#weekdays, #grid { display: grid; grid-template-columns: repeat(7, 1fr); }
#weekdays span { text-align: center; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 2px 0 6px; }
.day {
  background: transparent;
  border: 0;
  border-radius: 12px;
  padding: 3px 0 5px;
  height: 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.day .num { width: 30px; height: 30px; line-height: 30px; border-radius: 50%; font-size: 14px; font-variant-numeric: tabular-nums; }
.day.other .num { color: var(--muted); opacity: .6; }
.day.today .num { box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--accent); font-weight: 700; }
.day.selected .num { background: linear-gradient(145deg, var(--accent), var(--accent-2)); color: var(--on-accent); opacity: 1; font-weight: 700; box-shadow: 0 3px 10px rgba(177, 99, 255, .35); }
/* a day with no work shift */
.day.off { background: color-mix(in srgb, #5dcaa5 16%, transparent); }
.day.off .num { color: #5dcaa5; font-weight: 600; }
.day.off.selected .num { color: var(--on-accent); }
.dots { display: flex; gap: 3px; height: 5px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; }

#agenda {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0 10px calc(96px + env(safe-area-inset-bottom));
}
#agenda::-webkit-scrollbar { display: none; }
.columns, .row { display: grid; grid-template-columns: 30px 66px minmax(0, 1fr) auto; column-gap: 10px; align-items: center; }
.columns { padding: 6px 12px 8px; font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.columns span:first-child { grid-column: 2; }
.columns span:last-child { text-align: right; }
/* the day's events in one rounded card, hairlines between them */
#dayList { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
#dayList li { border-bottom: 1px solid var(--line); }
#dayList li:last-child { border-bottom: 0; }
#dayList li.empty { padding: 32px 12px; text-align: center; color: var(--muted); font: 500 16px/1.2 var(--dots); }
.row {
  width: 100%;
  min-height: 64px;
  padding: 10px 12px;
  background: transparent;
  border: 0;
  border-radius: 0;
  font-weight: 400;
  text-align: left;
}
.row:active { transform: none; background: var(--surface-2); }
.row .line {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0;
  opacity: .9;
}
.row .time { font: 700 16px/1 var(--dots); font-variant-numeric: tabular-nums; color: var(--muted); }
.row .name { font: 700 16px/1.2 var(--dots); overflow-wrap: anywhere; }
/* Greek in event names: a pixel font (Doto has no Greek) broken into dots to match */
.gr { font-family: "Tiny5", var(--mono); font-weight: 400; font-size: 1.08em; letter-spacing: .05em; -webkit-mask-image: radial-gradient(circle, #000 40%, transparent 48%); mask-image: radial-gradient(circle, #000 40%, transparent 48%); -webkit-mask-size: .125em .125em; mask-size: .125em .125em; }
.row .status { text-align: right; white-space: nowrap; }
.row .status b { display: block; font: 700 18px/1 var(--dots); font-variant-numeric: tabular-nums; }
.row .status small { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
/* happening now: a softly lit row with a purple edge */
.row.live { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.row.live .time, .row.live .status b { color: var(--accent); }
/* starting within two hours */
.row.soon .time, .row.soon .status b, .row.soon .status small { color: var(--soon); }
.row.past { opacity: .45; }

/* Tasks, under the day's events: the same rounded card, a round tick on the left */
.tasks-head { grid-template-columns: minmax(0, 1fr) auto; margin-top: 14px; }
.tasks-head span:first-child { grid-column: 1; }
#tasks { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
#taskList { list-style: none; margin: 0; padding: 0; }
#taskList li { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto 34px; column-gap: 10px; align-items: center; min-height: 54px; padding: 6px 4px 6px 12px; border-bottom: 1px solid var(--line); }
#taskList li.more { display: block; min-height: 0; padding: 0; }
.tick { width: 24px; height: 24px; padding: 0; border-radius: 50%; border: 1.5px solid var(--muted); background: transparent; display: grid; place-items: center; font-size: 13px; line-height: 1; color: transparent; }
.done .tick { border-color: transparent; background: linear-gradient(145deg, var(--accent), var(--accent-2)); color: var(--on-accent); }
.task-name { font: 700 16px/1.2 var(--dots); overflow-wrap: anywhere; }
.done .task-name { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
/* days left: like an event's status, a big dotted value over a small label */
.due { text-align: right; white-space: nowrap; }
.due b { display: block; font: 700 18px/1 var(--dots); font-variant-numeric: tabular-nums; }
.due small { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.due.today b, .due.today small { color: var(--soon); }
.due.late b, .due.late small { color: var(--danger); }
.done .due b { color: var(--muted); }
.task-drop { width: 34px; height: 34px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; }
.task-drop:active { color: var(--danger); }
.more button { width: 100%; padding: 10px 12px; border: 0; border-radius: 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
#taskList li:last-child { border-bottom: 0; }
/* adding a task: its own card above the list */
#taskForm { display: grid; grid-template-columns: minmax(0, 1fr) 72px 36px; gap: 6px; align-items: center; padding: 8px; margin-bottom: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; }
#taskForm input[type=text] { min-width: 0; height: 38px; padding: 8px 10px; }
/* the due date is a small chip ("Due", or "25 Oct" once picked); the real date field lies
   invisible on top of it, so a tap still opens the phone's own date picker. iPhone draws an
   empty date field with today's date and too wide to fit, so the field itself is never shown. */
.due-pick { position: relative; height: 38px; display: grid; place-items: center; border: 1px solid var(--line-2); border-radius: 12px; background: var(--bg); color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; }
.due-pick.set { color: var(--text); border-color: rgba(177, 99, 255, .45); }
.due-pick:focus-within { border-color: rgba(177, 99, 255, .55); box-shadow: 0 0 0 4px rgba(177, 99, 255, .12); }
.due-pick input { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; }
#taskAdd { width: 36px; height: 36px; padding: 0; border-radius: 11px; font-size: 20px; font-weight: 400; line-height: 1; box-shadow: none; }

/* Week: seven day columns, scrolled sideways */
#week {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 10px;
  padding: 4px 10px calc(96px + env(safe-area-inset-bottom));
  scrollbar-width: none;
}
#week::-webkit-scrollbar { display: none; }
.week-day {
  flex: 0 0 calc((100% - 16px) / 2.6);
  min-width: 118px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 6px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  align-self: flex-start;
}
.week-day.today { border-color: rgba(177, 99, 255, .5); background: linear-gradient(180deg, rgba(177, 99, 255, .1), transparent 120px), var(--surface); }
.week-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  background: transparent;
  border: 0;
  border-radius: 10px;
  padding: 2px 4px 4px;
  color: var(--muted);
  font-size: 12px;
}
.week-head b { font: 700 17px/1 var(--dots); color: var(--text); }
.week-day.today .week-head, .week-day.today .week-head b { color: var(--accent); }
.week-day.selected .week-head b { text-decoration: underline; text-underline-offset: 4px; }
.chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  padding: 7px 8px;
  border: 0;
  border-left: 3px solid var(--c);
  border-radius: 10px;
  background: var(--surface-2);
  font-weight: 400;
}
.chip-time { font: 700 13px/1 var(--dots); color: var(--c); }
.chip-name { font: 700 13px/1.2 var(--dots); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.chip.past { opacity: .45; }
.week-empty { color: var(--muted); padding: 4px 4px; }

#add {
  position: absolute;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: var(--on-accent);
  font-size: 26px;
  font-weight: 400;
  line-height: 1;
  padding: 0;
  box-shadow: 0 6px 20px rgba(177, 99, 255, .35);
}
/* while typing, the keyboard pushes the page up: the + would float over the list */
body.typing #add { display: none; }

/* Sheets */
dialog {
  width: min(100% - 24px, 480px);
  max-height: calc(var(--app-h, 100dvh) - 24px);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-2);
  border-radius: 24px;
  padding: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
}
dialog::backdrop { background: rgba(0, 0, 0, .72); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
dialog h2 { font: 700 20px/1 var(--dots); margin-bottom: 16px; color: var(--text); }
dialog h2::after { content: "."; color: var(--accent); }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
input[type=text], textarea, select, input[type=date], input[type=time] {
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 0;
  transition: border-color .2s, box-shadow .2s;
}
input[type=text]:focus, textarea:focus, select:focus, input[type=date]:focus, input[type=time]:focus { border-color: rgba(177, 99, 255, .55); box-shadow: 0 0 0 4px rgba(177, 99, 255, .12); }
input[type=text], textarea { width: 100%; }
::placeholder { color: var(--muted); }
textarea { resize: vertical; }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); }
.row-field { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row-field > span:first-child { color: var(--muted); flex: none; font-size: 13px; }
.when { display: flex; gap: 6px; min-width: 0; }
select { max-width: 65%; }
.actions { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.spacer { flex: 1; }
#calList { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
#calList label { display: flex; align-items: center; gap: 10px; }
#calList i { width: 12px; height: 12px; border-radius: 50%; flex: none; }
#calList span { overflow-wrap: anywhere; }
#calList li { display: flex; align-items: center; gap: 8px; }
#calList label { flex: 1; min-width: 0; }
#calList small { display: block; font-size: 11px; color: var(--muted); }
#calList small.bad { color: var(--danger); }
#calList .mini { padding: 4px 10px; font-size: 12px; }

/* Bringing a calendar along: subscribe by link, or import a file */
#bring { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
#bring h3 { margin: 0; font: 700 18px/1 var(--dots); }
#subForm { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.hint { margin: 0; font-size: 12px; color: var(--muted); }
#bring details { font-size: 13px; }
#bring details > .hint { margin: 8px 0; }
#bring summary { cursor: pointer; color: var(--accent); }
#gConnect { align-self: stretch; }
#gAccounts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#gAccounts li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
#gAccounts span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.howto { margin: 0; padding-left: 18px; color: var(--text); display: flex; flex-direction: column; gap: 6px; }
#importBtn { align-self: flex-start; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid rgba(177, 99, 255, .45);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .6);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  max-width: calc(100% - 32px);
  z-index: 10;
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
