:root {
  --ink: #171816;
  --muted: #73766f;
  --line: #e5e6e1;
  --soft: #f5f5f1;
  --accent: #263e32;
  --white: #fff;
  --danger: #a23b3b;
  font-family: Inter, "Noto Sans JP", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #fafaf8;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input { font: inherit; }
button { cursor: pointer; }

.site-header {
  height: 76px; padding: 0 clamp(20px, 5vw, 72px); display: flex; align-items: center;
  justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(250,250,248,.92);
}
.brand { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; font-weight: 650; letter-spacing: -.02em; }
.brand-mark { width: 22px; height: 22px; border: 2px solid var(--ink); box-shadow: inset 0 0 0 4px #fafaf8, inset 0 0 0 6px var(--ink); }
.account-actions { display: flex; gap: 16px; align-items: center; }
.user-greeting { color: var(--muted); font-size: .88rem; }

main { width: min(1280px, calc(100% - 40px)); margin: 0 auto; }
.hero { max-width: 720px; padding: clamp(70px, 9vw, 120px) 0 clamp(52px, 7vw, 88px); }
.eyebrow { margin: 0 0 18px; color: #68766d; font-size: .68rem; font-weight: 750; letter-spacing: .18em; }
h1 { margin: 0; font-family: Georgia, "Yu Mincho", serif; font-weight: 400; font-size: clamp(2.5rem, 6vw, 5.4rem); line-height: 1.12; letter-spacing: -.045em; }
.hero-copy { max-width: 560px; margin: 28px 0 0; color: var(--muted); font-size: clamp(.95rem, 1.5vw, 1.1rem); line-height: 1.9; }

.studio { display: grid; grid-template-columns: minmax(320px, .82fr) minmax(420px, 1.18fr); background: var(--white); border: 1px solid var(--line); }
.controls { padding: clamp(28px, 4.5vw, 60px); border-right: 1px solid var(--line); }
.section-heading { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 24px; }
.section-heading h2 { margin: -3px 0 4px; font-family: Georgia, "Yu Mincho", serif; font-weight: 400; font-size: 1.55rem; }
.section-heading p { margin: 0; color: var(--muted); font-size: .8rem; }
.step { display: grid; place-items: center; flex: 0 0 auto; width: 30px; height: 30px; border: 1px solid #a7aaa3; border-radius: 50%; font-size: .65rem; }

.drop-zone { min-height: 196px; border: 1px dashed #b9bbb5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; transition: .2s ease; background: #fdfdfb; }
.drop-zone:hover, .drop-zone.is-dragging { border-color: var(--accent); background: #f4f7f3; }
.drop-zone strong { font-size: .94rem; }
.drop-zone > span:not(.upload-icon), .drop-zone small { color: var(--muted); font-size: .76rem; }
.upload-icon { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 5px; border: 1px solid var(--ink); border-radius: 50%; font-size: 1.4rem; font-weight: 300; }
.file-summary { min-height: 76px; padding: 15px 18px; align-items: center; justify-content: space-between; border: 1px solid var(--line); }
.file-summary > div { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.file-summary strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .84rem; }
.file-summary span { color: var(--muted); font-size: .72rem; }
.frame-heading { margin-top: 46px; }
.frame-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.frame-card { position: relative; display: flex; gap: 12px; min-height: 88px; padding: 13px; border: 1px solid var(--line); cursor: pointer; transition: .2s ease; }
.frame-card:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.frame-card input { position: absolute; opacity: 0; }
.frame-mini { position: relative; flex: 0 0 56px; height: 56px; background: #fff; border: 1px solid #d7d8d4; box-shadow: 0 2px 6px rgba(0,0,0,.04); }
.frame-mini::after { content: ""; position: absolute; background: #cbd0cd; left: var(--fx); top: var(--fy); width: var(--fw); height: var(--fh); }
.frame-copy { min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.frame-copy strong { font-size: .78rem; }
.frame-copy span { margin-top: 4px; color: var(--muted); font-size: .67rem; line-height: 1.4; }

.button { border: 0; min-height: 44px; padding: 0 20px; border-radius: 2px; font-weight: 650; font-size: .83rem; }
.button-primary { background: var(--accent); color: white; }
.button-primary:hover { background: #182a21; }
.button-secondary { background: transparent; border: 1px solid #bfc1bc; }
.button:disabled { opacity: .42; cursor: not-allowed; }
.text-button { padding: 3px 0; background: transparent; border: 0; color: #58675e; font-size: .78rem; text-decoration: underline; text-underline-offset: 3px; }
.generate-button { width: 100%; min-height: 56px; margin-top: 24px; display: flex; justify-content: center; align-items: center; gap: 14px; }
.status { min-height: 22px; margin: 12px 0 0; text-align: center; color: var(--muted); font-size: .78rem; }
.status.error, .form-error { color: var(--danger); }

.preview-column { min-width: 0; padding: clamp(28px, 5vw, 72px); background: var(--soft); display: flex; flex-direction: column; justify-content: center; }
.preview-label { display: flex; justify-content: space-between; margin-bottom: 12px; color: var(--muted); font-size: .64rem; letter-spacing: .14em; }
.preview-canvas { position: relative; width: 100%; aspect-ratio: 1; background: #fff; box-shadow: 0 22px 55px rgba(38, 43, 39, .11); overflow: hidden; }
.preview-photo-area { position: absolute; overflow: hidden; background: #eceeeb; }
.preview-photo-area img { width: 100%; height: 100%; display: block; }
.preview-placeholder { width: 100%; height: 100%; display: grid; place-items: center; color: #a3a7a1; font-size: clamp(.6rem, 1.2vw, .75rem); letter-spacing: .22em; background: linear-gradient(135deg, #eef0ed, #e2e5e1); }
.preview-note { margin: 16px 0 0; color: var(--muted); font-size: .7rem; text-align: center; }

.history-section { padding: clamp(72px, 10vw, 130px) 0; }
.history-section h2 { margin: 0; font-family: Georgia, "Yu Mincho", serif; font-weight: 400; font-size: clamp(1.8rem, 3vw, 2.8rem); }
.history-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 34px; }
.history-item { min-width: 0; padding: 20px; background: white; border: 1px solid var(--line); }
.history-item strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .82rem; }
.history-meta { margin: 7px 0 18px; color: var(--muted); font-size: .7rem; }
.history-item a { color: var(--accent); font-size: .77rem; font-weight: 650; text-underline-offset: 4px; }
.empty-history { color: var(--muted); font-size: .85rem; }

footer { width: min(1280px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 38px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; color: var(--muted); font-size: .72rem; }
.auth-dialog { width: min(440px, calc(100% - 32px)); padding: 42px; border: 0; box-shadow: 0 24px 80px rgba(0,0,0,.22); }
.auth-dialog::backdrop { background: rgba(20,22,20,.48); backdrop-filter: blur(3px); }
.auth-dialog h2 { margin: 0; font-family: Georgia, "Yu Mincho", serif; font-size: 2rem; font-weight: 400; }
.dialog-description { margin: 12px 0 26px; color: var(--muted); font-size: .82rem; line-height: 1.6; }
.dialog-close { position: absolute; right: 18px; top: 15px; background: none; border: 0; font-size: 1.5rem; font-weight: 200; }
.auth-dialog form { display: grid; gap: 16px; }
.auth-dialog label { display: grid; gap: 7px; color: #4b4d49; font-size: .75rem; }
.auth-dialog input { width: 100%; height: 46px; padding: 0 12px; border: 1px solid #cfd1cc; background: #fff; }
.auth-dialog input:focus { outline: 2px solid #b5c5ba; border-color: var(--accent); }
.form-error { min-height: 18px; margin: -3px 0 0; font-size: .74rem; }
.auth-switch { display: block; margin: 20px auto 0; }
.muted { color: var(--muted); font-size: .8rem; }

@media (max-width: 850px) {
  .studio { grid-template-columns: 1fr; }
  .controls { border-right: 0; border-bottom: 1px solid var(--line); }
  .preview-column { order: -1; padding: clamp(26px, 8vw, 60px); }
  .preview-canvas { max-width: 560px; margin: 0 auto; }
  .history-list { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .site-header { height: 64px; padding: 0 18px; }
  .brand { font-size: .86rem; }
  .brand-mark { width: 19px; height: 19px; }
  .user-greeting { display: none; }
  main, footer { width: calc(100% - 28px); }
  .hero { padding: 58px 2px 46px; }
  .hero-copy { margin-top: 20px; }
  .controls { padding: 26px 20px; }
  .preview-column { padding: 28px 20px 36px; }
  .frame-list, .history-list { grid-template-columns: 1fr; }
  .frame-card { min-height: 78px; }
  footer { flex-direction: column; gap: 7px; }
  .auth-dialog { padding: 36px 24px 28px; }
}
