/* ===== 全体 ===== */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: #070A10;
  color: #E8EEF5;
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP",
    "Yu Gothic", Meiryo, sans-serif;
  line-height: 1.6;
}

.app-root {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.app-header h1 {
  margin: 0;
  font-size: 1.55rem;
  color: #00E5FF;
  letter-spacing: 0.04em;
}
.app-sub {
  margin: 4px 0 0;
  color: #9FB3C8;
  font-size: 0.92rem;
}

/* ===== ツールバー ===== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0;
}

.mode-switch {
  display: inline-flex;
  background: #101826;
  border: 1px solid #22314a;
  border-radius: 999px;
  padding: 4px;
}
.mode-btn {
  border: none;
  background: transparent;
  color: #9FB3C8;
  font-size: 1rem;
  padding: 8px 22px;
  border-radius: 999px;
  cursor: pointer;
}
.mode-btn.active {
  background: #00E5FF;
  color: #04222b;
  font-weight: 700;
}

.toolbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  border-radius: 8px;
  font-size: 0.98rem;
  padding: 10px 18px;
  cursor: pointer;
  border: 1px solid #22314a;
}
.btn-main {
  background: #00E5FF;
  color: #04222b;
  font-weight: 700;
  border-color: #00E5FF;
}
.btn-main:hover { background: #4deeff; }
.btn-sub {
  background: #101826;
  color: #E8EEF5;
}
.btn-sub:hover { border-color: #00E5FF; color: #00E5FF; }

/* ===== レイアウト ===== */
.layout {
  display: flex;
  gap: 28px;
  align-items: flex-start;
}
.editor {
  flex: 0 0 380px;
  background: #0C1220;
  border: 1px solid #1b2942;
  border-radius: 12px;
  padding: 18px;
}
.editor h2 {
  font-size: 1.02rem;
  margin: 14px 0 10px;
  color: #00E5FF;
}
.editor h2:first-child { margin-top: 0; }

.preview-wrap { flex: 1 1 auto; min-width: 0; }
.preview-title {
  font-size: 1.02rem;
  margin: 0 0 10px;
  color: #00E5FF;
}

/* ===== 入力欄 ===== */
.field { display: block; margin-bottom: 12px; }
.field span {
  display: block;
  font-size: 0.85rem;
  color: #9FB3C8;
  margin-bottom: 4px;
}
.field input,
.field textarea,
.add-field input,
.field-row input,
.field-row select {
  width: 100%;
  background: #070A10;
  border: 1px solid #22314a;
  border-radius: 8px;
  color: #E8EEF5;
  font-size: 1rem;
  padding: 9px 10px;
}
.field input:focus,
.field textarea:focus,
.add-field input:focus,
.field-row input:focus,
.field-row select:focus {
  outline: none;
  border-color: #00E5FF;
}
.hint { color: #7e93ab; font-size: 0.85rem; margin: 10px 0 0; }

/* テーマ選択 */
.theme-row { display: flex; gap: 8px; flex-wrap: wrap; }
.theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #101826;
  border: 1px solid #22314a;
  color: #E8EEF5;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.92rem;
}
.theme-btn.active { border-color: #00E5FF; color: #00E5FF; }
.swatch {
  width: 18px; height: 18px;
  border-radius: 4px;
  display: inline-block;
  border: 1px solid rgba(255,255,255,0.25);
}
.sw-simple { background: #ffffff; }
.sw-navy   { background: #0b1e3a; }
.sw-warm   { background: #fdf6ec; }

/* 申込書の項目編集 */
.field-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  align-items: center;
}
.field-row .fr-label { flex: 1 1 auto; }
.field-row .fr-type { flex: 0 0 96px; }
.field-row .fr-opts { flex: 1 1 auto; }
.field-row .fr-del {
  flex: 0 0 auto;
  background: #101826;
  border: 1px solid #22314a;
  color: #ff8fa3;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}
.add-field { display: flex; gap: 8px; margin: 6px 0 16px; }
.add-field input { flex: 1 1 auto; }
.add-field .btn { flex: 0 0 auto; }

/* ===== 名刺（画面プレビュー／印刷 共通部品） =====
   内側の寸法は em 指定。コンテナの font-size で全体が拡縮する。 */
.card {
  --card-bg: #ffffff;
  --card-fg: #1c2733;
  --card-accent: #00a8c5;
  --card-sub: #5c6f82;
  background: var(--card-bg);
  color: var(--card-fg);
  border-radius: 0.35em;
  padding: 1.1em 1.3em;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}
.card .c-org {
  font-size: 0.82em;
  color: var(--card-accent);
  font-weight: 700;
  letter-spacing: 0.08em;
  border-bottom: 0.14em solid var(--card-accent);
  padding-bottom: 0.35em;
  min-height: 1.2em;
}
.card .c-main { margin-top: 0.4em; }
.card .c-name {
  font-size: 1.65em;
  font-weight: 700;
  line-height: 1.25;
}
.card .c-role {
  font-size: 0.9em;
  color: var(--card-sub);
  margin-left: 0.6em;
  font-weight: 400;
}
.card .c-msg {
  font-size: 0.85em;
  margin-top: 0.3em;
  min-height: 1.2em;
}
.card .c-contact {
  font-size: 0.82em;
  color: var(--card-sub);
  border-top: 0.06em solid var(--card-sub);
  padding-top: 0.4em;
  display: flex;
  gap: 1.2em;
  flex-wrap: wrap;
}

/* テーマ */
.card.theme-simple { --card-bg: #ffffff; --card-fg: #1c2733; --card-accent: #00a8c5; --card-sub: #5c6f82; }
.card.theme-navy   { --card-bg: #0b1e3a; --card-fg: #ffffff; --card-accent: #00E5FF; --card-sub: #a9c4de; }
.card.theme-warm   { --card-bg: #fdf6ec; --card-fg: #4a3823; --card-accent: #e08a3c; --card-sub: #8a7355; }

/* 画面プレビュー用の名刺サイズ（91:55 比率） */
#cardPreview .card {
  width: 100%;
  max-width: 520px;
  aspect-ratio: 91 / 55;
  font-size: 17px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.55);
}

/* ===== 申込書（画面プレビュー／印刷 共通部品） ===== */
.form-sheet {
  background: #ffffff;
  color: #1c2733;
  padding: 2.2em 2.4em;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}
.form-sheet .f-title {
  text-align: center;
  font-size: 1.45em;
  font-weight: 700;
  border-bottom: 0.12em solid #1c2733;
  padding-bottom: 0.45em;
  margin-bottom: 1.1em;
}
.form-sheet .f-row {
  display: flex;
  align-items: stretch;
  border-bottom: 0.05em solid #b9c6d2;
  padding: 0.55em 0;
  min-height: 2.6em;
}
.form-sheet .f-label {
  flex: 0 0 9em;
  font-weight: 700;
  font-size: 0.95em;
  padding-top: 0.15em;
}
.form-sheet .f-blank { flex: 1 1 auto; }
.form-sheet .f-blank.box {
  border: 0.05em solid #b9c6d2;
  min-height: 4.2em;
  border-radius: 0.2em;
}
.form-sheet .f-choice { font-size: 0.95em; padding-top: 0.15em; }
.form-sheet .f-choice .opt { margin-right: 1.4em; white-space: nowrap; }
.form-sheet .f-date {
  text-align: right;
  font-size: 0.92em;
  margin-bottom: 0.8em;
}
.form-sheet .f-note {
  margin-top: 1.2em;
  font-size: 0.85em;
  color: #45566a;
  white-space: pre-wrap;
}

/* 画面プレビュー用の申込書（A4 比率） */
#formPreview .form-sheet {
  width: 100%;
  max-width: 640px;
  aspect-ratio: 1 / 1.414;
  font-size: 13.5px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

/* ===== 印刷 ===== */
#printArea { display: none; }

@page { size: A4; margin: 8mm; }

@media print {
  body { background: #ffffff; }
  .app-root { display: none !important; }
  #printArea { display: block !important; }

  /* 名刺 10 面付け */
  .print-cards {
    display: grid;
    grid-template-columns: 91mm 91mm;
    column-gap: 4mm;
    row-gap: 0;
    justify-content: center;
  }
  .print-cards .card {
    width: 91mm;
    height: 55mm;
    font-size: 12.5pt;
    border: 0.25mm solid #c9d4de;
    border-radius: 0;
  }

  /* 申込書 */
  .print-form .form-sheet {
    width: 100%;
    font-size: 11.5pt;
    padding: 6mm 4mm;
  }
}

/* ===== レスポンシブ ===== */
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .editor { flex: 1 1 auto; width: 100%; }
  .preview-wrap { width: 100%; }
  #cardPreview .card { font-size: 14px; }
  #formPreview .form-sheet { font-size: 11px; }
  .field-row { flex-wrap: wrap; }
  .field-row .fr-label { flex: 1 1 100%; }
}
