:root {
  --bg: #eef0f3;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #6b7280;
  --line: #dde1e6;
  --accent: #2f6fd6;
  --danger: #e5484d;
  --radius: 18px;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
svg { width: 100%; height: 100%; display: block; }

#app { height: 100%; }

.view {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
}

.bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 10px;
}
.bar.sub { align-items: center; padding-bottom: 8px; }
.bar h1 { margin: 2px 0 0; font-size: 30px; font-weight: 700; letter-spacing: .5px; }
.bar h2 { margin: 0; font-size: 17px; font-weight: 600; flex: 1; text-align: center; }
.bar .grow { flex: 1; }
.bar-actions { display: flex; gap: 10px; }
.date { font-size: 13px; color: var(--muted); }
.count { font-size: 18px; color: var(--muted); font-weight: 500; margin-left: 4px; }

.icon-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--surface);
  padding: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  flex: none;
}
.icon-btn.primary { background: var(--accent); color: #fff; }
.icon-btn.danger { color: var(--danger); }
.icon-btn.on { background: var(--accent); color: #fff; }
.icon-btn:active { transform: scale(.94); }

.save-btn {
  width: 64px; height: 36px;
  border-radius: 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.save-btn:disabled { background: #c3cad4; }

.list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 16px calc(env(safe-area-inset-bottom) + 8px);
  container-type: size;
}

.slot {
  position: relative;
  height: calc((100cqh - 48px) / 4);
  min-height: 76px;
  margin-bottom: 12px;
  transition: height .26s ease, margin .26s ease, opacity .26s ease;
}
.list.sorting .slot { transition: transform .2s ease; }
.list.sorting .slot.dragging { transition: none; z-index: 2; }
.slot.dragging .card { box-shadow: 0 10px 24px rgba(0,0,0,.18); }
.slot.collapse { height: 0 !important; min-height: 0; margin-bottom: 0; opacity: 0; }

.under {
  position: absolute; inset: 0;
  border-radius: var(--radius);
  background: var(--danger);
  display: flex; justify-content: flex-end; align-items: center;
  opacity: 0;
  pointer-events: none;
}
.under.show { opacity: 1; pointer-events: auto; }
.done-btn {
  width: 104px; height: 100%;
  color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 14px; font-weight: 600;
}
.done-btn svg { width: 28px; height: 28px; }

.card {
  position: absolute; inset: 0;
  border-radius: var(--radius);
  display: flex; align-items: center; gap: 14px;
  padding: 0 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.07);
  touch-action: pan-y;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  cursor: pointer;
}

.thumb {
  flex: none;
  width: 56px; height: 56px;
  border-radius: 50%;
  padding: 13px;
}
.thumb.big { width: 76px; height: 76px; padding: 17px; }

.info { min-width: 0; }
.title { font-size: 21px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { font-size: 13px; opacity: .72; margin-top: 4px; }
.meta .pin svg { display: inline-block; width: 13px; height: 13px; vertical-align: -2px; margin-right: 3px; }

.empty { text-align: center; color: var(--muted); padding-top: 30vh; font-size: 16px; }

.scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 24px);
}

.field { display: block; margin-bottom: 20px; }
.label { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; color: var(--muted); margin: 0 4px 8px; }
.label em { font-style: normal; font-weight: 400; font-size: 12px; }

input, textarea {
  width: 100%;
  font: inherit; font-size: 17px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
  resize: none;
}
input:focus, textarea:focus { border-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 14px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 15px;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip i, .props i { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); display: inline-block; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.thumb-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.thumb-opt {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 4px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 12px;
}
.thumb-opt svg { width: 28px; height: 28px; }
.thumb-opt.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.images { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.img-tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface);
}
.img-tile img, .img-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-tile .missing { display: flex; height: 100%; align-items: center; justify-content: center; font-size: 12px; color: var(--muted); background: var(--line); }
.img-tile.add { border: 1.5px dashed #b8c0ca; color: var(--muted); padding: 30%; }
.img-tile .rm {
  position: absolute; top: 6px; right: 6px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff;
  padding: 6px;
}

.hero {
  border-radius: 22px;
  padding: 22px 18px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.07);
}
.hero h2 { margin: 0; font-size: 26px; font-weight: 700; word-break: break-all; }

.props {
  margin: 16px 0 0;
  background: var(--surface);
  border-radius: 16px;
  padding: 0 16px;
}
.props div { display: flex; justify-content: space-between; padding: 13px 0; border-bottom: 1px solid var(--line); }
.props div:last-child { border-bottom: 0; }
.props dt { color: var(--muted); }
.props dd { margin: 0; display: flex; align-items: center; gap: 6px; }

.desc {
  background: var(--surface);
  border-radius: 16px;
  padding: 14px 16px;
  margin: 16px 0 0;
  font-size: 16px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
}

.videos { display: grid; gap: 10px; margin-top: 16px; }
.videos video { width: 100%; max-height: 70vh; border-radius: 14px; background: #000; display: block; }
.videos .missing { background: var(--surface); border-radius: 16px; padding: 14px 16px; color: var(--muted); font-size: 14px; }
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 14px; display: block; cursor: zoom-in; }

.toast {
  position: fixed; left: 0; right: 0; margin: 0 auto; width: max-content;
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  background: rgba(30,32,36,.92); color: #fff;
  border-radius: 14px;
  padding: 12px 16px;
  display: flex; align-items: center; gap: 16px;
  font-size: 15px;
  max-width: calc(100% - 32px);
  z-index: 10;
}
.toast[hidden], .lightbox[hidden], [hidden] { display: none !important; }
.toast button { color: #7fb2ff; font-weight: 600; flex: none; white-space: nowrap; }

.icon-spacer { width: 42px; flex: none; }

.menu {
  background: var(--surface);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 20px;
}
.menu button {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  height: 54px;
  font-size: 17px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.menu button:last-child { border-bottom: 0; }
.menu button:active { background: #f3f4f6; }
.menu button svg { width: 22px; height: 22px; flex: none; color: var(--accent); }
.menu button span { flex: 1; }
.menu button svg:last-child:not(:first-child) { width: 16px; height: 16px; color: #b0b7c1; }
.version { text-align: center; font-size: 13px; color: var(--muted); margin-top: 8px; }
.menu-title { font-size: 13px; color: var(--muted); margin: 0 4px 8px; }

.week-card {
  background: var(--surface);
  border-radius: 16px;
  overflow: hidden;
}
.week { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 14px; }
.week col.day { width: 34px; }
.week th, .week td { height: 44px; text-align: center; border-bottom: 1px solid var(--line); padding: 0; }
.week thead th { height: 38px; font-size: 13px; color: var(--muted); font-weight: 600; }
.week th.name { text-align: left; padding: 0 6px 0 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.week thead th.name, .week tfoot th.name { color: var(--muted); font-weight: 600; font-size: 13px; }
.week .nm { overflow: hidden; text-overflow: ellipsis; }
.week th.name em { font-style: normal; font-size: 12px; color: var(--accent); margin-left: 4px; font-weight: 600; }
.week .today { background: #eaf2fd; }
.week thead .today { color: var(--accent); }
.week td i { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0,0,0,.18); vertical-align: middle; }
.week td.weekly { font-size: 12px; color: var(--muted); text-align: left; padding-left: 10px; background: repeating-linear-gradient(-45deg, transparent 0 6px, rgba(0,0,0,.025) 6px 12px); }
.week tbody tr { cursor: pointer; }
.week tbody tr:active { background: #f3f4f6; }
.week tfoot th, .week tfoot td { border-bottom: 0; font-weight: 600; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 14px 4px 0; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0,0,0,.18); }

.lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.92);
  z-index: 20;
}
.lb-track {
  position: absolute; inset: 0;
  display: flex;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.lb-track::-webkit-scrollbar { display: none; }
.lb-slide {
  flex: 0 0 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  display: flex; align-items: center; justify-content: center;
}
.lb-slide img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-count {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  color: #fff; font-size: 14px;
  background: rgba(255,255,255,.15);
  padding: 4px 12px; border-radius: 12px;
  pointer-events: none;
}
.lb-count:empty { display: none; }
.lb-close {
  position: absolute; right: 14px;
  top: calc(env(safe-area-inset-top) + 14px);
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  color: #fff;
  padding: 10px;
}
