@font-face {
  font-family: "Pretendard Variable";
  src: url("/PretendardVariable.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("/IBMPlexMono-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #000000;
  --surface: #0d0d0d;
  --text: #f4f4f4;
  --muted: rgba(255, 255, 255, 0.62);
  --accent: #ffffff;
  --accent-weak: rgba(255, 255, 255, 0.14);
  --index-header-side-width: 68px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", "Pretendard", sans-serif;
}

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

.app-shell {
  width: min(1400px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.index-page .app-shell {
  width: 100%;
  margin: 0;
  padding: 48px 0 132px;
}

.index-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  height: 48px;
  margin: 0;
  padding: 0 16px;
  background: #000;
  display: grid;
  grid-template-columns: var(--index-header-side-width) minmax(0, 1fr) var(--index-header-side-width);
  align-items: center;
  column-gap: 12px;
}

.index-logo-box {
  width: var(--index-header-side-width);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 4px;
}

.index-logo {
  height: 22px;
  width: auto;
  display: block;
}

.ratio-filter-wrap {
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  align-self: stretch;
  padding-top: 16px;
}

.ratio-filter-tabs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.ratio-filter-tabs::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.ratio-filter-btn {
  flex: 0 0 auto;
  background: transparent;
  border: 0;
  font-family: "IBM Plex Mono", monospace;
  font-weight: 500;
  font-size: 14px;
  line-height: 1;
  letter-spacing: 0.01em;
  color: inherit;
  padding: 0;
  border-radius: 0;
  position: relative;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 18px;
  padding-bottom: 7px;
  white-space: nowrap;
  opacity: 0.36;
  transition: opacity 0.18s ease;
}

.ratio-filter-btn::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0;
  transform: translateX(-50%);
  transition: opacity 0.18s ease;
}

.ratio-filter-btn:hover {
  background: transparent;
  opacity: 0.62;
}

.ratio-filter-btn.active {
  background: transparent;
  color: inherit;
  opacity: 1;
}

.ratio-filter-btn.active::after {
  opacity: 1;
}

.ratio-filter-btn.blur-pulse {
  animation: ratioFilterBlurPulse 0.22s ease;
}

@keyframes ratioFilterBlurPulse {
  0% {
    filter: blur(0px);
    transform: scale(1);
  }
  40% {
    filter: blur(2.5px);
    transform: scale(0.95);
  }
  100% {
    filter: blur(0px);
    transform: scale(1);
  }
}

.top-login-btn {
  height: 32px;
  width: var(--index-header-side-width);
  min-width: var(--index-header-side-width);
  border-radius: 999px;
  padding: 0 6px;
  background: #000;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  justify-self: stretch;
}

.top-login-btn:hover {
  background: #000;
  opacity: 0.8;
}

.top-login-btn.is-authenticated {
  background: #8a8a8a;
  color: #fff;
}

.top-login-btn.is-authenticated:hover {
  background: #8a8a8a;
  opacity: 0.88;
}

.settings-menu {
  position: fixed;
  top: 56px;
  right: 16px;
  z-index: 70;
  width: min(220px, calc(100vw - 32px));
  padding: 12px;
  border-radius: 10px;
  border: 0.5px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.96);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-credit {
  margin: 0 0 4px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 12px;
}

.settings-credit strong {
  font-family: "IBM Plex Mono", monospace;
  color: #fff;
}

.settings-menu-btn {
  width: 100%;
  height: 36px;
  border-radius: 8px;
  background: #111;
  border: 0.5px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 12px;
  text-align: left;
  padding: 0 10px;
}

.settings-menu-btn:hover {
  background: #171717;
  opacity: 1;
}

.index-page.ui-light-mode {
  background: #fff;
  color: #111;
}

.index-page.ui-light-mode .index-header {
  background: #fff;
  border-bottom: 0;
}

.index-page.ui-light-mode .index-logo,
.index-page.ui-light-mode .top-login-btn {
  filter: none;
}

.index-page.ui-light-mode .index-logo {
  filter: brightness(0);
}

.index-page.ui-light-mode .settings-menu {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.2);
}

