:root {
  --color-sky: #a8d4e6;
  --color-champagne: #efc59f;
  --color-champagne-bright: #f7dab8;
  --color-ink: #17373f;
  --font-display: "Iowan Old Style", "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, serif;
  --font-sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  min-width: 320px;
  min-height: 100%;
  color-scheme: light;
  background: var(--color-sky);
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  color: #f7fbfa;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  background: linear-gradient(145deg, #0c4650, #9ccfdb);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.drawer-open {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

button,
input {
  color: inherit;
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
a,
label[for] {
  -webkit-tap-highlight-color: transparent;
}

svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  min-height: 44px;
  padding: 0.68rem 1rem;
  color: #17373f;
  background: #fff;
  border-radius: 999px;
  box-shadow: 0 12px 32px rgba(10, 42, 47, 0.24);
  transform: translateY(-180%);
  transition: transform 180ms var(--ease-out);
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 3px solid #fbe6a8;
  outline-offset: 3px;
}

.status-message {
  margin: 0.8rem 0;
  padding: 0.72rem 0.9rem;
  color: #7e2a2d;
  background: rgba(255, 231, 227, 0.94);
  border: 1px solid rgba(160, 55, 60, 0.2);
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 650;
}

.primary-button,
.enter-space,
.quiet-action,
.icon-button,
.reset-button,
.password-toggle {
  min-width: 44px;
  min-height: 44px;
}

.primary-button,
.enter-space {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  width: 100%;
  padding: 0.85rem 1.15rem;
  border-radius: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  transition: transform 200ms var(--ease-out), box-shadow 200ms var(--ease-out), opacity 180ms ease;
}

.primary-button:hover:not(:disabled),
.enter-space:hover {
  transform: translateY(-2px);
}

.primary-button:disabled {
  opacity: 0.5;
}

.button-arrow {
  font-size: 1.15rem;
  transition: transform 180ms var(--ease-out);
}

.primary-button:hover .button-arrow,
.enter-space:hover span:last-child {
  transform: translateX(3px);
}

/* Background drawer */

.drawer-layer {
  position: fixed;
  z-index: 50;
  inset: 0;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  min-width: 100%;
  height: 100%;
  padding: 0;
  background: rgba(8, 38, 42, 0.1);
  opacity: 0;
  backdrop-filter: blur(0);
  transition: opacity 280ms ease, backdrop-filter 280ms ease;
}

.settings-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: min(29rem, 100%);
  height: 100%;
  padding: clamp(1.4rem, 4vw, 2.25rem);
  overflow-y: auto;
  color: #17373f;
  background: rgba(249, 252, 247, 0.94);
  border-left: 1px solid rgba(255, 255, 255, 0.88);
  box-shadow: -26px 0 70px rgba(16, 55, 61, 0.2);
  backdrop-filter: blur(28px) saturate(116%);
  transform: translateX(102%);
  transition: transform 320ms var(--ease-out);
}

.drawer-layer.is-open .drawer-backdrop {
  background: rgba(8, 38, 42, 0.38);
  opacity: 1;
  backdrop-filter: blur(5px);
}

.drawer-layer.is-open .settings-drawer {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.drawer-kicker {
  margin: 0 0 0.3rem;
  color: #376e71;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.24em;
}

.drawer-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 3vw, 2.15rem);
  font-weight: 600;
  line-height: 1.25;
}

.icon-button {
  display: grid;
  flex: 0 0 44px;
  place-items: center;
  color: #315e63;
  background: rgba(224, 242, 239, 0.82);
  border: 1px solid rgba(64, 120, 123, 0.15);
  border-radius: 50%;
}

.icon-button svg {
  width: 1.25rem;
  height: 1.25rem;
}

.background-preview {
  position: relative;
  margin: 1.7rem 0 1.4rem;
  overflow: hidden;
  background: #d5eff0;
  border: 1px solid rgba(41, 91, 96, 0.18);
  border-radius: 18px;
  box-shadow: 0 16px 34px rgba(44, 89, 92, 0.13);
  aspect-ratio: 16 / 9;
}

.background-preview picture {
  display: contents;
}

