* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #f7f8fa;
  --card: #ffffff;
  --ink: #2b2f36;
  --ink-sub: #6b7280;
  --line: #e3e6ea;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --warn: #ea8600;
}
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Yu Gothic UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
.topbar {
  padding: 16px 16px 12px;
  padding-top: calc(16px + env(safe-area-inset-top));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 700; }
.topbar .sub { margin: 2px 0 0; font-size: 13px; color: var(--ink-sub); }

main { max-width: 640px; margin: 0 auto; padding: 12px 12px 40px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}

/* 使う場所モード */
.modebar { display: flex; gap: 8px; margin: 12px 0 8px; }
.modebar .mode {
  flex: 1; min-height: 48px; border: 1px solid var(--line);
  background: #fff; color: var(--ink-sub); border-radius: 8px;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.modebar .mode.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.modehint {
  margin: 0 0 12px; font-size: 13px; color: var(--ink);
  background: #eef1f5; border-radius: 8px; padding: 10px 12px; line-height: 1.55;
}

/* ファイル選択 */
.drop {
  display: block;
  border: 2px dashed var(--line);
  border-radius: 10px;
  padding: 22px 14px;
  text-align: center;
  cursor: pointer;
}
.drop.drag { border-color: var(--accent); background: #f0f5ff; }
.drop-icon { font-size: 32px; color: var(--accent); line-height: 1; }
.drop-text { font-size: 18px; font-weight: 600; margin-top: 6px; }
.drop-hint { font-size: 12px; color: var(--ink-sub); margin-top: 4px; }
/* スマホモードの入口（写真／ファイル） */
.phone-pick { display: none; grid-template-columns: 1fr 1fr; gap: 8px; }
.pickbtn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 96px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); font-size: 15px; font-weight: 600;
  cursor: pointer; text-align: center; padding: 10px;
}
.pickbtn-emoji { font-size: 28px; line-height: 1; }
body.mode-phone .phone-pick { display: grid; }
body.mode-phone #drop { display: none; }

.filelist { list-style: none; margin: 12px 0 0; padding: 0; }
.filelist li {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  margin-top: 8px; font-size: 14px;
}
.filelist .kind {
  font-size: 11px; font-weight: 700; color: var(--accent);
  border: 1px solid var(--accent); border-radius: 4px; padding: 1px 5px;
}
.filelist .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filelist .rm {
  border: none; background: none; color: var(--ink-sub);
  font-size: 20px; line-height: 1; padding: 4px 8px; cursor: pointer;
  min-height: 44px; min-width: 44px;
}
.link-btn {
  display: block; width: 100%; margin-top: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-sub);
  border-radius: 8px; padding: 10px; font-size: 14px; min-height: 44px; cursor: pointer;
}

/* 文言 */
.field-label { display: block; font-size: 14px; color: var(--ink-sub); margin-bottom: 6px; }
.text-input {
  width: 100%; font-size: 18px; padding: 12px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
.text-input:focus { outline: none; border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 8px; padding: 10px 14px; font-size: 13px; cursor: pointer; min-height: 44px;
}
.chip:active { background: #eef2f7; }

/* スライダー */
.slider-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; }
.slider-row label { width: 48px; font-size: 14px; color: var(--ink-sub); flex-shrink: 0; }
.slider-row input[type=range] { flex: 1; accent-color: var(--accent); height: 44px; }
.slider-row .val { width: 56px; text-align: right; font-size: 14px; font-variant-numeric: tabular-nums; }

/* プレビュー */
.preview-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.preview-head span:first-child { font-weight: 600; }
.preview-note { font-size: 12px; color: var(--ink-sub); }
.preview-wrap {
  background: #eceff3; border-radius: 8px; padding: 10px;
  display: flex; justify-content: center; align-items: center; min-height: 120px;
}
#preview { max-width: 100%; height: auto; background: #fff; border: 1px solid var(--line); }

/* 実行 */
.actions { position: sticky; bottom: 0; padding: 12px 0 calc(8px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); }
.combine-opt {
  display: none; align-items: center; gap: 10px; min-height: 44px;
  margin-bottom: 8px; font-size: 15px; color: var(--ink); cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 0 12px;
}
.combine-opt input { width: 22px; height: 22px; accent-color: var(--accent); flex-shrink: 0; }
.btn {
  width: 100%; border: none; border-radius: 10px; padding: 16px;
  font-size: 18px; font-weight: 700; cursor: pointer; min-height: 56px;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:disabled { background: #b8c2d1; cursor: default; }
.status { text-align: center; font-size: 14px; margin: 8px 0 0; min-height: 20px; }
.status.warn { color: var(--warn); }
.privacy { text-align: center; font-size: 12px; color: var(--ink-sub); margin-top: 16px; }

/* 保存ボタン（結果） */
.save-btn { display: block; margin-top: 8px; text-decoration: none; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-sub { background: #fff; color: var(--accent); border: 1px solid var(--accent); font-weight: 600; font-size: 14px; }
.share-note { margin: 0 0 4px; font-size: 13px; color: var(--ink-sub); line-height: 1.5; }

/* エラー表示 */
.card-warn { border-color: var(--warn); }
.card-warn .preview-head span { color: var(--warn); }
.err-line { margin: 8px 0 0; font-size: 14px; word-break: break-all; }
.err-line strong { color: var(--warn); }
