.aidm-server-save {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 2147483000;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid rgba(80, 94, 135, .2);
  border-radius: 999px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 8px 28px rgba(30, 38, 70, .18);
  color: #46506e;
  font: 700 12px/1.2 -apple-system, BlinkMacSystemFont, "Pretendard", "Noto Sans KR", sans-serif;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.aidm-server-save-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #6d7a9c;
}

.aidm-server-save.saving .aidm-server-save-dot {
  background: #5b73ed;
  animation: aidm-server-pulse 1s infinite;
}

.aidm-server-save.saved .aidm-server-save-dot {
  background: #20a36a;
}

.aidm-server-save.dirty .aidm-server-save-dot {
  background: #d89b23;
}

.aidm-server-save.error .aidm-server-save-dot {
  background: #cf4e56;
}

.aidm-server-save.identity .aidm-server-save-dot {
  background: #e08b27;
  animation: aidm-server-pulse 1.4s infinite;
}

.aidm-server-save.waiting .aidm-server-save-dot {
  background: #7c66df;
  animation: aidm-server-pulse 1.2s infinite;
}

.aidm-student-identity-button {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 52px);
  z-index: 2147483000;
  min-height: 36px;
  padding: 8px 13px;
  border: 1px solid rgba(80, 94, 135, .2);
  border-radius: 999px;
  background: rgba(255, 255, 255, .97);
  box-shadow: 0 7px 22px rgba(30, 38, 70, .15);
  color: #46506e;
  font: 700 12px/1.2 -apple-system, BlinkMacSystemFont, "Pretendard", "Noto Sans KR", sans-serif;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.aidm-student-identity-button.required {
  border-color: rgba(224, 139, 39, .45);
  background: #fff8ed;
  color: #a85f0d;
}

.aidm-student-identity-button.complete {
  color: #33415f;
}

.aidm-student-history-button {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 98px);
  z-index: 2147483000;
  min-height: 36px;
  padding: 8px 13px;
  border: 1px solid rgba(86, 111, 231, .28);
  border-radius: 999px;
  background: #eef2ff;
  box-shadow: 0 7px 22px rgba(30, 38, 70, .14);
  color: #4059c7;
  font: 800 12px/1.2 -apple-system, BlinkMacSystemFont, "Pretendard", "Noto Sans KR", sans-serif;
  cursor: pointer;
}

.aidm-student-history-button[hidden] {
  display: none !important;
}

.aidm-identity-layer[hidden] {
  display: none !important;
}

.aidm-identity-layer,
.aidm-identity-layer * {
  box-sizing: border-box;
}

.aidm-identity-layer {
  position: fixed;
  inset: 0;
  z-index: 2147483600;
  display: grid;
  place-items: center;
  padding: 20px;
  color: #27324b;
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Noto Sans KR", sans-serif;
}

.aidm-identity-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(21, 27, 44, .62);
  backdrop-filter: blur(5px);
}

.aidm-identity-card {
  position: relative;
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  border: 1px solid rgba(111, 127, 173, .22);
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 30px 90px rgba(13, 22, 52, .3);
}

.aidm-identity-form {
  margin: 0;
  padding: 28px;
}

.aidm-identity-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.aidm-identity-kicker {
  margin: 0 0 7px;
  color: #6277e7;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
}

.aidm-identity-heading h2 {
  margin: 0;
  color: #202943;
  font-size: clamp(22px, 4vw, 28px);
  line-height: 1.25;
  letter-spacing: -.03em;
}

.aidm-identity-close {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid #dfe4f0;
  border-radius: 50%;
  background: #f7f8fb;
  color: #55617b;
  font: 400 25px/32px Arial, sans-serif;
  cursor: pointer;
}

.aidm-identity-description {
  margin: 12px 0 22px;
  color: #68738d;
  font-size: 14px;
  line-height: 1.6;
}

.aidm-identity-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.aidm-identity-field {
  display: grid;
  gap: 7px;
  margin: 0;
}

.aidm-identity-field-wide {
  grid-column: 1 / -1;
}

.aidm-identity-field span {
  color: #37435f;
  font-size: 13px;
  font-weight: 800;
}

.aidm-identity-field input,
.aidm-identity-field select {
  width: 100%;
  height: 48px;
  margin: 0;
  padding: 0 14px;
  border: 1px solid #d9dfec;
  border-radius: 12px;
  outline: none;
  background: #fbfcfe;
  color: #202943;
  font: 500 15px/1.3 -apple-system, BlinkMacSystemFont, "Pretendard", "Noto Sans KR", sans-serif;
  box-shadow: none;
}

.aidm-identity-field small {
  color: #7b8499;
  font-size: 12px;
  line-height: 1.5;
}

.aidm-school-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.aidm-school-input-row input[readonly] {
  background: #eef3ff;
  color: #314fa9;
  font-weight: 750;
}

.aidm-school-edit-button {
  min-width: 88px;
  border: 1px solid #8192dd;
  border-radius: 12px;
  background: #fff;
  color: #4c61bd;
  font-weight: 800;
  cursor: pointer;
}

.aidm-school-edit-button[hidden] {
  display: none !important;
}

.aidm-resume-pin-toggle-wrap[hidden],
.aidm-resume-pin-field[hidden] {
  display: none !important;
}

.aidm-resume-pin-toggle-wrap {
  display: grid;
  gap: 8px;
}

.aidm-resume-pin-help {
  margin: 0;
  color: #69738a;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.55;
}

.aidm-resume-pin-toggle {
  width: 100%;
  min-height: 48px;
  padding: 11px 16px;
  border: 1px solid #8192dd;
  border-radius: 12px;
  background: #f5f7ff;
  color: #4058bd;
  font-weight: 800;
  cursor: pointer;
}

