:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, "Noto Sans JP", sans-serif;
  --green: #147a3d;
  --green-dark: #0e5b2d;
  --green-soft: #e9f5ed;
  --ink: #17231b;
  --muted: #607066;
  --line: #dce7df;
  --holiday: #bb2d3b;
  --saturday: #2d64b3;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(155deg, #edf7f0, #f8faf8 46%, #edf3ef);
  color: var(--ink);
}
button, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }
[hidden] { display: none !important; }

.shell {
  max-width: 860px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 16px max(36px, env(safe-area-inset-bottom));
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.brand img { width: 52px; height: 52px; border-radius: 14px; box-shadow: 0 5px 18px rgba(20,122,61,.2); }
.brand h1 { margin: 0; font-size: clamp(1.25rem, 4vw, 1.65rem); }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: .9rem; }
.print-button {
  display: none;
  min-height: 42px;
  margin-left: auto;
  border: 1px solid #b8c9bd;
  border-radius: 10px;
  padding: 0 17px;
  background: white;
  color: var(--green-dark);
  font-weight: 750;
  box-shadow: 0 4px 14px rgba(23,55,34,.08);
}
.print-button:hover, .print-button:focus-visible { background: var(--green-soft); outline: 2px solid var(--green); outline-offset: 2px; }
.print-context { display: none; }

