/* 保護者お当番ヘルパー — mobile-first */
:root {
  --bg: #f4f7f5;
  --surface: #ffffff;
  --text: #1a2e28;
  --muted: #5a6f68;
  --primary: #1a5f4a;
  --primary-press: #134738;
  --accent: #e8f5f0;
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --border: #d0ddd7;
  --radius: 12px;
  --tap: 48px;
  --shadow: 0 2px 8px rgba(26, 95, 74, 0.08);
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP",
    "Yu Gothic", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px 120px;
}

.header {
  padding: 8px 0 12px;
}

.title {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--primary);
}

.subtitle {
  margin: 4px 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  background: var(--surface);
  padding: 6px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.tab {
  flex: 1;
  min-height: var(--tap);
  border: none;
  border-radius: 10px;
  background: transparent;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tab.is-active {
  background: var(--primary);
  color: #fff;
}

.panel[hidden] {
  display: none !important;
}

/* Fields */
.field {
  display: block;
  margin-bottom: 16px;
}

.field-inner {
  display: block;
  margin-bottom: 12px;
}

.field-row {
  display: flex;
  gap: 12px;
}

.field-half {
  flex: 1;
  min-width: 0;
}

.label {
  display: block;
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 6px;
}

.sublabel {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.req {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--danger);
  background: var(--danger-bg);
  padding: 2px 6px;
  border-radius: 4px;
  vertical-align: middle;
}

.note {
  margin: -8px 0 14px;
  font-size: 0.85rem;
  color: var(--muted);
}

input[type="text"],
input[type="number"],
input[type="date"],
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  font-family: inherit;
  font-size: 1.05rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
}

input[type="date"] {
  min-height: var(--tap);
  font-size: 1.1rem;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 95, 74, 0.2);
}

input.is-invalid,
textarea.is-invalid,
.slot-list.is-invalid {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.slot-list.is-invalid {
  border: 2px solid var(--danger);
  border-radius: 10px;
  padding: 4px;
  background: var(--danger-bg);
}

.hint {
  display: block;
  margin-top: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--danger);
}

.hint[hidden] {
  display: none !important;
}

textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.6;
}

/* Slot radios */
.slot-fieldset {
  margin: 0 0 12px;
  padding: 0;
  border: none;
}

.slot-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slot-option {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap);
  padding: 10px 14px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  font-size: 1.05rem;
}

.slot-option:has(input:checked) {
  border-color: var(--primary);
  background: var(--accent);
}

.slot-option input[type="radio"] {
  width: 22px;
  height: 22px;
  min-width: 22px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.slot-label {
  flex: 1;
  font-weight: 600;
  line-height: 1.35;
}

#other-time-wrap[hidden] {
  display: none !important;
}

/* Injury */
.injury-toggle {
  margin-bottom: 8px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap);
  padding: 4px 0;
  cursor: pointer;
  font-size: 1.05rem;
  -webkit-tap-highlight-color: transparent;
}

.check-row input[type="checkbox"] {
  width: 24px;
  height: 24px;
  min-width: 24px;
  accent-color: var(--primary);
  cursor: pointer;
}

.injury-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

.injury-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
}

.injury-row-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.injury-row input {
  min-height: var(--tap);
}

.btn-remove-injury {
  align-self: flex-end;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 8px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--danger);
  cursor: pointer;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 12px 20px;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow);
}

.btn-primary:active {
  background: var(--primary-press);
}

.btn-secondary {
  width: 100%;
  background: var(--accent);
  color: var(--primary);
  border: 2px solid var(--primary);
  margin-bottom: 8px;
}

.btn-secondary.btn-sm {
  width: auto;
  margin-bottom: 0;
  padding: 8px 14px;
  min-height: var(--tap);
  font-size: 0.95rem;
  white-space: nowrap;
}

.btn-ghost {
  background: transparent;
  color: var(--primary);
  font-size: 0.95rem;
  text-decoration: underline;
  padding: 8px 12px;
  min-height: var(--tap);
}

.btn-lg {
  font-size: 1.15rem;
  min-height: 56px;
}

.actions {
  margin-top: 20px;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 20%);
  z-index: 5;
}

.status {
  min-height: 1.5em;
  margin: 10px 0 0;
  text-align: center;
  font-weight: 700;
  color: var(--primary);
  font-size: 1rem;
}

.status.is-error {
  color: var(--danger);
}

/* History */
.history-section {
  margin-top: 28px;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.history-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}

.history-note {
  margin: 0 0 12px;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-list:empty + .history-empty {
  display: block;
}

.history-empty {
  display: none;
  margin: 8px 0 0;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
}

.history-empty.is-visible {
  display: block;
}

.history-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
}

.history-item-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.history-item-label {
  font-weight: 700;
  font-size: 1rem;
  word-break: break-word;
}

.history-item-time {
  font-size: 0.85rem;
  color: var(--muted);
}

.history-item .btn-recopy {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 16px;
  border: 2px solid var(--primary);
  border-radius: 10px;
  background: var(--accent);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
}

/* Attendance */
.attend-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.attend-toolbar .note {
  margin: 0;
  flex: 1;
}

.roster-edit {
  margin-bottom: 16px;
  padding: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.roster-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.roster-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 2px solid transparent;
}

.roster-item.is-absent {
  border-color: #e8a87c;
  background: #fff8f0;
}

.roster-name {
  font-weight: 700;
  font-size: 1.1rem;
  padding: 4px 0;
}

.roster-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}

@media (min-width: 400px) {
  .injury-row-fields {
    flex-direction: row;
  }
  .injury-row-fields input {
    flex: 1;
  }
}
