/* Story Production System — author Studio PWA (studio.spspublishing.com) */
[data-sps-theme="light"] {
  --sps-bg: #f8f5ef;
  --sps-bg-alt: #ede6da;
  --sps-text: #1a1a3a;
  --sps-heading: #111118;
  --sps-muted: #5c5c6a;
  --sps-card-border: rgba(44, 47, 99, 0.22);
  --sps-input-border: rgba(44, 47, 99, 0.34);
  --sps-placeholder: #4a4a5c;
  --sps-card-bg: #ffffff;
  --sps-modal-surface: #ffffff;
  --sps-input-bg: #f3efe8;
  --sps-primary: #f2b34c;
  --sps-primary-hover: #e38b2c;
  --sps-primary-text: #1a1a3a;
  --sps-link: #2c2f63;
  --sps-focus: rgba(245, 211, 122, 0.5);
  --sps-error: #b42318;
  --sps-success: #1b6e3c;
  --sps-header-bg: #1a1a3a;
  --sps-toggle-icon: #f5d37a;
}

[data-sps-theme="dark"] {
  --sps-bg: #1a1a3a;
  --sps-bg-alt: rgba(75, 63, 121, 0.45);
  --sps-text: #f8f5ef;
  --sps-heading: #ffdfa3;
  --sps-muted: #c4bfd8;
  --sps-card-border: rgba(110, 79, 158, 0.45);
  --sps-input-border: rgba(245, 211, 122, 0.28);
  --sps-placeholder: #a39ebc;
  --sps-card-bg: rgba(75, 63, 121, 0.5);
  --sps-modal-surface: #2c2f63;
  --sps-input-bg: rgba(26, 26, 58, 0.75);
  --sps-primary: #f2b34c;
  --sps-primary-hover: #e38b2c;
  --sps-primary-text: #1a1a3a;
  --sps-link: #f5d37a;
  --sps-focus: rgba(245, 211, 122, 0.45);
  --sps-error: #f5a3a0;
  --sps-success: #8fd4a8;
  --sps-header-bg: #1a1a3a;
  --sps-toggle-icon: #f5d37a;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--sps-text);
  -webkit-font-smoothing: antialiased;
}

[data-sps-theme="light"] body {
  background: var(--sps-bg);
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -20%, rgba(242, 179, 76, 0.22), transparent 55%),
    radial-gradient(ellipse 80% 50% at 100% 100%, rgba(44, 47, 99, 0.06), transparent 50%);
}

[data-sps-theme="dark"] body {
  background: var(--sps-bg);
  background-image:
    linear-gradient(180deg, #1a1a3a 0%, #2c2f63 38%, #2c2f63 68%, #4b3f79 100%),
    radial-gradient(ellipse 100% 70% at 50% -15%, rgba(242, 179, 76, 0.14), transparent 52%),
    radial-gradient(ellipse 75% 55% at 100% 100%, rgba(75, 63, 121, 0.4), transparent 55%);
}

.hidden {
  display: none !important;
}

.studio-update-banner {
  position: sticky;
  top: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--sps-header-bg) 92%, var(--sps-primary));
  border-bottom: 1px solid var(--sps-card-border);
}

.studio-update-banner.hidden {
  display: none !important;
}

.studio-update-banner__text {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--sps-heading);
}

.studio-update-banner .studio-launch__cta {
  width: auto;
  min-height: 40px;
  padding: 8px 16px;
}

.studio-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 20px 18px 32px;
}

.studio-shell__card {
  width: 100%;
  max-width: 440px;
  background: var(--sps-card-bg);
  border: 1px solid var(--sps-card-border);
  border-radius: 18px;
  box-shadow:
    0 1px 2px rgba(26, 26, 58, 0.04),
    0 16px 40px rgba(26, 26, 58, 0.1);
  padding: 0 22px 22px;
  overflow: hidden;
}

.studio-shell__brand {
  text-align: center;
}

.studio-shell__logo-wrap {
  width: calc(100% + 44px);
  margin: 0 -22px 14px;
  padding: 18px 16px 16px;
  background: radial-gradient(ellipse 120% 100% at 50% 0%, #4b3f79 0%, #2c2f63 42%, #1f1b35 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.studio-shell__brand-icon {
  display: block;
  width: min(120px, 36vw);
  height: auto;
  margin: 0 auto;
  object-fit: contain;
}

.studio-shell__title {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--sps-heading);
}

