:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #60646c;
  --hairline: #d7dce2;
  --surface: #ffffff;
  --surface-2: #f6f8f9;
  --brand: #087f7a;
  --brand-ink: #064c49;
  --brand-soft: #dff4f1;
  --amber: #b26800;
  --amber-soft: #fff0cf;
  --rose: #b42347;
  --rose-soft: #ffe1e8;
  --violet: #5d4fb3;
  --violet-soft: #ece9ff;
  --blue: #2563a9;
  --blue-soft: #e4f0ff;
  --shadow: 0 12px 30px rgba(21, 32, 43, 0.08);
  --radius: 8px;
  --phone-w: 28rem;
  --header-h: 60px;
  --bottom-nav-h: 72px;
  --calendar-appbar-h: 112px;
  --calendar-week-strip-h: 116px;
  --calendar-report-h: 52px;
  --content-pad-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: #e5e5e5;
  color: var(--ink);
}

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

button {
  border: 0;
}

.app-shell {
  position: relative;
  width: min(var(--phone-w), 100%);
  min-height: 100vh;
  margin: 0 auto;
  overflow-x: hidden;
  background: var(--surface-2);
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
}

.page-head {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--hairline);
  backdrop-filter: blur(10px);
}

.head-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--header-h);
  padding: 14px 16px;
}

.brand-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.brand-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.content {
  padding: 16px 16px var(--content-pad-bottom);
}

.flow-band,
.panel {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.flow-band {
  padding: 16px;
}

.section-title {
  margin: 0 0 12px;
  font-size: 19px;
  line-height: 1.35;
}

.subsection-title {
  margin: 18px 0 10px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.4;
}

.section-copy {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.notice {
  margin: 16px 0 0;
  padding: 12px;
  color: #4d3900;
  background: var(--amber-soft);
  border: 1px solid #f2cc75;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.6;
}

.progress {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin: 0 0 16px;
}

.progress span {
  height: 4px;
  border-radius: 99px;
  background: #dde3e8;
}

.progress .active {
  background: var(--brand);
}

.stack {
  display: grid;
  gap: 10px;
}

.choice {
  width: 100%;
  min-height: 52px;
  padding: 12px;
  text-align: left;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}

.choice[aria-pressed="true"],
.choice:focus-visible {
  border-color: var(--brand);
  outline: 2px solid rgba(8, 127, 122, 0.2);
}

.choice-main {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
}

.choice-sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

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

.date-button,
.time-button {
  min-height: 48px;
  padding: 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  text-align: center;
}

.date-button.is-active,
.time-button.is-active {
  color: var(--brand-ink);
  background: var(--brand-soft);
  border-color: var(--brand);
  font-weight: 700;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}

.field textarea {
  min-height: 88px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand);
  outline: 2px solid rgba(8, 127, 122, 0.16);
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.actions.wrap {
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  font-weight: 700;
}

.btn.primary {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

.btn.danger {
  color: #fff;
  background: var(--rose);
  border-color: var(--rose);
}

.btn.ghost {
  background: transparent;
}

.btn:disabled {
  opacity: 0.55;
}

.btn.icon {
  width: 44px;
  padding: 0;
  font-size: 18px;
}

.menu-button {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
  width: 44px;
  min-height: 44px;
  background: transparent;
}

.menu-button span {
  display: block;
  height: 2px;
  background: var(--brand);
  border-radius: 99px;
}

.menu-button span:nth-child(1),
.menu-button span:nth-child(2) {
  width: 28px;
}

.menu-button span:nth-child(3) {
  width: 20px;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 50%;
  z-index: 50;
  display: flex;
  width: min(var(--phone-w), 100%);
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  padding: 7px 8px calc(7px + env(safe-area-inset-bottom, 0px));
  background: var(--brand);
  border-top: 1px solid rgba(4, 76, 73, 0.35);
  transform: translateX(-50%);
}

.nav-tab {
  position: relative;
  display: flex;
  flex: 1 1 20%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  min-height: 58px;
  color: rgba(255, 255, 255, 0.82);
  background: transparent;
  border-radius: 0;
  text-decoration: none;
}

.nav-tab svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-tab span {
  max-width: 100%;
  overflow: hidden;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-tab.active {
  color: var(--brand-ink);
  background: #b8ece7;
}

.nav-tab:disabled {
  opacity: 0.35;
}

.side-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.38);
}

.side-drawer {
  position: fixed;
  top: 0;
  right: max(0px, calc((100vw - var(--phone-w)) / 2));
  z-index: 100;
  display: flex;
  flex-direction: column;
  width: min(18rem, 85vw);
  height: 100vh;
  background: var(--surface);
  box-shadow: -18px 0 40px rgba(21, 32, 43, 0.18);
}

.side-drawer header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--header-h);
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline);
}

