* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --bg: #f4f5fb;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e5e7eb;
  --danger: #dc2626;
}
body {
  font-family: -apple-system, "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.hidden { display: none !important; }
.view { min-height: 100vh; }

/* 登入 */
#login-view { display: flex; align-items: center; justify-content: center; }
.login-box {
  background: var(--card); padding: 40px 32px; border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,.08); text-align: center; width: min(90%, 340px);
}
.login-logo { font-size: 56px; margin-bottom: 8px; }
.login-box h1 { font-size: 22px; margin-bottom: 24px; }
.login-box input {
  width: 100%; padding: 12px 14px; font-size: 16px; border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 14px;
}

/* 按鈕 */
.btn-primary {
  background: var(--primary); color: #fff; border: none; padding: 12px 24px;
  font-size: 16px; border-radius: 10px; cursor: pointer; width: 100%;
}
.btn-primary:active { background: var(--primary-dark); }
.btn-small {
  background: var(--primary); color: #fff; border: none; padding: 6px 14px;
  font-size: 14px; border-radius: 8px; cursor: pointer;
}
.btn-white { background: #fff; color: var(--primary); font-weight: bold; }
.btn-ghost {
  background: none; border: none; color: var(--muted); font-size: 14px;
  cursor: pointer; padding: 8px 12px;
}

/* header 日期導覽 */
header {
  background: var(--primary); color: #fff; padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.date-nav { display: flex; align-items: center; gap: 4px; flex: 1; }
.nav-btn {
  background: rgba(255,255,255,.15); border: none; color: #fff; font-size: 22px;
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer; line-height: 1;
}
.date-center { text-align: center; flex: 1; position: relative; }
#date-picker {
  border: none; background: none; color: #fff; font-size: 17px; font-weight: bold;
  text-align: center; width: 100%; font-family: inherit;
}
#date-picker::-webkit-calendar-picker-indicator { filter: invert(1); }
#date-label { font-size: 12px; opacity: .85; }

/* 通知橫幅 */
.banner {
  background: #f59e0b; color: #fff; padding: 10px 16px; font-size: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
}

/* 行程清單 */
main { padding: 16px; padding-bottom: 120px; max-width: 640px; margin: 0 auto; }
.empty-state { text-align: center; color: var(--muted); padding: 60px 0; font-size: 15px; }
.empty-state .big { font-size: 48px; display: block; margin-bottom: 12px; }
.event-card {
  background: var(--card); border-radius: 14px; padding: 14px 16px; margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06); display: flex; gap: 14px; align-items: flex-start;
}
.event-card.past { opacity: .55; }
.event-time { font-size: 18px; font-weight: bold; color: var(--primary); min-width: 56px; }
.event-body { flex: 1; min-width: 0; }
.event-title { font-size: 16px; font-weight: 600; word-break: break-word; }
.event-note { font-size: 13px; color: var(--muted); margin-top: 2px; white-space: pre-wrap; word-break: break-word; }
.event-badges { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.badge {
  font-size: 11px; background: #eef2ff; color: var(--primary);
  padding: 2px 8px; border-radius: 999px;
}
.event-actions { display: flex; flex-direction: column; gap: 6px; }
.icon-btn { background: none; border: none; font-size: 17px; cursor: pointer; padding: 4px; }

/* footer */
footer {
  position: fixed; bottom: 0; left: 0; right: 0; background: var(--card);
  border-top: 1px solid var(--border); display: flex; justify-content: space-around;
  padding: 6px 0; padding-bottom: calc(6px + env(safe-area-inset-bottom));
}

/* FAB */
.fab {
  position: fixed; right: 20px; bottom: calc(64px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 50%; background: var(--primary); color: #fff;
  font-size: 30px; border: none; cursor: pointer; box-shadow: 0 4px 14px rgba(79,70,229,.4);
  line-height: 1;
}

/* 彈窗 */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex;
  align-items: flex-end; justify-content: center; z-index: 50;
}
.modal-box {
  background: var(--card); border-radius: 18px 18px 0 0; padding: 22px 20px;
  padding-bottom: calc(22px + env(safe-area-inset-bottom));
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
}
@media (min-width: 600px) {
  .modal-overlay { align-items: center; }
  .modal-box { border-radius: 18px; }
}
.modal-box h2 { font-size: 18px; margin-bottom: 16px; }
.modal-box label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.modal-box input, .modal-box textarea {
  display: block; width: 100%; padding: 10px 12px; font-size: 16px; margin-top: 4px;
  border: 1px solid var(--border); border-radius: 10px; font-family: inherit;
}
.row { display: flex; gap: 10px; }
.row label { flex: 1; }
fieldset { border: none; margin-bottom: 12px; }
legend { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex !important; align-items: center; margin: 0 !important;
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px;
  font-size: 13px !important; color: var(--text) !important; cursor: pointer; user-select: none;
}
.chip input { display: none; }
.chip:has(input:checked) { background: var(--primary); color: #fff !important; border-color: var(--primary); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.modal-actions .btn-primary { width: auto; padding: 10px 28px; }

.error-msg { color: var(--danger); font-size: 13px; margin-top: 8px; }

/* toast */
.toast {
  position: fixed; bottom: calc(130px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%); background: rgba(31,36,48,.92); color: #fff;
  padding: 10px 20px; border-radius: 999px; font-size: 14px; z-index: 99;
  max-width: 86%; text-align: center;
}
