:root {
  --bg: #f7f4ee;
  --surface: #ffffff;
  --surface-soft: #eef4ef;
  --ink: #242c28;
  --muted: #68736d;
  --line: #d9dfd8;
  --accent: #476b5f;
  --accent-strong: #294f44;
  --rose: #c9827a;
  --today: #d5453d;
  --danger: #9f4646;
  --shadow: 0 10px 24px rgba(36, 44, 40, 0.07);
  --radius: 8px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
  overflow-x: hidden;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 0;
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 760;
  padding: 10px 14px;
  touch-action: manipulation;
}

button:active {
  transform: translateY(1px);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(71, 107, 95, 0.28);
  outline-offset: 2px;
}

button.secondary,
.small-button,
.chip {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--accent-strong);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 8;
  border-bottom: 1px solid rgba(71, 107, 95, 0.14);
  background: rgba(247, 244, 238, 0.96);
  backdrop-filter: blur(18px);
  padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
}

.week-toolbar {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto 44px auto;
  align-items: center;
  gap: 8px;
  width: min(100%, 900px);
  margin: 0 auto;
}

.week-title {
  min-width: 0;
}

.month-label,
.section-label,
.date-label,
.save-status,
.message,
.quiet-note,
.helper-copy {
  margin: 0;
}

.month-label,
.section-label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 820;
  letter-spacing: 0;
  text-transform: uppercase;
}

.week-button {
  display: inline-flex;
  max-width: 100%;
  min-height: 44px;
  align-items: center;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 1.26rem;
  font-weight: 850;
  padding: 0;
  text-align: left;
}

.icon-button {
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 999px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 1.7rem;
  line-height: 1;
  padding: 0;
}

.today-jump,
.menu-button {
  min-height: 44px;
  border-radius: 999px;
  background: #ffffff;
  color: var(--accent-strong);
  box-shadow: inset 0 0 0 1px var(--line);
  padding: 8px 12px;
}

.menu-button {
  background: var(--accent);
  color: #ffffff;
  box-shadow: none;
}

.day-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  width: min(100%, 900px);
  margin: 10px auto 0;
}

.day-tab {
  display: grid;
  min-width: 0;
  min-height: 58px;
  align-content: center;
  gap: 2px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 6px 2px;
  text-align: center;
}

.day-tab.is-active {
  background: var(--ink);
  color: #ffffff;
}

.day-tab.is-today:not(.is-active) {
  color: var(--today);
}

.day-letter {
  display: block;
  font-size: 0.75rem;
  font-weight: 850;
  text-transform: uppercase;
}

.day-number {
  display: block;
  font-size: 1.28rem;
  font-weight: 820;
  line-height: 1;
}

.view-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  width: min(100%, 900px);
  margin: 10px auto 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  padding: 3px;
}

.view-tab {
  min-height: 44px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 8px 6px;
}

.view-tab.is-active {
  background: var(--accent);
  color: #ffffff;
}

.save-status {
  width: min(100%, 900px);
  min-height: 20px;
  margin: 7px auto 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 720;
}

.app-shell {
  width: min(100%, 900px);
  margin: 0 auto;
  padding: 14px 12px 30px;
}

.view-panel,
.theme-card,
.archive-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.view-panel {
  padding: 14px;
}

.view-heading,
.section-row,
.sheet-heading,
.archive-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.view-heading {
  margin-bottom: 10px;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.15;
}

h1 {
  margin-top: 3px;
  font-size: 1.42rem;
}

h2 {
  font-size: 1.02rem;
}

h3 {
  font-size: 1rem;
}

.date-label,
.quiet-note,
.helper-copy {
  color: var(--muted);
  font-weight: 700;
}

.date-label {
  text-align: right;
}

.helper-copy {
  margin-bottom: 12px;
  font-size: 0.92rem;
}

.subsection + .subsection {
  margin-top: 18px;
}

.theme-list,
.field-grid,
.overview-grid,
.archive-list,
.sheet-actions,
.archive-actions {
  display: grid;
  gap: 12px;
}