.index-page.ui-light-mode .settings-credit {
  color: rgba(0, 0, 0, 0.66);
}

.index-page.ui-light-mode .settings-credit strong {
  color: #111;
}

.index-page.ui-light-mode .settings-menu-btn {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.2);
  color: #111;
}

.index-page.ui-light-mode .settings-menu-btn:hover {
  background: #f4f4f4;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.text-link {
  color: var(--muted);
  font-size: 13px;
}

input,
textarea,
button {
  font-family: inherit;
  border: none;
  outline: none;
}

button {
  background: var(--accent-weak);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}

button:hover {
  background: rgba(255, 255, 255, 0.2);
}

button:focus-visible,
.tab-btn:focus-visible,
.template-card:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.9);
  outline-offset: 1px;
}

.field-label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--muted);
}

input[type="text"],
textarea {
  width: 100%;
  background: #111;
  color: var(--text);
  padding: 10px;
  font-size: 13px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

input[type="text"]::placeholder,
textarea::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

input[type="text"] {
  border-radius: 0;
}

textarea {
  min-height: 240px;
  resize: vertical;
  line-height: 1.4;
}

.button-row {
  display: flex;
  gap: 8px;
}

.z-index-copy-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.z-index-copy-btn {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1;
}

.z-index-copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.create-modal-card {
  width: min(1080px, 100%);
}

.create-modal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 14px;
  align-items: start;
}

.create-modal-editor {
  min-width: 0;
}

.create-preview-panel {
  min-width: 0;
}

.create-preview-stage {
  width: 100%;
  aspect-ratio: 1080 / 1350;
  background: #000;
  border: 0.5px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}

.create-preview-canvas {
  width: 1080px;
  height: 1350px;
  transform-origin: top left;
}

.create-preview-empty {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--muted);
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0.82));
  text-align: center;
  padding: 12px;
}

.create-preview-stage.has-preview .create-preview-empty {
  display: none;
}

.button-row.right {
  justify-content: flex-end;
}

.status-text {
  margin: 0 0 12px;
  min-height: 18px;
  font-size: 12px;
  color: var(--muted);
}

.status-text.error {
  color: #b10000;
}

.style-section {
  margin-bottom: 14px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.section-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.style-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.style-card {
  position: relative;
  background: #111;
  border: 0.5px solid rgba(255, 255, 255, 0.2);
  padding: 8px;
  border-radius: 8px;
}

.style-card-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 12px;
  line-height: 18px;
  z-index: 1;
}

.style-card-delete:hover {
  background: rgba(255, 255, 255, 0.24);
}

.style-card-delete:disabled {
  opacity: 0.5;
  cursor: wait;
}

.style-card-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  border-radius: 12px;
}

.style-card-name {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.style-card-mode-row {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.style-card-mode-btn {
  height: 26px;
  border-radius: 999px;
  background: #171717;
  border: 0.5px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 11px;
  padding: 0;
}

.style-card-mode-btn.active {
  background: #fff;
  color: #111;
}

.style-card-mode-btn:hover {
  background: #202020;
  opacity: 1;
}

.style-card-mode-btn.active:hover {
  background: #fff;
}

.style-card-mode-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

.style-thumb-preview {
  width: 92px;
  height: 92px;
  object-fit: cover;
  display: block;
  margin: 0 0 10px;
  border-radius: 8px;
}

.style-mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.style-mode-btn {
  height: 34px;
  border-radius: 999px;
  background: #111;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 12px;
}

.style-mode-btn.active {
  background: #fff;
  color: #111;
}

.style-mode-btn:hover {
  background: #202020;
  opacity: 1;
}

.style-mode-btn.active:hover {
  background: #fff;
}

.style-toggle-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}

.style-toggle-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  background: #111;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 6px;
}

.style-toggle-btn.active {
  background: #fff;
  color: #111;
}

.style-toggle-thumb {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 12px;
  flex-shrink: 0;
}