.side-drawer nav,
.side-drawer .side-actions {
  display: grid;
  gap: 4px;
  padding: 10px;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px;
  color: var(--ink);
  background: transparent;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 800;
}

.side-link:hover {
  background: var(--surface-2);
}

.side-link svg {
  width: 20px;
  height: 20px;
  stroke: var(--muted);
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.summary-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--hairline);
}

.summary-row dt {
  color: var(--muted);
  font-size: 13px;
}

.summary-row dd {
  margin: 0;
  text-align: right;
  font-weight: 700;
}

.error,
.success {
  padding: 12px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.6;
}

.error {
  color: var(--rose);
  background: var(--rose-soft);
  border: 1px solid #f2a3b7;
}

.success {
  color: var(--brand-ink);
  background: var(--brand-soft);
  border: 1px solid #9bd9d3;
}

.empty {
  padding: 18px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--hairline);
  border-radius: var(--radius);
}

.admin-shell {
  background: #f0f1f4;
}

.admin-layout {
  min-height: 100vh;
}

.admin-layout.calendar-mode {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  background: #f1f2f5;
}

.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: #fff;
  border-bottom: 1px solid var(--hairline);
}

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

.admin-title h1 {
  margin: 0;
  font-size: 18px;
}

.admin-title p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.segmented {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 8px 12px;
  background: #fff;
  border-bottom: 1px solid var(--hairline);
}

.segmented button {
  min-height: 38px;
  padding: 8px 12px;
  white-space: nowrap;
  color: var(--muted);
  background: transparent;
  border-radius: 99px;
  font-weight: 700;
}

.segmented button.active {
  color: var(--brand-ink);
  background: var(--brand-soft);
}

.admin-content {
  padding: 12px 12px var(--content-pad-bottom);
}

.calendar-content {
  flex: 1;
  min-height: 0;
  padding: 0 0 calc(var(--bottom-nav-h) + var(--calendar-report-h) + env(safe-area-inset-bottom, 0px));
}

.calendar-content > .error,
.calendar-content > .success {
  margin: 10px;
}

.calendar-appbar {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 72px;
  align-items: end;
  gap: 10px;
  min-height: var(--calendar-appbar-h);
  padding: 34px 14px 14px;
  background: #18bdae;
}

.calendar-today-btn {
  min-height: 48px;
  color: #fff;
  background: transparent;
  font-size: 22px;
  font-weight: 700;
  text-align: left;
}

.calendar-mode-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: 44px;
  padding: 4px;
  background: #f0f0f2;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.calendar-mode-switch button {
  min-width: 0;
  color: #1f1f1f;
  background: transparent;
  border-radius: 9px;
  font-size: 18px;
  font-weight: 800;
}

.calendar-mode-switch button.active {
  background: #fff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.14);
}

.calendar-header-icon {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  justify-self: end;
  color: #fff;
  background: transparent;
}

.calendar-header-icon svg {
  width: 44px;
  height: 44px;
  stroke: currentColor;
  stroke-width: 1.9;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(72px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
  overflow-x: auto;
}

.stat {
  min-width: 72px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}

.stat b {
  display: block;
  font-size: 18px;
}

.stat span {
  color: var(--muted);
  font-size: 11px;
}

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

.calendar-title {
  font-weight: 800;
}

.week-strip {
  min-height: var(--calendar-week-strip-h);
  background: #f2f2f6;
  border-bottom: 1px solid #e1e2e6;
}

.week-nav-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 72px;
  align-items: center;
  min-height: 40px;
  padding: 4px 10px 0;
}