.studio-shell__subtitle {
  margin: 10px auto 0;
  max-width: 36ch;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--sps-muted);
}

.studio-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 18px;
}

.studio-form__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.studio-form__label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--sps-heading);
}

.studio-form__input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  font: inherit;
  font-size: 1rem;
  color: var(--sps-text);
  background: var(--sps-input-bg);
  border: 1px solid var(--sps-input-border);
  border-radius: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.studio-form__input::placeholder {
  color: var(--sps-placeholder);
  opacity: 1;
}

.studio-form__input:hover {
  border-color: rgba(44, 47, 99, 0.42);
}

[data-sps-theme="dark"] .studio-form__input:hover {
  border-color: rgba(245, 211, 122, 0.42);
}

.studio-form__input:focus {
  outline: none;
  border-color: var(--sps-primary-hover);
  box-shadow: 0 0 0 3px var(--sps-focus);
}

.studio-form__input-wrap--password {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  min-height: 44px;
  background: var(--sps-input-bg);
  border: 1px solid var(--sps-input-border);
  border-radius: 8px;
  overflow: hidden;
}

.studio-form__input--with-toggle {
  border: none;
  border-radius: 0;
  box-shadow: none;
  min-height: 44px;
}

.studio-form__input--with-toggle:focus {
  box-shadow: none;
}

.studio-form__input-wrap--password:focus-within {
  border-color: var(--sps-primary-hover);
  box-shadow: 0 0 0 3px var(--sps-focus);
}

.studio-form__pw-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  padding: 0 10px;
  font: inherit;
  color: var(--sps-link);
  background: rgba(255, 255, 255, 0.18);
  border: none;
  border-left: 1px solid rgba(44, 47, 99, 0.08);
  cursor: pointer;
}

[data-sps-theme="dark"] .studio-form__pw-toggle {
  background: rgba(0, 0, 0, 0.22);
  border-left-color: rgba(255, 255, 255, 0.12);
}

.studio-form__pw-toggle-icons {
  display: grid;
}

.studio-form__pw-icon {
  grid-area: 1 / 1;
  display: block;
}

.studio-form__meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.studio-form__remember-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--sps-muted);
  cursor: pointer;
}

.studio-form__remember-label input {
  width: 16px;
  height: 16px;
  accent-color: var(--sps-primary);
}

.studio-form__link-btn {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--sps-link);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.studio-form__feedback {
  min-height: 1.25rem;
}

.studio-form__message {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.45;
}

.studio-form__message--error {
  color: var(--sps-error);
}

.studio-form__message--success {
  color: var(--sps-success);
}

.studio-form__actions .studio-launch__cta {
  width: 100%;
}

.studio-form__footnote {
  margin: 4px 0 0;
  font-size: 0.8125rem;
  text-align: center;
  color: var(--sps-muted);
}

.studio-form__link {
  color: var(--sps-link);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.studio-home {
  padding-top: 22px;
}

.studio-home__top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.studio-home__logo {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: contain;
}

.studio-home__product {
  margin: 0;
  font-weight: 700;
  color: var(--sps-heading);
}

.studio-home__by {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--sps-muted);
}

.studio-home__greet {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--sps-heading);
}

.studio-home__body,
.studio-home__hint {
  margin: 10px 0 0;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--sps-muted);
}

.studio-home__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.studio-home__actions .studio-launch__cta {
  width: 100%;
}

.studio-modal {
  position: fixed;
  inset: 0;
  z-index: 9800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.studio-modal.hidden {
  display: none !important;
}

.studio-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 10, 36, 0.72);
}

.studio-modal__panel {
  position: relative;
  width: 100%;
  max-width: 400px;
  padding: 22px;
  border-radius: 16px;
  background: var(--sps-modal-surface);
  border: 1px solid var(--sps-card-border);
}

.studio-modal__title {
  margin: 0;
  font-size: 1.15rem;
  color: var(--sps-heading);
}

.studio-modal__text {
  margin: 10px 0 0;
  font-size: 0.9rem;
  color: var(--sps-muted);
}

.studio-modal__field {
  margin-top: 14px;
}