.ratio-toggle-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.ratio-toggle-btn {
  width: 100%;
  background: #111;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  text-align: center;
  padding: 8px 10px;
}

.ratio-toggle-btn.active {
  background: #fff;
  color: #111;
}

.ratio-tab-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.ratio-tab-btn {
  flex: 1 1 calc(50% - 3px);
  min-width: 0;
  text-align: center;
  background: #111;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 6px 10px;
}

.ratio-tab-btn.active {
  background: #fff;
  color: #111;
}

.filter-top {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
}

.style-change-btn {
  height: 40px;
  min-width: 118px;
  max-width: min(52vw, 220px);
  border-radius: 999px;
  background: #fff;
  border: 0.5px solid rgba(0, 0, 0, 0.2);
  color: #111;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
}

.style-change-btn:hover {
  background: #fff;
  opacity: 0.86;
}

.style-change-btn img {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  object-fit: cover;
  display: block;
  flex: 0 0 auto;
  background: #f2f2f2;
}

.style-change-btn.is-empty img {
  opacity: 0;
}

.style-change-btn span {
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.style-picker-wrap {
  flex: 1;
  min-width: 0;
  height: 48px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
  padding: 0 16px;
  border-radius: 999px;
  overflow: visible;
}

.refresh-wrap {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: 0;
}

.hue-wrap {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: #ffffff;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
  border-radius: 999px;
}

#hueTrigger {
  position: relative;
  background: transparent;
  color: inherit;
  padding: 0;
  width: 24px;
  height: 24px;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.24s ease, transform 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}

#hueTrigger:hover {
  background: transparent;
  opacity: 0.9;
}

#hueDot {
  width: 22px;
  height: 22px;
  display: block;
  border-radius: 999px;
  background: hsl(0 100% 50%);
  border: 1px solid rgba(0, 0, 0, 0.24);
  transition: opacity 0.26s ease, filter 0.34s ease, transform 0.34s ease;
}

#hueCheck {
  position: absolute;
  width: 20px;
  height: 20px;
  display: block;
  opacity: 0;
  filter: blur(6px);
  transform: scale(0.7);
  transition: opacity 0.26s ease, filter 0.34s ease, transform 0.34s ease;
}

.hue-popover {
  position: absolute;
  left: 13px;
  bottom: calc(100% + 13px);
  width: 22px;
  height: 22px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  filter: blur(7px);
  transition:
    width 0.46s cubic-bezier(0.22, 1, 0.36, 1),
    height 0.46s cubic-bezier(0.22, 1, 0.36, 1),
    right 0.46s cubic-bezier(0.22, 1, 0.36, 1),
    bottom 0.46s cubic-bezier(0.22, 1, 0.36, 1),
    border-radius 0.46s cubic-bezier(0.22, 1, 0.36, 1),
    padding 0.3s ease,
    opacity 0.28s ease,
    filter 0.46s ease;
}

.hue-wrap.is-open #hueDot {
  opacity: 0;
  filter: blur(6px);
  transform: scale(0.72);
}

.hue-wrap.is-open #hueCheck {
  opacity: 1;
  filter: blur(0);
  transform: scale(1);
}

.hue-wrap.is-open .hue-popover {
  left: 0;
  bottom: calc(100% + 10px);
  width: 220px;
  height: 48px;
  padding: 0 32px;
  border-radius: 14px;
  opacity: 1;
  pointer-events: auto;
  filter: blur(0);
}

.tab-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
}