.background-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.background-preview span {
  position: absolute;
  right: 0.75rem;
  bottom: 0.75rem;
  padding: 0.35rem 0.65rem;
  color: #fff;
  background: rgba(12, 48, 54, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  backdrop-filter: blur(10px);
}

.background-catalog {
  display: grid;
  gap: 0.7rem;
  margin-bottom: 1rem;
}

.background-catalog-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.background-catalog-heading h3 {
  margin: 0;
  color: #234b51;
  font-size: 0.88rem;
  font-weight: 750;
}

.background-catalog-heading span {
  color: #58777b;
  font-size: 0.72rem;
}

.background-preset-form {
  margin: 0;
}

.background-preset-card {
  display: grid;
  grid-template-columns: 6.6rem minmax(0, 1fr) auto;
  min-height: 4.5rem;
  width: 100%;
  align-items: center;
  gap: 0.8rem;
  padding: 0.5rem;
  color: #244b51;
  text-align: left;
  background: rgba(239, 249, 246, 0.9);
  border: 1px solid rgba(53, 121, 122, 0.24);
  border-radius: 16px;
  transition: transform 180ms var(--ease-out), border-color 180ms ease, box-shadow 180ms ease;
}

.background-preset-card:hover {
  border-color: rgba(47, 132, 130, 0.55);
  box-shadow: 0 12px 26px rgba(38, 97, 99, 0.12);
  transform: translateY(-2px);
}

.background-preset-art {
  display: block;
  overflow: hidden;
  background: linear-gradient(135deg, #f7e3c8, #d6a16f);
  border-radius: 12px;
  aspect-ratio: 16 / 9;
}

.background-preset-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.background-preset-copy {
  display: grid;
  min-width: 0;
  gap: 0.18rem;
}

.background-preset-copy strong {
  font-family: var(--font-display);
  font-size: 0.95rem;
}

.background-preset-copy small {
  overflow: hidden;
  color: #587277;
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.background-preset-action {
  padding: 0.35rem 0.55rem;
  color: #2f7475;
  background: rgba(218, 241, 235, 0.9);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 750;
}

.background-form {
  display: grid;
  gap: 0.9rem;
}

.dropzone {
  display: grid;
  min-height: 13rem;
  place-items: center;
  align-content: center;
  gap: 0.55rem;
  padding: 1.2rem;
  text-align: center;
  background: rgba(239, 249, 246, 0.85);
  border: 1px dashed rgba(53, 121, 122, 0.42);
  border-radius: 18px;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.dropzone:hover,
.dropzone.is-dragging {
  background: rgba(223, 245, 239, 0.96);
  border-color: #3f9894;
  transform: translateY(-2px);
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.dropzone-icon {
  display: grid;
  width: 3.1rem;
  height: 3.1rem;
  place-items: center;
  color: #397d7d;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 10px 24px rgba(52, 111, 110, 0.12);
}

.dropzone-icon svg {
  width: 1.4rem;
  height: 1.4rem;
}

.dropzone strong {
  font-size: 0.94rem;
}

.dropzone small,
.selected-file,
.drawer-footnote {
  color: #4f6c71;
  font-size: 0.76rem;
}

.selected-file {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-save {
  color: #fff;
  background: linear-gradient(135deg, #267f82, #397f77);
  box-shadow: 0 13px 26px rgba(38, 127, 130, 0.2);
}

.drawer-divider {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 1.2rem 0 0.85rem;
  color: #4f6c71;
  font-size: 0.72rem;
}

.drawer-divider::before,
.drawer-divider::after {
  flex: 1;
  height: 1px;
  content: "";
  background: rgba(50, 102, 105, 0.16);
}

.reset-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.72rem 1rem;
  color: #3e696d;
  background: transparent;
  border: 1px solid rgba(56, 106, 109, 0.24);
  border-radius: 14px;
  font-weight: 650;
}

.reset-button:hover {
  background: rgba(221, 242, 237, 0.72);
}

.reset-button svg {
  width: 1.15rem;
  height: 1.15rem;
}

.drawer-footnote {
  margin: 1rem 0 0;
  line-height: 1.7;
}

@media (max-width: 720px) {
  .settings-drawer {
    top: auto;
    bottom: 0;
    width: 100%;
    height: min(88dvh, 48rem);
    border-top: 1px solid rgba(255, 255, 255, 0.88);
    border-left: 0;
    border-radius: 24px 24px 0 0;
    transform: translateY(102%);
  }

  .drawer-layer.is-open .settings-drawer {
    transform: translateY(0);
  }

  .dropzone {
    min-height: 10.5rem;
  }

  .background-preset-card {
    grid-template-columns: 5.7rem minmax(0, 1fr) auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skip-link,
  .settings-drawer,
  .drawer-backdrop,
  .primary-button,
  .enter-space,
  .dropzone,
  .background-preset-card {
    transition-duration: 120ms;
  }
}
