:root {
  color-scheme: light;
  --page-bg: #f3eadf;
  --page-bg-2: #efe0d4;
  --panel: #fffaf2;
  --ivory: #fff7e8;
  --wood: #6f4634;
  --wood-deep: #3f2920;
  --wood-soft: #8b5e49;
  --sakura: #e6aebc;
  --sakura-deep: #c98598;
  --leaf: #6f7d61;
  --line: #cfb5a4;
  --line-soft: #e2cfc1;
  --text: #2c211c;
  --muted: #715b50;
  --shadow: 0 9px 22px rgba(63, 41, 32, .14);
  --app-safe-top: min(var(--safe-area-inset-top, env(safe-area-inset-top, 0px)), 7dvh);
  --app-safe-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  --app-header-body: 42px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  color: var(--text);
  background:
    linear-gradient(135deg, var(--page-bg) 0%, var(--page-bg-2) 52%, #f8f0e8 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .12;
  background: repeating-linear-gradient(90deg, rgba(95, 59, 45, .11) 0 1px, transparent 1px 36px);
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { border: 0; cursor: pointer; }

.app-shell {
  position: relative;
  z-index: 1;
  height: 100svh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) 1px var(--app-safe-bottom);
  overflow: hidden;
}

.install-app-bar {
  position: relative;
  z-index: 35;
  width: min(100%, 560px);
  margin: 0 auto;
  padding: 7px 12px 0;
  background: linear-gradient(180deg, rgba(255,250,242,.98), rgba(255,250,242,.82));
}

.install-app-bar[hidden] { display: none; }

.app-header {
  position: relative;
  z-index: 50;
  min-height: calc(var(--app-safe-top) + var(--app-header-body));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(var(--app-safe-top) + 2px) 12px 4px;
  color: var(--ivory);
  background: linear-gradient(90deg, var(--wood-deep), var(--wood) 62%, var(--wood-soft));
  border-bottom: 1px solid #2f1e17;
  box-shadow: 0 3px 12px rgba(63, 41, 32, .22);
}

.app-header,
.app-header *,
.app-footer,
.app-footer * {
  touch-action: manipulation;
}

.app-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--sakura-deep), var(--ivory), var(--leaf), var(--sakura-deep));
  opacity: .9;
}