.style-picker-wrap .tab-list {
  --style-tab-gap: 8px;
  flex-wrap: nowrap;
  align-items: flex-end;
  height: 80px;
  margin-top: -32px;
  padding: 0 2px;
  gap: var(--style-tab-gap);
  overflow-x: hidden;
  overflow-y: hidden;
  touch-action: pan-y;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.style-picker-wrap .tab-list::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.style-tab-spacer {
  flex: 0 0 max(0px, calc(50% - 20px - var(--style-tab-gap)));
  height: 1px;
  pointer-events: none;
}

.tab-btn {
  background: var(--accent-weak);
  color: var(--muted);
  padding: 7px 11px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
}

.tab-btn.active {
  background: var(--accent);
  color: #111;
}

.style-tab-btn {
  position: relative;
  width: 40px;
  min-width: 40px;
  height: 40px;
  border-radius: 999px;
  padding: 0;
  background: #fff;
  overflow: hidden;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  transform-origin: center bottom;
  transform: translateY(-4px);
  will-change: transform, filter, height, border-radius;
  transition:
    width 0.22s ease,
    height 0.22s ease,
    border-radius 0.22s ease,
    transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.22s ease;
}

.style-tab-btn.active {
  width: 40px;
  min-width: 40px;
  height: 60px;
  border-radius: 24px;
  padding: 4px;
  background: #111;
  justify-content: flex-start;
  color: inherit;
  outline: none;
  z-index: 2;
  animation: styleTabMorphRise 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.style-tab-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  display: block;
  border-radius: 999px;
  transition: border-radius 0.22s ease;
  flex: 0 0 auto;
}

.style-tab-btn.active .style-tab-thumb {
  width: 32px;
  height: 32px;
  animation: styleTabThumbFocus 0.3s ease-out both;
}

.style-tab-dot {
  margin-top: 6px;
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: #fff;
  display: none;
  pointer-events: none;
}

.style-tab-btn.active .style-tab-dot {
  display: block;
}

@keyframes styleTabMorphRise {
  from {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 999px;
    background: #fff;
    transform: translateY(10px) scale(0.92);
    filter: blur(6px);
    opacity: 0.74;
  }
  72% {
    filter: blur(1px);
  }
  to {
    width: 40px;
    height: 60px;
    padding: 4px;
    border-radius: 24px;
    background: #111;
    transform: translateY(-4px) scale(1);
    filter: blur(0);
    opacity: 1;
  }
}

@keyframes styleTabThumbFocus {
  from {
    filter: blur(4px);
    transform: scale(0.95);
  }
  to {
    filter: blur(0);
    transform: scale(1);
  }
}

#refreshBtn {
  background: #000;
  color: #fff;
  padding: 0 14px;
  min-height: 40px;
  border-radius: 999px;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

#refreshBtn:hover {
  background: #000;
  opacity: 0.72;
}

#refreshBtn img {
  width: 18px;
  height: 18px;
  display: block;
  filter: brightness(0) invert(1);
}

#refreshBtn.is-shuffling {
  animation: shuffleButtonBlur 0.5s ease;
}

#refreshCountLabel {
  display: inline-block;
  font-size: 12px;
  line-height: 1;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
}

.index-page.ui-light-mode #refreshBtn {
  background: #000;
  color: #fff;
  border: 0;
}

.index-page.ui-light-mode #refreshBtn:hover {
  background: #000;
  opacity: 0.76;
}

.index-page.ui-light-mode #refreshBtn img {
  filter: brightness(0) invert(1);
}

.index-page.ui-light-mode #refreshCountLabel {
  color: #fff;
}

.hue-control {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  margin: 0;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.24s ease;
}

.hue-wrap.is-open .hue-control {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 0.12s;
}

#hueValue {
  font-family: "IBM Plex Mono", monospace;
  font-size: 32px;
  line-height: 1;
  color: #111;
  min-width: 40px;
  text-align: right;
}

.hue-control input[type="range"] {
  width: 130px;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  height: 18px;
}

.hue-control input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    #ff0000 0%,
    #ffff00 16.66%,
    #00ff00 33.33%,
    #00ffff 50%,
    #0000ff 66.66%,
    #ff00ff 83.33%,
    #ff0000 100%
  );
}

.hue-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  margin-top: -4px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.35);
}

.hue-control input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    #ff0000 0%,
    #ffff00 16.66%,
    #00ff00 33.33%,
    #00ffff 50%,
    #0000ff 66.66%,
    #ff00ff 83.33%,
    #ff0000 100%
  );
}

.hue-control input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.35);
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  gap: 10px;
}

