/*
 * Colors, text and the page layout. appearance.js chooses light or dark. Every color needs a value for both.
 * Every control is at least 44 points tall, which is Apple's smallest comfortable tap size.
 */

:root {
  color-scheme: dark;
  --background: #1c1d20;
  --card: #232428;
  --inset: #2c2e33;
  --raised: #3a3c42;
  --line: #34363c;
  --border: #43464d;
  --strong-border: #757a83;
  --text: #ececef;
  --soft-text: #a2a6ae;
  /* Green words and thin outlines. Filled shapes use done-fill, which is the same green in light and dark. */
  --done: #3cc47c;
  --done-fill: #3cc47c;
  --on-done: #10251a;
  --main: #c81e2b;
  --on-main: #ffffff;
  /* Selected things that are red, such as a date or a weekday. */
  --on-selected: #ececef;
  --current: #ff7078;
  --done-card: #173226;
  --chart: #3987e5;
  /* The split tag's words and line. The chart's blue is too faint for small words. */
  --split: #5b9df0;
  --late: #ccae68;
  --undo: #ececef;
  --on-undo: #1c1d20;
  --message: #c9cbd0;
  --switch-off: #5a5e67;
  --switch-knob: #ececef;
  --menu-line: #50535b;
  --unavailable: #62666e;
  --behind-dialog: rgb(0 0 0 / 60%);
  --drag-shadow: rgb(0 0 0 / 60%);
  --menu-shadow: none;
  --tap: 44px;
}

:root[data-theme='light'] {
  color-scheme: light;
  --background: #ffffff;
  --card: #f3f4f6;
  --inset: #ffffff;
  --raised: #e4e6ea;
  --line: #dfe2e7;
  --border: #c9ccd2;
  --strong-border: #7d828c;
  --text: #1c1d20;
  --soft-text: #5d626b;
  --done: #17753f;
  --on-selected: #ffffff;
  --current: #c81e2b;
  --done-card: #e6f6ec;
  --late: #80600f;
  --split: #1f66c1;
  --undo: #50555d;
  --on-undo: #ffffff;
  --message: #43474f;
  --switch-off: #8b9099;
  --switch-knob: #ffffff;
  --menu-line: #cfd3d9;
  --unavailable: #9a9ea6;
  --behind-dialog: rgb(0 0 0 / 40%);
  --drag-shadow: rgb(0 0 0 / 25%);
  --menu-shadow: 0 4px 18px rgb(0 0 0 / 25%);
}

/*
 * iPhone always draws a white clock and battery for this app, so light mode needs a darker strip behind them. Its height
 * comes from the iPhone, so it's 0 anywhere without that space. The thin line is inside it, so it's gone then too.
 */
:root[data-theme='light'] body::before {
  position: fixed;
  z-index: 10;
  inset: 0 0 auto;
  height: env(safe-area-inset-top);
  background: #50555d;
  box-shadow: inset 0 -1px 0 #9aa0a9;
  content: '';
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--background);
}

body {
  color: var(--text);
  font: 17px/1.3 -apple-system, system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

#app {
  height: 100dvh;
}

button,
input,
textarea {
  color: inherit;
  font: inherit;
}

button {
  min-height: var(--tap);
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  text-align: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:active {
  opacity: 0.75;
}

:focus-visible {
  outline: 3px solid var(--current);
  outline-offset: 2px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3,
strong {
  font-weight: 500;
}

h1 {
  font-size: 25px;
  overflow-wrap: anywhere;
}

h2 {
  font-size: 21px;
  overflow-wrap: anywhere;
}

h3 {
  font-size: 17px;
}

.soft {
  color: var(--soft-text);
}

.small {
  font-size: 15px;
}

.minor {
  color: var(--soft-text);
  font-size: 0.85em;
}

.page {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  height: 100%;
  margin: 0 auto;
  padding-top: env(safe-area-inset-top);
}

.page-header {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 64px;
  padding: 10px 20px;
}

.page-header h1:focus,
.bar-header h1:focus,
.page-body h1:focus {
  outline: none;
}

.header-actions {
  display: flex;
  flex: none;
  margin-right: -10px;
}

.bar-header {
  display: grid;
  flex: none;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 6px 16px;
}

.bar-header h1 {
  font-size: 18px;
  text-align: center;
}

.bar-header button {
  white-space: nowrap;
}

.bar-header .bar-end {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.under-header {
  flex: none;
  padding: 0 20px 10px;
  text-align: center;
}

.page-body > p.small {
  margin-bottom: 12px;
}

.page-body {
  flex: 1;
  min-height: 0;
  padding: 2px 16px 16px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.page-body.centered {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  text-align: center;
}

.page-footer {
  flex: none;
  padding: 8px 16px;
}

.page-footer:empty {
  display: none;
}

.page:not(.has-tabs) {
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.tab-bar {
  display: grid;
  flex: none;
  grid-template-columns: repeat(4, 1fr);
  padding: 4px 4px max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--card);
}

.tab-bar button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 52px;
  color: var(--soft-text);
  font-size: 14px;
}

.tab-bar button[aria-current='page'] {
  color: var(--current);
}

.progress {
  display: flex;
  flex: none;
  height: 6px;
  margin: 0 20px 12px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--line);
}

.progress span {
  height: 100%;
}

.progress .done {
  background: var(--done-fill);
}

.progress .skipped {
  background: var(--current);
}

@media (prefers-reduced-motion: no-preference) {
  .progress span {
    transition: width 0.2s;
  }
}
