:root {
  /* 黒板グリーン系統 */
  --green:        #5a8a6e;   /* メインの黒板グリーン */
  --green-deep:   #436a55;   /* 濃い緑（ホバー、テキスト強調） */
  --green-soft:   #e8f0ea;   /* 淡い緑（背景・選択中の影） */
  --green-line:   #b8d2c1;   /* 罫線・境界用 */
  --chalk-cream:  #f7f5ee;   /* チョークの白に近いクリーム */

  --text:  #2a3a32;
  --muted: #748077;
  --line:  #e6ece8;
  --bg:    #f3f7f4;          /* 全体背景：ごく淡い緑がかった白 */
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont,
               "Hiragino Maru Gothic ProN", "Hiragino Maru Gothic Pro",
               "Hiragino Sans", "Yu Gothic", "Yu Gothic Medium",
               "M PLUS Rounded 1c", "Noto Sans JP",
               sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
.page { min-height: 100vh; display: grid; place-items: center; padding: 18px; }
.card {
  width: min(760px, 100%);
  background: white;
  border-radius: 24px;
  box-shadow: 0 12px 36px rgba(60, 95, 75, .14);
  padding: 24px;
}
.brand { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }
.brand picture { display: block; flex-shrink: 0; }
.logo {
  width: 88px;
  height: 88px;
  border-radius: 16px;
  display: block;
  object-fit: contain;
}
h1 {
  margin: 0;
  font-size: clamp(28px, 6vw, 44px);
  letter-spacing: .02em;
  color: var(--green-deep);
}
.brand p { margin: 4px 0 0; color: var(--muted); }
.form { display: grid; gap: 14px; }

/* アップロードエリア */
.upload-box {
  position: relative;
  border: 2px dashed var(--green-line);
  border-radius: 18px;
  background: var(--chalk-cream);
  min-height: 138px;
  display: grid;
  place-content: center;
  text-align: center;
  cursor: pointer;
  padding: 18px;
  transition: background .15s ease, border-color .15s ease;
}
.upload-box:hover { background: #f0f5ee; }
.upload-box.is-drag {
  background: var(--green-soft);
  border-color: var(--green);
}
.upload-title { font-weight: 700; color: var(--green-deep); }
.upload-note { display: block; margin-top: 6px; color: var(--muted); font-size: 14px; }
.upload-filename {
  display: block;
  margin-top: 8px;
  color: var(--green-deep);
  font-size: 13px;
  word-break: break-all;
}
.upload-box input[type="file"] { display: none; }

/* プレビュー */
.preview-wrap { border-radius: 18px; overflow: hidden; background: #eef1ef; text-align: center; }
.preview-wrap img { max-width: 100%; max-height: 360px; display: block; margin: auto; }

/* フィールド共通 */
.field-label { font-weight: 700; margin-top: 8px; color: var(--green-deep); }

/* カラーチップ */
.color-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.color-chip {
  border: 1px solid #d6dbd7;
  border-radius: 999px;
  background: white;
  padding: 9px 13px;
  cursor: pointer;
  font: inherit;
  transition: border-color .15s ease, box-shadow .15s ease, transform .05s ease;
}
.color-chip:hover { border-color: var(--green); }
.color-chip:active { transform: scale(.97); }
.color-chip.is-selected {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
  font-weight: 700;
}
.color-chip::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: -2px;
  background: var(--c);
  border: 1px solid #ccc;
}
input[type="color"] {
  width: 44px;
  height: 40px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

/* 入力 */
select, textarea {
  width: 100%;
  border: 1px solid #d6dfd9;
  border-radius: 14px;
  padding: 13px 14px;
  font: inherit;
  background: white;
  color: inherit;
}
select:focus, textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}
textarea { resize: vertical; line-height: 1.7; }
.counter { text-align: right; color: var(--muted); font-size: 13px; margin-top: -8px; }

/* ボタン */
.primary, .download, .secondary {
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  font-weight: 700;
  font-size: 16px;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  transition: filter .15s ease, transform .05s ease;
  display: inline-block;
}
.primary, .download { background: var(--green); color: white; }
.primary:hover, .download:hover { filter: brightness(1.05); }
.primary:active, .download:active { transform: translateY(1px); }
.primary:disabled { background: #b8c8be; cursor: not-allowed; transform: none; }
.secondary { background: var(--green-soft); color: var(--green-deep); }
.secondary:hover { filter: brightness(.97); }

/* 結果エリア */
.result {
  margin-top: 22px;
  padding: 18px;
  border-radius: 18px;
  background: var(--chalk-cream);
  display: grid;
  gap: 12px;
}
.result h2 { margin: 0; color: var(--green-deep); }
.result-preview {
  background: #eef1ef;
  border-radius: 14px;
  overflow: hidden;
  text-align: center;
}
.result-preview img {
  max-width: 100%;
  max-height: 360px;
  display: block;
  margin: 0 auto;
}
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.result-actions > * { flex: 1 1 auto; }
#captionResult { min-height: 120px; background: white; }
.copy-status {
  min-height: 1.2em;
  font-size: 13px;
  color: var(--green-deep);
  text-align: right;
}

/* アラート */
.alert { padding: 12px 14px; border-radius: 14px; margin-bottom: 14px; }
.error { background: #fff0f0; color: #a33131; }

/* フッター */
footer { margin-top: 24px; text-align: center; color: var(--muted); }
.brand-line { height: 3px; background: var(--green); border-radius: 999px; margin-bottom: 8px; }

@media (max-width: 520px) {
  .card { padding: 18px; border-radius: 20px; }
  .brand { align-items: flex-start; }
  .logo { width: 64px; height: 64px; border-radius: 12px; }
  .result-actions { flex-direction: column; }
  .result-actions > * { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
