:root {
  --bg: #d7f7f8;
  --paper: #ffffff;
  --ink: #222222;
  --muted: #666666;
  --line: #d5d5d5;
  --header: #ffcf4a;
  --accent: #2fbec7;
  --accent-dark: #14959c;
  --danger: #9a9a9a;
  --peach: #ffe2bf;
  --weekend: #eef6ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 18px 10px 36px;
}

.app-header {
  text-align: center;
  padding: 8px 0 20px;
}

.app-header h1 {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  color: #255a64;
  font-size: clamp(2rem, 9vw, 4rem);
  line-height: 1.15;
  font-weight: 900;
  letter-spacing: 0;
}

.brand-drop {
  width: clamp(30px, 8vw, 48px);
  height: clamp(30px, 8vw, 48px);
  object-fit: contain;
  transform: translateY(0.04em);
  flex: 0 0 auto;
}

.brand-mark {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: clamp(54px, 15vw, 86px);
  height: clamp(54px, 15vw, 86px);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: inset 0 -4px 0 rgba(47, 190, 199, 0.2), 0 3px 0 rgba(37, 90, 100, 0.12);
  flex: 0 0 auto;
}

.brand-book {
  position: absolute;
  width: 56%;
  height: 62%;
  border: 4px solid #2fbec7;
  border-radius: 7px;
  background: linear-gradient(90deg, #f9ffff 0 48%, #e6f8fa 48% 52%, #f9ffff 52%);
  transform: rotate(-4deg);
}

.brand-book::before,
.brand-book::after {
  content: "";
  position: absolute;
  left: 13%;
  right: 13%;
  height: 3px;
  border-radius: 999px;
  background: #a9dce2;
}

.brand-book::before {
  top: 30%;
}

.brand-book::after {
  top: 54%;
}

.brand-moon {
  position: absolute;
  right: 14%;
  top: 13%;
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: #ffd76b;
  box-shadow: -7px 0 0 #ffffff;
}

.view.hidden {
  display: none;
}

.toolbar,
.actions,
.bottom-actions,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 12px 0;
  flex-wrap: wrap;
}

.month-picker,
.date-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.week-label {
  min-width: min(68vw, 420px);
  padding: 10px 14px;
  border-radius: 8px;
  background: #ffffff;
  color: #255a64;
  font-weight: 900;
  text-align: center;
  box-shadow: inset 0 -3px 0 rgba(47, 190, 199, 0.16);
}

select,
input {
  border: 2px solid #cfcfd3;
  border-radius: 7px;
  background: #f4f4f7;
  min-height: 46px;
  padding: 6px 10px;
}

input {
  width: 100%;
  background: white;
  text-align: center;
}

.icon-button {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 2rem;
  line-height: 1;
  box-shadow: 0 4px 0 var(--accent-dark);
}

.primary-button,
.secondary-button,
.cloud-button,
.danger-button {
  border: 0;
  border-radius: 8px;
  color: white;
  font-weight: 800;
  min-height: 54px;
  padding: 10px 18px;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.13);
}

.primary-button {
  background: var(--accent);
}

.secondary-button {
  background: #4c9fb4;
}

.cloud-button {
  background: #2fa866;
}

.danger-button {
  background: var(--danger);
}

.tooltip-wrap {
  position: relative;
  display: inline-flex;
}

