:root { --ink:#151515; --paper:#faf9f7; --line:#dedbd4; --shell:#eceae6; --panel:#f8f6f2; }
*{box-sizing:border-box}
body{margin:0;background:var(--shell);color:var(--ink);font-family:'metallophile-sp8','Helvetica Neue','PingFang SC','Hiragino Sans GB','Microsoft YaHei','Apple SD Gothic Neo','Malgun Gothic',Arial,sans-serif}
button,textarea,input{font:inherit}

/* Full-bleed light page; content constrained to a wide centered column. */
.app{
  width:min(1300px,calc(100% - 48px));margin:0 auto;min-height:100dvh;
  padding:32px 0 40px;
  display:flex;flex-direction:column;
}

.hero{text-align:center;margin:2px 0 24px}
h1{font-size:clamp(26px,3.4vw,40px);line-height:1.15;letter-spacing:-.01em;margin:0;font-weight:500}
.intro{max-width:580px;margin:10px auto 0;font-size:14px;line-height:1.55;color:#6e6a63;font-family:'DM Sans','Helvetica Neue','PingFang SC','Hiragino Sans GB','Microsoft YaHei','Apple SD Gothic Neo','Malgun Gothic',Arial,sans-serif}
/* Language pills sit below the pre-save panel, on the page background. */
.langs{
  display:flex;justify-content:center;flex-wrap:nowrap;gap:5px;margin:12px 0 0;
}
.langs button{
  border:1px solid var(--line);border-radius:999px;background:transparent;
  color:#7a756d;padding:4px 8px;font-size:10px;cursor:pointer;line-height:1.45;
  font-family:'DM Sans','Helvetica Neue','PingFang SC','Hiragino Sans GB','Microsoft YaHei','Apple SD Gothic Neo','Malgun Gothic',Arial,sans-serif;
  transition:background .15s,color .15s,border-color .15s;
}
.langs button:hover{background:#fff;color:#2b2926}
.langs button.is-active{background:#171717;border-color:#171717;color:#fff}

.workspace{display:grid;grid-template-columns:270px minmax(0,1fr) 210px;gap:28px;align-items:start;flex:1}

.editor-panel{
  background:var(--panel);border:1px solid rgba(0,0,0,.05);border-radius:20px;
  padding:16px;position:sticky;top:16px;box-shadow:0 12px 32px rgba(0,0,0,.06);
}
.field-group{margin-bottom:14px}
.field-group>label:first-child{display:block;font-size:10.5px;letter-spacing:.12em;text-transform:uppercase;font-weight:500;margin-bottom:7px;color:#4d4a45}
.upload{
  display:flex;align-items:center;justify-content:center;min-height:44px;padding:0 12px;text-align:center;
  border:1.5px dashed #bcb6ab;border-radius:14px;background:#fbfaf8;cursor:pointer;font-size:13px;color:#54504a;
  transition:background .15s,border-color .15s;
}
.upload:hover{background:#fff;border-color:#8f8a81}
#photoInput{display:none}
.touch-hint{display:none}
textarea{
  display:block;width:100%;resize:vertical;border:1px solid var(--line);border-radius:12px;
  background:#fff;padding:12px 13px;line-height:1.45;font-size:14px;outline:none;transition:border-color .15s;
}
textarea:focus{border-color:#8f8a81}
.hint{margin:6px 0 0;color:#8f8a81;font-size:11px;font-family:'DM Sans',sans-serif}
input[type=range]{display:block;width:100%;margin:0;accent-color:#161616}
.range-labels{display:flex;justify-content:space-between;font-size:10px;color:#948f86;margin-top:4px;font-family:'DM Sans',sans-serif}
.actions{display:grid;gap:9px}
.download{
  border:0;border-radius:999px;background:#171717;color:#fff;padding:12px;font-weight:500;cursor:pointer;
  transition:background .15s;
}
.download:hover{background:#333}
.secondary{border:1px solid var(--line);border-radius:999px;background:transparent;color:#44413c;padding:10px;cursor:pointer;font-size:13px}
.secondary:hover{background:#fff}

.preview-area{display:flex;justify-content:center;min-width:0}
/* Desktop preview: panel-height box that crops the square card's empty top and
   bottom bands (the export stays the full 1080x1080 square). */
.card-shell{
  width:min(640px,100%,calc((100dvh - 220px)*1.37));aspect-ratio:640/468;
  border-radius:18px;overflow:hidden;box-shadow:0 24px 64px rgba(0,0,0,.18);
}
canvas{display:block;width:100%;height:100%;object-fit:cover;background:#fff;touch-action:none;cursor:pointer}
canvas.draggable{cursor:grab}
canvas.dragging{cursor:grabbing}

/* Pre-save sidebar: rounded ink panel, with the language pills beneath it. */
.rail{position:sticky;top:16px}
.presave{
  background:#171717;color:#fff;border-radius:20px;
  padding:20px 18px;box-shadow:0 12px 32px rgba(0,0,0,.14);
}
.presave-label{margin:0 0 16px;font-size:14px;font-weight:500;letter-spacing:-.01em;line-height:1.35}
.presave-eyebrow{display:block;font-size:9.5px;font-weight:500;letter-spacing:.17em;text-transform:uppercase;color:rgba(255,255,255,.5);margin-bottom:6px}
.presave-links{display:flex;flex-direction:column;gap:8px}
.presave-links a{
  color:#fff;text-decoration:none;font-size:11.5px;letter-spacing:.03em;white-space:nowrap;
  border:1px solid rgba(255,255,255,.3);border-radius:999px;padding:9px 14px;text-align:center;
  transition:background .15s,color .15s,border-color .15s;
}
.presave-links a:hover{background:#fff;color:#151515;border-color:#fff}

/* Mobile: full screen; one column, no scrolling. */
@media(max-width:850px){
  .app{
    width:100%;margin:0;
    height:100dvh;min-height:0;
    padding:12px 14px calc(12px + env(safe-area-inset-bottom));gap:12px;
  }
  /* One 12px rhythm between every stacked block, and inside them. */
  .hero{flex:none;margin:0}
  h1{font-size:18px;line-height:1.25}
  .intro{font-size:11px;line-height:1.4;margin:6px auto 0}
  .workspace{display:flex;flex-direction:column;align-items:stretch;gap:12px;flex:1;min-height:0}

  /* The card takes exactly the height the fixed blocks leave over and crops
     the square's empty bands (object-fit: cover keeps the centre, so the
     frame and message are always in view). Capped at square so a tall gap
     never crops the sides instead. The export stays the full 1080x1080. */
  .preview-area{order:1;flex:1;min-height:0;align-items:stretch}
  .card-shell{
    width:100%;height:100%;
    /* Never crop tighter than the content band: the card art spans 444 of the
       1080 units around centre, so the box must stay at least 444/1080 of its
       own width tall. */
    min-height:calc((100vw - 28px) * 0.425);
    max-height:min(100%, calc(100vw - 28px));
    aspect-ratio:auto;display:block;margin:auto;
    border-radius:14px;box-shadow:0 10px 28px rgba(0,0,0,.15);
  }
  canvas{width:100%;height:100%;max-width:none;max-height:none;object-fit:cover}

  .editor-panel{order:2;flex:none;position:static;padding:12px;border-radius:16px}
  .field-group{margin-bottom:12px}
  .field-group>label:first-child{font-size:9px;margin-bottom:6px}
  .upload{min-height:38px;font-size:12px;border-radius:11px}
  /* height:auto lets the rows attribute govern, so the whole message stays
     readable without scrolling inside the field. */
  textarea{padding:9px 10px;font-size:13px;line-height:1.34;height:auto;resize:none;border-radius:10px}
  .hint,.range-labels{display:none}
  .field-photo,.field-crop{display:none}
  .touch-hint{display:block;margin:0 0 12px;font-size:10px;line-height:1.35}

  .actions{grid-template-columns:1fr 88px;gap:8px}
  .download{padding:12px;font-size:13.5px}
  .secondary{padding:12px 6px;font-size:12.5px}

  .rail{order:3;flex:none;position:static}
  .presave{border-radius:16px;padding:11px 12px;margin:0}
  .presave-label{font-size:11.5px;margin:0 0 9px}
  .presave-eyebrow{display:none}
  .langs{margin:12px 0 0;gap:5px}
  .langs button{padding:4px 9px;font-size:10px}
  /* One swipeable row of pills instead of a stack. */
  .presave-links{flex-direction:row;flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch;margin:0 -12px;padding:0 12px}
  .presave-links::-webkit-scrollbar{display:none}
  .presave-links a{padding:7px 13px;font-size:11px}
}
