/* TokTok QR — bright modern art QR studio */

:root {
  --bg: #fff7f2;
  --bg-elevated: rgba(255, 255, 255, 0.78);
  --surface: #ffffff;
  --ink: #1c1917;
  --ink-soft: #57534e;
  --ink-faint: #a8a29e;
  --line: rgba(28, 25, 23, 0.08);
  --line-strong: rgba(28, 25, 23, 0.14);
  --accent: #ff6b4a;
  --accent-deep: #e84f2d;
  --accent-soft: #ffe3db;
  --sky: #7ec8ff;
  --mint: #7dd3b0;
  --shadow: 0 18px 50px rgba(120, 70, 40, 0.08);
  --shadow-soft: 0 8px 24px rgba(120, 70, 40, 0.06);
  --radius: 20px;
  --radius-sm: 12px;
  --radius-xs: 10px;
  --font: "Outfit", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --max: 1180px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  word-break: normal;
  overflow-wrap: normal;
  hyphens: none;
  -webkit-hyphens: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Language-aware line breaking: never split Korean words; use native CJK rules. */
html:lang(ko) body {
  word-break: keep-all;
  overflow-wrap: break-word;
}

html:lang(ja) body,
html:lang(zh-Hans) body,
html:lang(zh-Hant) body {
  word-break: normal;
  overflow-wrap: normal;
  line-break: strict;
}

img {
  max-width: 100%;
  display: block;
}

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

a {
  color: var(--accent-deep);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--ink);
}

/* Ambient background */

.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(70px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.55;
}

