:root {
  color-scheme: light;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --ink: #172033;
  --muted: #657085;
  --line: #dce2ec;
  --brand: #087a79;
  --brand-dark: #055e61;
  --blue: #236fd6;
  --blue-soft: #dceafe;
  --danger: #b84b35;
  --warn-soft: #fff2d4;
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  width: min(480px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--surface);
  box-shadow: 0 0 0 1px rgb(26 34 52 / 5%), 0 24px 70px rgb(26 34 52 / 14%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgb(255 255 255 / 94%);
  border-bottom: 1px solid var(--line);
  padding: 14px 16px 12px;
  backdrop-filter: blur(14px);
}

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

.brand {
  min-width: 0;
}

.brand strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.deadline {
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--warn-soft);
  color: #7b5510;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.statusline {
  display: flex;
  min-height: 24px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.status-pill {
  border-radius: 999px;
  background: #e8f5f3;
  color: var(--brand-dark);
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.status-note {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.periods {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.periods::-webkit-scrollbar {
  display: none;
}

.period {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 700;
}

.period[aria-pressed="true"] {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.calendar {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcff;
}

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

.month-head h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: 0;
}

.progress {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.weekdays,
.days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.weekdays {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.day {
  position: relative;
  display: grid;
  min-height: 48px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: #a0a7b4;
  font-weight: 800;
}

.day.is-target {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.day.is-submitted {
  border-color: color-mix(in srgb, var(--blue) 34%, var(--line));
  color: #11335f;
}

.day.is-submitted::before {
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--blue-soft);
  content: "";
}

.day.is-current {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--brand) 56%, transparent);
}

.day-number {
  position: relative;
  z-index: 1;
}

.legend {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.legend i {
  width: 18px;
  height: 18px;
  border: 1px solid color-mix(in srgb, var(--blue) 24%, var(--line));
  border-radius: 50%;
  background: var(--blue-soft);
}

.summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 10px;
}

.summary-head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0;
}

.summary-count {
  border-radius: 999px;
  background: #edf3fb;
  color: #255b9b;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.submitted-list {
  display: grid;
  gap: 10px;
  padding: 0 16px 92px;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #fbfcff;
  color: var(--muted);
  padding: 18px;
  text-align: center;
  font-size: 14px;
  line-height: 1.7;
}

.shift-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
}

.shift-row__main {
  min-width: 0;
}

.shift-row strong {
  display: block;
  font-size: 15px;
  line-height: 1.35;
}

.shift-row span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.6;
}

.shift-row button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.submitbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 6;
  width: min(480px, 100%);
  margin: 0 auto;
  border-top: 1px solid var(--line);
  background: rgb(255 255 255 / 94%);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  backdrop-filter: blur(14px);
}

.submitbar button {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.submitbar button:disabled {
  background: #aab4c2;
  cursor: default;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: calc(76px + env(safe-area-inset-bottom));
  left: 16px;
  z-index: 12;
  width: min(448px, calc(100% - 32px));
  margin: 0 auto;
  border-radius: var(--radius);
  background: #172033;
  color: #fff;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 18px 44px rgb(15 23 42 / 26%);
}

.toast[hidden] {
  display: none;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  align-items: end;
  background: rgb(15 23 42 / 42%);
}

.overlay[hidden] {
  display: none;
}

.sheet {
  width: min(480px, 100%);
  margin: 0 auto;
  border-radius: 16px 16px 0 0;
  background: #fff;
  padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -24px 60px rgb(15 23 42 / 20%);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.sheet-title strong {
  display: block;
  font-size: 20px;
  line-height: 1.25;
}

.sheet-title span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.6;
}

.close {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
}

.time-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.field input {
  width: 100%;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0;
  text-align: center;
}

.field input:focus {
  border-color: var(--brand);
  outline: 3px solid color-mix(in srgb, var(--brand) 18%, transparent);
}

.presets {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.preset-row {
  display: grid;
  grid-template-columns: 52px repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
}

.preset-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.preset-row button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.helper {
  min-height: 24px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.6;
}

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

.sheet-actions {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  margin-top: 12px;
}

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

.delete {
  min-height: 46px;
  border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--line));
  border-radius: var(--radius);
  background: #fff;
  color: var(--danger);
  padding: 0 14px;
  font-weight: 800;
}

.save {
  min-height: 46px;
  border: 0;
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.save:disabled {
  background: #aab4c2;
  cursor: default;
}

@media (max-width: 370px) {
  .preset-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .preset-row span {
    grid-column: 1 / -1;
  }
}
