:root {
  --bg: #F4F6F8;
  --card: #FFFFFF;
  --ink: #16202B;
  --ink2: #5C6773;
  --ink3: #98A2AE;
  --line: #E6EAF0;
  --brand: #07A05A;
  --brand-dark: #058248;
  --brand-soft: #E9F7F0;
  --blue: #2F80ED;
  --blue-soft: #EAF2FD;
  --red: #D93A3E;
  --red-soft: #FDECEC;
  --amber: #C77B12;
  --amber-soft: #FDF3E3;
  --gray-soft: #F1F3F6;
  --radius: 16px;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body { display: flex; justify-content: center; }

#shell {
  position: relative;
  width: 100%;
  max-width: 480px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

@media (min-width: 520px) {
  #shell {
    box-shadow: 0 0 0 1px var(--line), 0 10px 40px rgba(16, 24, 40, 0.06);
    min-height: 100vh;
  }
}

/* ---------- 顶栏 ---------- */
#hdr {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 18px 14px;
  background: rgba(244, 246, 248, 0.92);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
}

.hdr-txt { flex: 1; min-width: 0; }
#title { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -0.2px; }
#subtitle { margin: 2px 0 0; font-size: 12.5px; color: var(--ink3); }

.back {
  width: 34px; height: 34px;
  margin-left: -6px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.1);
}
.back[hidden] { display: none; }

.badge {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge[hidden] { display: none; }

/* ---------- 内容区 ---------- */
#view {
  flex: 1;
  padding: 4px 18px calc(96px + env(safe-area-inset-bottom, 0px));
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.card.pad0 { padding: 0; overflow: hidden; }

.sec-title {
  margin: 22px 2px 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink2);
}
.sec-title:first-child { margin-top: 8px; }

.muted { color: var(--ink3); font-size: 13px; }
.small { font-size: 12.5px; }
.center { text-align: center; }

/* ---------- 登录页 ---------- */
.hero { padding: 46px 6px 18px; text-align: center; }
.hero .logo {
  width: 66px; height: 66px;
  margin: 0 auto 18px;
  border-radius: 19px;
  background: var(--brand);
  position: relative;
}
.hero .logo::before {
  content: "";
  position: absolute;
  left: 50%; top: 18px; bottom: 18px;
  width: 2px;
  background: #fff;
  border-radius: 1px;
  transform: translateX(-50%);
  box-shadow: -13px 0 0 #fff, 13px 0 0 #fff;
}
.hero .logo::after { display: none; }
.hero .logo i { display: none; }
.hero h2 { margin: 0 0 6px; font-size: 22px; font-weight: 600; letter-spacing: -0.3px; }
.hero p { margin: 0; color: var(--ink2); font-size: 13.5px; }

.login-box { margin-top: 6px; }
.agree { margin-top: 14px; font-size: 11.5px; color: var(--ink3); line-height: 1.7; text-align: center; }

