/*
 * 사이 产品主页的团队购买（static/js/sai-team.js）：照搬 사이 团队购买面板
 * （cn2kr apps/web/src/components/redeem/team.css），类名、尺寸、配色与之一致。
 * 颜色取 사이 默认皮肤「韩纸」的亮、暗两套种子，与 sai-plans.css 相同，只在 .tm-root 和页面上的团队单行里生效。
 * 弹窗尺寸固定，换步骤只换正文，正文内部滚动；有输入框，点遮罩不关，Esc 关。
 */

.tm-root, .tm-prow {
  --sf: 255 252 246; --fg: 70 50 25; --tx: 31 27 22;
  --cin-rgb: 196 78 52; --cel-rgb: 30 138 118; --gold-rgb: 160 108 34;
  --gold-a: #ecc98a; --gold-b: #f8e6c2; --on-gold: #2a1d08; --shade: 90 65 30;
}
:root[data-theme='dark'] .tm-root, :root[data-theme='dark'] .tm-prow {
  --sf: 16 18 28; --fg: 255 245 230; --tx: 241 236 227;
  --cin-rgb: 239 106 79; --cel-rgb: 127 209 191; --gold-rgb: 243 217 164;
  --gold-a: #f3d9a4; --gold-b: #fff2d6; --on-gold: #15110a; --shade: 0 0 0;
}
.tm-root {
  --line: rgb(var(--fg) / 0.075);
  --line-2: rgb(var(--fg) / 0.14);
  --hover-soft: rgb(var(--fg) / 0.05);
  --text: rgb(var(--tx));
  --text-2: rgb(var(--tx) / 0.68);
  --text-3: rgb(var(--tx) / 0.46);
  --gold: rgb(var(--gold-rgb));
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --sans: 'SF Pro Text', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Noto Sans SC', 'Microsoft YaHei', 'Malgun Gothic', system-ui, sans-serif;
  color-scheme: light;
}
:root[data-theme='dark'] .tm-root { color-scheme: dark; }

.tm-root {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 24px 16px;
  color: var(--text);
  font-family: var(--sans);
  animation: tm-in 0.3s var(--ease) both;
}
.tm-root.closing { animation: tm-out 0.26s var(--ease) both; pointer-events: none; }
.tm-root *, .tm-root *::before, .tm-root *::after { box-sizing: border-box; }
@keyframes tm-in { from { opacity: 0; } }
@keyframes tm-out { to { opacity: 0; } }
body.tm-open { overflow: hidden; }

.tm-scrim {
  position: absolute;
  inset: 0;
  background: rgb(var(--sf) / 0.6);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
}

.tm-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(560px, 100%);
  min-width: 0;
  max-height: 100%;
  border: 1px solid var(--line-2);
  border-radius: 24px;
  background: rgb(var(--sf));
  box-shadow: 0 30px 80px -30px rgb(var(--shade) / 0.45), 0 2px 8px rgb(var(--shade) / 0.06);
  outline: none;
  animation: tm-rise 0.42s var(--ease) both;
}
@keyframes tm-rise { from { transform: translateY(14px) scale(0.985); } }

.tm-head { display: flex; align-items: center; gap: 10px; padding: 16px 16px 10px 20px; }
.tm-head h2 { flex: 1; margin: 0; font-size: 16px; font-weight: 700; letter-spacing: 0.01em; }
.tm-lead { display: inline-flex; }
.tm-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgb(var(--gold-rgb) / 0.12);
  color: var(--gold);
}
.tm-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.tm-icon.sm { width: 30px; height: 30px; flex: none; }
.tm-icon:hover { background: var(--hover-soft); color: var(--text); }
.tm-icon:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.tm-b { height: min(580px, calc(100dvh - 190px)); overflow: hidden auto; padding: 4px 20px 12px; overscroll-behavior: contain; }

