.login-wrap.wide {
  width: min(520px, 100%);
}

.auth-row {
  display: grid;
  gap: 10px;
}

.auth-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 14px 0 6px;
}

.auth-input,
.auth-select,
.auth-textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 0.98rem;
  font-family: inherit;
  color: var(--text);
  background: rgba(12, 15, 21, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  outline: none;
  transition:
    border-color 0.2s var(--ease-ios, ease),
    box-shadow 0.25s var(--ease-ios, ease);
}

.auth-input:focus,
.auth-select:focus,
.auth-textarea:focus {
  border-color: rgba(122, 167, 255, 0.65);
  box-shadow: 0 0 0 4px rgba(77, 141, 255, 0.16);
}

.auth-textarea {
  min-height: 74px;
  resize: vertical;
}

.auth-input.code-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.auth-hint {
  margin: 8px 0 0;
  font-size: 0.76rem;
  line-height: 1.6;
  color: var(--muted);
}

.mode-pick {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.mode-opt {
  display: flex;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition:
    border-color 0.18s var(--ease-ios, ease),
    background 0.18s var(--ease-ios, ease),
    transform 0.18s var(--ease-spring, ease);
}

.mode-opt:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.mode-opt input {
  margin: 3px 0 0;
  flex: none;
  accent-color: #5c98ff;
}

.mode-opt:has(input:checked) {
  border-color: rgba(122, 167, 255, 0.55);
  background: rgba(77, 141, 255, 0.12);
}

.mode-opt b {
  display: block;
  font-size: 0.86rem;
  margin-bottom: 3px;
}

.mode-opt span.mode-desc {
  display: block;
  font-size: 0.74rem;
  line-height: 1.55;
  color: var(--muted);
}

.code-list {
  display: grid;
  gap: 8px;
  margin: 16px 0 0;
}

.code-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  animation: code-in 0.32s var(--ease-spring, ease) both;
}

@keyframes code-in {
  from {
    opacity: 0;
    transform: translate3d(0, 8px, 0);
  }
}

.code-item .code-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.code-item .code-note {
  font-family: system-ui, sans-serif;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0;
}

.code-item button {
  flex: none;
  padding: 6px 11px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background 0.16s var(--ease-ios, ease),
    transform 0.16s var(--ease-spring, ease);
}

.code-item button:hover {
  background: rgba(255, 255, 255, 0.16);
}

.code-item button:active {
  transform: scale(0.95);
}

.invite-table {
  width: 100%;
  margin-top: 14px;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.invite-table th,
.invite-table td {
  padding: 8px 6px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  color: var(--muted);
}

.invite-table th {
  font-weight: 600;
  color: #cfd6e4;
}

.invite-table td.ok {
  color: #7fe3b0;
}

.invite-table td.no {
  color: #dcc6ff;
}

.invite-table td:nth-child(2) {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.invite-kill {
  padding: 4px 9px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #dcc6ff;
  background: rgba(168, 131, 255, 0.1);
  border: 1px solid rgba(168, 131, 255, 0.32);
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background 0.16s var(--ease-ios, ease),
    transform 0.16s var(--ease-spring, ease);
}

.invite-kill:hover {
  background: rgba(168, 131, 255, 0.2);
}

.invite-kill:active {
  transform: scale(0.95);
}

.invite-kill:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#invite-body {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.auth-split {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.auth-secondary {
  padding: 10px 16px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 10px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  transition:
    background 0.16s var(--ease-ios, ease),
    transform 0.2s var(--ease-spring, ease);
}

.auth-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.auth-secondary:active {
  transform: scale(0.97);
}

.auth-ok {
  margin: 12px 0 0;
  padding: 10px 12px;
  font-size: 0.85rem;
  color: #9df0c2;
  background: rgba(52, 199, 89, 0.12);
  border: 1px solid rgba(52, 199, 89, 0.3);
  border-radius: 10px;
}

.auth-section-title {
  margin: 26px 0 6px;
  font-size: 0.95rem;
}

.hidden {
  display: none !important;
}

.invite-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  color: #ffd6d6;
}

.invite-code.dim {
  color: var(--muted);
}

.invite-copy {
  margin-left: 6px;
  padding: 3px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 7px;
  cursor: pointer;
}

.invite-copy:hover {
  background: rgba(255, 255, 255, 0.16);
}

.auth-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
}

.auth-toggle input {
  margin: 0;
  accent-color: #5c98ff;
}

.kg-back {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1;
  color: var(--muted);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  -webkit-tap-highlight-color: transparent;
  transition:
    color 0.16s var(--ease-ios, ease),
    background 0.16s var(--ease-ios, ease),
    border-color 0.16s var(--ease-ios, ease),
    transform 0.16s var(--ease-spring, ease);
}

