[hidden] {
  display: none !important;
}

body {
  overflow-x: hidden;
}

.main {
  width: 100%;
  min-width: 0;
  padding-top: 0;
}

.profile > div:not(.avatar),
.setting-row > div {
  min-width: 0;
}

.profile-account {
  overflow-wrap: anywhere;
}

#editNameBtn {
  flex-shrink: 0;
}

.launch-screen {
  position: fixed;
  z-index: 500;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--green);
  transition: opacity .35s ease, visibility .35s ease;
}

.launch-screen.leaving {
  visibility: hidden;
  opacity: 0;
}

.launch-clover {
  width: 92px;
  height: 92px;
  animation: launchGrow .7s cubic-bezier(.2, .8, .3, 1) both;
}

.launch-name {
  margin-top: 18px;
  color: var(--text);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 2px;
}

.launch-slogan {
  margin-top: 3px;
  color: var(--text-soft);
  font-size: .86rem;
}

@keyframes launchGrow {
  from { opacity: 0; transform: scale(.78) rotate(-8deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

.onboarding-shell {
  position: fixed;
  z-index: 490;
  inset: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  height: var(--app-viewport-height, 100dvh);
  min-height: 0;
  padding: 20px max(22px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg);
}

.intro-skip {
  align-self: flex-end;
  min-height: 40px;
  padding: 0 8px;
  color: var(--text-soft);
  font-size: .86rem;
}

.intro-stage {
  display: grid;
  flex: 1;
  min-height: 0;
  width: min(100%, 520px);
  margin: 0 auto;
}

.intro-step {
  display: none;
  grid-area: 1 / 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 0;
  text-align: center;
}

.intro-step.active {
  display: flex;
  animation: introIn .35s ease both;
}

@keyframes introIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.intro-step h1 {
  margin-top: 28px;
  font-size: 1.55rem;
  line-height: 1.35;
}

.intro-step p {
  width: min(100%, 380px);
  margin-top: 10px;
  color: var(--text-soft);
  font-size: .95rem;
  line-height: 1.9;
}

.intro-clover {
  width: 132px;
  height: 132px;
  color: var(--green);
}

.intro-leaves {
  position: relative;
  width: 150px;
  height: 132px;
}

.intro-leaves span {
  position: absolute;
  top: 34px;
  left: 55px;
  width: 52px;
  height: 68px;
  border-radius: 52% 52% 52% 12%;
  background: var(--green);
  transform-origin: 22px 44px;
  box-shadow: var(--shadow);
}

.intro-leaves span:nth-child(1) { transform: rotate(-72deg); }
.intro-leaves span:nth-child(2) { transform: rotate(48deg); }
.intro-leaves span:nth-child(3) { transform: rotate(168deg); }

.intro-journal {
  display: grid;
  gap: 12px;
  width: min(100%, 300px);
}

.intro-journal i {
  position: relative;
  display: block;
  height: 54px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.intro-journal i::before,
.intro-journal i::after {
  content: "";
  position: absolute;
  left: 18px;
  height: 1px;
  background: var(--line);
}

.intro-journal i::before { top: 19px; width: 60%; }
.intro-journal i::after { top: 32px; width: 42%; }

.intro-controls {
  position: sticky;
  z-index: 2;
  bottom: 0;
  flex: 0 0 auto;
  width: min(100%, 380px);
  margin: 0 auto;
  padding-top: 8px;
  background: var(--bg);
}

.intro-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  height: 22px;
}

.intro-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line);
  transition: width .2s ease, background .2s ease;
}

.intro-dot.active {
  width: 22px;
  border-radius: 4px;
  background: var(--green);
}

.intro-next {
  width: 100%;
  min-height: 46px;
  border-radius: 8px;
}

.topbar {
  position: sticky;
  z-index: 18;
  top: 0;
  margin: 0 -16px 22px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(12px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  width: min(100%, 752px);
  min-height: 58px;
  margin: 0 auto;
  padding: 8px 16px;
}

.topbar-inner svg {
  width: 27px;
  height: 27px;
  margin-right: 10px;
  color: var(--green);
}

.topbar-title {
  font-size: 1.06rem;
  font-weight: 700;
}

.slot textarea[data-today-edit] {
  border-style: solid;
  border-color: var(--green);
  background: var(--card);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.review-toolbar {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.review-toolbar .month-select {
  width: 100%;
  min-width: 0;
}

.review-toolbar .btn-random {
  width: auto;
  margin-left: 0;
  white-space: nowrap;
}

.avatar {
  overflow: hidden;
}

.avatar img,
.avatar > svg {
  width: 34px;
  height: 34px;
  object-fit: cover;
}

.avatar img {
  width: 100%;
  height: 100%;
}

.profile-editor {
  width: min(100%, 430px);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 24px;
  border-radius: 8px;
  background: var(--card);
  box-shadow: 0 16px 50px rgba(60, 60, 40, .2);
}

.profile-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.profile-editor-head h2 {
  font-size: 1.15rem;
}

.avatar-fieldset {
  margin-bottom: 20px;
  border: 0;
}

.avatar-fieldset legend,
.profile-form-field span {
  margin-bottom: 8px;
  color: var(--text-soft);
  font-size: .8rem;
}

.avatar-options {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 9px;
}

.avatar-choice {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg);
  color: var(--green-deep);
  transition: border-color .2s, box-shadow .2s, transform .2s;
}

.avatar-choice:hover {
  transform: translateY(-2px);
}

.avatar-choice.selected {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.avatar-choice svg {
  width: 55%;
  height: 55%;
}

.avatar-upload-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  margin: -4px 0 18px;
  padding: 9px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.avatar-upload-control:hover {
  border-color: var(--green);
}

.avatar-upload-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.avatar-upload-command {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--green-deep);
  font-size: .86rem;
  font-weight: 600;
}

.avatar-upload-command svg {
  width: 18px;
  height: 18px;
}

.avatar-upload-control small {
  color: var(--text-soft);
  font-size: .7rem;
  text-align: right;
}

.avatar-upload-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -8px 0 18px;
  color: var(--text-soft);
  font-size: .78rem;
}

.avatar-upload-preview img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
}

.profile-form-field {
  display: block;
}

.profile-form-field span {
  display: block;
}

.profile-form-field input {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: var(--card);
}

.profile-form-field input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.profile-edit-error {
  min-height: 22px;
  margin-top: 4px;
  color: var(--danger);
  font-size: .8rem;
}

.profile-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 18px;
  background: var(--bg);
}

