/* colors: one block per theme, picked by <html data-theme="..."> */

:root, [data-theme="light"] {
  --bg: #fff;
  --fg: #1b1b1b;
  --label: #555;
  --muted: #777;
  --line: #ddd;
  --line-soft: #eee;
  --link: #1a4fa0;
  --btn: #f3f3f3;
  --btn-hover: #e8e8e8;
  --btn-line: #999;
  --input-line: #aaa;
  --primary: #1b1b1b;
  --primary-fg: #fff;
  --mark: #fff3b0;
  --hover: #f5f5f5;
  --blank: #fafafa;
  --err: #b3261e;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-text: Georgia, "Times New Roman", serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #000;
  --fg: #ececec;
  --label: #aaa;
  --muted: #888;
  --line: #333;
  --line-soft: #222;
  --link: #ececec;
  --btn: #161616;
  --btn-hover: #262626;
  --btn-line: #555;
  --input-line: #555;
  --primary: #ececec;
  --primary-fg: #000;
  --mark: #383838;
  --hover: #141414;
  --blank: #0a0a0a;
  --err: #ff7b72;
  color-scheme: dark;
}

[data-theme="terminal"] {
  --bg: #000;
  --fg: #33ff66;
  --label: #2bd158;
  --muted: #1f9e45;
  --line: #0f4d22;
  --line-soft: #0a3317;
  --link: #33ff66;
  --btn: #000;
  --btn-hover: #062b12;
  --btn-line: #1f9e45;
  --input-line: #1f9e45;
  --primary: #33ff66;
  --primary-fg: #000;
  --mark: #0d4a20;
  --hover: #04200d;
  --blank: #020d05;
  --err: #ff5f56;
  --font: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  --font-text: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  color-scheme: dark;
}
[data-theme="terminal"] ::selection { background: var(--fg); color: var(--bg); }
[data-theme="terminal"] input, [data-theme="terminal"] textarea { caret-color: var(--fg); }

/* base */

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 var(--font);
}

a { color: var(--link); }

h1, h2, h3 { font-weight: 600; line-height: 1.25; }

/* header */

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 20px;
  max-width: 880px;
  margin: 0 auto;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}
.site { font-weight: 700; color: inherit; text-decoration: none; margin-right: auto; }
.top nav a { margin-right: 14px; }
.top nav a[aria-current] { color: inherit; text-decoration: none; font-weight: 600; }
.top .who { color: var(--muted); font-size: 14px; }
.top select { width: auto; padding: 1px 4px; font-size: 14px; }

main { max-width: 880px; margin: 0 auto; padding: 16px 16px 60px; }

/* form bits */

button {
  font: inherit;
  color: inherit;
  padding: 5px 12px;
  border: 1px solid var(--btn-line);
  border-radius: 3px;
  background: var(--btn);
  cursor: pointer;
}
button:hover { background: var(--btn-hover); }
button:disabled { opacity: .6; cursor: default; }
button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
button.primary:hover { background: var(--primary); opacity: .85; }
button.link {
  border: 0;
  padding: 0;
  background: none;
  color: var(--link);
  text-decoration: underline;
  font-size: inherit;
}

input, textarea, select {
  font: inherit;
  color: inherit;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--input-line);
  border-radius: 3px;
  background: var(--bg);
}
select { padding: 5px 6px; }
textarea { resize: vertical; }

label { display: block; margin: 0 0 12px; }
label > span { display: block; font-size: 14px; color: var(--label); margin-bottom: 3px; }

.muted { color: var(--muted); }
.small { font-size: 14px; }
.err { color: var(--err); min-height: 1.5em; margin: 6px 0 0; }

/* login */

.narrow { max-width: 340px; padding-top: 12vh; }
.narrow h1 { font-size: 22px; margin: 0 0 20px; }

/* log page */

.monthbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 12px; }
.monthbar h1 { font-size: 20px; margin: 0 6px 0 0; min-width: 8.5em; }