.bg-orb-a {
  width: 42vw;
  height: 42vw;
  min-width: 280px;
  min-height: 280px;
  top: -10vw;
  right: -8vw;
  background: radial-gradient(circle, #ffc4b5 0%, transparent 70%);
}

.bg-orb-b {
  width: 36vw;
  height: 36vw;
  min-width: 240px;
  min-height: 240px;
  bottom: 5vh;
  left: -10vw;
  background: radial-gradient(circle, #b9e2ff 0%, transparent 70%);
}

.bg-orb-c {
  width: 28vw;
  height: 28vw;
  min-width: 200px;
  min-height: 200px;
  top: 42vh;
  right: 18vw;
  background: radial-gradient(circle, #c8f0df 0%, transparent 70%);
  opacity: 0.4;
}

.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(28, 25, 23, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(28, 25, 23, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 30%, #000 20%, transparent 75%);
}

.app {
  position: relative;
  z-index: 1;
  width: min(100% - 2rem, var(--max));
  margin: 0 auto;
  padding: 1.25rem 0 3rem;
}

/* Top bar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  min-height: 56px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: transparent;
  border: 0;
  border-radius: 18px;
  padding: 0;
  box-shadow: none;
}

.brand-mark svg {
  width: 58px;
  height: 58px;
  display: block;
  filter: drop-shadow(0 9px 12px rgba(255, 107, 74, 0.22));
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.brand-text strong {
  font-size: clamp(1.8rem, 2.8vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.05em;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Match ghost button height/shape so header controls align cleanly */
select.lang-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  display: inline-flex;
  align-items: center;
  width: 7rem;
  min-width: 7rem;
  max-width: 7rem;
  height: 2.55rem;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 1.8rem 0 0.85rem;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1;
  color: var(--ink-soft);
  background-color: rgba(255, 255, 255, 0.55);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%2357534e' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  background-size: 14px 14px;
  box-shadow: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  transition: transform 0.18s var(--ease), background 0.18s var(--ease), border-color 0.18s var(--ease), color 0.18s var(--ease);
}

select.lang-select:hover {
  color: var(--ink);
  background-color: rgba(255, 255, 255, 0.9);
  border-color: var(--line-strong);
}

select.lang-select:focus {
  outline: none;
  color: var(--ink);
  border-color: rgba(255, 107, 74, 0.45);
  box-shadow: 0 0 0 4px rgba(255, 107, 74, 0.12);
}

select.lang-select:active {
  transform: scale(0.98);
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.7rem 1.15rem;
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform 0.18s var(--ease), background 0.18s var(--ease), box-shadow 0.18s var(--ease), border-color 0.18s var(--ease), opacity 0.18s var(--ease);
  text-decoration: none;
  white-space: nowrap;
  word-break: keep-all;
  user-select: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 24px rgba(255, 107, 74, 0.28);
}

.btn-primary:hover {
  background: var(--accent-deep);
  color: #fff;
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}

.btn-secondary:hover {
  border-color: rgba(28, 25, 23, 0.22);
  background: #fffaf7;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.55);
  border-color: var(--line);
  color: var(--ink-soft);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.btn-ghost:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
  border-color: var(--line-strong);
}

/* Workspace */

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 1.25rem;
  align-items: start;
}

.panel {
  background: var(--bg-elevated);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}

.controls {
  padding: 1.5rem;
}

.panel-head {
  margin-bottom: 1.35rem;
}

.panel-head h1 {
  margin: 0 0 0.45rem;
  font-size: clamp(1.55rem, 2.4vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.15;
}

.panel-head p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
  max-width: 48ch;
  line-height: 1.65;
  text-wrap: pretty;
}

html:lang(ko) .panel-head p {
  word-break: keep-all;
  overflow-wrap: break-word;
}

html:lang(ja) .panel-head p,
html:lang(zh-Hans) .panel-head p,
html:lang(zh-Hant) .panel-head p {
  line-break: strict;
  word-break: normal;
}

/* Form fields */

.field {
  margin-bottom: 1.1rem;
}

.field > label,
.field > .label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.label-row label {
  margin: 0;
}

.linkish {
  border: 0;
  background: none;
  color: var(--accent-deep);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.linkish:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.hint {
  margin: 0.4rem 0 0;
  font-size: 0.78rem;
  color: var(--ink-faint);
}

textarea,
select:not(.lang-select),
input[type="text"] {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.9rem;
  outline: none;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

textarea {
  resize: vertical;
  min-height: 88px;
  line-height: 1.45;
}

textarea:focus,
select:focus,
input[type="text"]:focus {
  border-color: rgba(255, 107, 74, 0.55);
  box-shadow: 0 0 0 4px rgba(255, 107, 74, 0.12);
}

select:not(.lang-select) {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2357534e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  padding-right: 2.4rem;
  cursor: pointer;
}

.mono {
  font-family: var(--mono);
  font-size: 0.8rem;
}

.color-row input[type="text"].mono {
  min-width: 0;
  flex: 1;
  font-size: 0.72rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tiny {
  font-size: 0.75rem;
  color: var(--ink-soft);
  min-width: 2.5rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
}

/* Dropzone */

.dropzone {
  display: block;
  cursor: pointer;
  border-radius: var(--radius);
  border: 1.5px dashed rgba(255, 107, 74, 0.35);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 243, 238, 0.65));
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease), transform 0.18s var(--ease);
  overflow: hidden;
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--accent);
  background: linear-gradient(180deg, #fff, #fff0eb);
}

.dropzone.is-dragover {
  transform: scale(1.01);
}

.dropzone-inner {
  width: 100%;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 1.1rem;
  text-align: center;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
}

.dropzone-inner.has-image {
  min-height: 148px;
}

.dropzone-inner.has-image::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(28, 25, 23, 0.15), rgba(28, 25, 23, 0.45));
}

.dropzone-inner.has-image > * {
  position: relative;
  z-index: 1;
  color: #fff;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}

.dropzone-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-deep);
  margin-bottom: 0.25rem;
}

.dropzone-inner.has-image .dropzone-icon {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  backdrop-filter: blur(8px);
}

.dropzone-inner strong {
  font-size: 0.92rem;
  font-weight: 600;
}

.dropzone-inner span {
  font-size: 0.78rem;
  color: var(--ink-faint);
}

.dropzone-inner.has-image span {
  color: rgba(255, 255, 255, 0.85);
}

/* Presets */

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.preset {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.45rem 0.75rem 0.45rem 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 0.18s var(--ease), color 0.18s var(--ease), background 0.18s var(--ease), transform 0.18s var(--ease);
}

.preset:hover {
  color: var(--ink);
  border-color: rgba(28, 25, 23, 0.22);
}

.preset:active {
  transform: scale(0.98);
}

.preset.is-active {
  color: var(--ink);
  border-color: rgba(255, 107, 74, 0.45);
  background: #fff7f4;
  box-shadow: 0 0 0 3px rgba(255, 107, 74, 0.1);
}

.swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--a) 50%, var(--b) 50%);
  border: 1px solid rgba(28, 25, 23, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

/* Color + range */

.color-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  padding: 3px;
  background: var(--surface);
  cursor: pointer;
  flex-shrink: 0;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 7px;
}

