/* Stampalette (LINEスタンプメーカー) スタイル */
:root {
  --line-green: #06C755;
  --line-green-dark: #05a648;
  --ink: #222;
  --sub: #667085;
  --bg: #f2f4f7;
  --card: #ffffff;
  --border: #e4e7ec;
  --danger: #d92d20;
  --warn-bg: #fffaeb;
  --warn-border: #fec84b;
  --info-bg: #ecfdf3;
  --info-border: #6ce9a6;
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
}
a { color: var(--line-green-dark); }
img { max-width: 100%; }

/* ---------- ヘッダー ---------- */
.topbar {
  background: var(--line-green);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  color: #fff;
  text-decoration: none;
  font-size: 1.25rem;
  font-weight: 700;
}
.nav-link {
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  margin-left: 16px;
  opacity: .95;
}
.nav-link:hover { text-decoration: underline; }

/* ---------- レイアウト ---------- */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(16,24,40,.06);
}
.section-title { margin: 8px 0 16px; }
.empty-note { color: var(--sub); }

/* ---------- バナー ---------- */
.banner {
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 20px;
  font-weight: 600;
}
.banner.warn { background: var(--warn-bg); border: 1px solid var(--warn-border); }
.banner.info { background: var(--info-bg); border: 1px solid var(--info-border); }
.banner.error { background: #fef3f2; border: 1px solid #fda29b; color: var(--danger); }

/* ---------- ボタン ---------- */
.btn {
  display: inline-block;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(.96); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--line-green);
  border-color: var(--line-green);
  color: #fff;
}
.btn.primary:hover { background: var(--line-green-dark); }
.btn.big { font-size: 1.15rem; padding: 14px 28px; }
.btn.danger { color: var(--danger); border-color: #fda29b; }
.btn.warn { color: #b54708; border-color: var(--warn-border); }
.btn.ghost { background: transparent; }
.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  filter: none;
}

/* ---------- トップ: hero ---------- */
.hero h1 { margin-top: 0; }
.lead { color: var(--sub); }
.create-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.create-form input[type="text"] {
  flex: 1 1 280px;
  font-size: 1.05rem;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

/* ---------- トップ: セット一覧 ---------- */
.set-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.set-card { padding: 0; overflow: hidden; margin-bottom: 0; }
.set-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 160px;
  background: repeating-conic-gradient(#f0f0f0 0% 25%, #fafafa 0% 50%) 50%/20px 20px;
  border-bottom: 1px solid var(--border);
}
.set-thumb img { max-height: 140px; width: auto; }
.thumb-placeholder { font-size: 3rem; opacity: .4; }
.set-info { padding: 14px 16px 16px; }
.set-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  display: block;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.set-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.set-date { color: var(--sub); font-size: .8rem; }
.set-actions { display: flex; gap: 8px; }

.badge {
  display: inline-block;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 700;
  padding: 2px 10px;
}
.badge.done { background: #ecfdf3; color: #027a48; }
.badge.running { background: #eff8ff; color: #175cd3; }
.badge.partial { background: var(--warn-bg); color: #b54708; }
.badge.draft { background: #f2f4f7; color: var(--sub); }

/* ---------- 使い方 ---------- */
.help-card h2 { margin-top: 0; }
.help-steps li { margin-bottom: 8px; }

/* ---------- セット画面 ---------- */
.field-label { font-weight: 700; display: block; margin-bottom: 6px; }
.title-input {
  width: 100%;
  font-size: 1.3rem;
  font-weight: 700;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.step-card h2 { margin-top: 0; display: flex; align-items: center; gap: 10px; }
.step-no {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--line-green);
  color: #fff;
  font-size: 1.05rem;
  flex-shrink: 0;
}
.step-desc { color: var(--sub); margin-top: 4px; }
.optional { font-size: .85rem; color: var(--sub); font-weight: 600; }

/* AI提案パネル */
.ai-panel {
  border: 1.5px dashed #b2ddff;
  background: #f5faff;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 16px 0;
}
.ai-panel h3 { margin: 0 0 4px; }
.ai-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 10px;
}
.ai-row input[type="text"] {
  flex: 1 1 260px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: .95rem;
  font-family: inherit;
}
.ai-target-label {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.ai-target-label select {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  background: #fff;
}
.suggest-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
  max-height: 340px;
  overflow-y: auto;
}
.suggest-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: .92rem;
  cursor: pointer;
}
.suggest-row input { width: 18px; height: 18px; margin-top: 3px; flex-shrink: 0; }
.suggest-row:has(input:not(:checked)) { opacity: .45; }

/* アイテムリスト */
.item-list { display: flex; flex-direction: column; gap: 10px; margin: 16px 0 10px; }
.item-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fcfcfd;
}
.item-row.invalidated { border-color: var(--warn-border); background: var(--warn-bg); }
.item-no {
  min-width: 44px;
  text-align: center;
  font-weight: 700;
  color: var(--sub);
  padding-top: 8px;
}
.item-thumb {
  width: 64px;
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-conic-gradient(#f0f0f0 0% 25%, #fff 0% 50%) 50%/14px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  font-size: 1.4rem;
}
.item-thumb img { max-width: 100%; max-height: 100%; }
.item-row textarea {
  flex: 1;
  min-height: 56px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: .95rem;
  font-family: inherit;
  line-height: 1.5;
}
.item-del {
  border: none;
  background: none;
  color: var(--sub);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 6px;
}
.item-del:hover { color: var(--danger); }
.item-toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.count-note { font-weight: 700; }
.count-note.ok { color: #027a48; }
.count-note.ng { color: #b54708; }

.style-details { margin-top: 18px; }
.style-details summary { cursor: pointer; font-weight: 700; }
.style-details textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: .95rem;
  margin-top: 8px;
}
.save-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 18px;
}
.save-note { color: var(--sub); font-size: .85rem; flex: 1; min-width: 220px; }

/* 参照画像 */
.ref-row { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.ref-preview {
  width: 180px;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: #fcfcfd;
  overflow: hidden;
}
.ref-preview img { max-width: 100%; max-height: 100%; }
.ref-controls { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.checkbox-label { font-weight: 600; display: flex; gap: 8px; align-items: center; cursor: pointer; }
.checkbox-label input { width: 20px; height: 20px; }
.tiny-note { color: var(--sub); font-size: .82rem; margin: 0; }

/* 生成 */
.gen-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 14px 0; }
.progress-area { margin: 18px 0 8px; }
.progress-label { font-weight: 700; margin-bottom: 6px; }
.progress-track {
  height: 22px;
  border-radius: 999px;
  background: #e4e7ec;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--line-green), #3ddc84);
  transition: width .6s ease;
}
.progress-stages { display: flex; gap: 18px; margin-top: 8px; color: var(--sub); font-size: .9rem; flex-wrap: wrap; }
.log-details { margin-top: 14px; }
.log-details summary { cursor: pointer; color: var(--sub); font-weight: 600; }
.log-view {
  background: #101828;
  color: #d0f5dd;
  border-radius: 10px;
  padding: 14px;
  font-size: .8rem;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ギャラリー */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.g-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  text-align: center;
}
.g-img {
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-conic-gradient(#f0f0f0 0% 25%, #fff 0% 50%) 50%/16px 16px;
}
.g-img img { max-height: 120px; max-width: 95%; }
.g-img .pending { font-size: 1.6rem; opacity: .35; }
.g-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-top: 1px solid var(--border);
  font-size: .82rem;
  color: var(--sub);
}
.g-stage { font-weight: 700; }
.g-stage.fitted { color: #027a48; }
.g-stage.base, .g-stage.transparent { color: #175cd3; }
.g-stage.none { color: #b54708; }
.g-regen {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 4px;
}
.g-regen:hover { transform: scale(1.15); }

/* main / tab */
.extra-images { display: flex; gap: 24px; margin-top: 20px; flex-wrap: wrap; }
.extra-item { text-align: center; }
.extra-label { font-size: .85rem; color: var(--sub); font-weight: 700; margin-bottom: 6px; }
.extra-item img {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: repeating-conic-gradient(#f0f0f0 0% 25%, #fff 0% 50%) 50%/16px 16px;
}
.extra-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
  align-items: flex-start;
  text-align: left;
}

/* ダウンロード */
.download-area { margin-top: 24px; }
.line-guide {
  margin-top: 18px;
  border: 1px solid var(--info-border);
  background: var(--info-bg);
  border-radius: var(--radius);
  padding: 6px 22px 14px;
}
.line-guide h3 { margin-bottom: 6px; }

/* 設定 */
.key-form { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.key-form input {
  flex: 1 1 320px;
  padding: 12px 14px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.key-status { margin: 10px 0; }

@media (max-width: 640px) {
  html { font-size: 15px; }
  .item-no { min-width: 30px; }
  .item-thumb { display: none; }
}

/* ---------- 認証画面 (ログイン / 新規登録) ---------- */
.auth-container { max-width: 520px; }
.auth-card h1 { margin-top: 0; }
.auth-form { display: flex; flex-direction: column; gap: 6px; }
.auth-form input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 1rem;
  margin-bottom: 10px;
}
.auth-form .btn { margin-top: 8px; }
.auth-note { color: var(--sub); font-size: .9rem; margin-top: 16px; }

/* ---------- ヘッダーのユーザー表示・ログアウト ---------- */
.topbar-inner nav { display: flex; align-items: center; flex-wrap: wrap; }
.nav-user { color: #fff; font-weight: 600; margin-left: 16px; opacity: .95; }
.nav-logout { display: inline; margin: 0; }
.nav-link-btn {
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
  padding: 0;
}
.nav-link-btn:hover { text-decoration: underline; }

/* ---------- クォータ表示 ---------- */
.quota-banner strong { font-size: 1.1em; }

/* ---------- 管理画面 ---------- */
.admin-stats { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.stat-card { text-align: center; padding: 18px; }
.stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-label { color: var(--sub); font-size: .9rem; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}
.admin-table th, .admin-table td {
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: middle;
}
.admin-table th { color: var(--sub); font-size: .85rem; white-space: nowrap; }
.admin-error { color: var(--danger); font-size: .85rem; }
.admin-num { width: 90px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; }
.admin-text { width: 150px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; }
.admin-actions { white-space: nowrap; }
.admin-actions .btn { padding: 6px 12px; font-size: .85rem; }
.admin-actions form { display: inline; }