.aidm-resume-pin-toggle:hover,
.aidm-resume-pin-toggle:focus-visible {
  border-color: #5f75df;
  background: #eef2ff;
}

.aidm-school-suggestions {
  display: grid;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
}

.aidm-school-suggestion {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #dbe2f2;
  border-radius: 10px;
  background: #fff;
  color: #27324b;
  text-align: left;
  cursor: pointer;
}

.aidm-school-suggestion:hover,
.aidm-school-suggestion:focus {
  border-color: #6d80e8;
  background: #f5f7ff;
}

.aidm-school-suggestion strong {
  font-size: 13px;
}

.aidm-school-suggestion span {
  color: #7b8499;
  font-size: 11px;
  font-weight: 500;
}

.aidm-remember-device {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 18px;
  color: #37435f;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.aidm-remember-device input {
  width: 18px;
  height: 18px;
  accent-color: #6178ed;
}

.aidm-remember-note {
  margin: 7px 0 0;
  color: #7b8499;
  font-size: 11px;
  line-height: 1.55;
}

.aidm-identity-field select {
  cursor: pointer;
}

.aidm-identity-field input:focus,
.aidm-identity-field select:focus {
  border-color: #6178ed;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(97, 120, 237, .13);
}

.aidm-identity-error {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff0f1;
  color: #b23442;
  font-size: 13px;
  font-weight: 700;
}

.aidm-identity-submit {
  width: 100%;
  min-height: 50px;
  margin: 20px 0 0;
  padding: 12px 18px;
  border: 0;
  border-radius: 13px;
  background: linear-gradient(135deg, #6178ed, #795ce8);
  box-shadow: 0 10px 24px rgba(97, 92, 226, .24);
  color: #fff;
  font: 800 15px/1.3 -apple-system, BlinkMacSystemFont, "Pretendard", "Noto Sans KR", sans-serif;
  cursor: pointer;
}

html.aidm-identity-open,
html.aidm-identity-open body {
  overflow: hidden !important;
}

html.aidm-upgrade-open,
html.aidm-upgrade-open body {
  overflow: hidden !important;
}

html.aidm-history-open,
html.aidm-history-open body {
  overflow: hidden !important;
}

.aidm-history-layer {
  z-index: 2147483650;
}

.aidm-history-card {
  width: min(680px, 100%);
  padding: 26px;
}

.aidm-history-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.aidm-history-head h2 {
  margin: 0;
  font-size: clamp(22px, 4vw, 28px);
}

.aidm-history-content {
  margin-top: 20px;
}

.aidm-history-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.aidm-history-summary > div {
  display: grid;
  gap: 5px;
  padding: 14px;
  border-radius: 13px;
  background: #f3f6ff;
}

.aidm-history-summary span {
  color: #77829c;
  font-size: 11px;
  font-weight: 750;
}

.aidm-history-summary strong {
  color: #304bac;
  font-size: 14px;
}

.aidm-history-content h3 {
  margin: 22px 0 10px;
  font-size: 16px;
}

.aidm-history-list {
  display: grid;
  gap: 9px;
}

.aidm-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 14px;
  border: 1px solid #e1e6f0;
  border-radius: 13px;
  background: #fff;
}

.aidm-history-item > div {
  min-width: 0;
}

.aidm-history-item strong,
.aidm-history-item span,
.aidm-history-item p {
  display: block;
}

.aidm-history-item strong {
  color: #27324b;
  font-size: 13px;
}

.aidm-history-item span {
  margin-top: 3px;
  color: #8a93a8;
  font-size: 10px;
}

.aidm-history-item p {
  margin: 6px 0 0;
  overflow: hidden;
  color: #68738d;
  font-size: 12px;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aidm-history-item a {
  flex: 0 0 auto;
  padding: 8px 11px;
  border-radius: 9px;
  background: #5971e8;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.aidm-history-empty {
  padding: 18px;
  border-radius: 12px;
  background: #f7f8fb;
  color: #7b8499;
  font-size: 13px;
  line-height: 1.6;
}

.aidm-upgrade-layer {
  z-index: 2147483700;
}

.aidm-upgrade-message.ok {
  background: #ecfdf5;
  color: #047857;
}

.aidm-upgrade-submit:disabled,
.aidm-upgrade-layer input:disabled {
  opacity: .62;
  cursor: wait;
}

@keyframes aidm-server-pulse {
  0%, 100% { opacity: .35; transform: scale(.85); }
  50% { opacity: 1; transform: scale(1.12); }
}

@media (max-width: 520px) {
  .aidm-server-save {
    right: 10px;
    bottom: 10px;
    max-width: calc(100vw - 20px);
    padding: 8px 12px;
    font-size: 11px;
  }

  .aidm-student-identity-button {
    right: 10px;
    bottom: 58px;
    padding: 7px 11px;
    font-size: 11px;
  }

  .aidm-student-history-button {
    right: 10px;
    bottom: 102px;
    padding: 7px 11px;
    font-size: 11px;
  }

  .aidm-identity-layer {
    place-items: end center;
    padding: 10px;
  }

  .aidm-identity-card {
    width: 100%;
    max-height: calc(100vh - 20px);
    border-radius: 20px;
  }

  .aidm-identity-form {
    padding: 22px 18px 20px;
  }

  .aidm-identity-grid {
    gap: 11px;
  }

  .aidm-school-input-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .aidm-school-edit-button {
    min-height: 40px;
  }

  .aidm-history-card {
    padding: 20px 17px;
  }

  .aidm-history-summary {
    grid-template-columns: 1fr;
  }

  .aidm-history-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .aidm-history-item a {
    align-self: stretch;
    text-align: center;
  }
}
