:root {
  --bg: #f4f1ff;
  --bg2: #fef6fb;
  --card: #ffffff;
  --ink: #2c2540;
  --muted: #8a82a3;
  --line: #e9e4f5;
  --brand: #7c5cff;
  --brand-ink: #ffffff;
  --ok: #1f9d63;
  --warn: #d9822b;
  --danger: #e5484d;
  --shadow: 0 10px 30px rgba(70, 50, 140, 0.12);
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "PingFang TC", "Noto Sans TC", -apple-system, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg), var(--bg2));
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.brand {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.brand .emoji { margin-right: 6px; }

.navlink {
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
}
.navlink:hover { color: var(--brand); border-color: var(--brand); }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
}

.card h2 {
  margin: 0 0 4px;
  font-size: 18px;
}
.card .sub {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 14px 0 6px;
  color: var(--ink);
}

select, input[type="text"], input[type="email"], input[type="password"], textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfaff;
  color: var(--ink);
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.15);
}
textarea { resize: vertical; min-height: 110px; line-height: 1.6; }

.btn {
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  background: var(--brand);
  color: var(--brand-ink);
  transition: transform .05s, filter .15s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.full { width: 100%; margin-top: 18px; }
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 9px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; }
.row > .btn { flex: 0 0 auto; }

.result {
  margin-top: 20px;
  padding: 22px;
  border-radius: 14px;
  text-align: center;
  display: none;
}
.result.show { display: block; }
.result.ok { background: #eafaf1; border: 1px solid #b7eccd; }
.result.warn { background: #fdf3e7; border: 1px solid #f4d9b0; }
.result.err { background: #fdeaea; border: 1px solid #f5c2c4; }
.result .lead { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.result .master { font-size: 30px; font-weight: 900; color: var(--brand); }
.result .msg { font-size: 15px; line-height: 1.7; }

.hint { font-size: 13px; color: var(--muted); margin-top: 10px; line-height: 1.6; }

.status-line {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14px; padding: 8px 14px; border-radius: 999px;
  background: #f2eeff; color: var(--brand); font-weight: 700;
}
.status-line.gray { background: #f0eef5; color: var(--muted); }

/* 名單 / 紀錄 表格 */
.list { list-style: none; padding: 0; margin: 14px 0 0; }
.list li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px; border: 1px solid var(--line);
  border-radius: 11px; margin-bottom: 8px; background: #fbfaff;
}
.list .who { font-weight: 700; }
.list .item-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.list .edit-input {
  flex: 1; margin-right: 10px; padding: 8px 11px; font-size: 14px;
  border: 1px solid var(--brand); border-radius: 9px; background: #fff;
}
.badge { font-size: 12px; padding: 2px 9px; border-radius: 999px; margin-left: 8px; }
.badge.bound { background: #eafaf1; color: var(--ok); }
.badge.free { background: #f0eef5; color: var(--muted); }

table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
td .arrow { color: var(--brand); margin: 0 6px; }

.empty { color: var(--muted); font-size: 14px; padding: 14px 0; }

.log { list-style: none; padding: 0; margin: 12px 0 0; font-size: 13px; }
.log li { padding: 8px 0; border-bottom: 1px dashed var(--line); color: var(--muted); }
.log .r { color: var(--ink); font-weight: 700; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px;
  font-size: 14px; box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.err { background: var(--danger); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(30, 22, 55, 0.45);
  display: none; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: #fff; border-radius: 18px; padding: 26px; max-width: 420px; width: 100%;
  box-shadow: var(--shadow); text-align: center;
}
.modal h3 { margin: 0 0 10px; font-size: 19px; }
.modal p { color: var(--muted); font-size: 14px; line-height: 1.7; margin: 0 0 22px; }
.modal .actions { display: flex; gap: 10px; }
.modal .actions .btn { flex: 1; }

.section-title { font-size: 13px; font-weight: 700; color: var(--muted); margin: 22px 0 6px; }
