:root {
  --bg: #F0F2F5;
  --primary: #1B4D3E;
  --primary-dark: #143B30;
  --accent: #F28C28;
  --surface: #FFFFFF;
  --text: #111111;
  --text-secondary: #4F5653;
  --text-muted: #7A807D;
  --border: #D7DDE2;
  --powder: #FAFAF8;
  --mineral: #C9CED2;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "BIZ UDPGothic", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
body { touch-action: manipulation; }
button, input, select { font: inherit; }

.app {
  width: min(1220px, 100%);
  margin: 0 auto;
  min-height: 100vh;
  padding: 24px;
}
.header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  padding: 0 0 16px;
  border-bottom: 2px solid var(--primary);
}
.header__brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.header__mark { font-size: 1.25rem; }
.header__brand small {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.16em;
}
.header__meta {
  color: var(--text-muted);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-align: right;
}

.view { display: none; }
.view--active { display: block; animation: fadeIn 180ms ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}
.card {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto;
  justify-items: center;
  min-height: 268px;
  padding: 26px 22px 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  text-align: center;
  transition: transform 140ms ease-out, border-color 140ms ease-out, box-shadow 140ms ease-out;
}
.card:active {
  transform: scale(0.98);
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(17,17,17,0.08);
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
  border-radius: 8px 8px 0 0;
  background: var(--border);
}
.card--out { border-color: var(--accent); }
.card--out::before { background: var(--accent); }
.card--in { border-color: var(--primary); }
.card--in::before { background: var(--primary); }
.card--done { border-color: var(--mineral); }
.card--done::before { background: var(--mineral); }
.card--leave { border-color: var(--primary); }
.card--leave::before { background: var(--primary); }
.card__photo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(100%, 300px);
  aspect-ratio: 16 / 9;
  margin: 6px 0 18px;
  overflow: hidden;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--primary);
  font-family: "BIZ UDPMincho", serif;
  font-size: 2.75rem;
  font-weight: 700;
}
.card__photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}
.card__name {
  margin-bottom: 12px;
  color: var(--text);
  font-size: 1.375rem;
  font-weight: 700;
}
.card__status {
  min-width: 112px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 9999px;
  color: var(--text-muted);
  background: var(--bg);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1.2;
}
.card__status--out { border-color: var(--accent); color: var(--accent); background: var(--powder); }
.card__status--in { border-color: var(--primary); color: var(--surface); background: var(--primary); }
.card__status--done { border-color: var(--mineral); color: var(--text-secondary); background: var(--bg); }
.card__status--leave { border-color: var(--primary); color: var(--primary); background: var(--bg); }
.card__status--loading { border-color: var(--border); color: var(--text-muted); }
.home-loading {
  grid-column: 1 / -1;
  padding: 48px 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-secondary);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
}

.panel {
  padding: 40px 32px;
  border-top: 4px solid var(--primary);
  border-radius: 8px;
  background: var(--surface);
}
.panel__topbar {
  display: flex;
  justify-content: flex-start;
  margin: -16px 0 24px;
}
.panel-home-btn,
.subnav__btn,
.btn--ghost,
.btn--primary,
.calendar__nav {
  min-height: 44px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.panel-home-btn {
  min-width: 112px;
  padding: 12px 18px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--primary);
}
.panel-home-btn:active,
.subnav__btn:active,
.btn--ghost:active,
.calendar__nav:active { background: var(--bg); }
.panel__name {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0;
}
.panel__sub {
  margin: 0 0 32px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  letter-spacing: 0.04em;
}
.panel__sub--in { color: var(--primary); font-weight: 700; }
.action-btn {
  display: block;
  width: 100%;
  padding: 32px;
  border: 0;
  border-radius: 4px;
  background: var(--primary);
  color: var(--surface);
  cursor: pointer;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  transition: background 140ms ease-out, transform 80ms ease-out;
}
.action-btn:active:not(:disabled) { background: var(--primary-dark); transform: scale(0.99); }
.action-btn:disabled { background: var(--mineral); color: var(--text-muted); cursor: not-allowed; }
.action-btn--compact { padding: 24px; font-size: 1.25rem; }
.work-mode {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}
.work-mode[hidden], .leave-half-fields[hidden] { display: none; }
.work-mode__opt {
  flex: 1;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  text-align: center;
}
.work-mode__opt--active {
  border-color: var(--primary);
  background: var(--bg);
  color: var(--primary);
  font-weight: 700;
}
.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 40px;
}
.subnav__btn {
  flex: 1;
  min-width: 140px;
  padding: 14px 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--primary);
}
.subnav__btn--ghost { color: var(--text-muted); }