.app-brand { min-width: 0; display: flex; align-items: center; gap: 7px; }
.brand-image { width: 24px; height: 24px; flex: 0 0 24px; object-fit: contain; border-radius: 4px; background: rgba(255, 247, 232, .12); }
.app-header h1 { margin: 0; font-size: 16px; line-height: 1.05; letter-spacing: .07em; }
.brand-kicker { margin: 0; color: #f0d8cc; font-size: 8px; font-weight: 700; letter-spacing: .13em; line-height: 1; transform: translateY(-1px); }

.settings-menu-button {
  width: 27px;
  height: 25px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 4px 5px;
  border: 1px solid rgba(255, 247, 232, .28);
  border-radius: 4px;
  background: rgba(255, 247, 232, .1);
}
.settings-menu-button span { width: 100%; height: 2px; border-radius: 2px; background: var(--ivory); }
.settings-menu-button[aria-expanded="true"] { background: rgba(255, 247, 232, .24); }

.app-main {
  width: min(100%, 560px);
  min-height: 0;
  margin: 0 auto;
  padding: 9px 12px 18px;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

.install-app-button {
  width: 100%;
  min-height: 48px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 6px 9px;
  border: 1px solid #536a3f;
  border-radius: 4px;
  color: #fffef7;
  background: linear-gradient(90deg, #647c4d, #7d9561);
  text-align: left;
  box-shadow: 0 4px 10px rgba(63, 41, 32, .12);
}

.install-app-button:active { background: linear-gradient(90deg, #597043, #718858); }
.install-app-button > span:nth-child(2) { min-width: 0; display: grid; gap: 1px; }
.install-app-button strong { font-size: 12px; font-weight: 900; }
.install-app-button small { color: #edf4e8; font-size: 8px; line-height: 1.3; }
.install-app-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; color: #536a3f; background: #fffef7; font-size: 18px; font-weight: 900; }
.install-app-arrow { font-size: 20px; }

.install-guide {
  position: fixed;
  z-index: 120;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(43, 32, 27, .55);
  backdrop-filter: blur(3px);
}

.install-guide[hidden] { display: none; }
.install-guide-card { width: min(100%, 390px); padding: 16px; border: 1px solid var(--line); border-radius: 6px; color: var(--text); background: var(--panel); box-shadow: 0 18px 42px rgba(43, 32, 27, .28); }
.install-guide-card h2 { margin: 0 0 8px; color: var(--wood-deep); font-size: 17px; }
.install-guide-card p { margin: 0 0 13px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.install-share-button { width: 100%; min-height: 42px; border-radius: 4px; color: #fff; background: linear-gradient(90deg, #647c4d, #7d9561); font-size: 12px; font-weight: 900; }
.install-guide-close { width: 100%; min-height: 34px; margin-top: 6px; color: var(--muted); background: transparent; font-size: 10px; font-weight: 800; }

.view-card, .notification-card, .menu-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  box-shadow: var(--shadow);
}

.login-card { margin-top: 4vh; padding: 22px 18px; }
.section-heading h2 { margin: 0; color: var(--wood-deep); font-size: 22px; }
.section-heading p { color: var(--muted); font-size: 13px; }
.eyebrow { margin: 0 0 4px; color: var(--sakura-deep); font-size: 9px; font-weight: 900; letter-spacing: .15em; }
.login-form { display: grid; gap: 14px; margin-top: 20px; }
.login-form label { display: grid; gap: 5px; color: var(--wood-deep); font-size: 12px; font-weight: 800; }
.login-form input { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid #bda18f; border-radius: 3px; background: #fffef9; color: var(--text); font-size: 16px; outline: none; }
.login-form input:focus { border-color: var(--sakura-deep); box-shadow: 0 0 0 2px rgba(201, 133, 152, .2); }
.primary-button { min-height: 46px; border-radius: 3px; background: linear-gradient(180deg, #75503e, #55372b); color: var(--ivory); font-weight: 900; }
.primary-button:disabled { opacity: .55; }
.form-message { min-height: 18px; margin: -3px 0 0; color: #a82d3c; font-size: 12px; }

.welcome-row { min-height: 30px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 2px 7px; }
.welcome-row p { margin: 0; color: var(--wood-deep); font-size: 11px; font-weight: 800; }
.text-button { padding: 5px 7px; background: transparent; color: var(--muted); font-size: 10px; }

.menu-section { margin-bottom: 9px; overflow: hidden; }
.menu-section-title {
  min-height: 33px;
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 7px 10px;
  color: var(--ivory);
  background: linear-gradient(90deg, #5f3b2d, #765240);
  border-bottom: 1px solid var(--wood-deep);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .05em;
}
.menu-section-title::before { content: ""; width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: var(--sakura); box-shadow: 6px 0 0 #d89aaa, 3px 5px 0 #f0c9d1; }
.menu-section-title small { margin-left: auto; color: #f0d8cc; font-size: 9px; font-weight: 600; }
.menu-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 8px; background: linear-gradient(180deg, #fffaf2, #f9ede3); }
.report-section .menu-grid { gap: 0; padding: 0; }
.report-section .menu-card,
.record-section .menu-card,
.planned-section .menu-card {
  min-height: 36px;
  grid-template-columns: 13px minmax(0, 1fr) auto;
  gap: 4px;
  padding: 2px 7px;
  border-width: 0 0 1px;
  border-radius: 0;
  box-shadow: none;
}
.report-section .menu-card::before,
.record-section .menu-card::before,
.planned-section .menu-card::before {
  content: "";
  width: 7px;
  height: 9px;
  align-self: center;
  justify-self: center;
  border-radius: 70% 30% 65% 35%;
  background: #d89aaa;
  transform: rotate(35deg);
}
.report-section .menu-copy,
.record-section .menu-copy,
.planned-section .menu-copy { gap: 0; }
.report-section .menu-copy strong,
.record-section .menu-copy strong,
.planned-section .menu-copy strong { font-size: 13px; line-height: 1.1; }
.record-section .menu-grid { gap: 0; padding: 0; }
.record-section .menu-card:last-child { border-bottom-width: 0; }
.planned-section .menu-grid { gap: 0; padding: 0; }
.planned-section .menu-card:last-child { border-bottom-width: 0; }

.menu-card {
  position: relative;
  width: 100%;
  min-height: 51px;
  display: grid;
  grid-template-columns: 31px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  padding: 6px 7px;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  background: #fffdf8;
  color: var(--text);
  text-align: left;
  text-decoration: none;
  box-shadow: 0 3px 8px rgba(63, 41, 32, .07);
}
.menu-card:active { background: #f8ebe8; border-color: var(--sakura-deep); }
.menu-icon { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 3px; color: var(--ivory); background: var(--wood); font-size: 12px; font-weight: 900; }
.resident .menu-icon { background: #85624f; }
.staff .menu-icon { background: #64768c; }
.concern .menu-icon { background: #b16f54; }
.daily-goods .menu-icon { background: #7b8061; }
.patrol .menu-icon { background: #5f765b; }
.visit .menu-icon { background: #746083; }
.menu-copy { min-width: 0; display: grid; gap: 2px; }
.menu-copy strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; line-height: 1.2; }
.menu-copy small { color: var(--muted); font-size: 9px; }
.menu-arrow { color: var(--wood-soft); font-size: 18px; line-height: 1; }
.menu-end { display: inline-flex; align-items: center; gap: 3px; }
.unread-badge { color: var(--muted); font-size: 9px; font-weight: 700; line-height: 1; white-space: nowrap; }
.unread-badge[hidden] { display: none; }

.planned-section { opacity: .88; }
.planned-section > summary { list-style: none; cursor: pointer; }
.planned-section > summary::-webkit-details-marker { display: none; }
.planned-section > .menu-section-title::after { content: "+"; width: 20px; height: 20px; display: grid; place-items: center; margin-left: 3px; border: 1px solid rgba(255, 247, 232, .35); border-radius: 3px; color: var(--ivory); font-size: 14px; line-height: 1; }
.planned-section[open] > .menu-section-title::after { content: "−"; }
.menu-card.is-disabled { cursor: default; color: #8e7d73; background: #f4eee8; box-shadow: none; }
.menu-card.is-disabled .menu-icon { background: #a49387; }
.operation-link .menu-icon { background: #65794f; }
.planned-label { color: #9a867b; font-size: 8px; font-weight: 900; }
.main-site-button { width: 100%; min-height: 38px; display: flex; align-items: center; justify-content: space-between; padding: 7px 11px; border: 1px solid #536a3f; border-radius: 4px; background: linear-gradient(90deg, #647c4d, #7d9561); color: #fffef7; font-size: 11px; font-weight: 900; }
.post-form-button { width: 100%; min-height: 44px; display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 8px; margin-top: 8px; padding: 6px 10px; border: 1px solid #563224; border-radius: 4px; background: linear-gradient(90deg, #704532, #895c44); color: #fff8ee; text-decoration: none; box-shadow: 0 7px 16px rgba(63, 41, 32, .16); }
.post-form-button:active { background: linear-gradient(90deg, #7d4d37, #96674d); }
.post-form-icon { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 50%; background: #f8dfc8; color: #5f3b2d; font-size: 14px; }
.post-form-text { min-width: 0; }
.post-form-title { display: block; font-size: 13px; font-weight: 800; letter-spacing: .03em; }
.post-form-note { display: block; color: #ead8ca; font-size: 9px; line-height: 1.35; }
.post-form-arrow { color: #f6d8bf; font-size: 18px; line-height: 1; }

.settings-drawer {
  position: absolute;
  z-index: 45;
  top: calc(var(--app-safe-top) + var(--app-header-body));
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 12px calc(18px + env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(63, 41, 32, .32);
  backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-105%);
  pointer-events: none;
  transition: transform .22s ease, opacity .16s ease, visibility 0s linear .22s;
  will-change: transform, opacity;
}
.settings-drawer.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
  transition-delay: 0s;
}
.notification-card { width: min(100%, 560px); margin: 0 auto; padding: 11px; }
.notification-card-heading { min-height: 34px; display: flex; align-items: center; gap: 8px; }
.notification-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 3px; background: #f0ded1; color: var(--wood); font-size: 14px; font-weight: 900; }
.notification-card-heading h3 { margin: 0; color: var(--wood-deep); font-size: 14px; }
.drawer-close-button { margin-left: auto; padding: 5px 7px; border: 1px solid var(--line); border-radius: 3px; background: #fffdf8; color: var(--muted); font-size: 9px; font-weight: 800; }
.notification-status { margin: 5px 0 0 38px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.notification-settings-table { margin-top: 10px; overflow: hidden; display: grid; grid-template-columns: 70px minmax(0, 1fr); border: 1px solid var(--line-soft); border-radius: 3px; background: #fffdf8; }
.settings-group-label { display: grid; place-items: start center; padding-top: 16px; border-right: 1px solid var(--line-soft); background: #f0ded1; color: var(--wood-deep); font-size: 10px; font-weight: 900; }
.settings-group-label.individual, .settings-group-body.individual,
.settings-group-label.unread, .settings-group-body.unread { border-top: 1px solid var(--line-soft); }
.settings-group-label.individual, .settings-group-body.individual { transition: opacity .18s ease, filter .18s ease; }
.settings-group-label.individual.is-disabled, .settings-group-body.individual.is-disabled { opacity: .38; filter: grayscale(.35); }
.settings-group-body.individual.is-disabled { pointer-events: none; }
.settings-row { min-height: 47px; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px; padding: 7px 9px; border-bottom: 1px solid #eee1d8; cursor: pointer; }
.settings-row:last-child { border-bottom: 0; }
.settings-name { min-width: 0; font-size: 11px; font-weight: 800; }
.settings-state { color: #98877d; font-size: 8px; font-weight: 900; white-space: nowrap; }
.settings-row:has(.notification-toggle-input:checked) .settings-state { color: #67734f; }
.notification-toggle-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.notification-toggle { width: 47px; height: 27px; flex: 0 0 47px; padding: 3px; border-radius: 999px; background: #cfc2b9; box-shadow: inset 0 1px 3px rgba(63, 41, 32, .18); transition: background .18s ease; }
.notification-toggle span { display: block; width: 21px; height: 21px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(63, 41, 32, .25); transition: transform .18s ease; }
.notification-toggle-input:checked + .notification-toggle { background: var(--leaf); }
.notification-toggle-input:checked + .notification-toggle span { transform: translateX(20px); }
.notification-toggle-input:focus-visible + .notification-toggle { outline: 3px solid rgba(201, 133, 152, .25); }
.timing-row { grid-template-columns: minmax(0, 1fr) auto; }
.timing-choice { display: inline-flex; padding: 2px; border-radius: 4px; background: #eee4dd; }
.timing-choice button { min-width: 45px; min-height: 26px; padding: 4px 7px; border-radius: 3px; background: transparent; color: #88776d; font-size: 9px; font-weight: 900; }
.timing-choice button.is-active { background: #fffdf8; color: var(--wood); box-shadow: 0 1px 4px rgba(63, 41, 32, .16); }
.timing-note { margin: 0; padding: 5px 9px 8px; color: #9c8d84; font-size: 8px; line-height: 1.35; }
.notification-test-button { width: 100%; min-height: 36px; margin-top: 8px; border: 1px solid var(--line); border-radius: 3px; background: #f0ded1; color: var(--wood-deep); font-size: 10px; font-weight: 900; }
.notification-test-button:disabled { opacity: .45; }

.app-footer {
  position: relative;
  height: 1px;
  min-height: 1px;
  overflow: hidden;
  background: rgba(111, 70, 52, .28);
}

.app-safe-zone {
  position: relative;
  height: var(--app-safe-bottom);
  min-height: 0;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(90deg, var(--wood-deep), var(--wood) 62%, var(--wood-soft));
}

.app-safe-zone span {
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}
.in-app-banner { position: fixed; z-index: 80; top: calc(8px + env(safe-area-inset-top)); left: 10px; right: 10px; display: grid; gap: 2px; padding: 11px 13px; border: 1px solid #2f1e17; border-radius: 4px; background: rgba(63, 41, 32, .97); color: var(--ivory); box-shadow: 0 12px 32px rgba(0, 0, 0, .25); }
.in-app-banner span { color: #efd8cc; font-size: 11px; }

.visit-date-tools { display: flex; align-items: center; gap: 7px; }
.visit-month-picker { min-width: 0; flex: 1 1 auto; display: flex; align-items: center; gap: 5px; }
.visit-month-picker label { min-width: 0; display: flex; align-items: center; gap: 3px; color: var(--wood-deep); font-size: 11px; font-weight: 900; }
.visit-month-picker label:first-child { flex: 1 1 58%; }
.visit-month-picker label:last-child { flex: 1 1 42%; }
.visit-month-picker select { width: 100%; min-width: 0; height: 29px; padding: 0 5px; border: 1px solid var(--line); border-radius: 4px; background: #fffdf8; color: var(--wood-deep); font-size: 16px; font-weight: 900; }
.visit-line-a-button { min-height: 29px; flex: 0 0 auto; padding: 0 9px; border: 1px solid var(--line); border-radius: 4px; background: #f0ded1; color: var(--wood-deep); font-size: 10px; font-weight: 900; }
.visit-line-a-button:disabled { cursor: default; opacity: .68; }
.visit-record-filter-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.visit-record-mode-choice { display: inline-flex; align-items: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 900; }
.visit-record-mode-choice button, .visit-unfilled-button { min-height: 27px; padding: 0 10px; border: 1px solid var(--line); border-radius: 4px; background: #fffdf8; color: var(--wood); font-size: 10px; font-weight: 900; }
.visit-record-mode-choice button.is-active, .visit-unfilled-button.is-active { border-color: var(--leaf); background: var(--leaf); color: var(--ivory); }
[hidden] { display: none !important; }

@media (min-width: 700px) {
  .app-main { padding-top: 14px; }
  .login-card { margin-top: 3vh; }
}
