:root {
  color-scheme: light;
  --forest-900: #173b2d;
  --forest-700: #214f3b;
  --forest-500: #3c7257;
  --forest-100: #e7efe9;
  --ink: #202a24;
  --muted: #68736d;
  --line: #d9ded9;
  --paper: #ffffff;
  --canvas: #f4f3ec;
  --warm: #efe7d7;
  --danger: #9c3d35;
  --nav-height: 70px;
  --timeline-height: 960px;
  font-family: "Yu Gothic UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--canvas);
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(33, 79, 59, 0.035) 1px, transparent 1px) 0 0 / 32px 32px,
    var(--canvas);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button:not(:disabled) {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #e2a94c;
  outline-offset: 2px;
}

.app-shell {
  width: 100%;
  max-width: 560px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 16px calc(var(--nav-height) + 40px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.72);
  border-inline: 1px solid rgba(33, 79, 59, 0.08);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 4px 14px;
}

.app-header h1,
.section-heading h2,
.sheet h2,
.placeholder-view h2 {
  margin: 0;
  color: var(--forest-900);
  font-weight: 750;
  letter-spacing: 0.01em;
}

.app-header h1 {
  font-size: 1.55rem;
}

.eyebrow,
.section-kicker {
  margin: 0 0 4px;
  color: var(--forest-500);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  font-size: 1.35rem;
}

.date-panel {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px auto;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--paper);
}

.date-heading {
  min-width: 0;
  text-align: center;
}

.date-main,
.date-sub {
  margin: 0;
}

.date-main {
  color: var(--forest-900);
  font-size: 1.05rem;
  font-weight: 750;
}

.date-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

.today-button,
.text-button {
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--forest-700);
  font-weight: 750;
}

.members-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  width: 100%;
  margin: 12px 0 22px;
  padding: 14px 16px;
  gap: 8px 12px;
  text-align: left;
  border: 1px solid #cfdad2;
  border-left: 4px solid var(--forest-500);
  background: #fbfdfb;
}

.members-panel .section-kicker {
  grid-column: 1;
}

.member-chips {
  display: flex;
  grid-column: 1;
  flex-wrap: wrap;
  gap: 7px;
}

.member-chip {
  display: inline-flex;
  min-height: 30px;
  padding: 4px 10px;
  align-items: center;
  border: 1px solid #c7d7cc;
  border-radius: 999px;
  background: var(--forest-100);
  color: var(--forest-900);
  font-size: 0.86rem;
  font-weight: 700;
}

.members-edit {
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: center;
  color: var(--forest-700);
  font-size: 0.82rem;
  font-weight: 750;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading h2 {
  font-size: 1.2rem;
}

.drag-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.77rem;
}

.timeline {
  position: relative;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  height: var(--timeline-height);
  user-select: none;
}

.time-labels {
  position: relative;
  height: 100%;
}

.time-label {
  position: absolute;
  right: 10px;
  color: var(--muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  transform: translateY(-50%);
}

.time-label:first-child {
  transform: none;
}

.time-label:last-child {
  transform: translateY(-100%);
}

.timeline-track {
  position: relative;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-top-color: #c7cec9;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(33, 79, 59, 0.12) 0,
      rgba(33, 79, 59, 0.12) 1px,
      transparent 1px,
      transparent 40px,
      rgba(33, 79, 59, 0.055) 40px,
      rgba(33, 79, 59, 0.055) 41px,
      transparent 41px,
      transparent 80px
    ),
    #fcfdfb;
  touch-action: pan-x pinch-zoom;
}

body.is-dragging {
  cursor: ns-resize;
}

.selection-range {
  position: absolute;
  z-index: 5;
  left: 7px;
  right: 7px;
  min-height: 40px;
  border: 2px dashed var(--forest-500);
  background: rgba(60, 114, 87, 0.19);
  pointer-events: none;
}