.tooltip-pop {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  z-index: 20;
  width: max-content;
  max-width: min(72vw, 280px);
  padding: 9px 12px;
  border-radius: 8px;
  background: #255a64;
  color: #ffffff;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.45;
  text-align: left;
  box-shadow: 0 8px 18px rgba(37, 90, 100, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.tooltip-pop::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  border: 7px solid transparent;
  border-top-color: #255a64;
  transform: translateX(-50%);
}

.tooltip-wrap:hover .tooltip-pop,
.tooltip-wrap:focus-within .tooltip-pop,
.tooltip-wrap:active .tooltip-pop {
  opacity: 1;
  transform: translate(-50%, 0);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.backup-status {
  min-height: 1.6em;
  margin: 4px 0 12px;
  color: #28666d;
  font-weight: 700;
  text-align: center;
}

.table-wrap {
  overflow-x: auto;
  background: white;
  border: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
}

.diary-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  table-layout: fixed;
  background: white;
}

.weekly-table {
  min-width: 1320px;
}

.diary-table th,
.diary-table td {
  border: 1px solid var(--line);
  padding: 12px 10px;
  vertical-align: middle;
}

.diary-table th {
  background: var(--peach);
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
}

.diary-table td {
  min-height: 112px;
  font-size: 1rem;
}

.edit-col {
  width: 54px;
}

.date-cell {
  width: 88px;
  text-align: center;
  font-size: 1.2rem;
  white-space: nowrap;
}

.saturday {
  background: var(--weekend);
}

.sunday {
  background: #fff0f0;
}

.row-edit {
  width: 42px;
  height: 42px;
  border: 0;
  background: transparent;
  font-size: 1.6rem;
  color: #333333;
}

.inline-actions {
  display: grid;
  gap: 6px;
}

.save-small,
.cancel-small,
.delete-small {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 800;
}

.save-small {
  background: var(--accent);
}

.cancel-small {
  background: #8a9ca0;
}

.delete-small {
  background: #b16d6d;
}

.status-icon {
  display: grid;
  place-items: center;
}

.empty-status {
  color: #8a8a8a;
  font-weight: 800;
}

.drop-mark,
.sun-mark {
  position: relative;
  display: inline-block;
  width: 126px;
  height: 112px;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.drop-mark,
.drop-mark.is-active,
.picture-choice[data-value="yes"][aria-pressed="true"] .drop-mark {
  background-image: url("icon-wet.svg");
}

.sun-mark,
.sun-mark.is-active,
.picture-choice[data-value="no"][aria-pressed="true"] .sun-mark {
  background-image: url("icon-dry.svg");
}

.drop-mark::before,
.drop-mark::after,
.sun-mark::before,
.sun-mark::after {
  content: none;
}

.cell-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.cell-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}

.check-box {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 2px solid #333333;
  flex: 0 0 auto;
}

.check-box.checked::after {
  content: "✓";
  display: block;
  color: var(--accent-dark);
  font-weight: 900;
  line-height: 18px;
  text-align: center;
}

.weight-line {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 10px;
  padding-top: 4px;
  border-bottom: 2px solid #333333;
  font-size: 1.05rem;
}

.number-cell,
.time-cell {
  text-align: center;
  white-space: nowrap;
}

.status-checks {
  display: grid;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}

.status-checks span {
  display: grid;
  grid-template-columns: 3.2em 24px;
  gap: 4px;
  align-items: center;
  justify-content: start;
}

.inline-choice {
  display: grid;
  gap: 6px;
}

.inline-choice label,
.status-edit,
.inline-field {
  display: flex;
  gap: 6px;
  align-items: center;
  min-height: 34px;
}

.status-edit {
  display: grid;
  grid-template-columns: 3.2em 24px;
  justify-content: start;
}

.inline-field {
  margin-top: 8px;
}

.inline-field input,
.inline-field textarea {
  width: 100%;
  min-height: 38px;
  border: 2px solid #cfcfd3;
  border-radius: 6px;
  background: #ffffff;
  padding: 5px 8px;
}

.inline-field input[type="time"] {
  min-width: 110px;
}

.inline-field textarea {
  resize: vertical;
  font: inherit;
}

.weekly-title,
.weekly-count {
  background: #f7fbfb;
  font-size: 1.25rem;
  font-weight: 900;
  text-align: center;
}

.result-field {
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 900;
}

.result-field input {
  max-width: 96px;
}

.weekly-readonly input {
  background: #ffffff;
  color: var(--ink);
  opacity: 1;
}

.print-title {
  display: none;
}

.card {
  background: var(--paper);
  border-radius: 20px;
  margin: 18px 0;
  overflow: hidden;
}

.graph-header {
  display: grid;
  gap: 12px;
  justify-items: center;
  margin: 10px 0 14px;
}

.graph-header h2 {
  margin: 0;
  color: #255a64;
  font-size: clamp(1.35rem, 6vw, 2rem);
}

.graph-range-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(100%, 360px);
  padding: 4px;
  border: 2px solid #bfe9ed;
  border-radius: 10px;
  background: #ffffff;
}

.graph-range-toggle button {
  min-height: 44px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #28666d;
  font-weight: 800;
}

.graph-range-toggle button.is-active {
  background: var(--accent);
  color: #ffffff;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.12);
}

.graph-summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 14px 0;
}

.graph-summary article {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 74px;
  padding: 12px;
  border: 2px solid #d5eff1;
  border-radius: 8px;
  background: #ffffff;
}

.graph-summary span {
  color: #28666d;
  font-weight: 700;
}

.graph-summary strong {
  color: #116d79;
  font-size: 1.55rem;
  line-height: 1;
}

.summary-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #e8fbfc;
  color: var(--accent);
}

.graph-card,
.memo-card {
  border-radius: 8px;
  padding: 14px;
}

.graph-legend {
  display: flex;
  gap: 8px 14px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
  color: #315b61;
  font-size: 0.88rem;
  font-weight: 700;
}

