:root {
  color-scheme: light;
  --paper: #efe4d4;
  --paper-deep: #e6d8c4;
  --ink: #241910;
  --muted: #66594c;
  --card: #fffaf3;
  --line: #eadccb;
  --espresso: #2a211c;
  --foam: #f6efe6;
  --caramel: #a85a32;
  --leaf: #215c3a;
  --leaf-bg: #e5f3e8;
  --sand: #f8f0e4;
  --danger: #8c342c;
  --shadow: 0 14px 40px rgba(60, 36, 18, 0.08);
  font-family: "Segoe UI", "Microsoft JhengHei UI", "Microsoft JhengHei", "PingFang HK", "Noto Sans TC", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% -8%, #f8f1e6 0, transparent 36%),
    linear-gradient(180deg, #f4eadc 0%, var(--paper) 42%, #e8dccb 100%);
}

button, input { font: inherit; color: inherit; }

button {
  cursor: pointer;
  touch-action: manipulation;
}

.loading { color: var(--muted); }

.app {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 22px 16px calc(36px + env(safe-area-inset-bottom));
}

.sign {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  background: var(--espresso);
  color: #f7f0e6;
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: 8px 8px 0 #e3d3c0;
}

.logo {
  width: 52px;
  height: 52px;
  display: block;
}

.shop {
  margin: 0;
  letter-spacing: 0.18em;
  font-size: 13px;
}

.sign h1 {
  margin: 2px 0 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.sub {
  margin: 2px 0 0;
  color: #d9c3ae;
  letter-spacing: 0.14em;
  font-size: 12px;
  text-transform: uppercase;
}

.whoami, .card, .banner {
  margin-top: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.whoami {
  position: sticky;
  top: 8px;
  z-index: 4;
  padding: 8px 14px 10px;
}

.who-toggle {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  text-align: left;
}

.who-label { display: flex; flex-direction: column; min-width: 0; }

.chev { color: var(--muted); font-size: 14px; }

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

.me {
  margin: 2px 0 0;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
}

.muted { color: var(--muted); }

.card, .banner { padding: 14px; }

.cal-head {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
}

.month-wrap { text-align: center; }

.month {
  margin: 0;
  font-size: 22px;
}

.text-btn, .btn, .person, .day, .icon {
  border: 0;
  background: transparent;
}

.text-btn {
  margin-top: 2px;
  color: var(--caramel);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

.weekdays {
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.weekdays .we { color: var(--caramel); }

.day {
  min-height: 88px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #f0e6da;
  padding: 5px 4px 4px;
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
}

.day:hover { border-color: #ddcbb8; }

.day.weekend { background: #fff8f2; }

.day.others { background: var(--sand); }

.day.mine {
  background: var(--leaf-bg);
  box-shadow: inset 0 0 0 1.5px var(--leaf);
}

.day.pending { opacity: 0.55; }

.num {
  width: 1.45rem;
  height: 1.45rem;
  display: inline-grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.day.today .num {
  background: var(--espresso);
  color: white;
  border-radius: 999px;
}

.day.weekend .num { color: var(--caramel); }

.day.today .num { color: white; }

.holiday {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 9px;
  line-height: 1.15;
  color: var(--caramel);
}

.names {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.names span, .chip {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.names span {
  font-size: 11px;
  line-height: 1.25;
  color: #6a4b32;
}

.names .mine, .chip.mine {
  color: var(--leaf);
  font-weight: 700;
}

.names .more { color: var(--muted); }

.agenda { margin-top: 18px; }

.agenda h2, .picker h2, .modal h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.leave {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 10px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.leave-date {
  margin: 0;
  font-size: 16px;
}

.leave-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 4px;
}

.count {
  border-radius: 999px;
  background: var(--espresso);
  color: #f6efe6;
  font-size: 12px;
  padding: 2px 7px;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  max-width: 100%;
  background: #f3e4d4;
  color: #6a4328;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 13px;
}

.chip.mine { background: var(--leaf-bg); }

.empty {
  margin: 8px 0 0;
  color: var(--muted);
}

.picker p { line-height: 1.55; }

.person-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.person {
  flex: 1;
  text-align: left;
  min-height: 52px;
  border-radius: 12px;
  background: var(--foam);
  border: 1px solid var(--line);
  padding: 0 14px;
  font-size: 18px;
  font-weight: 700;
}

.person.current { box-shadow: inset 0 0 0 1.5px var(--leaf); background: var(--leaf-bg); }

.add {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.add input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid #ddcfbf;
  background: white;
  padding: 0 12px;
}

.btn {
  min-height: 48px;
  border-radius: 12px;
  padding: 0 14px;
  background: var(--espresso);
  color: #f7f0e6;
  border: 1px solid var(--espresso);
  white-space: nowrap;
}

.btn.small { min-height: 40px; padding: 0 12px; }

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border-color: #ddcfbf;
}

.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

.btn:disabled, .day:disabled { cursor: wait; opacity: 0.6; }

.icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid #ddcfbf;
  background: white;
  font-size: 26px;
  line-height: 1;
}

.form-error { color: var(--danger); min-height: 1.2em; margin: 8px 0 0; }

.modal-back {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(36, 25, 16, 0.42);
  display: grid;
  place-items: end center;
  padding: 16px;
}

.modal {
  width: min(420px, 100%);
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.modal p { line-height: 1.5; }

.row { display: flex; justify-content: flex-end; gap: 8px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(8px);
  opacity: 0;
  pointer-events: none;
  z-index: 30;
  max-width: calc(100% - 32px);
  background: var(--espresso);
  color: #f7f0e6;
  border-radius: 999px;
  padding: 10px 14px;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

button:focus-visible, input:focus-visible {
  outline: 2px solid var(--caramel);
  outline-offset: 2px;
}

@media (min-width: 720px) {
  .day { min-height: 96px; padding: 8px; }
  .names span { font-size: 13px; }
  .holiday { font-size: 11px; }
  .modal-back { place-items: center; }
}

@media (prefers-reduced-motion: reduce) {
  #toast { transition: none; }
}
