/* 首頁（index.html）：輸入代碼 + 登入 */
* { box-sizing: border-box; }
html { min-height: 100%; }
body.home { margin: 0; min-height: 100vh; color: var(--t-ink); font-family: var(--t-font); overflow-x: hidden; }
body.home:not(.is-ready) .home-main { visibility: hidden; }
button, input { font: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.home-top {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.home-brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.home-brand > span:last-child { display: grid; }
.home-brand strong { font-size: 17px; }
.home-brand small { color: var(--t-muted); font-size: 12px; font-weight: 700; }
.home-mark {
  width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 14px; color: #fff; font-size: 24px; font-weight: 900;
  background: linear-gradient(145deg, #7b6ff7, var(--t-primary-dark));
  box-shadow: 0 8px 20px rgba(91, 79, 240, 0.3);
  transform: rotate(-5deg);
}

.home-top-link {
  padding: 9px 16px; border: 1px solid var(--t-line); border-radius: 999px;
  color: var(--t-primary-dark); background: rgba(255, 255, 255, 0.8);
  font-weight: 800; text-decoration: none; white-space: nowrap;
}
.home-top-link:hover { background: #fff; border-color: #cbc6f5; }

.home-main { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
  gap: clamp(24px, 5vw, 64px);
  align-items: start;
  padding: clamp(20px, 5vw, 56px) 0 32px;
}

.hero-copy { position: relative; padding-top: 12px; }
.hero-kicker {
  display: inline-block; padding: 6px 14px; border-radius: 999px;
  color: var(--t-coral); background: #fff0eb; font-size: 14px; font-weight: 900;
}

.hero-copy h1 {
  margin: 18px 0 16px;
  font-size: clamp(40px, 6.4vw, 76px);
  line-height: 1.08;
  letter-spacing: -0.01em;
}

.hero-typed {
  background: linear-gradient(100deg, var(--t-primary), #a26bff 55%, var(--t-coral));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  border-right: 0.08em solid var(--t-primary);
  padding-right: 0.06em;
  animation: home-caret 0.9s steps(1) infinite;
  white-space: nowrap;
}

@keyframes home-caret { 50% { border-color: transparent; } }

.hero-lead { max-width: 520px; margin: 0; color: var(--t-muted); font-size: 18px; font-weight: 600; line-height: 1.7; }

/* 小示範：一句話自動打出來 */
.hero-demo {
  position: relative; z-index: 1;
  max-width: 520px; margin-top: 30px; padding: 16px 20px 18px;
  border: 1px solid var(--t-line); border-radius: 20px;
  background: rgba(255, 255, 255, 0.92); box-shadow: var(--t-shadow-lift);
  transform: rotate(-1.2deg);
}
.demo-head { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; color: var(--t-muted); font-size: 12px; font-weight: 800; }
.demo-head i { width: 10px; height: 10px; border-radius: 50%; background: #ffb4a3; }
.demo-head i:nth-child(2) { background: #ffd98a; }
.demo-head i:nth-child(3) { background: #94e3c4; }
.demo-head span { margin-left: auto; }
.demo-line { min-height: 2.2em; margin: 0; font-size: 26px; letter-spacing: 0.06em; line-height: 1.6; }
.demo-line span { display: inline-block; border-radius: 4px; color: #b8b6cf; }
.demo-line span.ok { color: #0f7a57; background: rgba(18, 184, 134, 0.12); animation: fx-pop 260ms cubic-bezier(.3, 1.6, .5, 1); }
.demo-line span.bad { color: #c42b31; background: rgba(229, 72, 77, 0.14); animation: fx-shake 320ms ease; }
.demo-line span.cur { color: var(--t-ink); background: rgba(91, 79, 240, 0.14); box-shadow: inset 0 -3px 0 var(--t-primary); }
.demo-stats { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 10px; color: var(--t-muted); font-size: 13px; font-weight: 800; }
.demo-stats b { color: var(--t-ink); font-size: 16px; font-variant-numeric: tabular-nums; }
.demo-combo { color: var(--t-primary); }
.demo-combo b { color: var(--t-primary); }
.demo-combo.is-bump b { display: inline-block; animation: fx-bump 240ms ease; }

/* 漂浮的鍵帽 */
.hero-keys { position: absolute; inset: 0; pointer-events: none; }
.kc {
  position: absolute; width: 54px; height: 54px; display: grid; place-items: center;
  border-radius: 14px; background: #fff; color: var(--t-primary);
  box-shadow: 0 5px 0 #dcd8f6, 0 14px 26px rgba(47, 39, 140, 0.12);
  font-size: 24px; font-weight: 900;
  animation: home-float 6s ease-in-out infinite;
}
.kc-1 { right: 4%; top: 0; animation-delay: -1s; }
.kc-2 { right: 16%; top: 120px; color: var(--t-coral); animation-delay: -3s; transform: rotate(8deg); }
.kc-3 { right: -2%; top: 250px; color: var(--t-mint-dark); animation-delay: -2s; }
.kc-4 { left: 40%; top: -6px; animation-delay: -4s; }
.kc-5 { right: 2%; bottom: 60px; color: #d48806; animation-delay: -5s; }
@keyframes home-float { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-14px) rotate(6deg); } }

/* 右邊：代碼卡 + 登入卡 */
.hero-side { display: grid; gap: 18px; }

.code-card {
  position: relative;
  padding: 26px 26px 22px;
  border-radius: 26px;
  color: #fff;
  background: linear-gradient(150deg, #6f62f7 0%, var(--t-primary) 45%, #3a2fb8 100%);
  box-shadow: 0 26px 60px rgba(67, 55, 201, 0.35);
  overflow: hidden;
}
.code-card::before {
  content: ""; position: absolute; width: 240px; height: 240px; right: -90px; top: -110px;
  border-radius: 50%; background: rgba(255, 255, 255, 0.1);
}
.code-card-kicker { position: relative; color: rgba(255, 255, 255, 0.75); font-size: 13px; font-weight: 900; letter-spacing: 0.08em; }
.code-card h2 { position: relative; margin: 4px 0 18px; font-size: 28px; }

.code-field { position: relative; display: block; margin-bottom: 16px; }
.code-field input {
  position: relative; z-index: 1;
  width: 100%; height: 76px; padding: 0;
  border: 0; border-radius: 18px; outline: none;
  color: transparent; caret-color: transparent; background: transparent;
  font-size: 16px; text-transform: uppercase; cursor: text;
}
.code-field input::selection { background: transparent; }
.code-slots {
  position: absolute; inset: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px;
  padding: 8px; border-radius: 18px; background: #fff;
  box-shadow: 0 6px 0 rgba(31, 29, 71, 0.25);
}
.code-slots i {
  display: grid; place-items: center;
  border-radius: 12px; background: var(--t-soft);
  color: var(--t-ink); font-family: "Consolas", "SFMono-Regular", "Menlo", monospace;
  font-size: 34px; font-style: normal; font-weight: 900;
  transition: background 160ms ease;
}
.code-slots i.is-filled { background: var(--t-primary-soft); animation: fx-bump 220ms ease; }
.code-field input:focus ~ .code-slots i.is-current { box-shadow: inset 0 -4px 0 var(--t-primary); animation: fx-caret 1.1s ease-in-out infinite; }
.code-field input:focus ~ .code-slots { box-shadow: 0 6px 0 rgba(31, 29, 71, 0.25), 0 0 0 4px rgba(255, 255, 255, 0.45); }
.code-field.is-error .code-slots { animation: fx-shake 360ms ease; box-shadow: 0 6px 0 rgba(31, 29, 71, 0.25), 0 0 0 4px rgba(255, 122, 89, 0.85); }

.home-field { display: grid; gap: 6px; margin-bottom: 14px; font-size: 14px; font-weight: 800; }
.home-field input,
.home-field select {
  width: 100%; min-height: 50px; padding: 10px 14px;
  border: 1px solid var(--t-line); border-radius: 14px; outline: none;
  color: var(--t-ink); background: #fff; font-size: 17px;
}
.home-field select:focus,
.home-field input:focus { border-color: var(--t-primary); box-shadow: 0 0 0 4px rgba(91, 79, 240, 0.15); }
.code-card .home-field { position: relative; color: rgba(255, 255, 255, 0.9); }
.code-card .home-field input,
.code-card .home-field select { border-color: transparent; }
.code-card .home-field input:focus { box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.45); }

.code-signed { position: relative; margin: -4px 0 14px; color: rgba(255, 255, 255, 0.9); font-weight: 700; }

.home-submit {
  position: relative;
  width: 100%; min-height: 58px; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border: 0; border-radius: 999px; cursor: pointer;
  color: var(--t-primary-dark); background: #fff;
  box-shadow: 0 6px 0 rgba(31, 29, 71, 0.3);
  font-size: 19px; font-weight: 900;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.home-submit svg { width: 22px; height: 22px; fill: currentColor; transition: transform 160ms ease; }
.home-submit:hover svg { transform: translateX(4px); }
.home-submit:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(31, 29, 71, 0.3); }
.home-submit:disabled { opacity: 0.7; cursor: wait; }
.home-submit.secondary { color: #fff; background: linear-gradient(135deg, #7366f6, var(--t-primary)); box-shadow: 0 5px 0 var(--t-primary-dark); min-height: 52px; font-size: 17px; }

.home-message { min-height: 1.4em; margin: 12px 0 0; font-weight: 800; text-align: center; }
.code-card .home-message { position: relative; color: #ffe1d8; }
.login-card .home-message { color: var(--t-red); }

.login-card {
  padding: 18px 22px 16px;
  border: 1px solid var(--t-line); border-radius: 22px;
  background: rgba(255, 255, 255, 0.92); box-shadow: var(--t-shadow);
}
.login-tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 14px; border-radius: 999px; background: var(--t-soft); }
.login-tab { flex: 1; padding: 9px 12px; border: 0; border-radius: 999px; color: var(--t-muted); background: transparent; font-weight: 900; cursor: pointer; }
.login-tab.is-active { color: var(--t-ink); background: #fff; box-shadow: 0 2px 8px rgba(47, 39, 140, 0.1); }
.login-note { margin: 10px 0 0; color: var(--t-muted); font-size: 13px; font-weight: 600; text-align: center; }
.guest-login-pane .login-note { margin: 0 0 12px; }

/* 三個步驟 */
.home-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 12px 0 40px; }
.home-steps article {
  padding: 20px 22px; border: 1px solid var(--t-line); border-radius: 20px;
  background: rgba(255, 255, 255, 0.8); box-shadow: var(--t-shadow);
  transition: transform 160ms ease;
}
.home-steps article:hover { transform: translateY(-3px); }
.home-steps b {
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 12px;
  color: #fff; background: var(--t-primary); font-size: 17px;
}
.home-steps article:nth-child(2) b { background: var(--t-coral); }
.home-steps article:nth-child(3) b { background: var(--t-mint); }
.home-steps h3 { margin: 12px 0 4px; font-size: 18px; }
.home-steps p { margin: 0; color: var(--t-muted); font-weight: 600; line-height: 1.6; }

.home-credit { margin: 0; padding: 0 16px 28px; color: var(--t-muted); font-size: 13px; font-weight: 700; text-align: center; }

.home-toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50;
  transform: translate(-50%, 18px); max-width: calc(100vw - 32px);
  padding: 12px 18px; border-radius: 14px; color: #fff; background: var(--t-ink);
  opacity: 0; pointer-events: none; transition: 160ms ease; font-weight: 800;
}
.home-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .home-hero { grid-template-columns: 1fr; }
  .hero-side { order: -1; }
  .hero-demo, .hero-keys { display: none; }
  .hero-copy h1 { margin-top: 10px; font-size: clamp(34px, 9vw, 52px); }
  .home-steps { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .home-brand small { display: none; }
  .home-brand strong { font-size: 15px; }
  .code-card { padding: 22px 18px 18px; }
  .code-field input { height: 68px; }
  .code-slots i { font-size: 28px; }
  .code-slots { gap: 4px; padding: 6px; }
}
.code-hint { position: relative; margin: -6px 0 14px; color: rgba(255, 255, 255, 0.75); font-size: 13px; font-weight: 700; }

/* ---------- 登入／註冊 ---------- */
.login-tab[hidden] { display: none; }
.auth-pane[hidden] { display: none; }

.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 50px;
  margin-bottom: 12px;
  border: 1px solid #dadce0;
  border-radius: 999px;
  color: #1f1f1f;
  background: #fff;
  font-size: 16px;
  font-weight: 800;
  text-decoration: none;
  transition: background 140ms ease, box-shadow 140ms ease;
}
.google-btn:hover { background: #f8f9fb; box-shadow: 0 2px 8px rgba(31, 29, 71, 0.1); }
.google-btn:focus-visible { outline: 3px solid rgba(91, 79, 240, 0.35); outline-offset: 2px; }
.google-btn[hidden] { display: none; }
.g-logo { width: 20px; height: 20px; flex: none; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  color: var(--t-muted);
  font-size: 12px;
  font-weight: 800;
}
.auth-divider[hidden] { display: none; }
.auth-divider::before,
.auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--t-line); }

.home-field small { color: var(--t-muted); font-weight: 600; }

.login-links { display: flex; justify-content: space-between; gap: 8px; margin: 12px 0 0; }
.login-links:has(> :only-child) { justify-content: center; }
.link-btn {
  padding: 4px 2px;
  border: 0;
  color: var(--t-primary);
  background: none;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }
.link-btn[hidden] { display: none; }

.role-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 14px; padding: 0; border: 0; }
.role-pick legend { margin-bottom: 6px; padding: 0; font-size: 14px; font-weight: 800; }
.role-pick label { position: relative; }
.role-pick label[hidden] { display: none; }
.role-pick input { position: absolute; opacity: 0; pointer-events: none; }
.role-pick span {
  display: grid;
  place-items: center;
  min-height: 46px;
  border: 1px solid var(--t-line);
  border-radius: 14px;
  color: var(--t-ink);
  background: #fff;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  transition: 140ms ease;
}
.role-pick input:checked + span { border-color: var(--t-primary); color: var(--t-primary-dark); background: var(--t-primary-soft); box-shadow: inset 0 0 0 1px var(--t-primary); }
.role-pick input:focus-visible + span { outline: 3px solid rgba(91, 79, 240, 0.35); outline-offset: 2px; }
.role-pick.is-missing span { animation: fx-shake 360ms ease; border-color: var(--t-red); }

.auth-title { margin: 2px 0 6px; font-size: 19px; text-align: center; }
.auth-lead { margin: 0 0 14px; }

.auth-done { padding: 6px 0 2px; text-align: center; }
.auth-done-icon {
  display: inline-grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(145deg, #7b6ff7, var(--t-primary-dark));
  font-size: 26px;
}
.auth-done h3 { margin: 10px 0 6px; font-size: 19px; }
.auth-done p { margin: 0 0 12px; color: var(--t-muted); font-weight: 600; line-height: 1.6; }
.dev-link { display: block; margin: 0 0 10px; padding: 10px 12px; border-radius: 12px; color: #8a5a07; background: #fff3d9; font-size: 13px; font-weight: 800; }
.dev-link[hidden] { display: none; }

.role-big { display: grid; gap: 10px; }
.role-big-btn {
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  border: 1px solid var(--t-line);
  border-radius: 16px;
  color: var(--t-ink);
  background: #fff;
  text-align: left;
  cursor: pointer;
  transition: 140ms ease;
}
.role-big-btn:hover { border-color: var(--t-primary); background: var(--t-primary-soft); }
.role-big-btn b { font-size: 17px; }
.role-big-btn small { color: var(--t-muted); font-weight: 600; }
.role-big-btn[hidden] { display: none; }