.tm-f { display: flex; align-items: center; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.tm-gap { flex: 1; }
.tm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: rgb(var(--sf));
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, opacity 0.2s;
}
.tm-btn:hover:not(:disabled) { background: var(--hover-soft); }
.tm-btn.ghost { border-color: transparent; background: none; color: var(--text-2); }
.tm-btn.ghost:hover:not(:disabled) { color: var(--text); }
.tm-btn.primary { border-color: transparent; background: linear-gradient(120deg, var(--gold-a), var(--gold-b)); color: var(--on-gold); }
.tm-btn.primary:hover:not(:disabled) { background: linear-gradient(120deg, var(--gold-a), var(--gold-a)); }
.tm-btn:disabled { opacity: 0.5; cursor: default; }
.tm-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.tm-spin { display: inline-flex; }
.tm-spin .ic, .tm-qr > .ic { animation: tm-spin 0.9s linear infinite; }
@keyframes tm-spin { to { transform: rotate(360deg); } }

.tm-center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 100%; padding: 12px 8px; text-align: center; }
.tm-center p { margin: 0; max-width: 380px; font-size: 13.5px; line-height: 1.65; color: var(--text-2); }
.tm-ic { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 18px; background: rgb(var(--gold-rgb) / 0.12); color: var(--gold); }
.tm-amt { font-size: 18px; font-weight: 700; }

.tm-body { display: flex; flex-direction: column; gap: 18px; padding: 2px 2px 8px; }
.tm-sub { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--text-2); }
.tm-sec { display: flex; flex-direction: column; gap: 10px; }
.tm-h { margin: 0; font-size: 12px; font-weight: 650; letter-spacing: 0.06em; color: var(--text-3); }

/* 卡种：每块是一张小卡，卡面是사이权益对比框的材质（月卡青瓷釉、年卡金箔、字数包洒金笺）。
   face-*.webp 由사이的 cardFace.ts 按宣纸皮肤亮暗两套画出（同这里的配色）；图没到时先显示 --flat 渐变。 */