.template-grid.is-shuffling {
  animation: shuffleBlur 0.5s ease;
}

@keyframes shuffleBlur {
  0% {
    filter: blur(0px);
    opacity: 1;
  }
  40% {
    filter: blur(2px);
    opacity: 0.92;
  }
  100% {
    filter: blur(0px);
    opacity: 1;
  }
}

@keyframes shuffleButtonBlur {
  0% {
    filter: blur(0px);
    opacity: 1;
  }
  40% {
    filter: blur(1.5px);
    opacity: 0.8;
  }
  100% {
    filter: blur(0px);
    opacity: 1;
  }
}

.template-card {
  position: relative;
  padding: 8px;
  background: var(--surface);
  border-radius: 10px;
}

.template-card-designer {
  padding-top: 28px;
}

.template-style-toggle-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.template-style-chip {
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.16);
}

.template-style-chip.active {
  background: transparent;
  outline: 2px solid rgba(255, 255, 255, 0.82);
  outline-offset: 1px;
}

.template-style-chip:disabled {
  opacity: 0.5;
  cursor: wait;
}

.template-style-chip-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 12px;
  line-height: 18px;
}

.thumbnail-stage {
  width: 160px;
  height: auto;
  aspect-ratio: 1080 / 1350;
  overflow: hidden;
  background: #000;
  border-radius: 12px;
  border: 0;
  box-shadow: none;
  margin: 0 auto;
}

.thumbnail-canvas {
  width: 1080px;
  height: 1350px;
  transform-origin: top left;
  pointer-events: none;
}

.index-page .template-grid {
  display: block;
  padding: 0 16px 16px;
  column-width: 300px;
  column-gap: 6px;
}

.index-page .template-card {
  display: inline-block;
  width: 100%;
  margin: 0 0 6px;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  padding: 0;
  background: transparent;
  border-radius: 0;
}

.index-page .thumbnail-frame {
  --thumb-frame-radius: 0px;
  --thumb-frame-stroke: 1px;
  --thumb-stage-radius: 0px;
  width: 100%;
  margin: 0;
  padding: var(--thumb-frame-stroke);
  background: #e0e0e0;
  border-radius: var(--thumb-frame-radius);
  overflow: hidden;
  isolation: isolate;
}

.index-page .thumbnail-stage {
  width: 100%;
  height: auto;
  margin: 0;
  background: #000;
  border: 0;
  box-shadow: none;
  border-radius: 0;
  overflow: hidden;
  clip-path: none;
}

.index-page .thumbnail-stage > .thumbnail-canvas {
  border-radius: 0;
  overflow: hidden;
}

.index-page .thumbnail-stage > .thumbnail-canvas > .template-root {
  border-radius: 0;
  overflow: hidden;
}

.style-picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: rgba(0, 0, 0, 0.74);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.style-picker-modal {
  width: min(780px, 100%);
  max-height: min(78vh, 720px);
  overflow: auto;
  background: transparent;
}

.style-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.style-picker-item {
  position: relative;
  width: 100%;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.98);
  border: 0;
  padding: 10px 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: #111;
  animation: stylePickerDropIn 0.28s ease both;
  animation-delay: var(--style-item-delay, 0s);
}

.style-picker-item:hover {
  background: #fff;
  opacity: 1;
}

.style-picker-item.is-selected {
  outline: 2px solid rgba(0, 0, 0, 0.82);
  outline-offset: 0;
}

.style-picker-item-thumb {
  width: 54px;
  height: 54px;
  border-radius: 10px;
  object-fit: cover;
  display: block;
}

.style-picker-item-name {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: rgba(0, 0, 0, 0.78);
  text-align: center;
  width: 100%;
  line-height: 1.2;
}

.style-picker-item-spinner {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0, 0, 0, 0.18);
  border-top-color: #111;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
}

.style-picker-item.is-loading .style-picker-item-spinner {
  opacity: 1;
  animation: stylePickerSpin 0.72s linear infinite;
}