.auth-wrap {
  width: min(100%, 390px);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 26px;
}

.auth-brand svg {
  width: 58px;
  height: 58px;
  margin-bottom: 8px;
}

.auth-brand-name {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: 2px;
}

.auth-slogan {
  margin-top: 2px;
  color: var(--text-soft);
  font-size: .82rem;
}

.auth-panel {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 22px;
  padding: 3px;
  border-radius: 8px;
  background: var(--green-soft);
}

.auth-tabs button {
  min-height: 38px;
  border-radius: 6px;
  color: var(--text-soft);
  font-size: .9rem;
}

.auth-tabs button.active {
  background: var(--card);
  color: var(--green-deep);
  box-shadow: 0 1px 5px rgba(70, 80, 60, .1);
  font-weight: 600;
}

.auth-field {
  display: block;
  margin-bottom: 15px;
}

.auth-field span {
  display: block;
  margin-bottom: 6px;
  color: var(--text-soft);
  font-size: .8rem;
}

.auth-field input {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: var(--card);
  transition: border-color .2s, box-shadow .2s;
}

.auth-field input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.auth-nickname,
.auth-invite {
  display: none;
}

.auth-shell.register-mode .auth-nickname,
.auth-shell.register-mode .auth-invite {
  display: block;
}

.auth-error {
  min-height: 24px;
  margin: -2px 0 8px;
  color: var(--danger);
  font-size: .8rem;
}

.auth-submit {
  width: 100%;
  min-height: 44px;
  border-radius: 8px;
}

.btn:disabled,
button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.loading-line {
  position: fixed;
  z-index: 300;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  overflow: hidden;
  background: var(--green-soft);
}

.loading-line::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 38%;
  background: var(--green);
  animation: loadingSlide 1s ease-in-out infinite;
}

@keyframes loadingSlide {
  from { transform: translateX(-120%); }
  to { transform: translateX(300%); }
}

.app-offline .main {
  opacity: .7;
  pointer-events: none;
}

.letter-item.failed .env {
  background: #fbeae7;
}

.letter-item.failed .env svg {
  color: var(--danger);
}

.letter-status.failed {
  color: var(--danger);
}

@media (max-width: 420px) {
  .auth-shell {
    align-items: start;
    padding-top: 12vh;
  }

  .auth-panel {
    padding: 20px;
  }

  .profile {
    gap: 12px;
    padding: 18px;
  }

  .avatar {
    width: 56px;
    height: 56px;
  }

  .setting-group {
    padding-inline: 18px;
  }

  .setting-row {
    gap: 8px;
  }

  .topbar {
    margin-bottom: 18px;
  }

  .review-toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .review-toolbar .seg {
    min-width: 0;
  }

  .review-toolbar .seg button {
    flex: 1;
    padding-inline: 12px;
  }

  .review-toolbar .month-select {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .review-toolbar .btn-random {
    grid-column: 2;
    grid-row: 1;
    padding-inline: 14px;
  }

  .profile-editor {
    padding: 20px;
  }

  .avatar-options {
    grid-template-columns: repeat(3, 1fr);
  }

  .avatar-upload-control {
    align-items: flex-start;
    flex-direction: column;
  }

  .avatar-upload-control small {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  .launch-clover,
  .intro-step.active {
    animation: none;
  }
}