.cal {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.cal > * { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cal .dow { font-size: 12px; color: var(--muted); padding: 3px 6px; }
.cal .blank { background: var(--blank); }
.cal button.day {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  min-height: 78px;
  padding: 3px 6px 5px;
  border-top: 0;
  border-left: 0;
  border-radius: 0;
  background: var(--bg);
  text-align: left;
  min-width: 0;
}
.cal button.day:hover { background: var(--hover); }
.cal button.day.sel { background: var(--mark); }
.cal .n { font-size: 13px; color: var(--muted); }
.cal .today .n { color: var(--fg); font-weight: 700; text-decoration: underline; }
.cal .line {
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal .ini { display: none; }

.totals { margin: 10px 0 0; font-size: 14px; color: var(--label); }
.totals span { margin-right: 18px; white-space: nowrap; }

.dayhead { font-size: 19px; margin: 32px 0 4px; }

.entry { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.entry .head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.entry .name { font-weight: 600; }
.entry .act { color: var(--label); }
.entry .tools { margin-left: auto; font-size: 14px; }
.entry .tools button { margin-left: 10px; }
.entry .note { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.entry .att { display: inline-block; margin-top: 4px; font-size: 14px; }

.entryform { max-width: 540px; margin-top: 22px; }
.entryform h3 { font-size: 16px; margin: 0 0 10px; }
.entryform .row { display: flex; gap: 12px; }
.entryform .row .hours { flex: 0 0 6.5em; }
.entryform .row .what { flex: 1; min-width: 0; }
.entryform .actions { display: flex; gap: 10px; align-items: center; }

/* searchable note picker in the entry form */
.lbl { display: block; font-size: 14px; color: var(--label); margin-bottom: 3px; }
.picker { position: relative; margin-bottom: 12px; }
.options {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  top: 100%;
  margin: 2px 0 0;
  padding: 3px 0;
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--input-line);
  border-radius: 3px;
}
.options li { padding: 5px 8px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.options li.active { background: var(--mark); }
.options li .d { color: var(--muted); font-size: 12px; margin-left: 8px; }
.options li.empty { color: var(--muted); cursor: default; }

.mynotes { margin-top: 34px; padding-top: 14px; border-top: 1px solid var(--line); }
.mynotes h3 { font-size: 16px; margin: 0 0 6px; }
.mynotes ul { margin: 6px 0 10px; padding-left: 20px; }

/* notes page */

.notes { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 28px; }
.filters { display: grid; gap: 6px; margin-top: 12px; }
.filters .two { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.filters input, .filters select { font-size: 14px; padding: 4px 6px; }
.notelist h3 { font-size: 13px; font-weight: 600; color: var(--muted); margin: 22px 0 0; }
.notelist .s {
  display: block;
  font-size: 12px;
  color: var(--label);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notelist ul { list-style: none; margin: 8px 0 0; padding: 0; }
.notelist a {
  display: block;
  padding: 6px 8px;
  margin: 0 -8px;
  border-radius: 3px;
  color: inherit;
  text-decoration: none;
}
.notelist a:hover { background: var(--hover); }
.notelist a.on { background: var(--mark); }
.notelist .t { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notelist .d { display: block; font-size: 12px; color: var(--muted); }

.back { display: none; margin-bottom: 10px; }

.editor .title {
  font-size: 24px;
  font-weight: 600;
  border: 0;
  border-radius: 0;
  padding: 2px 0;
}
.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  padding: 4px 0 10px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
  color: var(--muted);
}
.meta label { display: flex; align-items: center; gap: 6px; margin: 0; }
.meta input[type="date"], .meta select { width: auto; padding: 2px 4px; font-size: 14px; }
.editor .status { margin-left: auto; }
.editor .status.bad { color: var(--err); }
.editor .body {
  display: block;
  border: 0;
  border-radius: 0;
  padding: 14px 0;
  min-height: 60vh;
  resize: none;
  overflow: hidden;
  font: 18px/1.65 var(--font-text);
}
.editor .title:focus, .editor .body:focus { outline: none; }

.reader h1 { font-size: 24px; margin: 2px 0 4px; }
.reader .text {
  padding: 14px 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 18px/1.65 var(--font-text);
}

.pick { color: var(--muted); margin-top: 40px; }

@media (max-width: 720px) {
  .notes { grid-template-columns: minmax(0, 1fr); }
  body.editing .notelist { display: none; }
  body.editing .back { display: inline-block; }
  body:not(.editing) .pick { display: none; }
}

@media (max-width: 560px) {
  .cal button.day { min-height: 58px; padding: 2px 3px 4px; }
  .cal .line { font-size: 11px; }
  .cal .full { display: none; }
  .cal .ini { display: inline; }
  .cal .dow { padding: 3px 3px; }
  .monthbar h1 { min-width: 0; font-size: 18px; }
}
