:root {
  --hm-sync: #087b68;
  --hm-sync-dark: #075f52;
  --hm-sync-soft: #eaf7f3;
  --hm-sync-danger: #b42318;
}

html.hm-auth-required .app-shell {
  visibility: hidden;
}

html.hm-sync-applying .app-shell {
  pointer-events: none;
}

#hm-auth-overlay,
.hm-sync-panel-layer {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: max(22px, env(safe-area-inset-top)) 16px max(22px, env(safe-area-inset-bottom));
  background: linear-gradient(150deg, #e7f7f2 0%, #f9fcfb 52%, #dff1ec 100%);
  color: #153b35;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.hm-auth-card,
.hm-sync-panel {
  width: min(100%, 460px);
  padding: 28px;
  border: 1px solid rgba(8, 123, 104, .14);
  border-radius: 28px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 24px 70px rgba(18, 71, 62, .16);
}

.hm-auth-logo {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin: 0 auto 18px;
  border-radius: 18px;
  background: var(--hm-sync);
  color: white;
  font-weight: 900;
  font-size: 20px;
  letter-spacing: .04em;
  box-shadow: 0 10px 26px rgba(8, 123, 104, .25);
}

.hm-auth-eyebrow {
  margin: 0 0 7px;
  color: var(--hm-sync);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .12em;
  text-align: center;
}

.hm-auth-card h1,
.hm-sync-panel h2 {
  margin: 0;
  color: #123c35;
  font-size: clamp(23px, 6vw, 29px);
  line-height: 1.14;
  text-align: center;
}

.hm-auth-intro {
  margin: 14px 0 20px;
  color: #55736e;
  font-size: 14px;
  line-height: 1.55;
  text-align: center;
}

.hm-auth-card form,
.hm-account-grid {
  display: grid;
  gap: 13px;
}

.hm-account-grid {
  grid-template-columns: 1fr 1fr;
}

.hm-auth-card label {
  display: grid;
  gap: 7px;
  color: #345c55;
  font-size: 13px;
  font-weight: 750;
}

.hm-auth-card input {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid #c9ded9;
  border-radius: 14px;
  outline: none;
  background: #fbfefd;
  color: #153b35;
  font: inherit;
  font-size: 16px;
  box-sizing: border-box;
}

.hm-auth-card input:focus {
  border-color: var(--hm-sync);
  box-shadow: 0 0 0 3px rgba(8, 123, 104, .1);
}

.hm-auth-card button,
.hm-sync-panel button {
  width: 100%;
  min-height: 50px;
  padding: 11px 15px;
  border: 0;
  border-radius: 15px;
  background: var(--hm-sync);
  color: white;
  font: inherit;
  font-size: 15px;
  font-weight: 850;
  cursor: pointer;
}

.hm-auth-card button:hover,
.hm-sync-panel button:hover {
  background: var(--hm-sync-dark);
}

.hm-auth-card button.hm-secondary,
.hm-sync-panel button.hm-secondary {
  border: 1px solid #c9ded9;
  background: white;
  color: var(--hm-sync-dark);
}

.hm-auth-message {
  min-height: 18px;
  color: #55736e;
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
}

.hm-auth-message.danger,
.hm-auth-help {
  color: var(--hm-sync-danger);
}

.hm-auth-help {
  margin: 0 0 16px;
  padding: 13px;
  border-radius: 13px;
  background: #fff0ee;
  font-size: 13px;
  line-height: 1.5;
}

.hm-auth-version {
  display: block;
  margin-top: 20px;
  color: #78918d;
  font-size: 11px;
  text-align: center;
}

.hm-auth-spinner {
  width: 32px;
  height: 32px;
  margin: 20px auto;
  border: 3px solid #cde6df;
  border-top-color: var(--hm-sync);
  border-radius: 50%;
  animation: hm-spin .8s linear infinite;
}

@keyframes hm-spin { to { transform: rotate(360deg); } }

.hm-account-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.hm-auth-card label.hm-account-choice {
  position: relative;
  display: block;
}

.hm-account-choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.hm-account-choice span {
  display: grid;
  place-items: center;
  min-height: 62px;
  padding: 10px;
  border: 1px solid #c9ded9;
  border-radius: 15px;
  background: #f7fbfa;
  text-align: center;
}

.hm-account-choice input:checked + span {
  border-color: var(--hm-sync);
  background: var(--hm-sync-soft);
  color: var(--hm-sync-dark);
  box-shadow: inset 0 0 0 1px var(--hm-sync);
}

.hm-sync-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 31px;
  margin-left: auto;
  padding: 6px 9px;
  border: 1px solid #c6ddd7;
  border-radius: 999px;
  background: #f5fbf9;
  color: #315b54;
  font: inherit;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.hm-sync-status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f59e0b;
}

.hm-sync-status[data-state="online"] i { background: #16a34a; }
.hm-sync-status[data-state="offline"] i { background: #94a3b8; }
.hm-sync-status[data-state="conflict"] i,
.hm-sync-status[data-state="error"] i,
.hm-sync-status[data-state="locked"] i { background: #dc2626; }
.hm-sync-status[data-state="syncing"] i { animation: hm-pulse 1s ease-in-out infinite; }

@keyframes hm-pulse { 50% { opacity: .3; transform: scale(.75); } }

.hm-sync-panel-layer {
  background: rgba(10, 34, 30, .52);
  backdrop-filter: blur(7px);
}

.hm-sync-panel {
  position: relative;
}

.hm-sync-panel .hm-panel-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 50%;
  background: #edf5f3;
  color: #385f58;
  font-size: 25px;
  line-height: 1;
}

.hm-sync-panel dl {
  display: grid;
  gap: 9px;
  margin: 22px 0;
}

.hm-sync-panel dl div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  border-radius: 11px;
  background: #f5faf9;
  font-size: 13px;
}

.hm-sync-panel dt { color: #607c77; }
.hm-sync-panel dd { margin: 0; color: #214d45; font-weight: 800; text-align: right; overflow-wrap: anywhere; }
.hm-sync-panel > button + button { margin-top: 10px; }

.hm-conflict-list {
  margin: 0 0 18px;
  padding: 13px;
  border-radius: 14px;
  background: #fff1ef;
}

.hm-sync-error {
  display: grid;
  gap: 4px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid #f1b8b2;
  border-radius: 13px;
  background: #fff1ef;
  color: #8f241c;
  font-size: 13px;
  line-height: 1.4;
}

.hm-conflict-list h3 {
  margin: 0 0 8px;
  color: var(--hm-sync-danger);
  font-size: 14px;
}

.hm-conflict-list article {
  display: grid;
  gap: 3px;
  padding: 8px 0;
  border-bottom: 1px solid #f3cbc6;
  font-size: 12px;
}

.hm-conflict-list article span { color: #704a45; line-height: 1.4; }
.hm-conflict-list .hm-secondary { margin-top: 10px; }
.hm-no-conflict { margin: 0 0 17px; color: #58736f; font-size: 13px; text-align: center; }

.hm-sync-toast {
  position: fixed;
  z-index: 11000;
  right: 16px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  left: 16px;
  max-width: 560px;
  margin: auto;
  padding: 13px 16px;
  border-radius: 14px;
  background: #113e37;
  color: white;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .2);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
}

.hm-sync-toast.danger { background: #9f241c; }

@media (max-width: 520px) {
  .hm-auth-card,
  .hm-sync-panel { padding: 23px 18px; border-radius: 23px; }
  .hm-account-grid { grid-template-columns: 1fr; }
  .hm-sync-status span { display: none; }
  .hm-sync-status { width: 31px; justify-content: center; padding: 0; }
}
