:root {
  --ink: oklch(22% .025 52);
  --faded: oklch(48% .03 62);
  --paper: oklch(96% .025 83);
  --paper-2: oklch(91% .042 76);
  --red: oklch(62% .16 32);
  --red-dark: oklch(40% .11 29);
  --blue: oklch(54% .10 235);
  --cyan: oklch(80% .075 210);
  --rule: oklch(68% .032 67);
  --serif: "Songti SC", "STSong", "Iowan Old Style", Georgia, serif;
  --sans: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
  --ease: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; overflow-x: hidden; color: var(--ink); background: var(--paper); font-family: var(--sans); font-size: 1rem; line-height: 1.5; }
button, textarea, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
[hidden] { display: none !important; }
.skip-link { position: fixed; top: -4rem; left: 1rem; z-index: 50; background: var(--ink); color: var(--paper); padding: .75rem 1rem; }
.skip-link:focus { top: 1rem; }

.grain { position: fixed; inset: 0; z-index: 40; pointer-events: none; opacity: .15; mix-blend-mode: multiply; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.3'/%3E%3C/svg%3E"); }
.light-leak { position: fixed; width: 35vw; height: 90vh; pointer-events: none; filter: blur(50px); opacity: .14; z-index: -1; animation: drift 12s ease-in-out infinite alternate; }
.leak-a { left: -10vw; top: -15vh; background: var(--red); transform: rotate(18deg); }
.leak-b { right: -15vw; bottom: -25vh; background: var(--cyan); animation-delay: -5s; }
@keyframes drift { to { transform: translate3d(8vw, 5vh, 0) rotate(-8deg) scale(1.12); } }
.rewind-line { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: -1; opacity: .2; }
.rewind-line path { fill: none; stroke: var(--blue); stroke-width: 1.5; stroke-dasharray: 8 13; stroke-dashoffset: 160; animation: rewind 9s linear infinite; }
@keyframes rewind { to { stroke-dashoffset: 0; } }
.reveal { animation: reveal .75s var(--ease) both; }
@keyframes reveal { from { opacity: 0; transform: translateY(24px) rotate(.35deg); } }

.kicker { margin: 0; font-size: .7rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.lang-toggle { border: 0; border-bottom: 1px solid; padding: .35rem 0; color: var(--ink); background: transparent; font-size: .72rem; font-weight: 800; letter-spacing: .08em; cursor: pointer; }
.lang-toggle:hover { color: var(--red); }

.login-shell { width: min(1120px, calc(100% - 2rem)); min-height: 100vh; margin: auto; display: grid; grid-template-columns: .9fr 1.1fr; align-items: center; gap: clamp(3rem, 9vw, 9rem); position: relative; }
.login-lang { position: absolute; right: 0; top: 2rem; }
.photo-stack { height: min(70vh, 620px); position: relative; animation: photo-in .9s var(--ease) both; }
@keyframes photo-in { from { opacity: 0; transform: translateX(-40px) rotate(-3deg); } }
.photo-stack picture { position: absolute; inset: 7% -7% 5% -17%; padding: .75rem; background: oklch(98% .01 80); box-shadow: 0 1rem 2.5rem oklch(25% .04 50 / .2); transform: rotate(-4deg); clip-path: polygon(2% 4%, 98% 0, 96% 93%, 88% 96%, 74% 94%, 57% 98%, 42% 95%, 24% 99%, 3% 94%); overflow: hidden; }
.photo-stack picture::after { content: ""; position: absolute; inset: .75rem; background: linear-gradient(100deg, transparent 40%, oklch(92% .08 80 / .18), transparent 70%); mix-blend-mode: screen; animation: photo-flare 7s ease-in-out infinite; }
.photo-stack img { width: 100%; height: 100%; display: block; object-fit: cover; filter: saturate(.8) contrast(.94); }
@keyframes photo-flare { 50% { transform: translateX(35%); opacity: .8; } }
.photo-label { position: absolute; z-index: 2; padding: .25rem .55rem; background: var(--paper); font-family: var(--serif); font-size: 1.2rem; box-shadow: 2px 2px 0 var(--ink); }
.label-us { left: -3%; top: 24%; transform: rotate(-10deg); }
.label-tr { right: 0; bottom: 18%; transform: rotate(7deg); }
.tape { position: absolute; width: 7rem; height: 2rem; top: 6%; left: 35%; transform: rotate(-10deg); background: oklch(89% .045 91 / .76); box-shadow: inset 0 0 1px var(--rule); z-index: 3; }
.login-card { animation-delay: .14s; }
.login-card h1 { margin: .45rem 0 clamp(3rem, 8vh, 6rem); font-family: var(--serif); font-size: clamp(4.5rem, 9vw, 8.5rem); font-weight: 400; letter-spacing: -.08em; line-height: .9; }
.login-form label { display: block; margin-bottom: .7rem; font-weight: 750; font-size: .8rem; }
.ink-input { display: flex; border-bottom: 2px solid var(--ink); transition: border-color .25s; }
.ink-input:focus-within { border-color: var(--blue); }
.ink-input input { width: 100%; border: 0; background: transparent; padding: 1rem 0; min-width: 0; }
.ink-input input:focus { outline: 0; }
.ink-input button { display: flex; gap: .8rem; align-items: center; white-space: nowrap; border: 0; background: transparent; color: var(--ink); font-weight: 800; cursor: pointer; padding-left: 1rem; transition: transform .2s var(--ease), color .2s; }
.ink-input button:hover { color: var(--red); transform: translateX(5px); }
.form-error { min-height: 1.5rem; color: var(--red-dark); font-size: .82rem; }
.login-form.shake { animation: shake .28s ease; }
.scribble { font-family: "Kaiti SC", "STKaiti", var(--serif); color: var(--red); transform: rotate(-5deg); }
.login-note { position: absolute; right: 1rem; bottom: 2rem; }

.app-shell { width: min(1200px, calc(100% - clamp(2rem, 7vw, 7rem))); margin: auto; }
.masthead { min-height: 6rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--rule); }
.brand { display: flex; align-items: center; gap: .75rem; color: inherit; text-decoration: none; font-size: .75rem; font-weight: 800; letter-spacing: .08em; }
.brand-stamp { width: 2.7rem; height: 2.7rem; display: grid; place-items: center; border-radius: 50%; color: var(--paper); background: var(--red); font-family: var(--serif); font-size: 1.15rem; transform: rotate(-7deg); }
.header-actions { display: flex; gap: 2rem; align-items: center; }
.text-button { border: 0; border-bottom: 1px solid; padding: .35rem 0; color: var(--ink); background: transparent; cursor: pointer; font-size: .75rem; font-weight: 800; }

.hero { min-height: 29rem; display: grid; grid-template-columns: 1fr auto; gap: 4rem; align-items: center; border-bottom: 1px solid var(--rule); animation-delay: .08s; }
.hero h1 { margin: .65rem 0 0; font-family: var(--serif); font-size: clamp(4rem, 9vw, 8rem); font-weight: 400; letter-spacing: -.075em; line-height: .83; }
.hero h1 em { color: var(--red); font-weight: 400; }
.route-polaroid { width: 18rem; min-height: 15rem; display: grid; grid-template-columns: 1fr 1.2fr 1fr; grid-template-rows: 1fr auto; align-items: center; padding: 2rem 1.5rem 3rem; background: oklch(98% .015 82); box-shadow: .7rem .8rem 0 var(--cyan); transform: rotate(3deg); position: relative; transition: transform .45s var(--ease); }
.route-polaroid:hover { transform: rotate(-1deg) translateY(-6px); }
.route-polaroid::after { content: ""; position: absolute; inset: .7rem .7rem 2.7rem; background: oklch(78% .04 215); z-index: -1; }
.route-polaroid div { display: grid; text-align: center; }
.route-polaroid b { font-family: var(--serif); font-size: 2.3rem; }
.route-polaroid span { font-size: .67rem; font-weight: 800; }
.route-polaroid svg { width: 100%; fill: none; stroke: var(--red); stroke-width: 2; stroke-dasharray: 170; animation: draw 2.2s var(--ease) .7s both; }
@keyframes draw { from { stroke-dashoffset: 170; } }
.route-polaroid small { position: absolute; bottom: .8rem; left: 1rem; font-family: "Kaiti SC", var(--serif); color: var(--red); transform: rotate(-3deg); }

.workbench, .activity { display: grid; grid-template-columns: 5rem 1fr; gap: 2rem; padding: clamp(3rem, 7vw, 6rem) 0; border-bottom: 1px solid var(--rule); animation-delay: .16s; }
.section-tag { width: 3rem; height: 3rem; display: grid; place-items: center; border: 1px solid var(--ink); border-radius: 50%; font-family: var(--serif); font-size: 1.2rem; }
.field-head { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1rem; }
.field-head label { font-family: var(--serif); font-size: clamp(1.8rem, 4vw, 3rem); letter-spacing: -.035em; }
.detected { padding: .45rem .7rem; background: var(--paper-2); font-size: .66rem; font-weight: 800; letter-spacing: .06em; white-space: nowrap; }
.credential-wrap { position: relative; overflow: hidden; }
textarea { display: block; width: 100%; min-height: 13rem; resize: vertical; border: 1px solid var(--rule); border-radius: 0; padding: 1.4rem; background: oklch(98% .012 80); color: var(--ink); font: .82rem/1.7 "SFMono-Regular", Consolas, monospace; transition: transform .25s var(--ease), border-color .25s; }
textarea:focus { outline: 0; border-color: var(--blue); transform: translateY(-2px); }
.clear-button { position: absolute; right: 1rem; top: 1rem; border: 1px solid var(--rule); background: var(--paper); color: var(--faded); padding: .38rem .7rem; cursor: pointer; font-size: .7rem; }
.ink-swipe { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(100deg, transparent 5%, var(--cyan) 45%, transparent 80%); opacity: 0; transform: translateX(-100%); }
.credential-wrap.pasted .ink-swipe { animation: swipe .7s var(--ease); }
@keyframes swipe { 40% { opacity: .4; } to { opacity: 0; transform: translateX(100%); } }
.action-row { display: flex; justify-content: space-between; align-items: center; gap: 1.5rem; margin-top: 1rem; }
.action-row p { color: var(--faded); font-size: .72rem; }
.action-row p span:first-child { color: var(--blue); }
.generate-button { min-width: 13rem; min-height: 3.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; border: 0; padding: .9rem 1.15rem; background: var(--ink); color: var(--paper); cursor: pointer; font-weight: 800; position: relative; overflow: hidden; transition: transform .16s, background .25s; }
.generate-button::before { content: ""; position: absolute; inset: 0; background: var(--red); transform: translateX(-103%) skewX(-12deg); transition: transform .35s var(--ease); }
.generate-button:hover::before { transform: translateX(0) skewX(0); }
.generate-button > * { position: relative; z-index: 1; }
.generate-button:active { transform: scale(.97); }
.generate-button:disabled { cursor: wait; opacity: .78; }
.button-progress { display: none; width: 3rem; height: 2px; background: color-mix(in oklch, var(--paper) 30%, var(--ink)); overflow: hidden; }
.button-progress::after { content: ""; display: block; width: 50%; height: 100%; background: var(--paper); animation: load 1s ease-in-out infinite alternate; }
.generate-button.loading .button-progress { display: block; }
@keyframes load { to { transform: translateX(100%); } }

.activity { padding-block: 2.5rem; }
.activity ol { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.activity li { display: flex; align-items: center; gap: .75rem; color: var(--faded); animation: item-in .4s var(--ease); }
.activity li::before { content: "✓"; width: 1.4rem; height: 1.4rem; display: grid; place-items: center; border-radius: 50%; background: var(--cyan); color: var(--ink); font-size: .7rem; font-weight: 800; }
@keyframes item-in { from { opacity: 0; transform: translateX(-16px); } }

.result-panel { margin: clamp(3rem, 7vw, 7rem) 0; padding: clamp(2rem, 5vw, 4rem); display: grid; grid-template-columns: auto 1fr; gap: 1.5rem 2rem; background: var(--red); color: var(--paper); box-shadow: 1rem 1rem 0 var(--paper-2); transform: rotate(-.5deg); animation: result-in .75s var(--ease); }
@keyframes result-in { from { opacity: 0; transform: rotate(-3deg) scale(.93); } }
.result-mark { width: 3.4rem; height: 3.4rem; display: grid; place-items: center; border: 2px solid var(--paper); border-radius: 50%; font-size: 1.5rem; animation: mark .55s var(--ease) .25s both; }
@keyframes mark { from { opacity: 0; transform: scale(.4) rotate(-30deg); } }
.result-panel h2 { margin: .25rem 0; font-family: var(--serif); font-size: clamp(2.4rem, 5vw, 4.5rem); font-weight: 400; letter-spacing: -.04em; }
.result-panel p { margin: 0; }
.result-url-row { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr auto auto; border-top: 1px solid color-mix(in oklch, var(--paper) 50%, var(--red)); border-bottom: 1px solid color-mix(in oklch, var(--paper) 50%, var(--red)); }
.result-url-row output { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 1rem 0; font-size: .8rem; }
.result-url-row button, .result-url-row a { border: 0; border-left: 1px solid color-mix(in oklch, var(--paper) 50%, var(--red)); padding: 1rem 1.2rem; background: transparent; color: inherit; text-decoration: none; cursor: pointer; font-weight: 800; }
.app-error { margin: 3rem 0; padding: clamp(1.5rem, 4vw, 2.5rem); display: grid; grid-template-columns: auto 1fr; gap: 1.3rem; border: 1px solid var(--red-dark); color: var(--red-dark); background: color-mix(in oklch, var(--paper) 88%, var(--red)); animation: shake .28s ease; }
.error-mark { width: 2.8rem; height: 2.8rem; display: grid; place-items: center; border: 2px solid currentColor; border-radius: 50%; font-family: var(--serif); font-size: 1.6rem; }
.error-body h3 { margin: .35rem 0 1.2rem; font-family: var(--serif); font-size: clamp(1.35rem, 3vw, 2rem); font-weight: 400; }
.error-body dl { display: flex; flex-wrap: wrap; gap: .8rem 2rem; margin: 0; }
.error-body dl div { min-width: 6rem; }
.error-body dt { color: var(--faded); font-size: .65rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.error-body dd { margin: .2rem 0 0; font-size: .82rem; }
.error-hint { margin: 1.2rem 0 0; color: var(--faded); font-size: .82rem; }
@keyframes shake { 30% { transform: translateX(-7px); } 65% { transform: translateX(6px); } }

@media (max-width: 760px) {
  .login-shell { grid-template-columns: 1fr; align-content: center; padding: 5rem 0 3rem; }
  .photo-stack { position: absolute; inset: 0; opacity: .18; z-index: -1; }
  .photo-stack picture { inset: 7% -45% 5% -55%; }
  .login-card h1 { font-size: clamp(4.3rem, 24vw, 6.5rem); margin-bottom: 4rem; }
  .login-note { bottom: 1rem; }
  .hero { grid-template-columns: 1fr; gap: 2.5rem; padding: 4rem 0; }
  .hero h1 { font-size: clamp(4rem, 21vw, 6rem); }
  .route-polaroid { width: min(100%, 18rem); justify-self: end; }
  .workbench, .activity { grid-template-columns: 1fr; gap: 1.2rem; }
  .section-tag { width: 2.5rem; height: 2.5rem; }
  .field-head, .action-row { align-items: stretch; flex-direction: column; }
  .detected { align-self: flex-start; }
  .generate-button { width: 100%; }
  .result-panel { grid-template-columns: 1fr; }
  .result-url-row { grid-template-columns: 1fr 1fr; }
  .result-url-row output { grid-column: 1 / -1; }
  .result-url-row button { border-left: 0; }
}

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