.panel {
  background: rgba(255,255,255,.97);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 10px 34px rgba(23,55,34,.08);
}
.settings { padding: 18px; margin-bottom: 14px; }
.settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }
label { display: block; margin-bottom: 7px; font-size: .9rem; font-weight: 750; }
select { width: 100%; min-height: 48px; border: 1px solid #acbbb1; border-radius: 10px; padding: 0 12px; background: white; color: var(--ink); }
.notification-button { min-height: 48px; border: 0; border-radius: 10px; padding: 0 18px; background: var(--green); color: white; font-weight: 750; white-space: nowrap; }
.notification-button.secondary { background: #eef3ef; color: #24402e; border: 1px solid #ccd9cf; }
.notification-actions { display: flex; gap: 8px; }
.status { min-height: 1.4em; margin: 10px 0 0; font-size: .87rem; line-height: 1.45; color: var(--muted); }
.status.success { color: var(--green); font-weight: 700; }
.status.error { color: #b42318; font-weight: 700; }
.ios-guide { margin: 0 0 13px; padding: 12px 14px; border-radius: 10px; background: #fff8df; color: #674f00; font-size: .88rem; line-height: 1.55; }
.ios-guide strong { display: block; }

.calendar-panel { overflow: hidden; }
.calendar-toolbar { display: grid; grid-template-columns: 46px 1fr 46px; align-items: center; padding: 15px 16px; background: var(--green); color: white; }
.calendar-toolbar h2 { margin: 0; text-align: center; font-size: 1.15rem; }
.month-button { width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.5); border-radius: 50%; background: rgba(255,255,255,.12); color: white; font-size: 1.45rem; }
.weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekdays { border-bottom: 1px solid var(--line); background: #f7faf8; }
.weekdays span { padding: 9px 2px; text-align: center; color: var(--muted); font-size: .78rem; font-weight: 700; }
.weekdays span:first-child { color: var(--holiday); }
.weekdays span:last-child { color: var(--saturday); }
.day-spacer, .day-cell { min-height: 102px; border-right: 1px solid #e6ede8; border-bottom: 1px solid #e6ede8; }
.calendar-grid > :nth-child(7n) { border-right: 0; }
.day-cell { position: relative; display: flex; width: 100%; padding: 5px 6px 6px; flex-direction: column; align-items: stretch; justify-content: flex-start; border-top: 0; border-left: 0; background: white; color: var(--ink); text-align: left; vertical-align: top; }
.day-cell:hover, .day-cell:focus-visible { background: #f2f8f4; outline: 2px solid var(--green); outline-offset: -2px; }
.day-cell.today { background: #fffcef; }
.day-heading { display: flex; min-width: 0; min-height: 29px; align-items: flex-start; gap: 3px; }
.day-number { display: inline-flex; width: 28px; height: 28px; flex: 0 0 28px; align-items: center; justify-content: center; border-radius: 50%; font-size: 1rem; font-weight: 800; line-height: 1; }
.holiday-name { min-width: 0; overflow: hidden; padding-top: 5px; color: var(--holiday); font-size: .61rem; font-weight: 750; line-height: 1.15; text-overflow: ellipsis; white-space: nowrap; }
.day-cell.sunday .day-number { color: var(--holiday); }
.day-cell.holiday .day-number { color: var(--holiday); }
.day-cell.saturday .day-number { color: var(--saturday); }
.day-cell.today .day-number { background: var(--green); color: white; }
.items { display: grid; gap: 3px; margin-top: 1px; }
.item-label { display: block; overflow: hidden; padding: 3px 5px; border-radius: 5px; background: var(--green); color: white; font-size: .68rem; font-weight: 750; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.item-label.more-items { background: #e8eee9; color: var(--green-dark); }
.memo-mark { position: absolute; top: 8px; right: 6px; color: #a06400; font-size: .78rem; }
.empty-message { grid-column: 1 / -1; padding: 38px 20px; text-align: center; color: var(--muted); }
.legend { display: grid; gap: 8px; padding: 12px 16px 15px; color: var(--muted); font-size: .78rem; }
.legend-title { color: var(--ink); font-size: .82rem; }
.item-legend { display: flex; gap: 7px 14px; flex-wrap: wrap; }
.legend-item, .memo-legend { display: inline-flex; align-items: center; gap: 5px; }
.legend-swatch { width: 11px; height: 11px; flex: 0 0 11px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.memo-legend::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #c98b13; }

dialog { width: min(92vw, 480px); border: 0; border-radius: 17px; padding: 0; box-shadow: 0 24px 80px rgba(0,0,0,.28); }
dialog::backdrop { background: rgba(10,25,15,.48); backdrop-filter: blur(2px); }
.dialog-body { padding: 22px; }
.dialog-body h2 { margin: 0 0 4px; font-size: 1.2rem; }
.schedule-summary { margin: 0 0 17px; color: var(--green-dark); font-weight: 700; }
textarea { width: 100%; min-height: 118px; resize: vertical; border: 1px solid #acbbb1; border-radius: 10px; padding: 11px; line-height: 1.5; }
.counter { margin: 4px 0 0; color: var(--muted); text-align: right; font-size: .75rem; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 15px; }
.dialog-actions button { min-height: 45px; border-radius: 9px; font-weight: 750; }
.save-button { border: 0; background: var(--green); color: white; }
.close-button { border: 1px solid #ccd9cf; background: #f1f5f2; color: #24402e; }
.delete-button { grid-column: 1 / -1; border: 0; background: transparent; color: #b42318; }
.privacy { margin: 14px 4px 0; color: #68756c; font-size: .78rem; line-height: 1.55; }
.print-footer { display: none; }

@media (max-width: 620px) {
  .shell { padding-left: 10px; padding-right: 10px; }
  .settings-grid { grid-template-columns: 1fr; }
  .notification-actions { display: grid; grid-template-columns: 1fr; }
  .notification-button { width: 100%; }
  .day-spacer, .day-cell { min-height: 82px; }
  .day-cell { padding: 5px 3px 4px; }
  .item-label { padding: 2px 3px; font-size: .6rem; }
  .memo-mark { top: 6px; right: 3px; font-size: .68rem; }
}

@media (min-width: 768px) {
  .print-button { display: inline-flex; align-items: center; justify-content: center; }
}

@media print {
  @page { size: A4 portrait; margin: 0; }
  :root { color-scheme: light; }
  * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  body { min-height: auto; background: white; color: #111; }
  .shell { max-width: none; margin: 0; padding: 9mm 9mm 34mm; }
  .brand { margin-bottom: 5mm; }
  .brand img, .brand-tagline, .print-button, .settings, .month-button, .privacy, dialog { display: none !important; }
  .brand h1 { font-size: 18pt; }
  .print-context { display: block; margin-top: 2mm !important; color: #333 !important; font-size: 10pt !important; }
  .panel { border: 1px solid #999; border-radius: 0; box-shadow: none; }
  .calendar-panel { overflow: visible; break-inside: avoid; }
  .calendar-toolbar { display: block; padding: 3mm; background: white; color: #111; border-bottom: 1px solid #999; }
  .calendar-toolbar h2 { font-size: 14pt; }
  .weekdays { background: #f3f3f3; }
  .weekdays span { padding: 2mm 1mm; font-size: 8pt; }
  .day-spacer, .day-cell { min-height: 23mm; border-color: #aaa; }
  .day-cell { padding: 1mm 1.5mm 1.5mm; }
  .day-cell:hover, .day-cell:focus-visible { background: white; outline: none; }
  .day-cell.today { background: #fffcef; }
  .day-cell.today .day-number { background: transparent; color: #111; }
  .day-cell.today.sunday .day-number, .day-cell.today.holiday .day-number { color: var(--holiday); }
  .day-cell.today.saturday .day-number { color: var(--saturday); }
  .day-heading { min-height: 7mm; }
  .day-number { width: 7mm; height: 7mm; flex-basis: 7mm; font-size: 10pt; }
  .holiday-name { padding-top: 1.3mm; font-size: 6.5pt; }
  .item-label { padding: .7mm 1mm; font-size: 6.7pt; line-height: 1.1; white-space: normal; }
  .memo-mark { font-size: 7pt; }
  .legend { padding: 3mm; font-size: 8pt; }
  .print-footer {
    position: fixed;
    bottom: 7mm;
    left: 9mm;
    display: flex;
    align-items: center;
    gap: 3mm;
    color: #222;
    font-size: 7pt;
  }
  .print-footer img { width: 23mm; height: 23mm; }
  .print-footer strong, .print-footer span { display: block; }
  .print-footer strong { margin-bottom: 1mm; font-size: 8pt; }
}