.edit__period {
  margin: -16px 0 24px;
  color: var(--text-muted);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
}
.table-wrap { overflow-x: auto; }
.edit__table {
  width: 100%;
  min-width: 780px;
  margin-top: 16px;
  border-collapse: collapse;
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface);
}
.edit__table th,
.edit__table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.9375rem;
}
.edit__table th {
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.edit__table tbody tr td:first-child { border-left: 4px solid transparent; }
.edit__table tr.row--editable { cursor: pointer; }
.edit__table tr.row--editable:active { background: var(--bg); }
.edit__table tr.row--leave td:nth-child(2),
.edit__table tr.row--leave td:nth-child(3),
.edit__table tr.row--leave td:nth-child(6) { color: var(--text-muted); }
.edit__table tr.row--mode-work td:first-child { border-left-color: var(--primary); }
.edit__table tr.row--mode-half-leave td:first-child { border-left-color: var(--accent); }
.edit__table tr.row--mode-paid-leave td:first-child { border-left-color: var(--primary-dark); }
.edit__table tr.row--mode-public-holiday td:first-child { border-left-color: var(--mineral); }
.edit__table tr.row--mode-absence td:first-child,
.edit__table tr.row--mode-other-leave td:first-child { border-left-color: var(--accent); }
.edit__date-cell { min-width: 76px; }
.edit__work-cell { min-width: 148px; }
.edit__lock-note {
  margin-top: 12px;
  padding: 12px;
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.75rem;
}

.date-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.date-chip__date,
.date-chip__week { font-weight: 700; }
.date-chip__week { min-width: 1.25em; font-size: 0.8125rem; }
.date-chip--sat .date-chip__date,
.date-chip--sat .date-chip__week { color: #2563eb; }
.date-chip--sun .date-chip__date,
.date-chip--sun .date-chip__week { color: #dc2626; }
.mode-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}
.mode-badge--work { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 9%, var(--surface)); color: var(--primary); }
.mode-badge--half-leave { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--accent); }
.mode-badge--paid-leave { border-color: var(--primary-dark); background: color-mix(in srgb, var(--primary-dark) 8%, var(--surface)); color: var(--primary-dark); }
.mode-badge--public-holiday { border-color: var(--mineral); background: var(--bg); color: var(--text-secondary); }
.mode-badge--absence,
.mode-badge--other-leave { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--surface)); color: var(--text); }
.work-summary {
  display: grid;
  grid-template-columns: 44px minmax(72px, 1fr);
  column-gap: 18px;
  align-items: baseline;
  white-space: nowrap;
}
.work-summary--empty { display: inline-block; color: var(--text-muted); }
.work-summary__total,
.work-summary__overtime { font-variant-numeric: tabular-nums; }
.work-summary__overtime {
  color: var(--accent);
  font-size: 0.8125rem;
  font-weight: 700;
}

.field { margin-bottom: 20px; }
.field__label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.16em;
}
.field__input,
.field__select {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}
.field__input:focus,
.field__select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}
.picker-field { position: relative; }
.picker-field--custom { cursor: pointer; }
.field__input--picker {
  position: relative;
  padding-right: 52px;
  cursor: pointer;
  user-select: none;
}
.field__input--picker::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.field__input--custom-date { caret-color: transparent; }
.picker-field::after {
  content: "";
  position: absolute;
  right: 18px;
  top: 50%;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--primary);
  border-bottom: 2px solid var(--primary);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.field__radio {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.field__radio label {
  flex: 1 1 136px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  text-align: center;
}
.field__radio label.active {
  border-color: var(--primary);
  background: var(--bg);
  color: var(--primary);
  font-weight: 700;
}
.field__radio input { display: none; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(17,17,17,0.55);
  backdrop-filter: blur(2px);
}
.modal--open { display: flex; animation: fadeIn 150ms ease-out; }
.modal__panel {
  width: min(480px, 100%);
  padding: 32px;
  border-top: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(17,17,17,0.16);
}
.modal__title { margin: 0 0 12px; color: var(--text); font-size: 1.25rem; font-weight: 700; }
.modal__body { margin: 0 0 24px; color: var(--text-secondary); font-size: 1.0625rem; line-height: 1.6; }
.modal__actions { display: flex; gap: 12px; }
.modal__actions button { flex: 1; padding: 16px; }
.btn--primary { border: 0; background: var(--primary); color: var(--surface); }
.btn--primary:disabled { background: var(--mineral); color: var(--text-muted); cursor: not-allowed; }
.btn--primary:active:not(:disabled) { background: var(--primary-dark); }
.btn--ghost { border: 1px solid var(--border); background: var(--surface); color: var(--text-secondary); }
.calendar-modal { z-index: 130; }
.calendar { max-width: 420px; padding: 24px; }
.calendar__header {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  gap: 8px;
  align-items: center;
  margin-bottom: 18px;
}
.calendar__title { margin: 0; color: var(--primary); font-size: 1.25rem; letter-spacing: 0.04em; text-align: center; }
.calendar__nav {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--primary);
  font-size: 2rem;
  line-height: 1;
}
.calendar__week,
.calendar__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.calendar__week {
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
}
.calendar__day {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}
.calendar__day:active { background: var(--bg); }
.calendar__day--blank { visibility: hidden; pointer-events: none; }
.calendar__day--today { border-color: var(--primary); }
.calendar__day--selected { background: var(--primary); color: var(--surface); }
.calendar__day--sat:not(.calendar__day--selected),
.calendar__sat { color: #2563eb; }
.calendar__day--sun:not(.calendar__day--selected),
.calendar__day--holiday:not(.calendar__day--selected),
.calendar__sun { color: #dc2626; }
.calendar__day--holiday:not(.calendar__day--selected) { background: #fff7f7; }
.calendar__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  z-index: 200;
  max-width: min(92vw, 720px);
  padding: 14px 24px;
  border-radius: 4px;
  background: var(--primary);
  color: var(--surface);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(8px);
  transition: opacity 180ms ease-out, transform 180ms ease-out;
  box-shadow: 0 12px 32px rgba(17,17,17,0.18);
}
.toast--show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast--error { background: var(--accent); color: var(--primary); }

@media (max-width: 900px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .app { padding: 16px; }
  .header { display: block; }
  .header__brand { display: block; }
  .header__brand small { display: block; margin-top: 2px; }
  .header__meta { margin-top: 8px; text-align: left; }
  .cards { grid-template-columns: 1fr; }
  .panel { padding: 32px 20px; }
  .panel__name { font-size: 1.5rem; }
  .action-btn { padding: 28px; font-size: 1.5rem; }
}
