:root {
  --bg: #0b1020;
  --panel: rgba(17, 24, 39, .88);
  --panel-2: #151d30;
  --line: rgba(255,255,255,.08);
  --text: #f8fafc;
  --muted: #98a2b3;
  --accent: #8b5cf6;
  --accent-2: #a78bfa;
  --good: #34d399;
  --warn: #f59e0b;
  --danger: #fb7185;
  --shadow: 0 24px 80px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background:
  radial-gradient(circle at 10% 0%, rgba(139,92,246,.15), transparent 32rem),
  radial-gradient(circle at 100% 20%, rgba(59,130,246,.10), transparent 30rem),
  var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
  "Noto Sans TC", sans-serif;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.topbar h1 { margin: 2px 0 0; font-size: clamp(24px, 4vw, 34px); letter-spacing: -.03em; }
.eyebrow { color: var(--accent-2); font-size: 11px; letter-spacing: .14em; font-weight: 800; }
.profile-btn {
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(255,255,255,.04);
  border-radius: 999px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.profile-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 18px rgba(52,211,153,.8); }

.shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto 50px;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, .8fr);
  gap: 18px;
}

.calendar-card, .side-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.calendar-card { padding: 18px; }
.side-panel { padding: 20px; min-height: 600px; display: flex; flex-direction: column; }

.calendar-head, .side-head, .dialog-title, .dialog-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.calendar-head { margin-bottom: 18px; }
.month-title { display: flex; align-items: center; gap: 10px; font-size: 20px; }
.icon-btn, .close-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255,255,255,.04); color: var(--text); font-size: 26px;
}
.text-btn {
  border: 0; background: rgba(139,92,246,.14); color: #ddd6fe; border-radius: 999px;
  padding: 7px 10px; font-size: 13px;
}

.weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.weekdays { margin-bottom: 8px; }
.weekdays span { text-align: center; color: var(--muted); font-size: 12px; padding: 4px; }

.day {
  position: relative;
  min-height: 105px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.025);
  color: var(--text);
  border-radius: 16px;
  padding: 10px;
  text-align: left;
  overflow: hidden;
  transition: .16s ease;
}
.day:hover { transform: translateY(-1px); border-color: rgba(167,139,250,.35); }
.day.outside { opacity: .28; }
.day.today { box-shadow: inset 0 0 0 1px rgba(139,92,246,.65); }
.day.selected { background: rgba(139,92,246,.13); border-color: rgba(167,139,250,.55); }
.day.locked::after {
  content: "🔒";
  position: absolute; top: 8px; right: 9px; font-size: 13px;
}
.day-num { font-weight: 800; font-size: 14px; }
.day-events { margin-top: 8px; display: grid; gap: 5px; }
.day-event {
  background: rgba(255,255,255,.07);
  padding: 5px 6px;
  border-radius: 8px;
  font-size: 11px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.day-more { color: var(--muted); font-size: 11px; }

.side-head { align-items: flex-start; margin-bottom: 12px; }
.side-head h2 { margin: 4px 0 0; font-size: 22px; }
.lock-badge {
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 10px;
  font-size: 12px; white-space: nowrap;
}
.lock-badge.mine { color: #bbf7d0; background: rgba(52,211,153,.12); border-color: rgba(52,211,153,.2); }
.lock-badge.other { color: #fde68a; background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.25); }
.lock-badge.neutral { color: var(--muted); }

.notice {
  border: 1px solid rgba(245,158,11,.23);
  background: rgba(245,158,11,.09);
  color: #fde68a;
  border-radius: 14px;
  padding: 11px 12px;
  margin: 6px 0 12px;
  font-size: 13px;
}

.booking-list { display: grid; gap: 10px; flex: 1; align-content: start; }
.booking-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px;
  background: rgba(255,255,255,.035);
}
.booking-card.editable:hover { border-color: rgba(167,139,250,.4); }
.booking-time { font-size: 12px; color: #c4b5fd; font-weight: 800; }
.booking-title { margin-top: 4px; font-weight: 800; font-size: 16px; }
.booking-meta { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.empty {
  color: var(--muted); border: 1px dashed var(--line); border-radius: 16px;
  padding: 24px 16px; text-align: center; margin-top: 6px;
}

.primary-btn, .secondary-btn, .danger-btn {
  border-radius: 14px; border: 1px solid transparent; padding: 12px 14px; font-weight: 800;
}
.primary-btn { background: linear-gradient(135deg, var(--accent), #6d5dfc); color: white; margin-top: 12px; }
.secondary-btn { background: rgba(255,255,255,.05); border-color: var(--line); color: var(--text); margin-top: 10px; }
.danger-btn { background: rgba(251,113,133,.12); border-color: rgba(251,113,133,.25); color: #fecdd3; }

.dialog { border: 0; background: transparent; color: var(--text); padding: 14px; }
.dialog::backdrop { background: rgba(0,0,0,.65); backdrop-filter: blur(5px); }
.dialog-card {
  width: min(580px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #111827;
  box-shadow: var(--shadow);
  padding: 20px;
}
.dialog-title h3 { margin: 4px 0 16px; font-size: 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.span-2 { grid-column: span 2; }
label { display: grid; gap: 7px; font-size: 12px; color: #cbd5e1; font-weight: 700; }
input, textarea {
  width: 100%; border: 1px solid var(--line); background: rgba(255,255,255,.045); color: var(--text);
  border-radius: 12px; padding: 11px 12px; outline: none;
}
input:focus, textarea:focus { border-color: rgba(167,139,250,.65); box-shadow: 0 0 0 3px rgba(139,92,246,.12); }
textarea { resize: vertical; }
.grow { flex: 1; }

.hidden { display: none !important; }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px);
  opacity: 0; pointer-events: none; background: #020617; border: 1px solid var(--line);
  color: var(--text); border-radius: 999px; padding: 10px 14px; font-size: 13px;
  transition: .2s ease; box-shadow: var(--shadow); z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side-panel { min-height: auto; }
  .day { min-height: 82px; padding: 8px; border-radius: 13px; }
  .day-event { display: none; }
  .day-events { margin-top: 8px; }
  .day-events::after { content: attr(data-count); color: var(--muted); font-size: 10px; }
}

@media (max-width: 520px) {
  .topbar { padding-top: 18px; }
  .profile-btn { max-width: 46%; }
  #profileName { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .calendar-card { padding: 12px; }
  .calendar-grid, .weekdays { gap: 5px; }
  .day { min-height: 67px; padding: 7px; }
  .day-num { font-size: 13px; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .dialog-actions { flex-wrap: wrap; }
}