.graph-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.graph-legend i {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

.legend-bar { background: #43c5c7; }
.legend-line { background: #2d72e8; }
.legend-dinner { background: #ff9f1c; }
.legend-bed { background: #7757c8; }
.legend-medicine { background: #42b86b; }

.graph-chart {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #d7ecef;
  border-radius: 8px;
}

.graph-chart svg {
  display: block;
  min-width: 880px;
  width: 100%;
  height: auto;
}

.axis-label,
.axis-number,
.small-time,
.date-label,
.row-label {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  fill: #42676c;
}

.axis-label,
.row-label {
  font-size: 16px;
  font-weight: 800;
}

.axis-number,
.small-time {
  font-size: 13px;
}

.date-label {
  font-size: 15px;
  font-weight: 700;
}

.medicine-check {
  fill: #ffffff;
  font-size: 14px;
  font-weight: 900;
}

.memo-card h2 {
  margin: 0 0 8px;
  color: #255a64;
  font-size: 1.25rem;
}

.memo-card ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 1.4em;
}

.memo-card li {
  color: #33494d;
}

.main-card {
  padding: 22px 14px 28px;
  text-align: center;
}

.main-card h2 {
  margin: 22px 0 20px;
  font-size: clamp(1.55rem, 7vw, 2.4rem);
  line-height: 1.35;
}

.wet-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.picture-choice {
  display: grid;
  justify-items: center;
  gap: 10px;
  border: 2px solid #9dc9f5;
  border-radius: 22px;
  background: linear-gradient(180deg, #f8fcff 0%, #eef8ff 100%);
  min-height: 184px;
  padding: 16px 10px 14px;
  font-weight: 700;
  color: var(--ink);
  box-shadow: 0 4px 0 rgba(45, 114, 232, 0.08);
}

.picture-choice[data-value="no"] {
  border-color: #f0c94f;
  background: linear-gradient(180deg, #fffdf3 0%, #fff7d8 100%);
  box-shadow: 0 4px 0 rgba(214, 158, 0, 0.09);
}

.picture-choice > span:last-child {
  display: grid;
  place-items: center;
  min-width: 128px;
  min-height: 38px;
  padding: 4px 18px;
  border-radius: 999px;
  background: #2f88cf;
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15);
}

.picture-choice[data-value="no"] > span:last-child {
  background: #f0c43e;
  color: #5c4700;
}

.picture-choice[aria-pressed="true"] {
  outline: 4px solid rgba(47, 190, 199, 0.45);
  outline-offset: 2px;
  transform: translateY(1px);
}

.record-card h2 {
  margin: 0;
  padding: 18px;
  background: var(--header);
  color: white;
  text-align: center;
  font-size: clamp(1.35rem, 6vw, 2rem);
}

.form-row {
  display: grid;
  grid-template-columns: minmax(96px, 30%) 1fr;
  gap: 14px;
  align-items: center;
  min-height: 88px;
  padding: 18px 14px;
  border-bottom: 2px dotted #dddddd;
  font-size: 1.1rem;
}

.tall-row {
  align-items: start;
}

.input-unit {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.field-help {
  display: grid;
  gap: 6px;
}

.field-help small {
  color: #333333;
  font-size: 0.95rem;
  line-height: 1.55;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.segmented button {
  min-height: 58px;
  border: 0;
  border-radius: 12px;
  background: #cbcbcb;
  color: white;
  font-weight: 800;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12);
}

.segmented button.is-active {
  background: var(--accent);
}

.time-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.time-inputs select {
  width: 76px;
}

.pill-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.pill-group label {
  min-width: 0;
}

.pill-group input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pill-group span {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 48px;
  padding: 8px 6px;
  border-radius: 8px;
  background: #cbcbcb;
  color: white;
  font-weight: 800;
  text-align: center;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12);
}

.pill-group label:has(input:checked) span {
  background: var(--accent);
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr;
  width: min(100%, 560px);
  margin: 24px auto;
}

@media (min-width: 720px) {
  .app-shell {
    padding-inline: 24px;
  }

  .detail-form {
    width: min(100%, 820px);
    margin: 0 auto;
  }

  .drop-mark,
  .sun-mark {
    width: 160px;
    height: 120px;
  }

  .picture-choice {
    min-height: 230px;
    padding-top: 24px;
  }

  .picture-choice > span:last-child {
    min-width: 156px;
    min-height: 44px;
    font-size: 1.18rem;
  }

  .graph-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 430px) {
  .app-shell {
    padding-inline: 8px;
  }

  .month-picker select,
  .date-line select {
    width: 88px;
    padding-inline: 6px;
  }

  .date-line {
    gap: 4px;
  }

  .form-row {
    grid-template-columns: minmax(88px, 29%) 1fr;
    gap: 10px;
    padding-inline: 10px;
    font-size: 1rem;
  }

  .segmented {
    gap: 8px;
  }

  .segmented button {
    min-height: 54px;
    padding-inline: 6px;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 10mm;
  }

  body {
    background: white;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .no-print,
  .app-header,
  #detail-view {
    display: none !important;
  }

  #list-view,
  .view.hidden {
    display: block !important;
  }

  #graph-view {
    display: none !important;
  }

  .print-title {
    display: block;
    text-align: center;
    margin: 0 0 8mm;
  }

  .print-title h2 {
    margin: 0;
    font-size: 22pt;
  }

  .print-title p {
    margin: 2mm 0 0;
    font-size: 12pt;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
  }

  .diary-table {
    min-width: 0;
    width: 100%;
    font-size: 9pt;
  }

  .diary-table th,
  .diary-table td {
    padding: 4mm 2mm;
  }

  .diary-table td {
    min-height: auto;
  }

  .drop-mark,
  .sun-mark {
    width: 15mm;
    height: 15mm;
    border-width: 2px;
  }

  .drop-mark::before,
  .drop-mark::after,
  .sun-mark::before,
  .sun-mark::after {
    display: none;
  }
}