:is(.tm-kind, .tm-swatch) { --band-ink: var(--on-gold); }
:is(.tm-kind, .tm-swatch)[data-kind='1'] {
  --band-ink: color-mix(in srgb, rgb(var(--cel-rgb)) 22%, var(--on-gold));
  --face: url('/static/icons/sai/face-1-light.webp?v=20261114');
  --flat: linear-gradient(160deg, color-mix(in srgb, rgb(var(--cel-rgb)) 35%, var(--gold-b)), color-mix(in srgb, rgb(var(--cel-rgb)) 52%, var(--gold-b)));
}
:is(.tm-kind, .tm-swatch)[data-kind='2'] {
  --face: url('/static/icons/sai/face-2-light.webp?v=20261114');
  --flat: linear-gradient(135deg, var(--gold-a), var(--gold-b) 55%, var(--gold-a));
}
:is(.tm-kind, .tm-swatch)[data-kind='3'] {
  --band-ink: color-mix(in srgb, rgb(var(--cin-rgb)) 30%, var(--on-gold));
  --face: url('/static/icons/sai/face-3-light.webp?v=20261114');
  --flat:
    radial-gradient(circle at 30% 35%, rgb(var(--gold-rgb) / 0.6) 0 1px, transparent 1.8px) 0 0 / 7px 6px,
    linear-gradient(160deg, color-mix(in srgb, rgb(var(--cin-rgb)) 30%, var(--gold-b)), color-mix(in srgb, rgb(var(--cin-rgb)) 44%, var(--gold-b)));
}
:root[data-theme='dark'] :is(.tm-kind, .tm-swatch)[data-kind='1'] { --face: url('/static/icons/sai/face-1-dark.webp?v=20261114'); }
:root[data-theme='dark'] :is(.tm-kind, .tm-swatch)[data-kind='2'] { --face: url('/static/icons/sai/face-2-dark.webp?v=20261114'); }
:root[data-theme='dark'] :is(.tm-kind, .tm-swatch)[data-kind='3'] { --face: url('/static/icons/sai/face-3-dark.webp?v=20261114'); }
.tm-swatch { flex: none; width: 30px; height: 20px; border-radius: 6px; border: 1px solid rgb(var(--fg) / 0.075); background: var(--face) center / cover no-repeat, var(--flat); }
.tm-kinds { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.tm-kind {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  min-height: 78px;
  padding: 12px 14px 11px;
  border: 1px solid rgb(var(--shade) / 0.12);
  border-radius: 14px;
  background: var(--face) center / cover no-repeat, var(--flat);
  color: var(--band-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 2px rgb(var(--shade) / 0.12), 0 4px 12px -6px rgb(var(--shade) / 0.3);
  transition: transform 0.2s, box-shadow 0.2s, filter 0.2s;
}
.tm-kind b { padding-right: 24px; font-size: 15px; font-weight: 700; letter-spacing: 0.01em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-kind small { font-size: 12.5px; font-weight: 560; opacity: 0.8; font-variant-numeric: tabular-nums; }
.tm-kind::after {
  content: '';
  position: absolute;
  top: 12px;
  right: 12px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--band-ink) 45%, transparent);
  background: color-mix(in srgb, var(--band-ink) 6%, transparent);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.tm-kind:not(.on) { filter: saturate(0.82); }
.tm-kind:hover { transform: translateY(-1px); filter: none; box-shadow: 0 2px 4px rgb(var(--shade) / 0.14), 0 10px 22px -10px rgb(var(--shade) / 0.42); }
.tm-kind:active { transform: translateY(0) scale(0.985); }
.tm-kind.on { box-shadow: 0 0 0 2px var(--gold), 0 10px 24px -10px rgb(var(--gold-rgb) / 0.55); }
.tm-kind.on::after { border-color: var(--band-ink); background: var(--band-ink); box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--band-ink) 18%, var(--gold-b)); }
.tm-kind:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* 份数 */
.tm-seats { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.tm-step { display: inline-flex; align-items: stretch; border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden; background: rgb(var(--sf) / 0.5); }
.tm-step button { width: 40px; border: 0; background: none; color: var(--text); font: inherit; font-size: 18px; cursor: pointer; }
.tm-step button:hover:not(:disabled) { background: var(--hover-soft); }
.tm-step button:disabled { color: var(--text-3); cursor: default; }
.tm-step input {
  width: 64px;
  padding: 9px 0;
  border: 0;
  border-inline: 1px solid var(--line);
  border-radius: 0;
  background: none;
  color: var(--text);
  font: 650 17px/1.2 var(--sans);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.tm-step input:focus { outline: none; background: rgb(var(--gold-rgb) / 0.08); }
.tm-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.tm-quick button {
  padding: 6px 12px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.tm-quick button:hover { background: var(--hover-soft); color: var(--text); }
.tm-quick button.on { border-color: rgb(var(--gold-rgb) / 0.6); background: rgb(var(--gold-rgb) / 0.1); color: var(--text); }

/* 折扣阶梯 */
.tm-ladder { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 0; padding: 0; list-style: none; }
.tm-ladder li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text-2);
  transition: background 0.25s, border-color 0.25s, color 0.25s;
}
.tm-ladder small { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.tm-ladder b { font-size: 14px; font-weight: 650; }
.tm-ladder li.on { border-color: rgb(var(--gold-rgb) / 0.6); background: rgb(var(--gold-rgb) / 0.1); color: var(--text); }
.tm-ladder li.on b { color: var(--gold); }
.tm-bulk { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin: 2px 0 0; font-size: 12.5px; color: var(--text-3); transition: color 0.25s; }
.tm-bulk.on { color: var(--gold); }
.tm-bulk .tm-link:focus-visible, .tm-mail:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }

/* 合计 */
.tm-sum { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: rgb(var(--fg) / 0.025); }
.tm-line { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.tm-line > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.tm-save { color: var(--gold); }
.tm-total { padding-top: 8px; border-top: 1px solid var(--line); color: var(--text); font-size: 14px; }
.tm-total b { font-size: 20px; font-weight: 700; }
.tm-next { margin: 2px 0 0; font-size: 12.5px; color: var(--gold); }
.tm-note { margin: -4px 0 0; font-size: 12px; line-height: 1.55; color: var(--text-3); }

/* 买过的 */
.tm-empty { margin: 0; font-size: 13px; color: var(--text-3); }
.tm-link { padding: 0; border: 0; background: none; color: var(--gold); font: inherit; font-weight: 600; cursor: pointer; }
.tm-list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tm-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s;
}
.tm-row:hover { background: var(--hover-soft); }
.tm-row:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.tm-row.off { opacity: 0.6; }
.tm-row > .ic { flex: none; color: var(--text-3); }
.tm-row-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tm-row-t b { font-size: 14px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-row-t small { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-row-p { flex: none; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }

.tm-qr { display: grid; place-items: center; width: 184px; height: 184px; padding: 8px; border-radius: 16px; background: #fff; color: var(--gold); box-shadow: 0 6px 18px rgb(var(--shade) / 0.16); }
.tm-qr img { display: block; width: 168px; height: 168px; }
.tm-contact p { text-wrap: pretty; }
.tm-contact p.ko { word-break: keep-all; }
.tm-mail { font-size: 12.5px; color: var(--text-3); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; overflow-wrap: anywhere; }
.tm-mail:hover { color: var(--text); }
.tm-done-row { font-size: 13px; color: var(--text-3); }

/* 一单的码 */
.tm-codes-head { display: flex; flex-direction: column; gap: 2px; }
.tm-codes-head b { font-size: 15px; }
.tm-codes-head small { font-size: 12.5px; color: var(--text-3); }
.tm-codes { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.tm-code { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.tm-code:last-child { border-bottom: 0; }
.tm-code-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tm-code-t code { font: 600 14px ui-monospace, 'SF Mono', Menlo, Consolas, monospace; letter-spacing: 0.08em; color: var(--text); overflow-wrap: anywhere; }
.tm-code-t small { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-code.void .tm-code-t code, .tm-code.expired .tm-code-t code { color: var(--text-3); text-decoration: line-through; text-decoration-color: rgb(var(--fg) / 0.25); }
.tm-chip { flex: none; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--hover-soft); color: var(--text-2); }
.tm-chip.open { background: rgb(var(--gold-rgb) / 0.12); color: var(--gold); }
.tm-chip.redeemed { background: rgb(var(--cel-rgb) / 0.14); color: rgb(var(--cel-rgb)); }

/* 页面上「团队购买」卡片里的单子：沿用 .sai-row，整行可点 */
.tm-prow { width: 100%; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; transition: background 0.2s; }
.tm-prow:hover { background: var(--bg-subtle, #f5f5f5); }
.tm-prow:focus-visible { outline: 2px solid var(--accent, #199cff); outline-offset: -2px; }
.tm-prow > .ic { flex: none; color: var(--text-tertiary, #a8a8a8); }
.tm-prow.off { opacity: 0.6; }
.tm-plink { padding: 0; border: 0; background: none; color: var(--accent, #199cff); font: inherit; font-weight: 600; cursor: pointer; }
.empty-state.tm-pempty { display: flex; align-items: center; gap: 14px; }
.tm-pempty img { flex: none; }

@media (max-width: 560px) {
  .tm-root { place-items: end stretch; padding: 0; }
  .tm-panel { width: 100%; border-radius: 22px 22px 0 0; border-bottom: 0; animation-name: tm-up; }
  .tm-b { height: min(560px, calc(100dvh - 170px)); padding: 4px 16px 12px; }
  .tm-f { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .tm-ladder { grid-template-columns: repeat(2, 1fr); }
  .tm-kinds { grid-template-columns: 1fr; gap: 8px; }
  .tm-kind { flex-direction: row; align-items: center; min-height: 56px; padding: 10px 46px 10px 14px; }
  .tm-kind b { padding-right: 0; }
  .tm-kind small { margin-left: auto; flex: none; }
  .tm-kind::after { top: calc(50% - 8px); right: 16px; }
  .tm-f { gap: 6px; }
  .tm-f .tm-btn { min-width: 0; padding: 0 12px; }
  .tm-f .tm-btn.primary { flex: 0 1 auto; padding-block: 6px; white-space: normal; line-height: 1.25; text-align: center; }
  .tm-f .tm-btn.primary .ic { flex: none; }
  .tm-f .tm-gap { flex: 1 1 0; min-width: 0; }
  /* 「一单的码」底部三个按钮：导出只留图标，完整说法在 aria-label 里 */
  .tm-f .tm-btn[data-act='export'] { width: 40px; padding: 0; font-size: 0; gap: 0; }
  .tm-f .tm-btn[data-act='export'] .ic { width: 17px !important; height: 17px !important; }
}
@keyframes tm-up { from { transform: translateY(40px); } }

@media (prefers-reduced-motion: reduce) {
  .tm-root, .tm-panel { animation: none !important; }
  .tm-kind, .tm-kind:hover, .tm-kind:active { transform: none; }
  .tm-spin .ic, .tm-qr > .ic { animation-duration: 2.4s; }
}
