:root {
  color-scheme: light;
  --brand-blue: #167cf6;
  --brand-blue-dark: #0e58da;
  --brand-sky: #38c8f4;
  --brand-yellow: #ffc62b;
  --brand-yellow-soft: #fff5c7;
  --ink: #14213a;
  --muted: #667085;
  --line: #dfe6ef;
  --surface: #ffffff;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --success: #027a48;
  --success-bg: #ecfdf3;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #f5f8fc; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Pretendard, "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 6% 8%, rgba(255, 198, 43, .20), transparent 24rem),
    radial-gradient(circle at 94% 12%, rgba(56, 200, 244, .22), transparent 28rem),
    linear-gradient(180deg, #f8fbff 0%, #f4f7fb 100%);
}
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.page-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.brand-bar { min-height: 88px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 14px; color: inherit; text-decoration: none; }
.brand-logo { display: block; width: 178px; height: auto; object-fit: contain; }
.brand-subtitle { padding-left: 14px; border-left: 1px solid #ccd8e8; color: #526174; font-weight: 900; font-size: 15px; white-space: nowrap; }
.text-button { border: 1px solid var(--line); background: rgba(255,255,255,.90); border-radius: 12px; padding: 10px 15px; color: var(--ink); font-weight: 900; }
.text-button:hover { border-color: #a8bad1; background: #fff; }
main { flex: 1; }

.login-layout { min-height: calc(100vh - 168px); display: grid; grid-template-columns: 1.08fr .92fr; align-items: center; gap: clamp(28px, 5vw, 72px); padding: 32px 0 64px; }
.welcome-panel { padding: 36px 0; }
.eyebrow { margin: 0 0 10px; color: #1265d7; font-size: 13px; font-weight: 1000; letter-spacing: .08em; text-transform: uppercase; }
.welcome-panel h1 { margin: 0; max-width: 680px; font-size: clamp(43px, 5.8vw, 74px); line-height: 1.09; letter-spacing: -.055em; }
.welcome-panel > p:not(.eyebrow) { max-width: 610px; margin: 24px 0 0; color: var(--muted); font-size: 18px; line-height: 1.75; }
.welcome-badges { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; }
.welcome-badges span { padding: 10px 15px; border-radius: 999px; background: rgba(255,255,255,.88); border: 1px solid var(--line); color: #21405f; font-weight: 900; box-shadow: 0 8px 24px rgba(16, 50, 90, .05); }
.login-card { background: rgba(255,255,255,.97); border: 1px solid rgba(255,255,255,.9); border-radius: 28px; padding: clamp(24px, 3.2vw, 38px); box-shadow: 0 24px 80px rgba(29,41,57,.14); }
.card-heading { display: flex; gap: 14px; align-items: center; margin-bottom: 23px; }
.login-brand-icon { width: 48px; height: 48px; border-radius: 15px; object-fit: cover; box-shadow: 0 8px 20px rgba(22,124,246,.18); }
.card-heading p { margin: 0; color: var(--muted); font-size: 13px; font-weight: 900; }
.card-heading h2 { margin: 2px 0 0; font-size: 28px; letter-spacing: -.035em; }

.academy-panel { margin: 0 0 18px; padding: 17px; border: 1px solid #d9e5f4; border-radius: 17px; background: #f8fbff; }
.academy-panel-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.academy-panel-heading div { display: grid; gap: 3px; }
.field-label { color: #1265d7; font-size: 12px; font-weight: 1000; }
.academy-panel-heading strong { font-size: 15px; }
.academy-search-form { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 9px; }
.academy-search-form input { min-width: 0; border: 1px solid #cbd8e7; border-radius: 12px; padding: 13px 14px; outline: none; background: #fff; color: var(--ink); }
.academy-search-form input:focus { border-color: var(--brand-blue); box-shadow: 0 0 0 4px rgba(22,124,246,.13); }
.academy-search-button { border: 0; border-radius: 12px; padding: 0 16px; background: var(--brand-blue); color: #fff; font-weight: 1000; white-space: nowrap; }
.academy-search-button:hover { background: var(--brand-blue-dark); }
.academy-search-message, .login-inline-message { min-height: 20px; margin: 10px 2px 0; color: #526174; font-size: 13px; font-weight: 700; line-height: 1.45; }
.academy-search-message.is-error, .login-inline-message.is-error { color: var(--danger); }
.academy-search-results { display: grid; gap: 8px; margin-top: 9px; max-height: 230px; overflow: auto; }
.academy-result-button { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; border: 1px solid #d8e3f0; border-radius: 12px; padding: 12px 13px; background: #fff; color: var(--ink); text-align: left; }
.academy-result-button:hover, .academy-result-button:focus-visible { border-color: var(--brand-blue); box-shadow: 0 0 0 3px rgba(22,124,246,.10); outline: none; }
.academy-result-button strong { font-size: 14px; }
.academy-result-button span { color: #1265d7; font-size: 12px; font-weight: 1000; white-space: nowrap; }
.selected-academy-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 18px; padding: 15px 16px; border-radius: 15px; background: linear-gradient(135deg, #eef7ff, #f5fbff); border: 1px solid #cfe4fa; }
.selected-academy-card div { display: grid; gap: 4px; min-width: 0; }
.selected-academy-card span { color: #1265d7; font-size: 12px; font-weight: 1000; }
.selected-academy-card strong { overflow-wrap: anywhere; }
.selected-academy-card button { flex: 0 0 auto; border: 1px solid #bcd4ec; border-radius: 10px; padding: 8px 11px; background: #fff; color: #24506f; font-size: 12px; font-weight: 900; }

.login-form { display: grid; gap: 16px; }
.login-form label { display: grid; gap: 8px; }
.login-form label span { font-size: 14px; font-weight: 900; }
.login-form input { width: 100%; border: 1px solid #d0d8e4; border-radius: 14px; padding: 14px 15px; background: #fff; color: var(--ink); outline: none; }
.login-form input:focus { border-color: var(--brand-blue); box-shadow: 0 0 0 4px rgba(22,124,246,.13); }
.login-form input:disabled { background: #f1f4f8; color: #98a2b3; }
.primary-button, .app-launch-button { width: 100%; border: 0; border-radius: 14px; padding: 15px 18px; font-weight: 1000; }
.primary-button { margin-top: 4px; background: linear-gradient(135deg, var(--brand-blue), #25a7f4); color: #fff; box-shadow: inset 0 -3px rgba(0,0,0,.08), 0 10px 24px rgba(22,124,246,.18); }
.primary-button:hover:not(:disabled) { filter: brightness(.97); }
.primary-button:disabled { background: #d9e0e9; color: #8c98a8; box-shadow: none; }
.login-help { margin: 13px 0 0; color: var(--muted); font-size: 13px; text-align: center; line-height: 1.55; }
.notice { border-radius: 13px; padding: 13px 15px; margin: 0 0 18px; font-size: 14px; font-weight: 800; line-height: 1.5; }
.notice.error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecdca; }
.notice.success { background: var(--success-bg); color: var(--success); border: 1px solid #abefc6; }
.notice.wide { margin: 0 0 22px; }

.student-hero { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 44px 0 34px; }
.student-hero h1 { margin: 0; font-size: clamp(34px, 5vw, 56px); letter-spacing: -.05em; }
.student-hero > div > p:last-child { margin: 13px 0 0; color: var(--muted); font-size: 17px; }
.student-chip { flex: 0 0 auto; display: grid; gap: 2px; min-width: 150px; padding: 16px 18px; border-radius: 18px; background: #fff; border: 1px solid var(--line); text-align: right; box-shadow: 0 12px 35px rgba(16,24,40,.06); }
.student-chip span { color: var(--muted); font-size: 13px; }
.student-chip strong { font-size: 17px; }
.apps-section { padding-bottom: 70px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin: 12px 0 22px; }
.section-heading h2 { margin: 0; font-size: 30px; letter-spacing: -.035em; }
.app-count { display: inline-grid; place-items: center; min-width: 56px; padding: 8px 12px; border-radius: 999px; background: #e9f4ff; color: #1265d7; font-weight: 1000; }
.apps-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 20px; }
.app-card { position: relative; overflow: hidden; display: flex; flex-direction: column; min-height: 330px; padding: 24px; border-radius: 24px; background: #fff; border: 1px solid var(--line); box-shadow: 0 14px 40px rgba(16,24,40,.07); }
.app-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 6px; background: var(--brand-blue); }
.app-card.theme-gugudan::before { background: var(--brand-yellow); }
.app-card.theme-scoring::before { background: linear-gradient(90deg, var(--brand-blue), var(--brand-sky)); }
.app-card.theme-arithmetic::before { background: #91a5bd; }
.app-card.is-pending { opacity: .82; }
.app-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-top: 4px; }
.app-icon { width: 68px; height: 68px; border-radius: 20px; display: grid; place-items: center; color: #fff; font-size: 29px; font-weight: 1000; box-shadow: inset 0 -4px rgba(0,0,0,.08); }
.app-icon-gugudan { background: linear-gradient(135deg, #ffd441, #ffad1f); color: #5e4200; }
.app-icon-scoring { background: linear-gradient(135deg, var(--brand-blue), var(--brand-sky)); }
.app-icon-arithmetic { background: linear-gradient(135deg, #8ca0b8, #63768d); }
.app-icon-default { background: linear-gradient(135deg, var(--brand-blue), var(--brand-sky)); }
.app-icon.has-image {
    overflow: hidden;
    padding: 0;
    background: #fff;
    border: 1px solid #e4eaf1;
    box-shadow: 0 10px 25px rgba(16,24,40,.10);
}
.app-icon.has-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #fff;
}
.status-badge { padding: 7px 10px; border-radius: 999px; font-size: 12px; font-weight: 1000; }
.status-badge.ready { color: #027a48; background: #ecfdf3; }
.status-badge.pending { color: #475467; background: #f2f4f7; }
.app-series-label { margin: 24px 0 4px !important; color: #7f93aa !important; font-size: 11px; line-height: 1 !important; font-weight: 1000; letter-spacing: .10em; }
.app-card h3 { margin: 3px 0 9px; font-size: 27px; letter-spacing: -.04em; }
.app-card > p:not(.app-series-label) { margin: 0 0 24px; color: var(--muted); line-height: 1.65; }
.app-card form, .app-card > button { margin-top: auto; }
.app-launch-button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; background: linear-gradient(135deg, var(--brand-blue), #25a7f4); color: #fff; box-shadow: inset 0 -3px rgba(0,0,0,.08); }
.app-launch-button:hover:not(.disabled) { filter: brightness(.97); }
.app-launch-button.disabled { background: #e6ebf1; color: #8c98a8; cursor: not-allowed; box-shadow: none; }
.new-window-note { margin: 14px 2px 0; color: var(--muted); font-size: 13px; text-align: right; }
.empty-card { padding: 58px 24px; text-align: center; border: 1px dashed #c9d0da; border-radius: 24px; background: rgba(255,255,255,.72); }
.empty-icon { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 18px; display: grid; place-items: center; background: #e9f4ff; color: #1265d7; font-size: 26px; font-weight: 1000; }
.empty-card h3 { margin: 0 0 8px; }
.empty-card p { margin: 0; color: var(--muted); }
footer { display: flex; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line); padding: 22px 0 30px; color: var(--muted); font-size: 13px; }

.launch-body { display: grid; place-items: center; padding: 24px; }
.launch-card { width: min(480px, 100%); padding: 38px; border-radius: 25px; background: #fff; border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(16,24,40,.12); text-align: center; }
.launch-logo { display: block; width: 172px; height: auto; margin: 0 auto 24px; }
.launch-card h1 { margin: 18px 0 8px; font-size: 25px; }
.launch-card p { margin: 0 0 24px; color: var(--muted); }
.spinner { width: 52px; height: 52px; margin: 0 auto; border: 6px solid #eaf0f7; border-top-color: var(--brand-blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 880px) {
  .login-layout { grid-template-columns: 1fr; padding-top: 18px; }
  .welcome-panel { padding-bottom: 0; }
  .welcome-panel h1 { font-size: clamp(40px, 11vw, 64px); }
  .apps-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 620px) {
  .page-shell { width: min(100% - 22px, 1180px); }
  .brand-bar { min-height: 74px; }
  .brand-logo { width: 142px; }
  .brand-subtitle { display: none; }
  .login-layout { min-height: auto; gap: 22px; padding-bottom: 48px; }
  .welcome-panel > p:not(.eyebrow), .welcome-badges { display: none; }
  .login-card { border-radius: 22px; padding: 24px 19px; }
  .academy-search-form { grid-template-columns: 1fr; }
  .academy-search-button { min-height: 45px; }
  .selected-academy-card { align-items: flex-start; }
  .student-hero { align-items: flex-start; padding-top: 30px; }
  .student-chip { display: none; }
  .apps-grid { grid-template-columns: 1fr; }
  .app-card { min-height: 300px; }
  .new-window-note { text-align: left; }
  footer { flex-direction: column; }
}

/* Phase 2-2C: 마이구구단 웹 런처 교환·충돌 화면 */
.secondary-button {
  width: 100%;
  border: 1px solid #cfd8e5;
  border-radius: 14px;
  padding: 14px 18px;
  background: #fff;
  color: var(--ink);
  font-weight: 1000;
}
.secondary-button:hover:not(:disabled) { background: #f7f9fc; border-color: #aebdce; }
.secondary-button:disabled { opacity: .58; cursor: not-allowed; }
.launch-conflict,
.launch-error {
  margin-top: 8px;
  padding: 20px;
  border-radius: 18px;
  text-align: left;
}
.launch-conflict {
  border: 1px solid #f6d365;
  background: #fff9df;
}
.launch-error {
  border: 1px solid #fecdca;
  background: var(--danger-bg);
  color: var(--danger);
}
.launch-conflict strong,
.launch-error strong { display: block; font-size: 18px; line-height: 1.4; }
.launch-conflict p,
.launch-error p { margin: 8px 0 18px; line-height: 1.6; }
.launch-conflict-actions { display: grid; gap: 10px; }
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  border: 1px solid #d0d8e4;
  border-radius: 14px;
  padding: 13px 16px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-weight: 1000;
}
.secondary-link:hover { background: #f7f9fc; }