.kg-back:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.kg-back:active {
  transform: scale(0.95);
}

.kg-back:focus-visible {
  color: var(--text);
  outline: 2px solid rgba(122, 167, 255, 0.6);
  outline-offset: 2px;
}

.kg-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 10px;
  margin-top: 22px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 0.78rem;
}

.kg-foot-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 4px 2px;
  color: var(--muted);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.16s var(--ease-ios, ease);
}

.kg-foot-link:hover {
  color: var(--text);
}

.kg-foot-sep {
  color: rgba(255, 255, 255, 0.18);
}

.kg-plan {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.kg-plan-opt {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition:
    border-color 0.18s var(--ease-ios, ease),
    background 0.18s var(--ease-ios, ease);
}

.kg-plan-opt:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.kg-plan-opt:has(input:checked) {
  border-color: rgba(122, 167, 255, 0.55);
  background: rgba(77, 141, 255, 0.12);
}

.kg-plan-opt input {
  flex: none;
  margin: 0;
  accent-color: #5c98ff;
}

.kg-plan-text {
  font-size: 0.84rem;
  line-height: 1.4;
  color: var(--text);
}

.invite-table td.invite-plan {
  white-space: nowrap;
  max-width: none;
  font-size: 0.68rem;
  line-height: 1.4;
}

.invite-table {
  font-size: 0.72rem;
}

.invite-table th,
.invite-table td {
  padding: 8px 3px;
}

.invite-table td.invite-when {
  white-space: normal;
  line-height: 1.35;
}

.invite-table td.invite-when .when-date,
.invite-table td.invite-when .when-time {
  display: block;
  white-space: nowrap;
}

.invite-table td.invite-when .when-time {
  color: rgba(255, 255, 255, 0.45);
}

.invite-table .invite-copy,
.invite-table .invite-kill {
  padding: 3px 6px;
  font-size: 0.66rem;
}

.invite-table .invite-code {
  font-size: 0.72rem;
}

.invite-note {
  display: inline-block;
  max-width: 56px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

@media (max-width: 560px) {
  .login-wrap.wide {
    width: 100%;
    padding-left: 12px;
    padding-right: 12px;
  }

  .login-card {
    padding-left: 14px;
    padding-right: 14px;
  }

  .login-card#kg-card .login-brand {
    padding-right: 82px;
  }

  #admin-pw,
  #kg-count,
  #kg-note {
    font-size: 1rem;
  }

  .auth-split {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .auth-split > * {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .auth-split > .login-hint {
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .auth-split > .auth-hint {
    text-align: left;
  }

  #verify-btn,
  #gen-btn,
  #copy-all {
    width: 100%;
  }

  .code-item {
    flex-wrap: wrap;
  }

  .code-item .code-text {
    flex: 1 1 100%;
    font-size: 0.84rem;
    letter-spacing: 0.04em;
  }

  .code-item button {
    flex: 1 1 auto;
  }

  #invite-body {
    overflow-x: visible;
  }

  .invite-table {
    display: block;
    font-size: 0.8rem;
  }

  .invite-table thead {
    display: none;
  }

  .invite-table tbody {
    display: block;
  }

  .invite-table tr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 8px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  }

  .invite-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
    padding: 2px 0;
    white-space: normal;
    border: 0;
  }

  .invite-table td:nth-child(1) {
    grid-column: 1 / -1;
  }

  .invite-table td .invite-code {
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .invite-table td:nth-child(2) {
    grid-column: 1 / -1;
    max-width: none;
    overflow: visible;
    text-overflow: clip;
  }

  .invite-note {
    display: block;
    max-width: none;
    overflow: visible;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .invite-table td:nth-child(3),
  .invite-table td:nth-child(5) {
    justify-content: flex-start;
  }

  .invite-table td:nth-child(4),
  .invite-table td:nth-child(6) {
    justify-content: flex-end;
    text-align: right;
  }

  .invite-table td.invite-plan {
    max-width: none;
    white-space: normal;
  }

  .invite-table td:nth-child(6) .invite-kill,
  .invite-table td:nth-child(6) .invite-copy {
    padding: 7px 12px;
    font-size: 0.76rem;
  }

  .kg-plan {
    flex-direction: column;
    gap: 6px;
  }

  .kg-plan-opt {
    flex: none;
    width: 100%;
    min-height: 44px;
  }
}

@media (min-width: 561px) {
  body.kg-page .login-wrap.wide {
    width: min(640px, 100%);
  }

  body.kg-page .invite-note {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    max-width: 120px;
    overflow: hidden;
    overflow-wrap: anywhere;
    white-space: normal;
    text-overflow: clip;
  }
}