.style-picker-item.is-loading .style-picker-item-thumb,
.style-picker-item.is-loading .style-picker-item-name {
  opacity: 0.52;
}

@keyframes stylePickerDropIn {
  from {
    opacity: 0;
    filter: blur(8px);
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0) scale(1);
  }
}

@keyframes stylePickerSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.empty-state {
  padding: 14px 0;
  font-size: 13px;
  color: var(--muted);
}

.index-page.ui-light-mode .empty-state {
  color: rgba(0, 0, 0, 0.58);
}

.hidden {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-card {
  width: min(860px, 100%);
  background: #0d0d0d;
  border: 0.5px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 14px;
}

.modal-card h2 {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 600;
}

.auth-backdrop {
  z-index: 130;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.auth-backdrop.is-opening {
  animation: authBackdropIn 0.28s ease both;
}

.auth-backdrop.is-opening .auth-modal-card {
  animation: authModalRiseIn 0.34s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes authBackdropIn {
  from {
    opacity: 0;
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
  }
  to {
    opacity: 1;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
}

@keyframes authModalRiseIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
    filter: blur(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0px);
  }
}

.auth-modal-card {
  width: min(380px, 100%);
  background: #fff;
  border: 0;
  border-radius: 24px;
  padding: 12px;
  color: #111;
}

.auth-head {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-bottom: 8px;
  min-height: 28px;
}

.auth-close-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

.auth-close-btn img {
  width: 16px;
  height: 16px;
  display: block;
  filter: brightness(0);
}

.auth-close-btn:hover {
  background: transparent;
  opacity: 0.65;
}

.auth-mode-row {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 18px;
  margin-bottom: 0;
}

.auth-mode-btn {
  flex: 0 0 auto;
  height: auto;
  min-width: 0;
  padding: 0 0 8px;
  border-radius: 0;
  border: 0;
  background: transparent;
  color: rgba(17, 17, 17, 0.45);
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  position: relative;
  transition: color 0.16s ease;
}

.auth-mode-btn::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0;
  transform: translateX(-50%);
  transition: opacity 0.16s ease;
}

.auth-mode-btn.active {
  color: #111;
}

.auth-mode-btn.active::after {
  opacity: 1;
}

.auth-mode-btn:hover {
  background: transparent;
  color: rgba(17, 17, 17, 0.72);
}

.auth-mode-btn.blur-pulse {
  animation: ratioFilterBlurPulse 0.22s ease;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 11px;
  margin-top: 8px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.auth-field > span {
  font-size: 14px;
  font-weight: 500;
  color: rgba(17, 17, 17, 0.58);
}

.auth-field > input {
  width: 100%;
  height: 40px;
  border-radius: 8px;
  border: 0;
  background: #f2f2f2;
  color: #111;
  padding: 0 12px;
  font-size: 14px;
}

.auth-field > input:focus {
  background: #ececec;
}

.auth-consent-row {
  position: relative;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  color: rgba(17, 17, 17, 0.88);
  user-select: none;
  cursor: pointer;
}

.auth-consent-row > span:first-child {
  line-height: 1.3;
}

.auth-consent-row > input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.auth-consent-switch {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #d2d2d2;
  position: relative;
  flex: 0 0 auto;
  transition: background-color 0.2s ease;
}

.auth-consent-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #fff;
  transition: transform 0.2s ease;
}

.auth-consent-row > input:checked + .auth-consent-switch {
  background: #111;
}

.auth-consent-row > input:checked + .auth-consent-switch::after {
  transform: translateX(18px);
}

.auth-error {
  margin: 0;
  color: #d93025;
  font-size: 12px;
}

.auth-submit-btn {
  width: 100%;
  height: 40px;
  border-radius: 24px;
  background: #111;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.auth-submit-btn:hover {
  background: #111;
  opacity: 0.86;
}

.preview-modal-card {
  width: 100vw;
  max-width: 100vw;
  min-width: 0;
  min-height: 100vh;
  --preview-frame-width: 100%;
  padding: 0;
  background: transparent;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
  margin-bottom: 8px;
  width: var(--preview-frame-width);
  max-width: 100%;
}

.preview-toolbar-title {
  margin: 0;
  color: #fff;
  text-align: center;
  font-family: "IBM Plex Mono", monospace;
  font-size: 18px;
  line-height: 1;
  letter-spacing: 0.01em;
}

.preview-tool-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border-radius: 0;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.preview-tool-btn:hover {
  background: transparent;
  opacity: 0.88;
}

.preview-tool-btn img {
  width: 18px;
  height: 18px;
  display: block;
}

.preview-viewport {
  width: 100%;
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  overflow: hidden;
  background: transparent;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.preview-download-row {
  width: var(--preview-frame-width);
  max-width: min(100%, var(--preview-frame-width));
  margin-top: auto;
  padding: 0 0 16px;
  align-self: center;
}

#previewDownloadBtn {
  width: 100%;
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  background: #fff;
  color: #111;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
}

#previewDownloadBtn:hover {
  background: #fff;
  opacity: 0.9;
}