.week-jump {
  min-height: 36px;
  padding: 0;
  color: #888c91;
  background: transparent;
  font-size: 14px;
  font-weight: 800;
}

.week-jump:first-child {
  text-align: left;
}

.week-jump:last-child {
  text-align: right;
}

.week-range {
  overflow: hidden;
  color: #18bdae;
  font-size: 17px;
  font-weight: 900;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.week-date-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0;
  padding: 0 0 10px 48px;
}

.week-date {
  display: grid;
  min-width: 0;
  min-height: 66px;
  place-items: center;
  gap: 3px;
  color: #333;
  background: transparent;
}

.week-date span {
  color: #36383d;
  font-size: 15px;
  font-weight: 700;
}

.week-date b {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  color: #333;
  border-radius: 999px;
  font-size: 17px;
  line-height: 1;
}

.week-date.today b {
  color: #fff;
  background: #2c2c2f;
}

.week-date.saturday span,
.week-date.saturday b {
  color: #b8b8b8;
}

.week-date.sunday span,
.week-date.sunday b {
  color: #ff2d3e;
}

.week-date.sunday.today b {
  color: #fff;
}

.day-focus-label {
  min-height: 66px;
  padding: 18px 16px 0;
  color: #303236;
  font-size: 20px;
  font-weight: 900;
  text-align: center;
}

.month-strip {
  min-height: auto;
  padding-bottom: 14px;
}

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

.month-weekdays {
  padding: 4px 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.month-grid {
  gap: 6px;
  padding: 6px 14px 0;
}

.month-cell {
  display: grid;
  min-height: 52px;
  place-items: center;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}

.month-cell.outside {
  color: #b9bdc3;
  background: #f8f8fa;
}

.month-cell.today {
  color: #fff;
  background: #2c2c2f;
  border-color: #2c2c2f;
}

.month-cell span {
  min-height: 14px;
  color: var(--brand);
  font-size: 10px;
  font-weight: 900;
}

.calendar-scroll {
  height: calc(100vh - var(--calendar-appbar-h) - var(--calendar-week-strip-h) - var(--calendar-report-h) - var(--bottom-nav-h) - env(safe-area-inset-bottom, 0px));
  height: calc(100dvh - var(--calendar-appbar-h) - var(--calendar-week-strip-h) - var(--calendar-report-h) - var(--bottom-nav-h) - env(safe-area-inset-bottom, 0px));
  min-height: 360px;
  overflow-x: hidden;
  overflow-y: auto;
  background: #fff;
  border: 0;
  border-radius: 0;
}

.week-board {
  display: grid;
  grid-template-columns: 48px repeat(7, minmax(0, 1fr));
  width: 100%;
  min-width: 0;
}

.day-board {
  grid-template-columns: 48px minmax(0, 1fr);
}

.corner-cell,
.day-head {
  position: sticky;
  top: 0;
  z-index: 4;
  min-height: 44px;
  padding: 8px 4px;
  background: #fff;
  border-bottom: 1px solid var(--hairline);
  text-align: center;
}

.corner-cell {
  left: 0;
  z-index: 5;
  border-right: 1px solid var(--hairline);
}

.day-head.today {
  color: var(--brand-ink);
  background: var(--brand-soft);
}

.day-head b {
  display: block;
  font-size: 13px;
}

.day-head span {
  color: var(--muted);
  font-size: 11px;
}

.time-rail {
  position: sticky;
  left: 0;
  z-index: 2;
  height: 1728px;
  background: #eef0f2;
  border-right: 1px solid var(--hairline);
}

.time-label {
  position: absolute;
  right: 3px;
  color: #85898e;
  font-size: 13px;
  transform: translateY(-8px);
}

.day-column {
  position: relative;
  height: 1728px;
  border-right: 1px solid var(--hairline);
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 35px,
      rgba(32, 33, 36, 0.11) 35px,
      rgba(32, 33, 36, 0.11) 36px
    ),
    #fff;
  touch-action: pan-y;
}