.theme-card {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.theme-card h2 {
  color: var(--accent-strong);
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 44px;
  border-radius: 999px;
  padding: 8px 12px;
}

.chip.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.field-grid,
.overview-grid {
  grid-template-columns: 1fr;
}

.field {
  display: grid;
  min-width: 0;
  gap: 6px;
  color: var(--ink);
  font-weight: 760;
}

.field span {
  font-size: 0.92rem;
}

.field .prompt {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 650;
}

input,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdfb;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  padding: 11px 12px;
}

input {
  min-height: 46px;
}

input[readonly] {
  color: var(--muted);
  background: #f8faf7;
}

textarea {
  min-height: 92px;
  overflow: hidden;
  resize: none;
}

.concept-field textarea {
  min-height: 150px;
}

.photo-section {
  display: grid;
  gap: 10px;
}

.small-button {
  min-height: 44px;
  padding: 8px 12px;
}

.text-button {
  justify-self: start;
  min-height: 44px;
  background: transparent;
  color: var(--danger);
  padding: 8px 0;
}

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

.photo-preview {
  display: grid;
  gap: 8px;
  margin: 0;
}

.photo-preview img {
  display: block;
  width: 100%;
  max-height: 380px;
  border-radius: var(--radius);
  object-fit: cover;
}

.photo-preview figcaption {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.archive-actions {
  grid-template-columns: 1fr;
  margin-bottom: 12px;
}

.archive-card {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.archive-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.archive-card-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.message {
  position: fixed;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  left: 12px;
  z-index: 30;
  width: min(calc(100% - 24px), 500px);
  min-height: 0;
  margin: 0 auto;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 28px rgba(36, 44, 40, 0.14);
  color: var(--danger);
  font-size: 0.84rem;
  font-weight: 820;
  padding: 10px 14px;
  text-align: center;
  transform: translateY(120%);
  transition: transform 180ms ease;
  pointer-events: none;
}

.message.is-visible {
  transform: translateY(0);
}

.message.is-success {
  color: var(--accent-strong);
}

.action-sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  align-items: end;
  background: rgba(35, 43, 39, 0.28);
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
}

.action-sheet[hidden] {
  display: none;
}

.sheet-panel {
  width: min(100%, 520px);
  margin: 0 auto;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 18px 45px rgba(35, 43, 39, 0.22);
  padding: 14px;
}

.sheet-heading {
  align-items: center;
  margin-bottom: 12px;
}

.sheet-actions {
  grid-template-columns: 1fr;
}

.danger-button {
  border: 1px solid rgba(159, 70, 70, 0.24);
  background: #ffffff;
  color: var(--danger);
}

.print-report {
  display: none;
}

@media (min-width: 680px) {
  .app-header {
    padding-right: 24px;
    padding-left: 24px;
  }

  .app-shell {
    padding: 22px 24px 34px;
  }

  .view-panel {
    padding: 18px;
  }

  .field-grid,
  .overview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field-wide,
  .concept-field {
    grid-column: 1 / -1;
  }

  .archive-actions,
  .sheet-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media print {
  @page {
    margin: 10mm;
  }

  html,
  body {
    background: #ffffff;
    color: #000000;
  }

  body {
    min-height: auto;
    padding: 0;
    font-size: 10.5pt;
  }

  .app-header,
  .message,
  .action-sheet,
  #reportForm {
    display: none !important;
  }

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

  .print-report {
    display: block;
  }

  .print-report h1 {
    margin-bottom: 2mm;
    font-size: 18pt;
  }

  .print-report h2 {
    margin: 4mm 0 2mm;
    border-bottom: 1px solid #cccccc;
    padding-bottom: 1mm;
    font-size: 12pt;
  }

  .print-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2mm 5mm;
  }

  .print-item,
  .print-day {
    break-inside: avoid;
  }

  .print-item strong {
    display: block;
    font-size: 9pt;
  }

  .print-item p {
    margin: 0;
    white-space: pre-wrap;
  }

  .print-photo {
    max-width: 80mm;
    max-height: 80mm;
    object-fit: contain;
  }
}
