/* ============================================================================
 * 賞状作成ツール — 画面のスタイル。
 * 賞状そのものは金を基調にしていても、アプリ側は白ベースで静かに保つ（§17）。
 * ==========================================================================*/

:root {
  --ct-gold: #b8892f;
  --ct-gold-soft: #f4ead6;
  --ct-ink: #1e293b;
  --ct-sub: #64748b;
  --ct-line: #e3e8ef;
  --ct-bg: #f6f7f9;
  --ct-card: #ffffff;
  --ct-radius: 12px;
}

body {
  background: var(--ct-bg);
}

/* ------------------------------------------------------------- appbar --- */

.ct-appbar {
  background: #fff;
  border-bottom: 1px solid var(--ct-line);
}

.ct-appbar-inner {
  max-width: 1660px;
  margin: 0 auto;
  padding: 0.55rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.ct-brand { display: flex; align-items: center; gap: 0.7rem; }

.ct-brand-icon {
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 11px;
  background: var(--ct-gold-soft);
  color: var(--ct-gold);
  flex-shrink: 0;
}

.ct-brand h1 { font-size: 1.1rem; margin: 0; color: var(--ct-ink); line-height: 1.3; }
.ct-brand p { margin: 0.1rem 0 0; font-size: 0.8rem; color: var(--ct-sub); }

.ct-appbar-actions { display: flex; align-items: center; gap: 0.8rem; }

.ct-save-state { font-size: 0.78rem; color: #16a34a; min-height: 1em; }

.ct-ghost-btn {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.42rem 0.8rem;
  border: 1px solid var(--ct-line); border-radius: 999px;
  background: #fff; color: var(--ct-sub);
  font-size: 0.82rem; text-decoration: none;
}
.ct-ghost-btn:hover { border-color: var(--ct-gold); color: var(--ct-gold); }

/* ---------------------------------------------------------- workspace --- */

.ct-workspace {
  max-width: 1660px;
  margin: 0 auto;
  padding: 0.4rem 1.25rem 1.2rem;
  display: grid;
  grid-template-columns: 196px minmax(320px, 366px) minmax(0, 1fr);
  gap: 1.1rem;
  align-items: start;
}

/* ------------------------------------------------------------- steps --- */

.ct-step-list { list-style: none; margin: 0; padding: 0; }

.ct-step-list li { position: relative; }

.ct-step-list li + li::before {
  content: '';
  position: absolute;
  left: 21px; top: -6px; height: 12px;
  border-left: 2px dotted #d6dbe3;
}

.ct-step-list button {
  width: 100%;
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.55rem 0.4rem;
  background: none; border: 0; cursor: pointer;
  text-align: left; color: var(--ct-sub);
  font-family: inherit;
}

.ct-step-ico {
  width: 30px; height: 30px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: #eef1f5; color: #94a3b8;
  transition: background 0.15s, color 0.15s;
}

.ct-step-txt { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.ct-step-txt strong { font-size: 0.84rem; color: #475569; font-weight: 700; }
.ct-step-txt span { font-size: 0.72rem; color: #94a3b8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ct-step-list button.is-active .ct-step-ico { background: var(--ct-gold-soft); color: var(--ct-gold); }
.ct-step-list button.is-active .ct-step-txt strong { color: var(--ct-gold); }

.ct-tip {
  margin-top: 1.2rem;
  padding: 0.85rem 0.9rem;
  background: #fffaf0;
  border: 1px solid #f1e2c4;
  border-radius: var(--ct-radius);
}
.ct-tip strong { display: block; font-size: 0.8rem; color: #8a6a24; margin-bottom: 0.4rem; }
.ct-tip p { margin: 0 0 0.45rem; font-size: 0.75rem; color: #7b6844; line-height: 1.6; }
.ct-tip p:last-child { margin-bottom: 0; }

/* -------------------------------------------------------------- form --- */

.ct-form { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }

.ct-card {
  background: var(--ct-card);
  border: 1px solid var(--ct-line);
  border-radius: var(--ct-radius);
  padding: 1.1rem;
}

.ct-card-title {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.98rem; color: var(--ct-ink);
  margin: 0 0 0.9rem;
}

.ct-num {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--ct-gold); color: #fff;
  font-size: 0.75rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}

.ct-kinds { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 0.5rem; }

.ct-kind {
  display: flex; flex-direction: column; align-items: center; gap: 0.28rem;
  padding: 0.7rem 0.35rem;
  background: #fff;
  border: 1px solid var(--ct-line); border-radius: 10px;
  cursor: pointer; font-family: inherit;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.ct-kind svg { color: #9aa5b4; }
.ct-kind strong { font-size: 0.84rem; color: #334155; font-weight: 700; }
.ct-kind span { font-size: 0.66rem; color: #94a3b8; text-align: center; line-height: 1.35; }
.ct-kind:hover { border-color: var(--ct-gold); background: #fffdf8; }
.ct-kind[aria-checked='true'] {
  border-color: var(--ct-gold); background: #fffaf0;
  box-shadow: 0 0 0 1px var(--ct-gold) inset;
}
.ct-kind[aria-checked='true'] svg { color: var(--ct-gold); }
.ct-kind[aria-checked='true'] strong { color: #8a6a24; }

.ct-field { margin-bottom: 1rem; }
.ct-field:last-child { margin-bottom: 0; }

.ct-field label, .ct-label {
  display: block;
  font-size: 0.82rem; font-weight: 700; color: #475569;
  margin-bottom: 0.35rem;
}

.ct-label-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.35rem; }
.ct-label-row label { margin-bottom: 0; }

.ct-req {
  display: inline-block; margin-left: 0.3rem;
  padding: 0.05rem 0.32rem; border-radius: 4px;
  background: #fdeaea; color: #d4443c;
  font-size: 0.63rem; font-weight: 700; vertical-align: 1px;
}

.ct-field input[type='text'],
.ct-field input[type='date'],
.ct-field textarea,
.ct-field select {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid #d9dfe7; border-radius: 8px;
  background: #fcfdfe;
  font-size: 0.92rem; font-family: inherit; color: var(--ct-ink);
}
.ct-field textarea { line-height: 1.7; resize: vertical; }
.ct-field input:focus, .ct-field textarea:focus, .ct-field select:focus {
  outline: none; border-color: var(--ct-gold); background: #fff;
  box-shadow: 0 0 0 3px rgba(184, 137, 47, 0.12);
}

.ct-row { display: flex; gap: 0.5rem; }
.ct-row select { width: auto; min-width: 108px; flex-shrink: 0; }
.ct-row input[type='date'] { flex: 1; }

.ct-field-split { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }

.ct-help { margin: 0.35rem 0 0; font-size: 0.72rem; color: #94a3b8; line-height: 1.55; }

.ct-mini-btn {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.32rem 0.62rem;
  border: 1px solid #e6d6b3; border-radius: 7px;
  background: #fffaf0; color: #8a6a24;
  font-size: 0.76rem; font-weight: 700; font-family: inherit; cursor: pointer;
}
.ct-mini-btn:hover { background: #fdf3e0; border-color: var(--ct-gold); }

.ct-link-btn {
  background: none; border: 0; padding: 0.2rem;
  color: #94a3b8; font-size: 0.75rem; font-family: inherit;
  cursor: pointer; text-decoration: underline;
}
.ct-link-btn:hover { color: #d4443c; }

.ct-seal { margin-top: 0.6rem; }
.ct-seal-set { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.55rem; flex-wrap: wrap; }
.ct-seal-set img {
  width: 42px; height: 42px; object-fit: contain;
  border: 1px solid var(--ct-line); border-radius: 7px; background: #fff; padding: 3px;
}

.ct-seg { display: inline-flex; border: 1px solid #d9dfe7; border-radius: 9px; overflow: hidden; background: #fff; }
.ct-seg button {
  padding: 0.55rem 1.5rem;
  border: 0; background: #fff; cursor: pointer;
  font-size: 0.86rem; font-family: inherit; color: #64748b;
}
.ct-seg button + button { border-left: 1px solid #e6ebf1; }
.ct-seg button[aria-pressed='true'] { background: #f6e7c8; color: #6f5416; font-weight: 700; }
.ct-seg-sm button { padding: 0.35rem 0.75rem; font-size: 0.78rem; }

/* ---------------------------------------------------------- preview --- */

.ct-preview {
  position: sticky; top: 0.7rem;
  background: var(--ct-card);
  border: 1px solid var(--ct-line);
  border-radius: var(--ct-radius);
  padding: 0.7rem;
  min-width: 0;
  display: flex; flex-direction: column; gap: 0.45rem;
  /* 高さは固定する。max-height だと中身の高さまで縮み、用紙が「全体表示」
     でも極端に小さくなる。差し引く 196px は上のナビ＋ヘッダー＋パンくずの
     実測値＋下部の操作バーで、初回表示でも倍率表示まで画面に収まる。 */
  height: calc(100vh - 248px);
  /* 縦の狭い画面では画面内に収めるより用紙を読める大きさに保つほうを優先し、
     少しだけスクロールしてもらう。 */
  min-height: 600px;
}

.ct-tpl-block .ct-label { margin-bottom: 0.4rem; }

.ct-tpl-list {
  display: flex; gap: 0.55rem;
  overflow-x: auto; padding-bottom: 0.25rem;
  scrollbar-width: thin;
}

.ct-tpl {
  position: relative; flex-shrink: 0;
  width: 102px;
  padding: 0; border: 2px solid var(--ct-line); border-radius: 8px;
  background: #fff; cursor: pointer; overflow: hidden; line-height: 0;
}
.ct-tpl svg { width: 100%; height: auto; display: block; }
.ct-tpl:hover { border-color: #d9c085; }
.ct-tpl[aria-checked='true'] { border-color: var(--ct-gold); box-shadow: 0 0 0 2px rgba(184, 137, 47, 0.2); }
.ct-tpl[aria-checked='true']::after {
  content: '✓';
  position: absolute; right: 5px; bottom: 5px;
  width: 19px; height: 19px; border-radius: 50%;
  background: var(--ct-gold); color: #fff;
  font-size: 0.7rem; line-height: 19px; text-align: center;
}
.ct-tpl-name {
  display: block; padding: 0.14rem 0.2rem;
  font-size: 0.58rem; color: #64748b; line-height: 1.3;
  text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.ct-stage {
  flex: 1; min-height: 0;
  background: #eef1f5;
  border: 1px solid var(--ct-line); border-radius: 10px;
  padding: 0.55rem;
  overflow: auto;
  display: flex; align-items: flex-start; justify-content: center;
}

.ct-paper {
  flex-shrink: 0;
  background: #fff;
  /* §17: 額縁のような強い影にしない。紙が浮いて見える程度に留める。*/
  box-shadow: 0 1px 5px rgba(15, 23, 42, 0.11);
  line-height: 0;
}
.ct-paper svg { width: 100%; height: auto; display: block; }

.ct-warn {
  margin: 0; padding: 0.5rem 0.7rem;
  background: #fff7ed; border: 1px solid #fed7aa; border-radius: 8px;
  font-size: 0.76rem; color: #b45309; line-height: 1.55;
}

.ct-stage-foot { min-height: 30px; display: flex; align-items: center; justify-content: space-between; gap: 0.7rem; flex-wrap: wrap; }
.ct-note { margin: 0; font-size: 0.7rem; color: #94a3b8; }

.ct-zoom { display: flex; align-items: center; gap: 0.3rem; }
.ct-zoom button {
  min-width: 30px; height: 30px;
  border: 1px solid #d9dfe7; border-radius: 7px;
  background: #fff; color: #475569;
  font-size: 0.9rem; font-family: inherit; cursor: pointer;
}
.ct-zoom button:hover { border-color: var(--ct-gold); color: var(--ct-gold); }
.ct-zoom span { min-width: 44px; text-align: center; font-size: 0.78rem; color: #64748b; }
.ct-zoom-fit { padding: 0 0.6rem; font-size: 0.76rem !important; }

/* --------------------------------------------------------- 保存・印刷 --- */

.ct-actionbar {
  position: sticky; bottom: 0; z-index: 6;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--ct-line);
}

.ct-actionbar-inner {
  max-width: 1660px; margin: 0 auto;
  padding: 0.7rem 1.25rem;
  display: flex; justify-content: flex-end; gap: 0.6rem; flex-wrap: wrap;
}

.ct-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.66rem 1.15rem;
  border: 1px solid #d9dfe7; border-radius: 9px;
  background: #fff; color: #475569;
  font-size: 0.88rem; font-weight: 700; font-family: inherit; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.ct-btn:hover { border-color: var(--ct-gold); color: var(--ct-gold); background: #fffdf8; }
.ct-btn[disabled] { opacity: 0.55; cursor: progress; }

.ct-btn-primary {
  background: var(--ct-gold); border-color: var(--ct-gold); color: #fff;
  padding: 0.66rem 1.6rem;
}
.ct-btn-primary:hover { background: #a67a25; border-color: #a67a25; color: #fff; }

/* ------------------------------------------------------------ modal --- */

.ct-modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.ct-modal[hidden] { display: none; }
.ct-modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.42); }

.ct-modal-panel {
  position: relative;
  width: min(560px, 100%); max-height: min(80vh, 720px);
  background: #fff; border-radius: 14px;
  padding: 1.1rem 1.2rem 1.2rem;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}

.ct-modal-head { display: flex; align-items: center; justify-content: space-between; }
.ct-modal-head h2 { margin: 0; font-size: 1rem; color: var(--ct-ink); }
.ct-modal-close { border: 0; background: none; font-size: 1.4rem; line-height: 1; color: #94a3b8; cursor: pointer; padding: 0 0.2rem; }
.ct-modal-lead { margin: 0.4rem 0 0.8rem; font-size: 0.78rem; color: var(--ct-sub); }

.ct-sample-list { overflow-y: auto; display: flex; flex-direction: column; gap: 0.5rem; }

.ct-sample {
  text-align: left; width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--ct-line); border-radius: 9px;
  background: #fff; cursor: pointer; font-family: inherit;
}
.ct-sample:hover { border-color: var(--ct-gold); background: #fffdf8; }
.ct-sample strong { display: block; font-size: 0.82rem; color: #8a6a24; margin-bottom: 0.25rem; }
.ct-sample span { display: block; font-size: 0.76rem; color: #64748b; line-height: 1.65; white-space: pre-wrap; }

/* ------------------------------------------------------------ toast --- */

.ct-toast {
  position: fixed; left: 50%; bottom: 5.2rem; transform: translateX(-50%);
  z-index: 80;
  padding: 0.6rem 1.1rem;
  background: rgba(30, 41, 59, 0.94); color: #fff;
  border-radius: 999px; font-size: 0.82rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
}
.ct-toast[hidden] { display: none; }

/* ------------------------------------------------------- 説明セクション --- */

.ct-section { margin: 2rem 0; }
.ct-section > h2 { font-size: 1.15rem; color: var(--ct-ink); margin: 0 0 0.9rem; }

.ct-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.8rem; }
.ct-grid article { background: #fff; border: 1px solid var(--ct-line); border-radius: var(--ct-radius); padding: 1rem; }
.ct-grid article > span {
  display: inline-block; margin-bottom: 0.4rem;
  padding: 0.1rem 0.5rem; border-radius: 999px;
  background: var(--ct-gold-soft); color: #8a6a24;
  font-size: 0.68rem; font-weight: 700;
}
.ct-grid h3 { font-size: 0.92rem; color: var(--ct-ink); margin: 0 0 0.35rem; }
.ct-grid p { font-size: 0.8rem; color: var(--ct-sub); line-height: 1.7; margin: 0; }

.ct-steps-doc { list-style: none; counter-reset: s; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.ct-steps-doc li {
  counter-increment: s;
  background: #fff; border: 1px solid var(--ct-line); border-radius: var(--ct-radius);
  padding: 0.85rem 1rem 0.85rem 2.8rem; position: relative;
}
.ct-steps-doc li::before {
  content: counter(s);
  position: absolute; left: 0.9rem; top: 0.9rem;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--ct-gold); color: #fff;
  font-size: 0.75rem; font-weight: 700; text-align: center; line-height: 22px;
}
.ct-steps-doc strong { display: block; font-size: 0.9rem; color: var(--ct-ink); margin-bottom: 0.2rem; }
.ct-steps-doc span { font-size: 0.8rem; color: var(--ct-sub); line-height: 1.7; }

.ct-related { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.7rem; }
.ct-related a {
  display: block; padding: 0.85rem 1rem;
  background: #fff; border: 1px solid var(--ct-line); border-radius: var(--ct-radius);
  text-decoration: none;
}
.ct-related a:hover { border-color: var(--ct-gold); }
.ct-related strong { display: block; font-size: 0.88rem; color: var(--ct-ink); margin-bottom: 0.15rem; }
.ct-related span { font-size: 0.76rem; color: var(--ct-sub); }

/* ------------------------------------------------------- レスポンシブ --- */

@media (max-width: 1240px) {
  .ct-workspace { grid-template-columns: minmax(320px, 380px) minmax(0, 1fr); }
  .ct-steps { grid-column: 1 / -1; }
  .ct-step-list { display: flex; gap: 0.2rem; overflow-x: auto; }
  .ct-step-list li { flex: 1 1 0; min-width: 132px; }
  .ct-step-list li + li::before { display: none; }
  .ct-tip { display: none; }
}

@media (max-width: 900px) {
  .ct-workspace { grid-template-columns: minmax(0, 1fr); padding: 0.4rem 0.9rem 1rem; }
  .ct-preview { position: static; height: auto; min-height: 0; order: 3; }
  .ct-form { order: 2; }
  .ct-steps { order: 1; }
  .ct-stage { max-height: 62vh; }
  .ct-appbar-inner { padding: 0.6rem 0.9rem; }
  .ct-actionbar-inner { padding: 0.6rem 0.9rem; justify-content: stretch; }
  .ct-actionbar-inner .ct-btn { flex: 1 1 auto; }
  .ct-actionbar-inner #btn-png { display: none; }
  .ct-brand h1 { font-size: 1rem; }
}

@media (max-width: 520px) {
  .ct-kinds { grid-template-columns: repeat(3, 1fr); }
  .ct-field-split { grid-template-columns: 1fr; }
  .ct-seg button { flex: 1; padding: 0.55rem 0.4rem; }
  .ct-seg { display: flex; width: 100%; }
}

/* --------------------------------------------------------------- 印刷 --- */

#cert-print-root { display: none; }

@media print {
  body { background: #fff !important; margin: 0 !important; padding: 0 !important; }
  body > *:not(#cert-print-root) { display: none !important; }
  #cert-print-root { display: block !important; }
  #cert-print-root svg { display: block; }
}
