:root {
  color-scheme: light;
  --ink: #19362f;
  --muted: #4d635d;
  --deep: #163f37;
  --green: #216455;
  --light: #e4f1ec;
  --page: #f1f6f4;
  --paper: #fff;
  --line: #ceddd7;
  --warning: #754015;
  --warning-bg: #fff1d9;
  --bar-height: 72px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--page); color: var(--ink); line-height: 1.55; }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  min-height: 44px;
  padding: .46rem .75rem;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: .65rem;
  font-weight: 650;
  cursor: pointer;
}
button:disabled { opacity: .55; cursor: default; }
.primary { background: var(--deep); border-color: var(--deep); color: white; }
:focus-visible { outline: 3px solid #329a82; outline-offset: 2px; }
h1, h2, p { margin-block-start: 0; }
h2 { font-size: 1.125rem; }
a { color: #165e50; }

.wrap { width: min(100%, 760px); margin-inline: auto; padding-inline: 12px; }
.top {
  position: sticky;
  z-index: 2;
  top: 0;
  background: var(--deep);
  color: white;
  padding-top: env(safe-area-inset-top);
}
.top-inner {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  align-items: center;
  gap: .4rem .35rem;
  padding-block: .65rem;
}
.identity, .top-actions, .sync-line { display: flex; align-items: center; gap: .4rem; }
.identity img { border-radius: .55rem; flex: 0 0 auto; }
.identity h1 { font-size: 1.08rem; margin: 0; word-break: keep-all; line-height: 1.2; }
.top-actions button {
  color: white;
  border-color: #65857a;
  background: transparent;
  padding-inline: .52rem;
  font-size: .9rem;
}
.sync-line { grid-column: 1 / -1; justify-content: space-between; font-size: .8rem; }
.view-tabs {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .35rem;
  margin-top: .18rem;
}
.view-tabs button { background: transparent; color: #e2f0e9; border-color: #65857a; }
.view-tabs [aria-selected="true"] { background: #e4f1ec; border-color: #e4f1ec; color: var(--deep); }
#last-sync { color: #e2f0e9; text-align: right; }
.status {
  flex: 0 0 auto;
  border-radius: 1rem;
  background: #d9e6e1;
  color: #213d35;
  padding: .12rem .55rem;
  font-size: .86rem;
  font-weight: 750;
}
.status[data-tone="good"] { background: #d6f2d4; color: #1e5235; }
.status[data-tone="warn"] { background: var(--warning-bg); color: var(--warning); }
.status[data-tone="error"] { background: #ffe1df; color: #832f2c; }
.menu {
  position: absolute;
  z-index: 3;
  top: 3.5rem;
  right: 12px;
  display: grid;
  padding: .4rem;
  gap: .25rem;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: .8rem;
  box-shadow: 0 8px 24px #17382e2b;
}
.menu button { text-align: left; }

main { padding-block: .8rem calc(var(--bar-height) + env(safe-area-inset-bottom) + 1rem); }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: .85rem; padding: .9rem; }
.login { display: grid; gap: .45rem; max-width: 390px; margin: 1rem auto 0; padding: 1.15rem; }
.login h2 { margin-bottom: .4rem; }
.login button { margin-top: .45rem; }
label { font-weight: 650; }
input:not([type="checkbox"]), select, textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: .55rem .65rem;
  background: white;
  border: 1px solid #a9bdb4;
  border-radius: .55rem;
}
.notice { margin: 0 0 .7rem; padding: .55rem .7rem; border-radius: .6rem; background: var(--light); overflow-wrap: anywhere; }
.note-tools { display: flex; justify-content: space-between; gap: .5rem; margin: 0 0 .55rem; }
.segments { display: flex; gap: 3px; padding: 3px; border-radius: .8rem; background: #dce9e3; }
.segments button { min-height: 38px; border: none; background: transparent; }
.segments [aria-pressed="true"] { background: white; color: var(--deep); }
.search, .toc, .conflict { margin-bottom: .65rem; }
.search { display: grid; gap: .45rem; }
.search-nav, .button-group { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
#result-count { margin-inline-end: auto; color: var(--muted); }
.toc { display: grid; gap: .18rem; max-height: 18rem; overflow: auto; }
.toc button { text-align: left; border: none; padding-inline: .55rem; overflow-wrap: anywhere; }
.toc button:hover { background: var(--light); }
.conflict { background: var(--warning-bg); border-color: #d6aa71; }
.conflict h2, .conflict p { margin-bottom: .45rem; }

.note { overflow-wrap: anywhere; padding-block: 1.1rem; }
.note p, .note pre, .note ul, .note ol { margin-block: 0 .6rem; }
.note ul, .note ol { padding-inline-start: 1.25rem; }
.note li { margin-block: .2rem; }
.note details { margin-block: .6rem; }
.note details:first-child { margin-block-start: 0; }
.note summary {
  padding: .44rem .2rem;
  color: var(--deep);
  font-size: 1.14rem;
  font-weight: 750;
  cursor: pointer;
  list-style-position: inside;
}
.note details details { margin-inline-start: .35rem; }
.note details details summary { font-size: 1.02rem; }
.note pre { padding: .65rem; background: var(--page); white-space: pre-wrap; }
.note .task-line { list-style: none; margin-inline-start: -1.25rem; }
.task-line label { display: flex; min-height: 42px; align-items: baseline; gap: .55rem; font-weight: inherit; }
input[type="checkbox"] { width: 1.15rem; height: 1.15rem; flex-shrink: 0; accent-color: var(--green); }
.task-done span { color: var(--muted); text-decoration: line-through; }
.note [data-line] { scroll-margin-top: 9.75rem; }
.search-hit { background: #ffebad; border-radius: .2rem; }
.search-current { outline: 2px solid #9c621a; outline-offset: 2px; }
.editor-panel { display: grid; gap: .5rem; }
textarea { resize: vertical; min-height: 13rem; font-family: Consolas, monospace; line-height: 1.5; }
#editor { min-height: max(15rem, 46vh); }
.editor-panel > button { justify-self: start; }

#schedule-days { display: grid; gap: .65rem; }
.schedule-day h2 { margin: 0 0 .45rem; }
.schedule-day h2 span { margin-inline-start: .2rem; color: var(--muted); font-size: .9rem; font-weight: 600; }
.schedule-day:last-child { margin-bottom: .35rem; }
.schedule-special {
  display: flex;
  align-items: baseline;
  gap: .55rem;
  margin: .3rem 0 .55rem;
  padding: .45rem .55rem;
  background: var(--light);
  border-radius: .5rem;
  overflow-wrap: anywhere;
}
.schedule-special strong { flex-shrink: 0; font-size: .86rem; color: var(--deep); }
.schedule-empty { color: var(--muted); margin-bottom: 0; }
.schedule-slots { list-style: none; margin: 0; padding: 0; }
.schedule-slots li {
  display: grid;
  grid-template-columns: 4.15rem minmax(0, 1fr);
  align-items: baseline;
  gap: .4rem;
  padding: .28rem 0;
  overflow-wrap: anywhere;
}
.schedule-slots li + li { border-top: 1px solid var(--line); }
.schedule-time { color: var(--green); font-weight: 750; font-variant-numeric: tabular-nums; }

.tasks {
  position: fixed;
  z-index: 1;
  bottom: 0;
  inset-inline: 0;
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  background: var(--paper);
}
.task-buttons { display: grid; grid-template-columns: 1fr 1fr .9fr; gap: .35rem; padding-block: .62rem; }
.task-buttons button { padding-inline: .3rem; word-break: keep-all; }
dialog {
  width: min(calc(100% - 20px), 470px);
  max-height: 90dvh;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: .9rem;
  padding: 1rem;
  overflow: auto;
}
dialog::backdrop { background: #14312bc0; }
dialog p { margin-bottom: .55rem; }
dialog form, .compare-columns, .compare-columns label { display: grid; gap: .5rem; min-width: 0; }
.choice { display: flex; align-items: center; min-height: 44px; gap: .4rem; font-weight: 400; }
.compare { width: min(calc(100% - 20px), 880px); }
.compare .button-group { margin-top: .65rem; }
.compare textarea { min-height: 8rem; }
#compare-warning { color: var(--warning); }

@media (min-width: 620px) {
  .wrap { padding-inline: 22px; }
  .identity h1 { font-size: 1.3rem; }
  .panel { padding-inline: 1.2rem; }
  .compare-columns { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
  .compare textarea { min-height: 19rem; }
}