.day-column.today {
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(24, 189, 174, 0.12) 0,
      rgba(24, 189, 174, 0.12) 35px,
      rgba(24, 189, 174, 0.18) 35px,
      rgba(24, 189, 174, 0.18) 36px
    ),
    #ddf1ee;
}

.now-line {
  position: absolute;
  right: 0;
  left: 0;
  height: 2px;
  background: var(--rose);
  z-index: 3;
}

.event-block {
  position: absolute;
  left: 2px;
  right: 2px;
  min-height: 30px;
  padding: 4px;
  overflow: hidden;
  color: var(--ink);
  border: 1px solid;
  border-radius: 6px;
  box-shadow: 0 3px 8px rgba(21, 32, 43, 0.1);
  font-size: 10px;
  line-height: 1.25;
}

.calendar-report-bar {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  left: 50%;
  z-index: 45;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  width: min(var(--phone-w), 100%);
  min-height: var(--calendar-report-h);
  padding: 8px 10px;
  color: #fff;
  background: #282828;
  transform: translateX(-50%);
}

.calendar-report-bar strong {
  white-space: nowrap;
  font-size: 13px;
}

.calendar-report-bar button {
  min-width: 0;
  min-height: 36px;
  padding: 6px 10px;
  overflow: hidden;
  color: #fff;
  background: transparent;
  border: 1px solid #fff;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-shell .bottom-nav {
  background: #fff;
  border-top-color: #e0e0e0;
}

.admin-shell .nav-tab {
  color: #9b9b9b;
}

.admin-shell .nav-tab.active {
  color: #18bdae;
  background: #d9f4f0;
  border-radius: var(--radius);
}

.admin-shell .nav-tab svg {
  stroke-width: 2;
}

.event-block.editable {
  cursor: grab;
  touch-action: none;
}

.event-block.availability {
  background: var(--brand-soft);
  border-color: #6cc8bf;
}

.event-block.personal {
  background: var(--amber-soft);
  border-color: #dca83a;
}

.event-block.pending {
  background: var(--violet-soft);
  border-color: #afa6ea;
}

.event-block.confirmed {
  background: var(--blue-soft);
  border-color: #8ab8ef;
}

.event-block.dirty {
  outline: 2px solid var(--rose);
}

.event-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.event-time {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.resize-handle {
  position: absolute;
  right: 0;
  left: 0;
  height: 14px;
}

.resize-handle.top {
  top: -2px;
}

.resize-handle.bottom {
  bottom: -2px;
}

.save-bar {
  position: fixed;
  right: 12px;
  bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 12px);
  left: 12px;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.drawer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 120;
  max-height: calc(100dvh - 18px);
  overflow: auto;
  padding: 16px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  background: #fff;
  border-top: 1px solid var(--hairline);
  box-shadow: 0 -18px 40px rgba(21, 32, 43, 0.16);
}

.drawer h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.drawer-grid {
  display: grid;
  gap: 12px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  padding: 12px;
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}

.list-item h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 800;
}

.badge.pending {
  color: #40327d;
  background: var(--violet-soft);
}

.badge.confirmed {
  color: #0f477e;
  background: var(--blue-soft);
}

.badge.denied,
.badge.canceled,
.badge.expired {
  color: var(--rose);
  background: var(--rose-soft);
}

.login-wrap {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 16px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 18px;
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

@media (min-width: 760px) {
  .content {
    padding: 20px 16px var(--content-pad-bottom);
  }

  .flow-band {
    padding: 22px;
  }

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

  .drawer {
    right: 20px;
    bottom: 20px;
    left: auto;
    width: 420px;
    max-height: calc(100vh - 40px);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
  }

  .save-bar {
    left: auto;
    width: 420px;
  }
}