.selection-range span {
  position: absolute;
  top: 7px;
  left: 8px;
  padding: 3px 6px;
  background: var(--forest-900);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.work-card {
  position: absolute;
  z-index: 2;
  left: 8px;
  right: 8px;
  min-height: 44px;
  overflow: hidden;
  padding: 8px 10px 8px 14px;
  text-align: left;
  border: 1px solid rgba(23, 59, 45, 0.14);
  border-left: 4px solid var(--card-accent, var(--forest-500));
  background: var(--card-bg, var(--forest-100));
  box-shadow: 0 2px 6px rgba(31, 49, 39, 0.06);
}

.work-card:hover {
  border-color: rgba(23, 59, 45, 0.35);
}

.work-card[data-tone="harvest"] { --card-accent: #9b6b2f; --card-bg: #f6eddd; }
.work-card[data-tone="sakaki"] { --card-accent: #3f7054; --card-bg: #e7f0e9; }
.work-card[data-tone="mowing"] { --card-accent: #607a37; --card-bg: #edf2df; }
.work-card[data-tone="watering"] { --card-accent: #47798a; --card-bg: #e6f0f2; }
.work-card[data-tone="washing"] { --card-accent: #5d6688; --card-bg: #eceef5; }
.work-card[data-tone="break"] { --card-accent: #8a7660; --card-bg: #f1ede7; }

.card-title-row {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.card-symbol {
  display: inline-grid;
  width: 23px;
  height: 23px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 0.68rem;
  font-weight: 800;
  opacity: 0.72;
}

.card-task {
  overflow: hidden;
  font-size: 0.94rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-time {
  margin-left: auto;
  color: #48524c;
  font-size: 0.72rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.card-meta {
  display: block;
  overflow: hidden;
  margin: 5px 0 0 30px;
  color: #58645d;
  font-size: 0.73rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.add-work-button {
  display: flex;
  width: calc(100% - 54px);
  min-height: 50px;
  margin: 14px 0 0 54px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px dashed var(--forest-500);
  background: #f7faf7;
  color: var(--forest-700);
  font-weight: 800;
}

.bottom-nav {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  padding: 6px max(8px, calc((100vw - 560px) / 2)) env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.nav-item {
  display: flex;
  min-width: 0;
  min-height: 52px;
  padding: 4px 2px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.68rem;
}

.nav-item span {
  font-size: 1rem;
  line-height: 1;
}

.nav-item.is-active {
  color: var(--forest-700);
  font-weight: 800;
}

.placeholder-view {
  min-height: 60vh;
  padding: 72px 20px;
  text-align: center;
}

.placeholder-mark {
  display: grid;
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  place-items: center;
  border: 1px solid #c9d4cc;
  border-radius: 50%;
  background: var(--forest-100);
  color: var(--forest-700);
  font-weight: 800;
}

.placeholder-view p {
  color: var(--muted);
}

.settings-view {
  min-height: 60vh;
  padding: 44px 4px;
}

.settings-view h2 {
  margin: 0;
  color: var(--forest-900);
}

.settings-view > p:not(.section-kicker, .api-key-status, .form-note) {
  color: var(--muted);
}

.settings-view form {
  display: grid;
  margin-top: 24px;
  gap: 12px;
}

.settings-view input {
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--paper);
}

.api-key-status {
  margin: 14px 0;
  padding: 10px 12px;
  border-left: 3px solid var(--forest-500);
  background: var(--forest-100);
  color: var(--forest-900);
  font-size: 0.86rem;
}

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

.sheet {
  width: min(100%, 560px);
  max-width: none;
  max-height: min(86vh, 760px);
  margin: auto auto 0;
  padding: 0;
  overflow: visible;
  border: 0;
  background: transparent;
}

.sheet::backdrop {
  background: rgba(18, 35, 27, 0.46);
  backdrop-filter: blur(2px);
}

.sheet-card {
  max-height: min(86vh, 760px);
  padding: 10px 18px calc(22px + env(safe-area-inset-bottom));
  overflow-y: auto;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  background: var(--paper);
  box-shadow: 0 -8px 28px rgba(20, 42, 31, 0.15);
}

.sheet-handle {
  width: 42px;
  height: 4px;
  margin: 0 auto 12px;
  border-radius: 99px;
  background: #c5cbc7;
}

.sheet-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.sheet h2 {
  font-size: 1.25rem;
}

.member-options,
.compact-members {
  display: grid;
  gap: 8px;
}

.member-option {
  position: relative;
  display: flex;
  min-height: 48px;
  padding: 10px 12px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  background: #fff;
}

.member-option input {
  width: 20px;
  height: 20px;
  accent-color: var(--forest-700);
}

.form-note,
.optional {
  color: var(--muted);
  font-size: 0.78rem;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 50px;
  padding: 11px 16px;
  border: 1px solid transparent;
  font-weight: 800;
}

.primary-button {
  width: 100%;
  background: var(--forest-700);
  color: #fff;
}

.secondary-button {
  border-color: #c9d4cc;
  background: var(--forest-100);
  color: var(--forest-900);
}

.danger-button {
  border-color: #e1c5c1;
  background: #f7eeec;
  color: var(--danger);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.search-field {
  display: flex;
  height: 48px;
  margin-bottom: 16px;
  padding: 0 12px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: #fafbf9;
}

.search-field input {
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.field-label {
  display: block;
  margin: 0 0 7px;
  color: #445149;
  font-size: 0.82rem;
  font-weight: 800;
}

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

.task-option {
  display: flex;
  min-height: 54px;
  padding: 9px 11px;
  align-items: center;
  gap: 9px;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 750;
}

.task-option span,
.selected-task .card-symbol {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #9ab0a1;
  border-radius: 50%;
  color: var(--forest-700);
  font-size: 0.72rem;
  font-weight: 800;
}

.selected-task {
  display: flex;
  width: 100%;
  min-height: 54px;
  margin-bottom: 18px;
  padding: 10px 12px;
  align-items: center;
  gap: 10px;
  text-align: left;
  border: 1px solid #b8cabd;
  background: var(--forest-100);
  color: var(--forest-900);
  font-weight: 800;
}

.selected-task small {
  margin-left: auto;
  color: var(--forest-700);
}

.form-grid {
  display: grid;
  gap: 16px;
}

.form-grid label,
.form-grid fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
}

select {
  min-height: 48px;
  padding: 0 12px;
}

textarea {
  padding: 11px 12px;
  resize: vertical;
}

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

.compact-members .member-option {
  min-width: 0;
  justify-content: center;
  padding: 8px 5px;
}

.form-error {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--danger);
  background: #f8edeb;
  color: #7f302a;
  font-size: 0.84rem;
}

#work-form .primary-button {
  margin-top: 18px;
}

.detail-list {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  margin: 0;
  border-top: 1px solid var(--line);
}

.detail-list dt,
.detail-list dd {
  margin: 0;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line);
}

.detail-list dt {
  color: var(--muted);
  font-size: 0.82rem;
}

.detail-list dd {
  font-weight: 650;
}

.detail-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 18px;
}

.readonly-record {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
  gap: 8px;
}

.readonly-record div {
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #f7f8f6;
}

.readonly-record dt,
.readonly-record dd {
  margin: 0;
}

.readonly-record dt {
  color: var(--muted);
  font-size: 0.76rem;
}

.readonly-record dd {
  margin-top: 2px;
  font-weight: 750;
}

.readonly-date {
  grid-template-columns: 1fr;
}

.edit-time-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 14px 0 0;
  gap: 8px;
}

.edit-time-fields label {
  min-width: 0;
}

.edit-time-error {
  margin: 8px 0 16px;
}

.task-picker-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.edit-actions,
.delete-actions {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  margin-top: 18px;
  gap: 8px;
}

.edit-actions .primary-button {
  width: auto;
}

.delete-summary {
  margin-top: 4px;
}

.overwrite-summary {
  margin: 0 0 12px;
  color: var(--muted);
}

.overwrite-changes {
  display: grid;
  margin: 0;
  padding: 0;
  gap: 8px;
  list-style: none;
}

.overwrite-change {
  display: grid;
  padding: 10px 12px;
  gap: 2px;
  border-left: 3px solid var(--forest-700);
  background: var(--forest-100);
  font-size: 0.86rem;
}

.overwrite-change span {
  color: var(--muted);
}

.overwrite-actions {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  margin-top: 18px;
  gap: 8px;
}

.overwrite-actions .primary-button {
  width: auto;
}

.toast {
  position: fixed;
  z-index: 40;
  right: 16px;
  bottom: calc(var(--nav-height) + 16px + env(safe-area-inset-bottom));
  left: 16px;
  max-width: 420px;
  margin: 0 auto;
  padding: 12px 16px;
  text-align: center;
  border-radius: 4px;
  background: var(--forest-900);
  color: #fff;
  box-shadow: 0 8px 24px rgba(20, 42, 31, 0.2);
  font-weight: 750;
}

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

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

  .date-panel {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
  }

  .date-panel .icon-button {
    width: 44px;
    height: 44px;
  }

  .today-button {
    grid-column: 1 / -1;
    min-height: 36px;
    border-top: 1px solid #e4e7e4;
  }

  .card-meta {
    margin-left: 0;
  }

  .compact-members {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 700px) {
  .app-shell {
    margin-block: 24px 100px;
    min-height: calc(100vh - 48px);
    padding-inline: 24px;
    box-shadow: 0 12px 36px rgba(35, 52, 42, 0.08);
  }

  .bottom-nav {
    right: 50%;
    left: auto;
    width: 560px;
    padding-inline: 8px;
    transform: translateX(50%);
    border-inline: 1px solid var(--line);
  }

  .sheet {
    margin-bottom: 20px;
  }

  .sheet-card {
    border-bottom: 1px solid var(--line);
    border-radius: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
