:root {
  color-scheme: light;
  --wood: #4c3527;
  --wood-soft: #755b47;
  --sand: #f4efe7;
  --paper: #fffdfa;
  --line: #d8cec1;
  --text: #2f2925;
  --muted: #746b65;
  --success: #315d47;
  --danger: #9d322c;
  --soft-success: #edf5ef;
  font-family: Helvetica, Arial, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: linear-gradient(180deg, #faf7f2 0%, var(--sand) 100%);
}

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

.page-shell {
  width: min(900px, 100%);
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 18px max(40px, env(safe-area-inset-bottom));
}

.page-header { padding: 10px 4px 24px; }
.brand { margin: 0 0 18px; color: var(--wood); font-weight: 700; letter-spacing: .02em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(1.75rem, 5vw, 2.35rem); }
h2 { margin-bottom: 6px; font-size: 1.3rem; }

.lead, .panel p, .section-heading p, .step-heading p {
  color: var(--muted);
  line-height: 1.7;
}

.panel {
  margin-bottom: 18px;
  padding: clamp(20px, 5vw, 30px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 0 8px 28px rgb(62 44 31 / 6%);
}

.compact-panel { padding-block: 18px; }
form, .content-fields { display: grid; gap: 12px; }
label { margin-top: 5px; font-weight: 700; }

input, textarea, select {
  width: 100%;
  min-height: 52px;
  padding: 12px 13px;
  border: 1px solid #a99b8f;
  border-radius: 10px;
  color: var(--text);
  background: #fff;
  font-size: 1rem;
  line-height: 1.55;
}

textarea { min-height: 92px; resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible,
summary:focus-visible {
  outline: 3px solid #b99b77;
  outline-offset: 3px;
}

button {
  min-height: 50px;
  border-radius: 11px;
  cursor: pointer;
}
button:disabled { cursor: wait; opacity: .58; }
button.is-busy[aria-disabled="true"] { cursor: progress; opacity: .72; }

.primary-button, .secondary-button {
  padding: 12px 18px;
  font-weight: 700;
}
.primary-button { border: 1px solid var(--wood); color: #fff; background: var(--wood); }
.secondary-button { border: 1px solid var(--wood-soft); color: var(--wood); background: transparent; }
.strong-button { background: #fff; }
.danger-button { border-color: #b86b65; color: var(--danger); background: #fff; }

.text-button {
  margin-top: 12px;
  padding: 8px 2px;
  border: 0;
  color: var(--wood);
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.account-bar, .account-actions, .section-heading, .step-heading, .art-actions, .save-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.account-bar, .section-heading { justify-content: space-between; }
.account-label { margin: 0; overflow-wrap: anywhere; font-weight: 700; }
.revision-label { margin: 4px 0 0; font-size: .9rem; }
.step-heading { align-items: flex-start; }
.step-heading p { margin-bottom: 0; }
.step-number {
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--wood-soft);
  font-size: 1.1rem;
  font-weight: 700;
}

.field-note { margin: 0; font-size: .9rem; }
.preview-link { flex: none; color: var(--wood); font-weight: 700; text-underline-offset: 4px; }
.preview-link-button { border: 0; padding: 0; background: transparent; font: inherit; cursor: pointer; }
.preview-links { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }

.text-style-settings {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.text-style-settings summary { min-height: 44px; color: var(--wood); font-weight: 700; cursor: pointer; }
.text-style-settings > .field-note { margin-bottom: 14px; }
.text-style-controls { display: grid; gap: 10px; }
.text-style-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(116px, 160px) minmax(116px, 160px);
  align-items: end;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.text-style-name { align-self: center; margin: 0; color: var(--text) !important; font-weight: 700; }
.text-style-field { display: grid; gap: 5px; margin: 0; font-size: .88rem; }
.text-style-field select { min-height: 46px; padding-block: 8px; }

.image-editor-section {
  margin-top: 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #faf8f4;
}
.image-editor-section h3 { margin-bottom: 5px; font-size: 1.08rem; }
.image-editor-section .section-heading p { margin-bottom: 0; }
.image-operation-state, .art-image-state {
  min-height: 1.6em;
  margin: 10px 0 0;
  color: var(--success) !important;
  font-weight: 700;
}
.image-operation-state.error, .art-image-state.error { color: var(--danger) !important; }
.hero-editor:empty { display: none; }
.hero-editor .art-item { margin-top: 14px; }
.hero-editor .art-item::before { content: "上"; }

.art-list {
  display: grid;
  gap: 18px;
  margin: 24px 0;
  padding: 0;
  list-style: none;
  counter-reset: artwork;
}

.art-item {
  display: grid;
  grid-template-columns: 42px minmax(170px, 240px) minmax(0, 1fr);
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  counter-increment: artwork;
}
.art-item.is-hidden { border-style: dashed; background: #f6f3ef; }
.art-item::before {
  content: counter(artwork);
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--wood-soft);
  font-weight: 700;
}

.art-image-column { display: grid; align-content: start; gap: 10px; }
.art-item img {
  display: block;
  width: 100%;
  height: 160px;
  border-radius: 9px;
  object-fit: cover;
  background: var(--sand);
}
.art-image-button { width: 100%; }
.art-edit-fields { display: grid; gap: 8px; }
.art-edit-fields label { font-size: .92rem; }
.art-edit-fields textarea { min-height: 74px; }
.art-state { margin: 0; font-weight: 700; }
.art-actions { grid-column: 2 / -1; justify-content: flex-end; flex-wrap: wrap; }
.move-button { min-width: 54px; padding: 0 12px; border: 1px solid var(--wood-soft); color: var(--wood); background: var(--paper); font-weight: 700; }

.fixed-preview {
  margin-top: 22px;
  padding: clamp(20px, 5vw, 36px);
  border-radius: 16px;
  color: #4a3a31;
  background: #f8f1e8;
  text-align: center;
}
.preview-hero { margin: 0 0 24px; }
.preview-hero img { display: block; width: 100%; max-height: 520px; aspect-ratio: 16 / 10; border-radius: 12px; object-fit: cover; background: var(--sand); }
.preview-hero .preview-art-copy { padding: 16px 4px 0; }
.preview-subtitle { margin-bottom: 18px; font-size: .9rem; letter-spacing: .06em; }
.fixed-preview h3 { margin-bottom: 6px; font-size: clamp(1.5rem, 5vw, 2.35rem); }
.soft-wrap {
  min-width: 0;
  max-width: 100%;
  white-space: pre-line;
  word-break: normal;
  overflow-wrap: anywhere;
}
.preview-artworks { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: start; gap: 12px; margin: 24px 0; }
.preview-art-card { display: flex; overflow: hidden; min-width: 0; align-items: stretch; justify-content: flex-start; flex-direction: column; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: #fff; text-align: left; box-shadow: 0 4px 20px rgb(55 43 29 / 4%); }
.preview-art-card img { display: block; width: 100%; height: auto; border-radius: 6px; object-fit: contain; background: var(--sand); }
.preview-art-image-button { display: block; width: 100%; min-height: 44px; padding: 0; border: 0; border-radius: 6px; background: transparent; cursor: zoom-in; }
.preview-art-copy { min-width: 0; padding-top: 10px; }
.preview-art-copy h4 { margin: 0 0 6px; }
.preview-art-copy p { margin: 0; white-space: pre-line; }
.preview-empty { grid-column: 1 / -1; padding: 20px; }
.preview-cta { display: inline-flex; min-height: 46px; align-items: center; justify-content: center; padding: 10px 18px; border-radius: 8px; color: #fff; background: var(--wood); font-weight: 700; }

.history-list { display: grid; gap: 10px; margin: 22px 0 12px; padding: 0; list-style: none; }
.history-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px; border: 1px solid var(--line); border-radius: 12px; }
.history-copy { margin: 0; color: var(--text) !important; font-weight: 700; }
.history-date { display: block; margin-top: 3px; color: var(--muted); font-size: .85rem; font-weight: 400; }
.history-item button { flex: none; }

.action-panel { position: sticky; bottom: 8px; z-index: 3; box-shadow: 0 10px 32px rgb(62 44 31 / 18%); }
.save-actions { align-items: stretch; }
.save-actions button { flex: 1; margin: 0; }
.save-state, .global-message { min-height: 1.6em; margin: 12px 0 0; color: var(--success); font-weight: 700; }
.global-message.error { color: var(--danger); }
.visually-hidden { position: fixed; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); opacity: 0; }
[hidden] { display: none !important; }

@media (max-width: 900px) {
  .preview-artworks { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .account-bar, .account-actions, .section-heading { align-items: stretch; flex-direction: column; }
  .preview-links { align-items: flex-start; }
  .text-style-row { grid-template-columns: 1fr 1fr; }
  .text-style-name { grid-column: 1 / -1; }
  .art-item { grid-template-columns: 38px minmax(0, 1fr); }
  .art-image-column, .art-edit-fields, .art-actions { grid-column: 1 / -1; }
  .art-image-column { grid-row: auto; }
  .art-item img { height: 58vw; min-height: 180px; max-height: 340px; }
  .art-actions { justify-content: stretch; }
  .art-actions button { flex: 1; }
  .save-actions { flex-direction: column; }
  .history-item { align-items: stretch; flex-direction: column; }
}

@media (max-width: 480px) {
  .page-shell { padding-inline: 12px; }
  .panel { border-radius: 14px; }
}

/* お客様向けMIYUKI LP */
.miyuki-public {
  min-height: 100vh;
  color: #3a302a;
  background: #fbf8f3;
}

.miyuki-public [hidden] { display: none !important; }

.public-shell {
  width: min(920px, 100%);
  min-width: 0;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(40px, env(safe-area-inset-bottom));
}

.public-nav {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 2px 22px;
}

.public-nav a { max-width: 100%; color: var(--wood); font-weight: 700; overflow-wrap: anywhere; text-underline-offset: 4px; }
.public-brand { font-family: Helvetica, Arial, sans-serif; font-size: 1.05rem; text-decoration: none; }
.public-content { display: grid; min-width: 0; max-width: 100%; gap: clamp(28px, 7vw, 64px); }
.public-hero { min-width: 0; max-width: 100%; margin: 0; }
.public-hero img { display: block; width: 100%; max-height: 72vh; border-radius: 18px; object-fit: cover; background: var(--sand); }
.public-hero-copy { width: min(720px, 100%); min-width: 0; max-width: 100%; margin: 18px auto 0; text-align: center; }
.public-hero-copy strong { display: block; color: var(--wood); font-size: 1.2rem; }
.public-hero-copy p { margin: 8px 0 0; line-height: 1.8; }
.public-copy { width: min(720px, 100%); min-width: 0; max-width: 100%; margin: 0 auto; text-align: center; }
.public-copy h1 { margin-bottom: 10px; color: var(--wood); font-size: clamp(2rem, 8vw, 4.6rem); letter-spacing: .02em; }
.public-subtitle { margin-bottom: 22px; color: var(--wood-soft); letter-spacing: .08em; }
.public-intro, .public-footer { margin: 0; color: #51463f; font-size: clamp(1rem, 2.8vw, 1.12rem); line-height: 2; }
.public-gallery { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: start; gap: clamp(8px, 1.6vw, 16px); }
.public-card { overflow: hidden; min-width: 0; border-radius: 12px; background: #fff; box-shadow: 0 8px 28px rgb(62 44 31 / 8%); }
.public-card-image-button { display: block; width: 100%; min-height: 44px; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.public-card img { display: block; width: 100%; height: auto; object-fit: contain; background: var(--sand); }
.public-card-copy { min-width: 0; padding: 10px; }
.public-card-copy:empty { display: none; }
.public-card h2 { margin-bottom: 6px; color: var(--wood); font-size: clamp(.9rem, 1.8vw, 1.05rem); overflow-wrap: anywhere; }
.public-card p { margin: 0; font-size: .88rem; line-height: 1.65; }
.public-cta { display: inline-flex; min-height: 52px; align-items: center; justify-content: center; margin-top: 24px; padding: 12px 22px; border-radius: 999px; color: #fff; background: var(--wood); font-weight: 700; text-decoration: none; }
.public-empty { min-height: 56vh; display: grid; place-items: center; }

.media-lightbox-open { overflow: hidden; }
.media-lightbox {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 56px;
  align-items: center;
  gap: 12px;
  padding: max(64px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  color: #fff;
  background: rgb(24 19 16 / 92%);
  touch-action: none;
}
.media-lightbox-figure { display: grid; min-width: 0; max-height: calc(100vh - 100px); justify-items: center; gap: 14px; margin: 0; }
.media-lightbox-figure img { display: block; width: auto; max-width: 100%; height: auto; max-height: calc(100vh - 190px); object-fit: contain; }
.media-lightbox-caption { width: min(720px, 100%); text-align: center; }
.media-lightbox-caption strong { display: block; font-size: 1.05rem; }
.media-lightbox-caption p { margin: 6px 0 0; line-height: 1.7; }
.media-lightbox-close, .media-lightbox-nav { min-width: 48px; min-height: 48px; border: 1px solid rgb(255 255 255 / 38%); border-radius: 999px; color: #fff; background: rgb(0 0 0 / 35%); font-weight: 700; }
.media-lightbox-close { position: absolute; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); font-size: 1.7rem; }
.media-lightbox-nav { font-size: 2rem; }
.media-lightbox-previous { grid-column: 1; }
.media-lightbox-next { grid-column: 3; }

.draft-preview-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 12px 16px;
  border: 1px solid #b69b79;
  border-radius: 12px;
  color: var(--wood);
  background: #fff4d9;
}
.draft-preview-banner span { color: #5f5148; }
.draft-preview-banner a { color: var(--wood); font-weight: 700; text-underline-offset: 4px; }
.draft-preview-unavailable { min-height: 56vh; display: grid; place-content: center; justify-items: center; gap: 14px; text-align: center; }
.draft-preview-unavailable h1, .draft-preview-unavailable p { margin: 0; }
.draft-preview-unavailable .secondary-button { display: inline-flex; align-items: center; text-decoration: none; }

@media (max-width: 900px) {
  .public-gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .preview-artworks, .public-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .public-nav { flex-wrap: wrap; }
  .public-hero img { border-radius: 12px; }
  .media-lightbox { grid-template-columns: 48px minmax(0, 1fr) 48px; gap: 6px; padding-inline: 8px; }
  .media-lightbox-figure img { max-height: calc(100vh - 210px); }
  .media-lightbox-caption { padding-inline: 8px; }
  .draft-preview-banner { align-items: flex-start; flex-direction: column; }
}