input[type="range"] {
  flex: 1;
  width: 100%;
  accent-color: var(--accent);
  height: 1.5rem;
  cursor: pointer;
}

.value-pill {
  display: inline-flex;
  align-items: center;
  margin-left: 0.35rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
}

.privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin: 1.2rem 0 0;
  padding: 0.85rem 0.95rem;
  border-radius: var(--radius-sm);
  background: rgba(126, 200, 255, 0.12);
  border: 1px solid rgba(126, 200, 255, 0.28);
  color: var(--ink-soft);
  font-size: 0.8rem;
  line-height: 1.45;
}

.privacy-note svg {
  flex-shrink: 0;
  margin-top: 0.1rem;
  color: #2f7fbf;
}

/* Preview panel */

.preview {
  padding: 1.35rem 1.35rem 1.2rem;
  position: sticky;
  top: 1rem;
}

.preview-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.preview-toolbar h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.status {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
  min-height: 1.2em;
}

.status.is-error {
  color: #c2410c;
}

.status.is-ready {
  color: #0f766e;
}

.preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-end;
}

.preview-stage {
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 196, 181, 0.35), transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(185, 226, 255, 0.4), transparent 40%),
    linear-gradient(160deg, #fff 0%, #fff8f4 100%);
  border: 1px solid var(--line);
  min-height: 360px;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

.preview-card {
  position: relative;
  width: min(100%, 420px);
  aspect-ratio: 1;
  border-radius: 18px;
  background: #fff;
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.8) inset,
    0 24px 60px rgba(120, 70, 40, 0.12);
  overflow: hidden;
  border: 1px solid rgba(28, 25, 23, 0.06);
}

.preview-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.35s var(--ease);
}

.preview-card img.is-visible {
  opacity: 1;
}

.skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    #f5f5f4 0%,
    #f5f5f4 35%,
    #fff 50%,
    #f5f5f4 65%,
    #f5f5f4 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton.is-hidden {
  display: none;
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.tips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  margin-top: 1rem;
}

.tips article {
  padding: 0.85rem 0.9rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--line);
}

.tips h3 {
  margin: 0 0 0.25rem;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.tips p {
  margin: 0;
  font-size: 0.76rem;
  color: var(--ink-soft);
  line-height: 1.5;
  text-wrap: pretty;
}

html:lang(ko) .tips h3,
html:lang(ko) .tips p,
html:lang(ko) .privacy-note,
html:lang(ko) .hint {
  word-break: keep-all;
  overflow-wrap: break-word;
}

html:lang(ja) .tips h3,
html:lang(ja) .tips p,
html:lang(zh-Hans) .tips h3,
html:lang(zh-Hans) .tips p,
html:lang(zh-Hant) .tips h3,
html:lang(zh-Hant) .tips p {
  line-break: strict;
}

/* Footer */

.footer {
  margin-top: 1.75rem;
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.8rem;
}

.footer p {
  margin: 0;
}

/* Toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%) translateY(12px);
  z-index: 50;
  background: var(--ink);
  color: #fff;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: 0 14px 40px rgba(28, 25, 23, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}

.toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Reduced motion */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .panel,
  .btn-ghost {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: #fff;
  }
}

/* Responsive */

@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .preview {
    position: static;
    order: -1;
  }

  .tips {
    grid-template-columns: 1fr;
  }

  .preview-stage {
    min-height: 300px;
  }
}

@media (max-width: 560px) {
  .app {
    width: min(100% - 1.25rem, var(--max));
    padding-top: 0.9rem;
  }

  .topbar {
    flex-wrap: wrap;
  }

  .brand-mark,
  .brand-mark svg {
    width: 48px;
    height: 48px;
  }

  .brand-text strong {
    font-size: 1.45rem;
  }

  select.lang-select {
    width: 6.25rem;
    min-width: 6.25rem;
    max-width: 6.25rem;
    height: 2.35rem;
    font-size: 0.78rem;
    padding: 0 1.6rem 0 0.7rem;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .controls,
  .preview {
    padding: 1.15rem;
  }

  .preview-toolbar {
    flex-direction: column;
  }

  .preview-actions {
    width: 100%;
  }

  .preview-actions .btn {
    flex: 1;
  }

  .btn-ghost span,
  .top-actions .btn-ghost {
    font-size: 0.82rem;
  }
}
