:root {
  --ink: #1e201c;
  --muted: #6f7169;
  --paper: #f2efe7;
  --paper-deep: #e8e2d6;
  --card: rgba(250, 248, 242, 0.76);
  --line: rgba(38, 42, 35, 0.14);
  --moss: #4d5f50;
  --moss-dark: #344239;
  --terracotta: #bd6c4d;
  --shadow: 0 28px 70px rgba(57, 51, 40, 0.12);
  --serif: "Songti SC", "Noto Serif CJK SC", "STSong", Georgia, serif;
  --sans: "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 9% 4%, rgba(210, 182, 136, 0.22), transparent 28rem),
    radial-gradient(circle at 92% 28%, rgba(83, 109, 88, 0.16), transparent 34rem),
    var(--paper);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button, label, select { -webkit-tap-highlight-color: transparent; }

.noise {
  position: fixed;
  inset: 0;
  opacity: 0.14;
  pointer-events: none;
  z-index: 10;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.18'/%3E%3C/svg%3E");
}

.site-header,
main,
footer { width: min(1180px, calc(100% - 40px)); margin-inline: auto; }

.site-header {
  height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center;
  color: #f8f5ec; background: var(--moss); border-radius: 50% 48% 45% 52%;
  font-family: var(--serif); font-size: 19px; transform: rotate(-5deg);
}
.brand strong { display: block; font-family: var(--serif); font-size: 20px; letter-spacing: 0.08em; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; letter-spacing: 0.2em; }

.status-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 13px;
  border: 1px solid var(--line); border-radius: 999px; color: var(--muted);
  background: rgba(255,255,255,.28); font-size: 12px;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #d09a55; box-shadow: 0 0 0 4px rgba(208,154,85,.12); }
.status-pill.ready .status-dot { background: #65856d; box-shadow: 0 0 0 4px rgba(101,133,109,.14); }
.status-pill.error .status-dot { background: #bb6557; box-shadow: 0 0 0 4px rgba(187,101,87,.14); }

.hero { min-height: 410px; display: flex; justify-content: space-between; align-items: center; padding: 74px 7% 66px; }
.hero-copy { max-width: 780px; }
.eyebrow { margin: 0 0 18px; color: var(--terracotta); font-weight: 650; font-size: 12px; letter-spacing: .22em; text-transform: uppercase; }
.hero h1 { margin: 0; font: 500 clamp(44px, 6.8vw, 80px)/1.12 var(--serif); letter-spacing: -.045em; }
.hero h1 em { color: var(--moss); font-style: normal; }
.hero-lead { max-width: 650px; margin: 28px 0 0; color: var(--muted); font-size: 17px; line-height: 1.9; }
.hero-stamp {
  width: 106px; height: 106px; flex: none; margin-left: 40px; display: grid; place-content: center; grid-template-columns: auto auto;
  gap: 7px; color: var(--moss); border: 1px solid rgba(77,95,80,.45); border-radius: 50%; transform: rotate(7deg);
}
.hero-stamp span { font: 500 33px/1 var(--serif); }
.hero-stamp small { font-size: 8px; line-height: 1.4; letter-spacing: .12em; }

.studio { display: grid; grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr); gap: 20px; align-items: start; }
.panel {
  position: relative; padding: 32px; overflow: hidden;
  background: var(--card); border: 1px solid rgba(255,255,255,.55); border-radius: 24px;
  box-shadow: 0 1px 0 rgba(255,255,255,.8) inset, 0 20px 50px rgba(75,68,55,.07);
  backdrop-filter: blur(12px);
}
.upload-panel { position: sticky; top: 20px; }
.settings-panel { grid-column: 2; }
.prompt-panel { grid-column: 1; }
.panel-heading { display: flex; align-items: center; gap: 16px; margin-bottom: 26px; }
.panel-heading.compact { align-items: flex-start; }
.panel-heading h2 { margin: 0 0 5px; font: 600 23px/1.2 var(--serif); }
.panel-heading p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.step { width: 35px; height: 35px; display: grid; place-items: center; flex: none; border: 1px solid var(--line); border-radius: 50%; color: var(--terracotta); font-size: 10px; letter-spacing: .05em; }

.drop-zone {
  min-height: 470px; display: grid; place-items: center; position: relative; overflow: hidden;
  border: 1px dashed rgba(77,95,80,.4); border-radius: 17px; background: rgba(237,232,221,.62);
  cursor: pointer; transition: border-color .25s, background .25s, transform .25s;
}
.drop-zone:hover, .drop-zone.dragging { border-color: var(--moss); background: rgba(230,229,216,.9); transform: translateY(-2px); }
.upload-empty { padding: 38px 24px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.upload-icon { width: 70px; height: 70px; display: grid; place-items: center; margin-bottom: 20px; border-radius: 50%; background: rgba(255,255,255,.68); color: var(--moss); box-shadow: 0 10px 30px rgba(77,95,80,.09); }
.upload-icon svg { width: 34px; }
.upload-empty strong { font: 600 18px var(--serif); }
.upload-empty span:last-child { margin-top: 9px; color: var(--muted); font-size: 12px; }
.upload-processing {
  position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 32px; text-align: center;
  background: rgba(242,239,231,.92); backdrop-filter: blur(10px);
}
.upload-processing strong { font: 600 18px var(--serif); }
.upload-processing > span:last-child { margin-top: 8px; color: var(--muted); font-size: 12px; }
.conversion-spinner {
  width: 44px; height: 44px; margin-bottom: 18px; border: 2px solid rgba(77,95,80,.18);
  border-top-color: var(--moss); border-radius: 50%; animation: spin .85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.upload-preview { position: absolute; inset: 0; background: #d8d4c9; }
.upload-preview img { width: 100%; height: 100%; display: block; object-fit: contain; }
.change-photo { position: absolute; right: 14px; bottom: 14px; padding: 8px 12px; border-radius: 999px; color: white; background: rgba(26,28,25,.68); backdrop-filter: blur(8px); font-size: 11px; }
.file-meta { min-height: 18px; margin: 10px 4px 0; color: var(--muted); font-size: 11px; text-align: center; }

fieldset { min-width: 0; padding: 0; margin: 0; border: 0; }
legend, .textarea-field > span, .select-field > span { margin-bottom: 10px; color: var(--ink); font-weight: 600; font-size: 12px; letter-spacing: .04em; }
.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; }
.simple-block { padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.28); }
.simple-block + .simple-block { margin-top: 16px; }
.simple-block-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.simple-block-heading h3 { margin: 0 0 3px; font: 600 18px/1.25 var(--serif); }
.simple-block-heading p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.simple-number { width: 28px; height: 28px; display: grid; place-items: center; flex: none; color: var(--moss); background: rgba(77,95,80,.11); border-radius: 50%; font-size: 11px; font-weight: 700; }
.style-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.style-card { min-height: 76px; display: flex; align-items: center; gap: 13px; padding: 11px; border: 1px solid var(--line); border-radius: 13px; cursor: pointer; transition: .22s ease; background: rgba(255,255,255,.28); }
.style-card:hover { transform: translateY(-1px); border-color: rgba(77,95,80,.48); }
.style-card.selected { border-color: var(--moss); background: rgba(77,95,80,.08); box-shadow: 0 0 0 1px var(--moss) inset; }
.style-card input { position: absolute; opacity: 0; pointer-events: none; }
.style-card > span:last-child { min-width: 0; }
.style-card strong, .style-card small { display: block; }
.style-card strong { font: 600 14px var(--serif); }
.style-card small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.style-swatch { width: 46px; height: 50px; flex: none; border-radius: 9px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.swatch-oil { background: linear-gradient(145deg, #b37949 4%, #384e4f 46%, #d7b36c 70%, #703f36); }
.swatch-watercolor { background: radial-gradient(circle at 70% 25%, #dcb8b2, transparent 33%), linear-gradient(150deg, #dce6df, #8bb5b8 50%, #f4d7aa); }
.swatch-ink { background: radial-gradient(circle at 35% 40%, #1e2424, transparent 25%), linear-gradient(135deg, #dddcd2, #7d8881 47%, #ece8dc); }
.swatch-impressionism { background: linear-gradient(145deg, #4e7b9a 8%, #e6c66e 35%, #d6815f 60%, #6b8e6b 84%); }
.swatch-ukiyoe { background: repeating-linear-gradient(150deg, #d76048 0 8px, #f2ddae 8px 16px, #345976 16px 24px); }
.swatch-gouache { background: linear-gradient(140deg, #b95f54 0 35%, #e3b966 35% 62%, #506e6a 62%); }
.swatch-custom { display: grid; place-items: center; color: var(--moss); background: #ebe7dc; border: 1px dashed rgba(77,95,80,.4); font-size: 20px; }
.style-custom { grid-column: 1 / -1; }
.custom-style-row { margin-top: 12px; }
.custom-style-row label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 11px; }
.custom-style-row input, .artist-field input, select, textarea, .prompt-preview {
  width: 100%; color: var(--ink); background: rgba(255,255,255,.52); border: 1px solid var(--line); border-radius: 10px; outline: 0; transition: border-color .2s, box-shadow .2s;
}
.custom-style-row input, .artist-field input { padding: 13px 14px; }
input:focus, select:focus, textarea:focus { border-color: var(--moss); box-shadow: 0 0 0 3px rgba(77,95,80,.1); }

.artist-field { display: block; margin-top: 16px; }
.artist-field > span { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 600; }
.artist-field small { color: var(--muted); font-weight: 400; }
.instruction-heading { align-items: flex-start; }
.instruction-heading > div { flex: 1; }
.voice-button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; flex: none; padding: 0 13px; color: var(--moss); background: rgba(77,95,80,.08); border: 1px solid rgba(77,95,80,.22); border-radius: 999px; cursor: pointer; font-size: 12px; font-weight: 600; transition: .2s; }
.voice-button:hover { background: rgba(77,95,80,.14); transform: translateY(-1px); }
.voice-button svg { width: 18px; height: 18px; }
.voice-button.listening { color: white; background: var(--terracotta); border-color: var(--terracotta); animation: voicePulse 1.2s ease-in-out infinite; }
.voice-button:disabled { color: var(--muted); cursor: not-allowed; opacity: .65; transform: none; }
@keyframes voicePulse { 50% { box-shadow: 0 0 0 6px rgba(189,108,77,.14); } }
.instruction-field { margin: 0; }
.instruction-field textarea { min-height: 128px; padding: 15px; font-size: 15px; line-height: 1.75; }
.voice-status { min-height: 19px; margin: 8px 2px 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.voice-status.active { color: var(--terracotta); font-weight: 600; }
.advanced-settings { margin-top: 18px; border: 1px solid var(--line); border-radius: 16px; background: rgba(236,232,222,.42); overflow: hidden; }
.advanced-settings > summary { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 18px; cursor: pointer; list-style: none; user-select: none; }
.advanced-settings > summary::-webkit-details-marker { display: none; }
.advanced-settings > summary strong, .advanced-settings > summary small { display: block; }
.advanced-settings > summary strong { font-size: 14px; }
.advanced-settings > summary small { margin-top: 4px; color: var(--muted); font-size: 10px; font-weight: 400; }
.advanced-settings > summary svg { width: 22px; flex: none; color: var(--moss); transition: transform .2s; }
.advanced-settings[open] > summary svg { transform: rotate(180deg); }
.advanced-content { padding: 0 18px 20px; border-top: 1px solid var(--line); }
.advanced-content .control-grid { margin-top: 20px; }
.advanced-prompt { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.advanced-prompt-heading { display: flex; align-items: end; justify-content: space-between; gap: 14px; margin-bottom: 10px; }
.advanced-prompt-heading strong, .advanced-prompt-heading small { display: block; }
.advanced-prompt-heading strong { font-size: 12px; }
.advanced-prompt-heading small { margin-top: 3px; color: var(--muted); font-size: 9px; }

.control-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px 12px; margin-top: 26px; }
.select-field { display: flex; flex-direction: column; }
select { appearance: none; padding: 12px 34px 12px 12px; cursor: pointer; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }

.texture-control { margin-top: 25px; }
.segmented { display: grid; grid-template-columns: repeat(4, 1fr); padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: rgba(231,226,215,.65); }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: block; padding: 9px; border-radius: 8px; color: var(--muted); font-size: 11px; text-align: center; }
.segmented input:checked + span { color: var(--ink); background: rgba(255,255,255,.82); box-shadow: 0 2px 9px rgba(68,61,49,.08); font-weight: 600; }
.control-hint { margin: 9px 2px 0; color: var(--muted); font-size: 10px; line-height: 1.55; }

.textarea-field { display: block; margin-top: 24px; }
.textarea-field > span { display: block; }
.textarea-field small { color: var(--muted); font-weight: 400; }
textarea { resize: vertical; padding: 13px; line-height: 1.65; }

.text-button { margin-left: auto; padding: 4px; border: 0; color: var(--moss); background: transparent; cursor: pointer; font-size: 11px; border-bottom: 1px solid rgba(77,95,80,.3); }
.prompt-preview { min-height: 250px; padding: 15px; color: #4d514a; background: rgba(236,232,222,.75); font: 12px/1.75 var(--sans); }
.prompt-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 16px; }
.switch-row { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.switch-row input { position: absolute; opacity: 0; }
.switch { width: 31px; height: 18px; flex: none; padding: 2px; border-radius: 99px; background: #c9c8c0; transition: .2s; }
.switch::after { content: ""; display: block; width: 14px; height: 14px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: .2s; }
.switch-row input:checked + .switch { background: var(--moss); }
.switch-row input:checked + .switch::after { transform: translateX(13px); }
.switch-row strong, .switch-row small { display: block; }
.switch-row strong { font-size: 11px; }
.switch-row small { margin-top: 2px; color: var(--muted); font-size: 9px; }

.action-panel { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; padding: 27px 31px; margin: 2px 0 78px; color: #f7f3e9; background: var(--moss-dark); border-radius: 20px; box-shadow: var(--shadow); }
.action-panel p { margin: 0 0 5px; font: 600 18px var(--serif); }
.action-panel small { color: rgba(255,255,255,.62); }
.primary-button, .secondary-button { min-height: 48px; display: inline-flex; justify-content: center; align-items: center; gap: 20px; padding: 0 21px; border: 0; border-radius: 999px; cursor: pointer; text-decoration: none; transition: transform .2s, box-shadow .2s, opacity .2s; }
.primary-button { color: var(--ink); background: #e7cc88; box-shadow: 0 8px 22px rgba(19,26,20,.18); font-weight: 650; }
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(19,26,20,.22); }
.primary-button svg { width: 20px; }
.primary-button:disabled { cursor: wait; opacity: .55; transform: none; }
.secondary-button { min-height: 42px; color: var(--moss); background: transparent; border: 1px solid rgba(77,95,80,.28); }
.compact-button { min-height: 42px; }

.result-section { padding: 70px 0 20px; border-top: 1px solid var(--line); }
.result-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 28px; }
.result-heading h2 { margin: 0; font: 500 clamp(30px, 4vw, 48px)/1.2 var(--serif); }
.result-actions { display: flex; gap: 10px; }
.comparison { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.comparison figure { min-height: 580px; position: relative; margin: 0; display: grid; place-items: center; overflow: hidden; border-radius: 18px; background: #ded9cf; box-shadow: 0 18px 40px rgba(65,58,45,.09); }
.comparison img { width: 100%; height: 100%; display: block; object-fit: contain; }
.comparison figcaption { position: absolute; z-index: 1; top: 13px; left: 13px; padding: 7px 11px; color: white; background: rgba(30,32,28,.62); border-radius: 999px; backdrop-filter: blur(8px); font-size: 10px; }
.result-frame::after { content: ""; position: absolute; inset: 9px; pointer-events: none; border: 1px solid rgba(255,255,255,.35); border-radius: 13px; }
.result-details { margin-top: 18px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.2); }
.result-details summary { padding: 14px 16px; cursor: pointer; color: var(--muted); font-size: 12px; }
.detail-body { padding: 0 16px 16px; }
.detail-body p { color: var(--muted); font-size: 11px; }
.detail-body pre { max-height: 260px; overflow: auto; white-space: pre-wrap; color: #575b54; font: 11px/1.7 var(--sans); }

.toast { position: fixed; z-index: 40; left: 50%; bottom: 28px; transform: translateX(-50%); max-width: min(520px, calc(100% - 40px)); padding: 12px 16px; color: #fff; background: #7b3f37; border-radius: 10px; box-shadow: 0 10px 35px rgba(60,30,25,.25); font-size: 13px; }
.generating-overlay { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; background: rgba(37,40,35,.72); backdrop-filter: blur(13px); }
.generating-card { width: min(450px, 100%); padding: 45px; text-align: center; background: var(--paper); border-radius: 22px; box-shadow: 0 30px 90px rgba(0,0,0,.28); }
.generating-card h2 { margin: 7px 0 12px; font: 500 30px var(--serif); }
.generating-card > p:not(.eyebrow) { min-height: 24px; color: var(--muted); font-size: 13px; }
.generating-card small { color: var(--muted); font-size: 10px; }
.brush-loader { height: 72px; display: flex; gap: 6px; justify-content: center; align-items: end; margin-bottom: 25px; }
.brush-loader span { width: 17px; height: 54px; border-radius: 50% 50% 4px 4px; transform-origin: bottom; animation: brush 1.4s ease-in-out infinite; }
.brush-loader span:nth-child(1) { height: 45px; background: #c17554; }
.brush-loader span:nth-child(2) { background: #506a58; animation-delay: -.3s; }
.brush-loader span:nth-child(3) { height: 39px; background: #d8b564; animation-delay: -.6s; }
@keyframes brush { 0%,100% { transform: scaleY(.75); opacity: .55; } 50% { transform: scaleY(1.08); opacity: 1; } }
.progress-track { height: 4px; margin: 24px 0 18px; overflow: hidden; border-radius: 99px; background: var(--paper-deep); }
.progress-track span { display: block; width: 38%; height: 100%; background: var(--moss); border-radius: inherit; animation: progress 2.1s ease-in-out infinite; }
@keyframes progress { 0% { transform: translateX(-110%); } 100% { transform: translateX(360%); } }

footer { min-height: 100px; display: flex; justify-content: space-between; align-items: center; margin-top: 75px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; letter-spacing: .08em; }

[hidden] { display: none !important; }

@media (max-width: 860px) {
  .hero { min-height: 360px; padding-inline: 3%; }
  .hero-stamp { display: none; }
  .studio { grid-template-columns: 1fr; }
  .upload-panel { position: relative; top: 0; }
  .settings-panel, .prompt-panel, .action-panel { grid-column: 1; grid-row: auto; }
  .upload-panel { grid-row: auto; }
  .drop-zone { min-height: 430px; }
  .action-panel { margin-bottom: 55px; }
  .comparison figure { min-height: 430px; }
}

@media (max-width: 600px) {
  .site-header, main, footer { width: min(100% - 24px, 1180px); }
  .site-header { height: 76px; }
  .status-pill { padding: 8px; }
  .status-pill span:last-child { display: none; }
  .hero { min-height: 335px; padding: 50px 3% 44px; }
  .hero h1 { font-size: 43px; }
  .hero-lead { font-size: 14px; line-height: 1.75; }
  .panel { padding: 22px; border-radius: 18px; }
  .drop-zone { min-height: 380px; }
  .style-grid, .control-grid, .prompt-options { grid-template-columns: 1fr; }
  .style-custom { grid-column: auto; }
  .simple-block { padding: 16px; }
  .instruction-heading { flex-wrap: wrap; }
  .voice-button { width: 100%; margin-top: 3px; }
  .advanced-prompt-heading { align-items: flex-start; flex-direction: column; }
  .action-panel { align-items: stretch; flex-direction: column; gap: 20px; padding: 23px; }
  .primary-button { width: 100%; }
  .result-heading { align-items: stretch; flex-direction: column; gap: 22px; }
  .result-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .comparison { grid-template-columns: 1fr; }
  .comparison figure { min-height: 420px; }
  .generating-card { padding: 34px 24px; }
  footer { align-items: flex-start; flex-direction: column; justify-content: center; gap: 7px; }
}

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