/* ---------- 按钮 ---------- */
.btn {
  display: block;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-radius: 13px;
  font-size: 15.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-ghost { background: var(--gray-soft); color: var(--ink); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-sm { padding: 9px 14px; font-size: 13px; border-radius: 10px; width: auto; display: inline-block; }

/* ---------- 用户卡 ---------- */
.user-card {
  background: linear-gradient(180deg, #FFFFFF 0%, #FFFFFF 100%);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.user-card::after {
  content: "";
  position: absolute;
  right: -30px; top: -30px;
  width: 110px; height: 110px;
  border-radius: 50%;
  background: var(--brand-soft);
}
.user-top { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.avatar {
  width: 46px; height: 46px;
  border-radius: 14px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 600;
  flex: none;
}
.user-name { font-size: 17px; font-weight: 600; }
.user-meta { font-size: 12.5px; color: var(--ink3); margin-top: 2px; }
.credit {
  position: relative; z-index: 1;
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.credit .n { font-size: 26px; font-weight: 600; letter-spacing: -0.5px; }
.credit .n.ok { color: var(--brand); }
.credit .n.warn { color: var(--amber); }
.credit .n.bad { color: var(--red); }
.credit .t { font-size: 12.5px; color: var(--ink3); }
.credit .sp { flex: 1; }
.credit .lv {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--gray-soft);
  color: var(--ink2);
}

/* ---------- 预约条目 ---------- */
.bk {
  display: flex;
  gap: 14px;
  padding: 15px 16px;
  background: #fff;
  border-radius: var(--radius);
  margin-bottom: 10px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  cursor: pointer;
  border: 1px solid transparent;
}
.bk:active { background: #FAFBFC; }

.bk-time {
  flex: none;
  width: 62px;
  text-align: center;
  padding-right: 12px;
  border-right: 1px solid var(--line);
}
.bk-time .d { font-size: 11.5px; color: var(--ink3); }
.bk-time .h { font-size: 13.5px; font-weight: 600; margin-top: 2px; letter-spacing: -0.2px; }
.bk-main { flex: 1; min-width: 0; }
.bk-room { font-size: 15px; font-weight: 600; }
.bk-sub { font-size: 12.5px; color: var(--ink3); margin-top: 3px; }
.bk-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }

.tag {
  display: inline-block;
  padding: 2.5px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.tag-blue { background: var(--blue-soft); color: var(--blue); }
.tag-green { background: var(--brand-soft); color: var(--brand-dark); }
.tag-gray { background: var(--gray-soft); color: var(--ink2); }
.tag-red { background: var(--red-soft); color: var(--red); }
.tag-amber { background: var(--amber-soft); color: var(--amber); }

/* ---------- 琴房卡 ---------- */
.room {
  display: flex;
  gap: 14px;
  padding: 16px;
  background: #fff;
  border-radius: var(--radius);
  margin-bottom: 11px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color 0.15s;
}
.room:active { border-color: var(--brand); }
.room.closed { opacity: 0.55; cursor: default; }

.room-thumb {
  flex: none;
  width: 56px; height: 56px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.1;
}
.room-thumb span { font-size: 10.5px; font-weight: 400; color: var(--brand); margin-top: 2px; }
.room-body { flex: 1; min-width: 0; }
.room-name { font-size: 15.5px; font-weight: 600; }
.room-desc { font-size: 12.5px; color: var(--ink3); margin-top: 3px; }
.room-fac {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}
.room-fac span {
  font-size: 11px;
  color: var(--ink2);
  background: var(--gray-soft);
  padding: 2px 7px;
  border-radius: 6px;
}

/* ---------- 日期条 ---------- */
.days {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 10px;
  margin: 0 -18px;
  padding-left: 18px;
  padding-right: 18px;
  scrollbar-width: none;
}
.days::-webkit-scrollbar { display: none; }
.day {
  flex: none;
  width: 54px;
  padding: 9px 0 8px;
  border-radius: 12px;
  background: #fff;
  border: 1.5px solid transparent;
  text-align: center;
  cursor: pointer;
  font-family: inherit;
}
.day .w { font-size: 11px; color: var(--ink3); }
.day .n { font-size: 16px; font-weight: 600; margin-top: 1px; }
.day.on { background: var(--brand); border-color: var(--brand); }
.day.on .w, .day.on .n { color: #fff; }

/* ---------- 时段网格 ---------- */
.slots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  margin-top: 4px;
}
.slot {
  position: relative;
  padding: 12px 0 11px;
  border-radius: 11px;
  background: #fff;
  border: 1.5px solid var(--line);
  text-align: center;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.13s;
}
.slot small { display: block; font-size: 10px; color: var(--ink3); font-weight: 400; margin-top: 1px; }
.slot.on {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.slot.on small { color: rgba(255, 255, 255, 0.8); }
.slot.off {
  background: var(--gray-soft);
  border-color: transparent;
  color: var(--ink3);
  cursor: default;
  text-decoration: line-through;
}
.slot.off small { text-decoration: none; }
.slot.taken {
  background: #fff;
  border-color: var(--line);
  border-style: dashed;
  color: var(--ink3);
  cursor: default;
}
.slot.taken small { color: var(--ink3); }

.legend {
  display: flex;
  gap: 16px;
  margin-top: 14px;
  font-size: 11.5px;
  color: var(--ink3);
}
.legend i {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 3px;
  margin-right: 5px;
  vertical-align: -1px;
}

/* ---------- 底部确认条 ---------- */
.bar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 30;
}
.bar[hidden] { display: none; }
.bar-info { flex: 1; min-width: 0; }
.bar-info .a { font-size: 13.5px; font-weight: 600; }
.bar-info .b { font-size: 11.5px; color: var(--ink3); margin-top: 1px; }
.bar .btn { width: auto; padding: 12px 26px; flex: none; }

/* ---------- 底部 tab ---------- */
#tabs {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 25;
}
#tabs[hidden] { display: none; }
#tabs button {
  flex: 1;
  border: 0;
  background: none;
  padding: 9px 0 8px;
  font-family: inherit;
  font-size: 10.5px;
  color: var(--ink3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
}
#tabs button.on { color: var(--brand); }

.ic {
  width: 21px; height: 21px;
  border: 1.6px solid currentColor;
  border-radius: 6px;
  display: block;
  position: relative;
}
.ic-home { border-radius: 7px; }
.ic-home::after {
  content: "";
  position: absolute;
  left: 5px; right: 5px; bottom: 3px;
  height: 1.6px;
  background: currentColor;
  box-shadow: 0 -5px 0 currentColor;
}
.ic-room::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 1.6px; height: 9px;
  background: currentColor;
  transform: translate(-50%, -50%);
}
.ic-list::after {
  content: "";
  position: absolute;
  left: 4px; right: 4px; top: 6px;
  height: 1.6px;
  background: currentColor;
  box-shadow: 0 5px 0 currentColor;
}
.ic-me { border-radius: 50%; width: 21px; height: 21px; }
.ic-me::after {
  content: "";
  position: absolute;
  left: 50%; bottom: -1px;
  width: 13px; height: 7px;
  border: 1.6px solid currentColor;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  transform: translateX(-50%);
  background: #fff;
}

/* ---------- 空态 ---------- */
.empty {
  padding: 56px 20px;
  text-align: center;
  color: var(--ink3);
  font-size: 13.5px;
}
.empty .box {
  width: 52px; height: 52px;
  margin: 0 auto 14px;
  border: 1.6px dashed #CBD3DD;
  border-radius: 14px;
}

.loading { padding: 60px 0; text-align: center; color: var(--ink3); font-size: 13.5px; }
.loading::after {
  content: "";
  display: block;
  width: 22px; height: 22px;
  margin: 14px auto 0;
  border: 2px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .loading::after { animation: none; }
  .btn:active { transform: none; }
}

/* ---------- 详情行 ---------- */
.kv {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--ink3); flex: none; }
.kv .v { text-align: right; font-weight: 500; }

.notice {
  margin-top: 14px;
  padding: 13px 14px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 12.5px;
  line-height: 1.7;
}
.notice.amber { background: var(--amber-soft); color: var(--amber); }

/* ---------- 弹层 ---------- */
.sheet-wrap {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-wrap[hidden] { display: none; }
.sheet-mask {
  position: absolute;
  inset: 0;
  background: rgba(16, 24, 40, 0.42);
}
.sheet {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 22px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  animation: up 0.24s ease-out;
}
@keyframes up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet h2 { margin: 0 0 14px; font-size: 17px; font-weight: 600; }
.sheet .btn { margin-top: 4px; }

/* ---------- toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translate(-50%, 10px);
  max-width: 320px;
  padding: 11px 18px;
  border-radius: 11px;
  background: rgba(22, 32, 43, 0.92);
  color: #fff;
  font-size: 13.5px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 80;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

.divider { height: 1px; background: var(--line); margin: 14px 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