.studio-modal__msg {
  margin: 10px 0 0;
  font-size: 0.8125rem;
}

.studio-modal__msg--success {
  color: var(--sps-success);
}

.studio-modal__msg--error {
  color: var(--sps-error);
}

.studio-modal__actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.studio-modal__actions .studio-launch__cta {
  flex: 1;
}

@keyframes studio-shell-card-shake-error {
  0%,
  100% {
    transform: translateX(0);
  }
  18% {
    transform: translateX(-8px);
  }
  36% {
    transform: translateX(8px);
  }
  54% {
    transform: translateX(-5px);
  }
  72% {
    transform: translateX(5px);
  }
}

.studio-shell__card--error-shake {
  animation: studio-shell-card-shake-error 0.42s ease;
}

.sps-theme-toggle {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 900;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--sps-header-bg);
  color: var(--sps-toggle-icon);
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sps-theme-toggle:hover {
  transform: scale(1.06);
}

.sps-theme-toggle-icons {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  line-height: 1;
}

.sps-theme-toggle-icon {
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

html[data-sps-theme="light"] .sps-theme-toggle-icon--to-dark {
  display: flex;
}

html[data-sps-theme="dark"] .sps-theme-toggle-icon--to-light,
html:not([data-sps-theme="light"]) .sps-theme-toggle-icon--to-light {
  display: flex;
}

.sps-theme-toggle-icon .sps-ui-icon-img {
  width: 18px;
  height: 18px;
  display: block;
  object-fit: contain;
}

.sps-action-busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
}

.sps-action-busy-overlay.hidden {
  display: none !important;
}

.sps-action-busy-overlay:focus {
  outline: none;
}

.sps-action-busy-overlay:focus-visible {
  outline: 2px solid var(--sps-focus);
  outline-offset: 4px;
}

.sps-action-busy-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 10, 36, 0.72);
  backdrop-filter: blur(4px);
}

[data-sps-theme="light"] .sps-action-busy-overlay__backdrop {
  background: rgba(26, 26, 58, 0.45);
}

.sps-action-busy-overlay__card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 36px 44px 32px;
  border-radius: 18px;
  max-width: min(90vw, 440px);
  width: 100%;
  box-sizing: border-box;
  background: color-mix(in srgb, var(--sps-card-bg) 94%, transparent);
  border: 1px solid var(--sps-card-border);
  border-left-width: 4px;
  border-left-color: color-mix(in srgb, var(--sps-primary, #f0a046) 50%, var(--sps-card-border));
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.45);
}

.sps-action-busy-overlay__heading {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.sps-action-busy-overlay__logo {
  display: block;
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.sps-action-busy-overlay__heading-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.sps-action-busy-overlay__title {
  margin: 14px 0 0;
  font-size: clamp(1.05rem, 3.2vw, 1.45rem);
  font-weight: 700;
  line-height: 1.25;
  color: var(--sps-heading);
}

.sps-action-busy-overlay__brand {
  margin: 10px 0 0;
  font-size: 0.88rem;
  color: var(--sps-muted);
}

.sps-action-busy-overlay__detail {
  margin: 14px 0 0;
  max-width: 26rem;
  font-size: 0.94rem;
  color: var(--sps-muted);
}

.sps-action-busy-overlay__detail.hidden {
  display: none !important;
}

.sps-action-busy-overlay__dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
}

.sps-action-busy-overlay__dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(
    145deg,
    var(--sps-primary) 0%,
    color-mix(in srgb, var(--sps-primary-hover) 55%, var(--sps-link) 45%) 100%
  );
  animation: sps-action-busy-dot 1.15s ease-in-out infinite;
}

.sps-action-busy-overlay__dots span:nth-child(2) {
  animation-delay: 0.14s;
}

.sps-action-busy-overlay__dots span:nth-child(3) {
  animation-delay: 0.28s;
}

@keyframes sps-action-busy-dot {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.52;
  }
  40% {
    transform: translateY(-9px);
    opacity: 1;
  }
}

[data-sps-theme="dark"] .sps-action-busy-overlay__backdrop {
  background: rgba(8, 6, 22, 0.82);
}

[data-sps-theme="dark"] .sps-action-busy-overlay__card {
  background: rgba(26, 26, 58, 0.94);
}