#previewDownloadBtn img {
  width: 20px;
  height: 20px;
  display: block;
}

.preview-canvas {
  width: 100%;
  height: 100%;
  transform-origin: top left;
  background: transparent;
  position: relative;
  overflow: hidden;
  display: block;
}

.preview-backdrop {
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: previewFadeIn 0.16s ease-out;
  overflow: hidden;
}

.preview-backdrop.is-opening .preview-modal-card {
  position: relative;
  z-index: 1;
  animation: previewPopIn 0.22s ease-out;
}

.preview-backdrop.is-opening .preview-canvas {
  animation: previewQuickBlurIn 0.18s ease-out 0.14s both;
}

.preview-backdrop.is-opening #closePreviewBtn {
  animation: previewQuickBlurIn 0.16s ease-out 0.20s both;
}

.preview-backdrop.is-opening #previewDownloadBtn {
  animation: previewQuickBlurIn 0.18s ease-out 0.26s both;
}

@keyframes previewFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes previewPopIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes previewQuickBlurIn {
  from {
    opacity: 0;
    filter: blur(6px);
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0);
  }
}

.template-root {
  width: 1080px;
  height: 1350px;
  position: relative;
  overflow: hidden;
}

.template-root.hue-root {
  filter: hue-rotate(var(--template-hue-angle, 0deg));
}

.template-root.hue-root .hue-image-neutral {
  filter: hue-rotate(calc(-1 * var(--template-hue-angle, 0deg)));
}

.template-root .editable-text-input {
  width: fit-content !important;
  display: inline-block !important;
  max-width: 100% !important;
  border-radius: 0 !important;
}

.template-root .editable-text-input:focus {
  opacity: 0.5;
}

.template-root .editable-text-input.input-fill {
  width: 100% !important;
  display: block !important;
}

.image-placeholder {
  position: relative;
  cursor: pointer;
}

.image-placeholder:not(.has-image) {
  background-color: #f1f1f1 !important;
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(0, 0, 0, 0.12) 0 8px,
    rgba(0, 0, 0, 0.04) 8px 16px
  ) !important;
  background-size: 24px 24px !important;
}

.image-placeholder::after {
  content: "IMAGE";
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 3px 6px;
  font-size: 10px;
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 999px;
}

.image-placeholder.has-image::after {
  display: none;
}

@media (max-width: 720px) {
  .index-page {
    --index-header-side-width: 60px;
  }

  .app-shell {
    padding: 14px;
  }

  .template-grid {
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  }

  .index-page .template-grid {
    column-width: 170px;
  }

  .create-modal-layout {
    grid-template-columns: 1fr;
  }

  .create-preview-panel {
    width: min(240px, 100%);
  }

  .index-header {
    grid-template-columns: var(--index-header-side-width) minmax(0, 1fr) var(--index-header-side-width);
    column-gap: 8px;
  }

  .ratio-filter-btn {
    font-size: 12px;
  }

  .ratio-filter-tabs {
    gap: 14px;
  }

}
