:root {
  color-scheme: light;
  --canvas: #f4f6f3;
  --page: #fff;
  --ink: #223a30;
  --soft: #52655a;
  --line: #dce6df;
  --brand: #1f5742;
  --head: #edf5ed;
  --color-a: #237348;
  --color-b: #1555a3;
  --color-c: #79429a;
  --color-d: #b04510;
  --color-e: #ac2f65;
  --color-f: #007578;
  --color-g: #a87d0b;
  --color-h: #4f6278;
  --chip-ink: #fff;
  --gold-ink: #18170c;
  --open: #fbeec5;
  --task-accent: #874909;
  --task-fill: #ffe5af;
  --task-ink: #613400;
  --error: #8a3229;
  font: 16px/1.4 system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #182019;
  --page: #202823;
  --ink: #eaf4ed;
  --soft: #b7c8bd;
  --line: #3c4b40;
  --brand: #b8eac8;
  --head: #28392c;
  --color-a: #64c18b;
  --color-b: #75b5ff;
  --color-c: #ca9ef7;
  --color-d: #ffa15d;
  --color-e: #fb97c1;
  --color-f: #4accc4;
  --color-g: #eac34c;
  --color-h: #a1b3c9;
  --chip-ink: #132019;
  --gold-ink: var(--chip-ink);
  --open: #534827;
  --task-accent: #ffd17d;
  --task-fill: #684711;
  --task-ink: #ffedca;
  --error: #ffb4a7;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; padding: 24px 10px; }
main {
  width: min(100%, 470px);
  margin-inline: auto;
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
}
header { padding: 16px 15px 14px; background: var(--head); }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.25rem, 5.5vw, 1.55rem); line-height: 1.2; letter-spacing: -.035em; }
h2 { font-size: 1.08rem; }
button, input, textarea, select { font: inherit; color: inherit; }
button { min-height: 44px; cursor: pointer; }
button:disabled { cursor: default; opacity: .65; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.plan-head, .guidance { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.identity { display: flex; align-items: center; gap: 10px; }
.plan-tools { display: flex; align-items: center; gap: 6px; }
.plan-mark { display: block; width: 42px; height: 42px; flex: none; border-radius: 10px; }
.home { display: grid; place-items: center; flex: none; min-width: 44px; padding: 0; border: 0; border-radius: 10px; background: transparent; }
.home:focus-visible { outline-offset: 2px; }
.quiet, .weeks button { background: transparent; color: var(--brand); border: 0; }
.quiet { padding-inline: 4px; font-size: .85rem; }
.icon { display: inline-block; width: 20px; height: 20px; flex: none; vertical-align: middle; pointer-events: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; padding: 0; margin: -1px; border: 0; }
.quiet, .primary, .secondary, .section-heading { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.section-heading { justify-content: flex-start; }
.icon-only, #password-visibility { min-width: 44px; padding-inline: 8px; }
.plan-tools button { border: 1px solid var(--line); border-radius: 10px; background: var(--page); }
#settings-button { padding-inline: 10px; font-weight: 600; }
#settings-button .icon { width: 22px; height: 22px; }
.icon-only { border-radius: 7px; }
@media (hover: hover) {
  .plan-tools button:hover, .quiet.icon-only:hover { background: var(--head); box-shadow: inset 0 0 0 1px currentColor; }
}
.weeks { display: grid; grid-template-columns: 46px 1fr 46px; align-items: center; text-align: center; border-bottom: 1px solid var(--line); }
.weeks button { display: grid; place-items: center; }
.weeks .icon { width: 22px; height: 22px; }
.weeks strong { font-size: .95rem; }
table { border-collapse: collapse; table-layout: fixed; width: 100%; }
.day-column { width: clamp(2.5rem, 10.75vw, 3rem); }
th, td { padding: 0; text-align: center; border-bottom: 1px solid var(--line); }
thead th { padding: 8px 0; font-size: .8rem; font-weight: 550; color: var(--soft); }
thead th:not(:first-child) { padding: 0; vertical-align: top; }
thead button { width: 100%; padding: 5px 0; display: flex; flex-direction: column; align-items: center; gap: 1px; border: 0; background: transparent; color: var(--brand); font-weight: 650; }
thead button > .icon { width: 19px; height: 19px; }
thead .daily-badge { display: inline-flex; align-items: center; gap: 2px; margin-top: 2px; background: var(--head); color: var(--brand); border-radius: 3px; padding: 1px 3px; font-size: .7rem; line-height: 1.25; }
thead .daily-badge .icon, .task-badge .icon { width: 12px; height: 12px; }
tbody th { font-size: .92rem; }
.has-tasks .day-name { padding-inline: 3px; border-radius: 4px; background: var(--task-fill); color: var(--task-ink); }
.day-date { display: block; color: var(--soft); font-size: .75rem; font-weight: 500; line-height: 1.2; font-variant-numeric: tabular-nums; letter-spacing: -.015em; white-space: nowrap; }
.today-label { display: none; }
.is-today > th, .is-today > td {
  background: var(--head);
  box-shadow: inset 0 2px var(--brand), inset 0 -2px var(--brand);
}
.is-today > th { padding-block: 4px; color: var(--brand); }
.is-today .today-label { display: block; font-size: .75rem; font-weight: 700; line-height: 1.2; }
.slot { width: 100%; padding: 0 2px; background: transparent; border: 0; font-size: clamp(1.125rem, 5.55vw, 1.5rem); font-weight: 650; line-height: 1.2; }
.name { display: inline-block; border-radius: 6px; max-width: 100%; padding: 5px 3px; overflow-wrap: anywhere; }
.slot[data-color]:not([data-color="-1"]) .name { width: 100%; }
.slot[data-color="-1"] .name { min-width: 2rem; color: var(--soft); font-weight: 800; }
.slot.name-compact { container-type: inline-size; }
.slot.name-compact .name {
  padding-inline: 1px;
  font-size: clamp(.75rem, 3.85vw, 1.25rem);
  font-size: clamp(.75rem, 20cqi, 1.25rem);
  letter-spacing: -.035em;
}
.slot.name-long .name { font-size: clamp(.81rem, 3.8vw, 1.05rem); line-height: 1.12; overflow-wrap: anywhere; }
.slot.initial-only .name { min-width: 1.8rem; max-width: 2.2rem; }
[data-color="0"] { --person-fill: var(--color-a); }
[data-color="1"] { --person-fill: var(--color-b); }
[data-color="2"] { --person-fill: var(--color-c); }
[data-color="3"] { --person-fill: var(--color-d); }
[data-color="4"] { --person-fill: var(--color-e); }
[data-color="5"] { --person-fill: var(--color-f); }
[data-color="6"] { --person-fill: var(--color-g); --person-ink: var(--gold-ink); }
[data-color="7"] { --person-fill: var(--color-h); }
.name, .person-name { background: var(--person-fill, transparent); color: var(--person-ink, var(--chip-ink)); }
.slot[aria-expanded="true"] .name { outline: 2px solid var(--ink); outline-offset: 1px; }
.task-badge { display: none; }
.slot.has-task { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding-block: 2px; }
.slot.has-task .name { padding-block: 1px; }
.slot.has-task .task-badge { display: inline-flex; align-items: center; gap: 2px; padding: 1px 3px; border-radius: 3px; color: var(--task-ink); background: var(--task-fill); font-size: .75rem; font-weight: 750; line-height: 1.1; }
#today-gap {
  display: flex; align-items: center; gap: 8px; width: calc(100% - 24px); margin: 8px 12px 0;
  padding: 8px 10px; border: 1px solid var(--task-accent); border-radius: 8px;
  background: var(--open); color: var(--ink); text-align: left; font-size: .94rem; font-weight: 600;
}
#today-gap .icon { color: var(--task-accent); }
#today-gap .icon:last-child { margin-inline-start: auto; }
.guidance { padding: 9px 12px; flex-wrap: wrap; }
.guidance p, #feedback, #start-status { color: var(--soft); font-size: .85rem; }
#weekly-tasks, #daily-tasks { padding: 12px 14px; border-top: 1px solid var(--line); }
#task-list, #daily-list { list-style: none; margin: 5px 0 0; padding: 0; }
:is(#task-list, #daily-list) li { border-bottom: 1px solid var(--line); }
:is(#task-list, #daily-list) li:last-child { border: 0; }
:is(#task-list, #daily-list) button { width: 100%; position: relative; display: block; text-align: left; padding: 8px 23px 8px 0; border: 0; background: transparent; }
:is(#task-list, #daily-list) button::after { content: ""; position: absolute; top: 50%; right: 3px; width: 7px; height: 7px; border: solid var(--soft); border-width: 1.5px 1.5px 0 0; transform: translateY(-50%) rotate(45deg); }
#daily-list .task-date { color: var(--brand); }
.routine-note { white-space: pre-wrap; overflow-wrap: anywhere; padding: 8px 10px; background: var(--page); border-left: 3px solid var(--brand); font-size: .9rem; }
#routine-dialog, #settings-dialog { width: min(92%, 420px); max-height: 85vh; padding: 0; background: var(--page); color: var(--ink); border-radius: 14px; border: 1px solid var(--line); }
dialog::backdrop { background: rgb(0 0 0 / .42); }
#routine-help { font-size: .9rem; color: var(--soft); }
.task-date { display: block; color: var(--task-accent); font-size: .82rem; font-weight: 650; }
.task-text { display: block; white-space: pre-wrap; overflow-wrap: anywhere; }
#feedback:not(:empty), #start-status:not(:empty) { padding: 10px 14px; }
#start-retry { margin: 0 14px 14px; }
form { display: grid; gap: 6px; padding: 16px 14px; }
:is(#visit-dialog, #bulk-dialog) {
  width: min(92%, 430px); max-height: 90vh; max-height: 90dvh;
  padding: 0; overflow: hidden; background: var(--page); color: var(--ink);
  border: 1px solid var(--line); border-radius: 16px;
}
:is(#editor, #bulk-form) { display: flex; flex-direction: column; gap: 0; padding: 0; max-height: inherit; }
.visit-head, .visit-actions { flex: none; padding: 8px 16px; }
.visit-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--head); }
.visit-head h2 { margin: 0; outline: none; }
.visit-body { display: grid; gap: 6px; align-content: start; min-height: 0; padding: 12px 16px; overflow-y: auto; overscroll-behavior: contain; }
#person { margin: 0 0 4px; padding: 0; min-width: 0; border: 0; }
#person legend { padding: 0; margin-bottom: 6px; font-weight: 650; }
:is(#visit-people, #bulk-person) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
:is(#visit-people, #bulk-person) label {
  display: flex; align-items: center; gap: 7px; min-height: 46px;
  margin: 0; padding: 5px 10px; border: 2px solid var(--line); border-radius: 8px;
  font-size: 1.05rem; font-weight: 650; color: var(--ink); overflow-wrap: anywhere; cursor: pointer;
}
:is(#visit-people, #bulk-person) label[data-color] {
  background: var(--person-fill); color: var(--person-ink, var(--chip-ink)); border-color: transparent;
}
:is(#visit-people, #bulk-person) label:has(:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--page); }
:is(#visit-people, #bulk-person) label:has(:focus-visible) { outline: 2px solid var(--brand); outline-offset: 1px; }
:is(#visit-people, #bulk-person) input { flex: none; width: 18px; height: 18px; min-height: 0; margin: 0; padding: 0; accent-color: var(--brand); }
#visit-people .unassigned-choice { grid-column: 1 / -1; min-height: 44px; font-size: .95rem; font-weight: 500; }
.visit-actions { border-top: 1px solid var(--line); }
.visit-actions .primary { width: 100%; margin: 0; }
@media (max-width: 480px) {
  :is(#visit-dialog, #bulk-dialog) {
    inset: auto 0 0; margin: 0 auto; width: 100%; max-width: none; max-height: 96vh; max-height: 96dvh;
    border-radius: 16px 16px 0 0; border-bottom: 0;
  }
  .visit-actions { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
}
label { font-size: .88rem; color: var(--soft); }
label:not(:first-child), form h2 { margin-top: 3px; }
input, textarea, select { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 7px; background: var(--page); padding: 8px; font-size: 16px; }
.password-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
textarea { resize: vertical; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.primary, .secondary { border: 1px solid var(--line); padding: 8px 14px; border-radius: 7px; background: var(--page); }
.primary { color: var(--page); background: var(--brand); border-color: var(--brand); }
form .primary, form .actions { margin-top: 4px; }
.actions .primary { margin-top: 0; }
.notice { padding: 11px 14px; border-top: 1px solid var(--line); }
.notice button { margin-top: 6px; }
#conflict { margin-block: 4px; background: var(--open); border: 0; border-radius: 7px; }
#conflict fieldset { margin: 10px 0 0; padding: 0; min-width: 0; border: 0; }
#conflict legend { padding: 0; font-weight: 700; }
#conflict label { display: flex; gap: 8px; align-items: flex-start; padding: 6px; margin: 3px 0; min-height: 44px; border: 1px solid var(--line); border-radius: 6px; background: var(--page); }
#conflict label:has(:checked) { box-shadow: inset 0 0 0 2px var(--brand); }
#conflict input { width: 18px; height: 18px; min-height: 0; margin: 2px 0 0; flex: none; accent-color: var(--brand); }
#conflict strong { display: block; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); }
#save-state { font-size: .9rem; color: var(--soft); }
#save-state:empty { display: none; }
body.session-check dialog:not(#session-check-dialog), body.session-check dialog:not(#session-check-dialog)::backdrop { visibility: hidden; }
#session-check-dialog { width: min(90%, 24rem); padding: 16px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--page); }
#session-check-retry { margin-top: 10px; }
.notice p, .error { font-size: .9rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.error, #plan-error { color: var(--error); }
.error:empty, #start-status:empty, #feedback:empty { display: none; }
.settings-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 5px 14px; background: var(--head); }
.name-mode, .theme-mode { min-width: 0; margin: 14px; padding: 0; border: 0; }
.name-mode legend, .theme-mode legend, .settings-people h3 { padding: 0; margin: 0; font-size: 1rem; font-weight: 650; }
.theme-options { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.theme-options label {
  display: flex; flex: 1 0 auto; align-items: center; justify-content: center; gap: 5px;
  min-height: 44px; padding: 4px 6px; margin: 0; border: 1px solid var(--line);
  border-radius: 7px; color: var(--ink); font-size: .94rem; cursor: pointer;
}
.theme-options input { width: 16px; height: 16px; min-height: 0; margin: 0; padding: 0; accent-color: var(--brand); }
.theme-options label:has(:checked) { background: var(--head); border-color: var(--brand); }
.theme-options label:has(:focus-visible) { outline: 2px solid var(--brand); outline-offset: 1px; }
.name-mode label { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: 0; color: var(--ink); font-size: .97rem; }
.name-mode input { width: 20px; height: 20px; min-height: 0; margin: 0; padding: 0; accent-color: var(--brand); }
.settings-people { padding: 13px 14px 16px; border-top: 1px solid var(--line); }
#settings-footer { padding: 10px 14px; border-top: 1px solid var(--line); }
#settings-people { list-style: none; margin: 5px 0 12px; padding: 0; }
#settings-people li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 3px; padding-block: 3px; border-bottom: 1px solid var(--line); }
.person-name { width: fit-content; max-width: 100%; padding: 2px 6px; border-radius: 5px; font-weight: 650; overflow-wrap: anywhere; }
.remove-person { color: var(--error); }
#settings-editor { margin-top: 12px; padding: 12px; background: var(--head); border-radius: 8px; }
#settings-name-wrap { display: grid; gap: 4px; }
#settings-colors { min-width: 0; margin: 5px 0; padding: 0; border: 0; }
#settings-colors legend { padding: 0; font-size: .95rem; font-weight: 650; }
#settings-color-hint { color: var(--soft); font-size: .85rem; margin: 2px 0 7px; }
.color-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
.color-options label {
  display: flex; align-items: center; gap: 7px; min-height: 44px; margin: 0; padding: 5px 7px;
  border: 2px solid transparent; border-radius: 7px; background: var(--person-fill, var(--page));
  color: var(--ink); font-size: .92rem; font-weight: 550; cursor: pointer;
}
.color-options input { flex: none; width: 17px; height: 17px; min-height: 0; margin: 0; padding: 0; accent-color: var(--brand); }
.color-options label[data-color] { color: var(--person-ink, var(--chip-ink)); }
.color-options label:has(:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--page); }
.color-options label:has(:focus-visible) { outline: 2px solid var(--brand); outline-offset: 1px; }
#settings-color-auto { grid-column: 1 / -1; }
#settings-conflict { border: 0; background: var(--open); border-radius: 6px; }
#settings-status:not(:empty), #settings-error:not(:empty) { margin-top: 9px; font-size: .9rem; overflow-wrap: anywhere; }
#settings-removal { overflow-wrap: anywhere; }
#bulk-open { margin: 0 12px 12px; color: var(--brand); }
#bulk-week { margin-top: 2px; font-size: .9rem; color: var(--soft); }
#bulk-form .visit-body { gap: 13px; }
#bulk-form fieldset { position: relative; min-width: 0; margin: 0; padding: 0; border: 0; }
#bulk-form legend, #bulk-preview-heading { padding: 0; margin: 0 0 5px; font-size: 1rem; font-weight: 650; }
#bulk-form .bulk-days-legend { display: flex; justify-content: space-between; align-items: center; gap: 4px; width: 100%; margin: 0; }
#bulk-weekdays { padding-inline: 6px; font-weight: 600; }
.bulk-choices { display: grid; gap: 4px; }
#bulk-days { grid-template-columns: repeat(7, 1fr); }
#bulk-periods { grid-template-columns: repeat(4, 1fr); }
.bulk-choices label {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 0; min-height: 44px; margin: 0; padding: 3px 1px; cursor: pointer;
  color: var(--ink); border: 1px solid var(--line); border-radius: 7px; font-weight: 550;
}
.bulk-choices input { width: 16px; height: 16px; min-height: 0; margin: 0; padding: 0; accent-color: var(--brand); }
.bulk-choices label:has(:checked) { background: var(--head); border-color: var(--brand); }
.bulk-choices label:has(:focus-visible) { outline: 2px solid var(--brand); outline-offset: 1px; }
#bulk-preview-area { padding: 9px 10px; color: var(--ink); background: var(--head); border-radius: 8px; }
#bulk-summary, #bulk-preview { font-size: .9rem; }
#bulk-preview { padding: 0; margin: 5px 0 0; list-style: none; }
#bulk-preview li { display: grid; grid-template-columns: minmax(6rem, auto) 1fr; gap: 8px; padding: 3px 0; }
#bulk-error:not(:empty) { padding-bottom: 6px; }
@media (max-width: 355px) {
  #bulk-days { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 480px) {
  body { padding: 0; background: var(--page); }
  main { width: 100%; border: 0; border-radius: 0; }
}
