:root {
  color-scheme: dark;
  font-family: "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #101210;
  color: #f4f2ec;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px),
    #101210;
  background-size: 32px 32px;
}

main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 48px 0 56px; }

header { display: flex; align-items: center; gap: 16px; margin-bottom: 48px; }
.brand-mark { display: grid; place-items: center; width: 48px; height: 48px; border: 1px solid #e84a2a; color: #e84a2a; font: 700 15px/1 Arial; }
.eyebrow { margin: 0 0 3px; color: #8b9188; font: 600 10px/1.2 Arial; letter-spacing: 2px; }
h1 { margin: 0; font-size: 23px; font-weight: 650; letter-spacing: 0; }
.model { margin-left: auto; border: 1px solid #353a34; padding: 8px 10px; color: #9ca198; font: 600 10px/1 Arial; letter-spacing: 1px; }

.workspace { display: grid; grid-template-columns: minmax(300px, 390px) minmax(0, 1fr); gap: 56px; align-items: start; }
form { padding-top: 6px; }
label, legend { display: block; margin-bottom: 10px; color: #c5c7c0; font-size: 13px; font-weight: 600; }
textarea { width: 100%; resize: vertical; min-height: 188px; border: 1px solid #353a34; border-radius: 4px; outline: none; background: #171a17; padding: 16px; color: #f4f2ec; font: 15px/1.7 inherit; transition: border-color .2s; }
textarea:focus { border-color: #e84a2a; }
textarea::placeholder { color: #676c65; }
fieldset { margin: 26px 0 30px; padding: 0; border: 0; }
.preset-fieldset { margin-top: 22px; margin-bottom: 26px; }
.preset-fieldset select { width: 100%; height: 44px; border: 1px solid #353a34; border-radius: 4px; outline: none; background: #171a17; padding: 0 12px; color: #f4f2ec; font: 13px inherit; }
.preset-fieldset small { display: block; margin-top: 8px; color: #686d66; font-size: 11px; line-height: 1.5; }
.sizes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sizes label { margin: 0; cursor: pointer; }
.sizes input { position: absolute; opacity: 0; }
.sizes span { display: flex; flex-direction: column; gap: 4px; border: 1px solid #353a34; border-radius: 4px; padding: 12px; color: #adafa8; font-size: 13px; transition: .2s; }
.sizes small { color: #686d66; font: 11px/1 Arial; }
.sizes input:checked + span { border-color: #e84a2a; background: rgba(232,74,42,.08); color: #fff; }
button { position: relative; width: 100%; height: 50px; border: 0; border-radius: 4px; background: #e84a2a; color: #fff; cursor: pointer; font: 650 15px/1 inherit; transition: background .2s; }
button:hover { background: #fa5938; }
button:disabled { cursor: wait; opacity: .75; }
.button-loader { display: none; width: 18px; height: 18px; margin: auto; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.loading .button-label { display: none; }
.loading .button-loader { display: block; }
.error { min-height: 20px; margin: 12px 0 0; color: #ff8067; font-size: 13px; }

.preview { position: relative; display: grid; place-items: center; min-height: 620px; overflow: hidden; border: 1px solid #2e332d; background: #151815; }
.preview::before, .preview::after { content: ""; position: absolute; width: 18px; height: 18px; border-color: #e84a2a; pointer-events: none; }
.preview::before { top: 10px; left: 10px; border-top: 1px solid; border-left: 1px solid; }
.preview::after { right: 10px; bottom: 10px; border-right: 1px solid; border-bottom: 1px solid; }
.empty-state { text-align: center; color: #777d75; }
.empty-state p { margin: 20px 0 7px; color: #a8ada5; font-size: 14px; }
.empty-state small { font-size: 12px; }
.crosshair { display: block; width: 44px; height: 44px; margin: auto; border: 1px solid #484e47; border-radius: 50%; background: linear-gradient(#484e47,#484e47) center/1px 60px no-repeat, linear-gradient(90deg,#484e47,#484e47) center/60px 1px no-repeat; }
#result-image { width: 100%; height: 100%; max-height: 720px; object-fit: contain; }
.result-actions { position: absolute; right: 16px; bottom: 16px; left: 16px; display: flex; align-items: center; gap: 16px; padding: 10px 12px; background: rgba(16,18,16,.88); border: 1px solid #363b35; backdrop-filter: blur(10px); }
.result-actions span { overflow: hidden; color: #a9aea6; font: 11px/1.3 monospace; text-overflow: ellipsis; white-space: nowrap; }
.result-actions a { margin-left: auto; flex: none; color: #ff6748; font-size: 12px; text-decoration: none; }
[hidden] { display: none !important; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 780px) {
  main { width: min(100% - 28px, 560px); padding-top: 28px; }
  header { margin-bottom: 32px; }
  .workspace { grid-template-columns: 1fr; gap: 28px; }
  .preview { min-height: min(120vw, 530px); }
  .model { font-size: 9px; }
}
