:root {
  --bg: #f6f7fa;
  --surface: #ffffff;
  --surface-muted: #eef1f6;
  --text: #18202f;
  --muted: #687386;
  --line: #dfe4ec;
  --accent: #3447d4;
  --accent-dark: #2535aa;
  --japan-red: #d83a3a;
  --shadow: 0 18px 55px rgba(24, 32, 47, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Noto Sans JP", Arial, sans-serif;
}

button,
textarea,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px 20px;
  background: #111827;
  color: #f8fafc;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: #ffffff url("./assets/nihondocs-logo.svg") center / cover no-repeat;
  border-radius: 50%;
  font-family: "Noto Sans JP", sans-serif;
  font-weight: 700;
  color: transparent;
  overflow: hidden;
}

.brand-mark::before {
  content: none;
  color: #ffffff;
  font-family: "Material Symbols Rounded";
  font-size: 24px;
  font-weight: 500;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 2px;
  color: #aeb8c8;
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.sidebar .nav-list {
  display: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  font-family: "Noto Sans JP", sans-serif;
  font-size: 13px;
}

.sidebar-note {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-note span,
.section-label,
.template-box span,
.score-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar-note span {
  color: #aeb8c8;
}

.sidebar-note strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
}

.sidebar-note p {
  margin: 8px 0 0;
  color: #cbd5e1;
  font-size: 13px;
  line-height: 1.55;
}

.main-panel {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.18;
  letter-spacing: 0;
}

.topbar p {
  margin-top: 8px;
  max-width: 720px;
  color: var(--muted);
  line-height: 1.55;
}

.topbar-actions,
.preview-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.primary-button,
.ghost-button,
.icon-button {
  min-height: 40px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 700;
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  padding: 0 16px;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.ghost-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 0 16px;
}

.compact {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
}

.preview-eye-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  padding: 0;
}

.material-symbol {
  font-family: "Material Symbols Rounded";
  font-size: 20px;
  font-weight: 500;
  line-height: 1;
}

.icon-button {
  width: 40px;
  border: 1px solid var(--line);
  background: var(--surface-muted);
  color: var(--text);
  font-size: 20px;
}

.document-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.main-panel > .document-strip {
  display: none;
}

.sidebar .document-strip {
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 0;
}

.api-status {
  margin: -8px 0 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: #465165;
  font-size: 13px;
  font-weight: 700;
}

.api-status.loading {
  border-color: rgba(52, 71, 212, 0.35);
  color: var(--accent);
}

.api-status.success {
  border-color: rgba(32, 128, 76, 0.35);
  color: #20804c;
}

.api-status.error {
  border-color: rgba(216, 58, 58, 0.35);
  color: #b22a2a;
}

.doc-tab {
  min-height: 78px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  box-shadow: 0 8px 24px rgba(24, 32, 47, 0.04);
}

.sidebar .doc-tab {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  column-gap: 10px;
  min-height: 64px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.13);
  color: #ffffff;
  box-shadow: none;
}

.sidebar .doc-tab::before {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-family: "Material Symbols Rounded";
  font-size: 22px;
  font-weight: 500;
  line-height: 1;
}

.sidebar .doc-tab[data-doc="cv"]::before {
  content: "description";
}

.sidebar .doc-tab[data-doc="kk"]::before {
  content: "family_restroom";
}

.sidebar .doc-tab[data-doc="ijazah"]::before {
  content: "school";
}

.sidebar .doc-tab[data-doc="paspor"]::before {
  content: "id_card";
}

.sidebar .doc-tab[data-doc="lain"]::before {
  content: "folder_copy";
}

.sidebar .doc-tab[data-doc="template"]::before {
  content: "auto_awesome";
}

.doc-tab span,
.doc-tab strong {
  display: block;
}

.doc-tab span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.sidebar .doc-tab span {
  color: #aeb8c8;
}

.doc-tab strong {
  margin-top: 8px;
  font-family: "Noto Sans JP", sans-serif;
  font-size: 18px;
}

.sidebar .doc-tab strong {
  display: none;
}

.doc-tab.active {
  border-color: rgba(52, 71, 212, 0.55);
  box-shadow: 0 14px 34px rgba(52, 71, 212, 0.14);
}

.sidebar .doc-tab.active {
  border-color: rgba(255, 255, 255, 0.32);
  background: #ffffff;
  color: #111827;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.18);
}

.sidebar .doc-tab.active span {
  color: #5b6678;
}

.sidebar .doc-tab.active strong {
  display: none;
}

.sidebar .doc-tab.active::before {
  background: #eef1f6;
  color: var(--accent);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(330px, 1.05fr) minmax(360px, 1.1fr) 280px;
  gap: 16px;
  align-items: start;
}

.workspace-grid:has(.kk-paper) {
  grid-template-columns: minmax(330px, 0.82fr) minmax(720px, 1.55fr);
}

.workspace-grid:has(.kk-paper) .quality-panel {
  grid-column: 1 / -1;
}

body.template-mode .workspace-grid {
  grid-template-columns: minmax(330px, 1.05fr) minmax(0, 1.35fr);
}

body.template-mode .quality-panel {
  display: none;
}

body.template-blank-mode .workspace-grid {
  grid-template-columns: 1fr;
  gap: 0;
}

body.template-blank-mode .editor-panel,
body.template-blank-mode .preview-panel {
  min-height: calc(100vh - 220px);
  padding: 0;
  border: none;
  border-radius: 0;
  background: #ffffff;
  box-shadow: none;
}

body.template-blank-mode .editor-panel > *,
body.template-blank-mode .preview-panel > * {
  display: none !important;
}

body.template-blank-mode .quality-panel {
  display: none !important;
}

body.template-blank-mode .workspace-grid,
body.template-blank-mode .editor-panel,
body.template-blank-mode .preview-panel {
  background: #ffffff;
}

.editor-panel,
.preview-panel,
.quality-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.editor-panel,
.preview-panel {
  padding: 18px;
}

.preview-panel {
  overflow-x: auto;
}

.quality-panel {
  padding: 16px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.panel-heading h2 {
  margin-top: 5px;
  font-size: 18px;
  line-height: 1.25;
}

.panel-heading.tight {
  margin-bottom: 14px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

#field-grid.cv-form-grid {
  display: block;
}

#field-grid.kk-form-grid {
  display: block;
}

#field-grid.kk-form-grid .field-grid {
  grid-template-columns: 1fr;
}

.input-section {
  margin-bottom: 18px;
}

.input-section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  color: #1f2a3d;
  font-size: 15px;
}

.section-with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-with-action h3 {
  flex: 1;
}

.photo-drop {
  position: relative;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 132px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px dashed #aeb8c8;
  border-radius: var(--radius);
  background: #fbfcfe;
}

.photo-drop:hover,
.photo-drop.dragging {
  border-color: rgba(52, 71, 212, 0.75);
  background: #f6f8ff;
}

.photo-drop input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.photo-frame {
  position: relative;
  display: grid;
  place-items: center;
  width: 84px;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(52, 71, 212, 0.08), transparent),
    #ffffff;
  color: #687386;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
}

.photo-frame img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-frame.has-photo span {
  display: none;
}

.photo-frame.has-photo img {
  display: block;
}

.photo-copy strong {
  display: block;
  font-size: 15px;
}

.photo-copy p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.kk-scan-drop {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px dashed #aeb8c8;
  border-radius: var(--radius);
  background: #fbfcfe;
}

.kk-scan-drop:hover,
.kk-scan-drop.dragging {
  border-color: rgba(52, 71, 212, 0.75);
  background: #f6f8ff;
}

.kk-scan-drop.ready {
  border-color: rgba(22, 163, 74, 0.55);
  background: #f4fbf7;
}

.kk-scan-drop input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.kk-scan-drop button {
  position: relative;
  z-index: 1;
}

.kk-scan-drop button.ready {
  border-color: rgba(52, 71, 212, 0.36);
  background: #3447d4;
  color: #ffffff;
  animation: ocr-ready-pulse 1.45s ease-in-out infinite;
}

.kk-scan-drop button.ready:hover {
  background: var(--accent-dark);
}

.scan-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  background: #e8ebf8;
  color: var(--accent);
  font-family: "Material Symbols Rounded";
  font-size: 24px;
}

.kk-scan-drop.ready .scan-icon {
  background: #dcfce7;
  color: #15803d;
}

.kk-scan-drop strong {
  display: block;
  font-size: 15px;
}

.kk-scan-drop p,
.scan-status {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.kk-scan-drop.ready p {
  color: #047857;
  font-weight: 800;
}

.scan-status {
  margin: -6px 0 16px;
}

@keyframes ocr-ready-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(52, 71, 212, 0.28);
    transform: translateY(0);
  }

  50% {
    box-shadow: 0 0 0 5px rgba(52, 71, 212, 0.08);
    transform: translateY(-1px);
  }
}

.form-field {
  display: grid;
  gap: 7px;
}

.kk-member-list {
  display: grid;
  gap: 12px;
}

.kk-format-note {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.kk-member-card {
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
}

.member-card-head {
  display: grid;
  grid-template-columns: 24px auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  border: 0;
  padding: 0 12px;
  background: #ffffff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.member-card-head:hover {
  background: #f6f8ff;
}

.member-card-head strong {
  font-size: 14px;
}

.member-card-head span:last-child {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-toggle-icon {
  color: var(--accent);
  font-family: "Material Symbols Rounded";
  font-size: 22px;
  line-height: 1;
  transition: transform 0.18s ease;
}

.member-card-head[aria-expanded="true"] .member-toggle-icon {
  transform: rotate(180deg);
}

.kk-member-body {
  display: none;
  padding: 12px;
  border-top: 1px solid #e1e6ef;
}

.kk-member-body.open {
  display: block;
}

.member-card-tools {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.add-member-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(52, 71, 212, 0.18);
}

.add-member-button:hover {
  background: var(--accent-dark);
}

.add-member-button span {
  font-family: "Material Symbols Rounded";
  font-size: 17px;
  line-height: 1;
}

.kk-member-subsection {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid #e1e6ef;
}

.kk-member-subsection + .kk-member-subsection {
  margin-top: 12px;
}

.kk-member-subsection h4 {
  margin: 0;
  color: #1d2738;
  font-size: 13px;
}

.member-grid {
  margin-bottom: 0;
}

.form-field label,
.text-editor span {
  color: #465165;
  font-size: 12px;
  font-weight: 700;
}

.form-field input,
.form-field select,
.mini-table-row input,
.mini-table-row select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  color: var(--text);
  background: #fbfcfe;
  outline: none;
}

.ghost-button:disabled,
.primary-button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.form-field input:focus,
.form-field select:focus,
.mini-table-row input:focus,
.mini-table-row select:focus,
.text-editor textarea:focus {
  border-color: rgba(52, 71, 212, 0.7);
  box-shadow: 0 0 0 3px rgba(52, 71, 212, 0.1);
}

.help-dot {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid #b8c1d1;
  border-radius: 50%;
  background: #ffffff;
  color: #5b6678;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.help-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.45);
}

.help-modal {
  width: min(420px, 100%);
  padding: 20px;
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 24px 80px rgba(17, 24, 39, 0.28);
}

.help-modal h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.help-modal p {
  color: #465165;
  line-height: 1.6;
}

.help-modal button {
  min-height: 38px;
  margin-top: 16px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: #ffffff;
  padding: 0 14px;
  font-weight: 800;
}

.long-input-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.48);
}

.long-input-modal {
  width: min(720px, 100%);
  padding: 18px;
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 28px 90px rgba(17, 24, 39, 0.3);
}

.long-input-header,
.long-input-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.long-input-header h3 {
  margin: 0;
  font-size: 18px;
}

.long-input-modal textarea {
  width: 100%;
  min-height: 190px;
  margin: 14px 0;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfe;
  color: var(--text);
  font: inherit;
  line-height: 1.55;
  outline: none;
}

.long-input-modal textarea:focus {
  border-color: rgba(52, 71, 212, 0.7);
  box-shadow: 0 0 0 3px rgba(52, 71, 212, 0.1);
}

.long-input-actions span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.donation-card {
  display: grid;
  gap: 14px;
  padding: 22px;
  border: 1px solid rgba(52, 71, 212, 0.18);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(52, 71, 212, 0.08), rgba(22, 163, 74, 0.08)),
    #ffffff;
  box-shadow: 0 18px 42px rgba(17, 24, 39, 0.08);
}

.donation-badge {
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.donation-card h3 {
  margin: 0;
  color: var(--text);
  font-size: 24px;
  line-height: 1.12;
}

.donation-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.donation-account {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid #dbe2ee;
  border-radius: var(--radius);
  background: #fbfcfe;
}

.donation-account span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.donation-account strong {
  color: var(--text);
  font-size: 26px;
  letter-spacing: 0.04em;
}

.copy-donation {
  width: fit-content;
}

.donation-copy-status {
  min-height: 18px;
  color: #047857;
  font-weight: 800;
}

.donation-preview {
  display: grid;
  place-items: center;
  min-height: 420px;
  padding: 36px;
  text-align: center;
}

.donation-preview > span {
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.donation-preview h3 {
  margin: 10px 0 0;
  font-size: 28px;
}

.donation-preview p {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.donation-preview div {
  display: grid;
  gap: 4px;
  min-width: 280px;
  margin: 12px 0;
  padding: 16px;
  border: 1px solid #dbe2ee;
  border-radius: var(--radius);
  background: #fbfcfe;
}

.donation-preview small {
  color: var(--muted);
  font-weight: 800;
}

.donation-preview strong {
  font-size: 28px;
  letter-spacing: 0.04em;
}

.donation-thanks {
  color: #047857 !important;
  font-weight: 800;
}

.backup-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.45);
}

.backup-modal {
  width: min(560px, 100%);
  max-height: min(680px, 88vh);
  overflow: auto;
  padding: 18px;
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 28px 90px rgba(17, 24, 39, 0.3);
}

.backup-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.backup-modal-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.backup-modal-head h3 {
  margin: 4px 0 0;
  font-size: 20px;
}

.backup-list {
  display: grid;
  gap: 10px;
}

.backup-item {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfe;
  color: var(--text);
  text-align: left;
}

.backup-item:hover {
  border-color: rgba(52, 71, 212, 0.45);
  background: #f6f8ff;
}

.backup-item strong {
  font-size: 15px;
}

.backup-item span,
.backup-empty p {
  color: var(--muted);
  font-size: 13px;
}

.backup-empty {
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px dashed #aeb8c8;
  border-radius: var(--radius);
  background: #fbfcfe;
}

.preview-modal-open {
  overflow: hidden;
}

.preview-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.64);
}

.preview-modal {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1180px, 100%);
  max-height: 94vh;
  overflow: hidden;
  border-radius: 10px;
  background: #f6f7fa;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

.preview-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.preview-modal-head h3 {
  margin: 4px 0 0;
  font-size: 17px;
}

.preview-modal-scroll {
  overflow: auto;
  padding: 18px;
}

.preview-modal-scroll .document-paper {
  margin: 0 auto;
  box-shadow: 0 18px 52px rgba(24, 32, 47, 0.14);
}

.preview-modal-scroll .document-paper.kk-paper {
  width: min(1120px, 100%);
  min-width: 920px;
}

.mini-table-editor {
  display: grid;
  gap: 8px;
}

.mini-table-head,
.mini-table-row {
  display: grid;
  gap: 8px;
  align-items: center;
}

.three-cols,
.four-cols,
.six-cols {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mini-table-head {
  display: none;
}

.mini-table-row {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
}

.mini-table-row input,
.mini-table-row select {
  min-height: 38px;
  padding: 0 9px;
  font-size: 13px;
}

.add-row-button {
  min-height: 36px;
  margin-top: 10px;
  border: 1px dashed #aeb8c8;
  border-radius: var(--radius);
  background: #fbfcfe;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.remove-row-button,
.remove-row {
  min-height: 34px;
  border: 1px solid rgba(216, 58, 58, 0.28);
  border-radius: var(--radius);
  background: #fff7f7;
  color: #b22a2a;
  font-size: 12px;
  font-weight: 800;
}

.add-row-button:hover {
  border-color: var(--accent);
  background: #f6f8ff;
}

.inline-select-label {
  display: grid;
  gap: 6px;
  color: #465165;
  font-size: 11px;
  font-weight: 800;
}

.text-editor {
  display: grid;
  gap: 8px;
}

.text-editor textarea {
  width: 100%;
  min-height: 245px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #fbfcfe;
  color: var(--text);
  line-height: 1.6;
  outline: none;
}

.document-paper {
  min-height: 552px;
  padding: 24px;
  border: 1px solid #d7dce5;
  background: #ffffff;
  color: #1d2738;
  box-shadow: inset 0 0 0 1px rgba(24, 32, 47, 0.02);
}

.document-paper.cv-paper {
  padding: 18px;
  color: #0f172a;
}

.document-paper.kk-paper {
  container-type: inline-size;
  width: 100%;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 297 / 210;
  padding: 1.84cqw;
  color: #0f172a;
}

.cv-paper .paper-header,
.kk-paper .paper-header {
  display: none;
}

.cv-paper .paper-header span {
  font-size: 20px;
}

.rirekisho-page {
  font-family: "Noto Sans JP", Inter, sans-serif;
  font-size: 9.5px;
  line-height: 1.25;
}

.cv-date-row,
.cv-title-row,
.cv-sign-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.cv-date-row {
  margin-bottom: 4px;
  color: #111827;
  font-size: 10px;
}

.cv-title-row {
  position: relative;
  align-items: flex-start;
  justify-content: center;
  min-height: 43mm;
  margin-bottom: 8px;
  padding-top: 24px;
}

.cv-title-row h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
  text-align: center;
}

.cv-title-row small,
.cv-main-table small {
  color: #334155;
  font-size: 8px;
  font-weight: 600;
}

.cv-title-row h3 small {
  display: block;
  margin-top: 2px;
}

.cv-paper .paper-photo {
  position: absolute;
  top: 0;
  right: 0;
  width: 30mm;
  min-height: 40mm;
  border: 1.4px solid #111827;
  background: #ffffff;
  color: #111827;
  font-size: 9px;
  font-weight: 800;
}

.cv-main-table,
.cv-section-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  margin-bottom: 6px;
  color: #111827;
}

.cv-main-table th,
.cv-main-table td,
.cv-section-table th,
.cv-section-table td {
  border: 1.2px solid #111827;
  padding: 3.5px 4px;
  vertical-align: middle;
  word-break: break-word;
}

.cv-main-table th,
.cv-section-table thead th {
  background: #f7f8fb;
  font-weight: 800;
  text-align: left;
}

.cv-main-table td,
.cv-section-table td {
  min-height: 22px;
  font-weight: 600;
}

.compact-cv-table th,
.compact-cv-table td {
  padding-top: 3px;
  padding-bottom: 3px;
}

.cv-section-table thead tr:first-child th {
  background: #e8ebf1;
  font-size: 11px;
}

.school-level {
  color: rgba(17, 24, 39, 0.46);
  font-weight: 700;
}

.family-table {
  margin-bottom: 5px;
}

.cv-sign-row {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1.2px solid #111827;
  font-size: 10px;
  font-weight: 700;
}

.paper-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.paper-meta div {
  min-height: 54px;
  padding: 8px;
  border: 1px solid #dfe4ec;
  font-family: "Noto Sans JP", sans-serif;
  font-size: 12px;
}

.paper-photo {
  display: grid;
  place-items: center;
  min-height: 92px;
  aspect-ratio: 3 / 4;
  overflow: hidden;
}

.paper-photo img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.paper-photo.has-photo span {
  display: none;
}

.paper-photo.has-photo img {
  display: block;
}

.paper-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 2px solid #111827;
  font-family: "Noto Sans JP", sans-serif;
}

.paper-header span {
  font-size: 24px;
  font-weight: 700;
}

.paper-header strong {
  color: var(--japan-red);
  font-size: 13px;
}

.jp-section {
  margin-bottom: 18px;
}

.jp-section h3 {
  margin: 0 0 8px;
  padding: 7px 10px;
  background: #f1f3f7;
  font-family: "Noto Sans JP", sans-serif;
  font-size: 15px;
}

.jp-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-family: "Noto Sans JP", sans-serif;
  font-size: 12px;
}

.jp-table th,
.jp-table td {
  padding: 7px 8px;
  border: 1px solid #dfe4ec;
  vertical-align: top;
}

.jp-table th {
  background: #f1f3f7;
  color: #1d2738;
  text-align: left;
  font-weight: 700;
}

.kk-paper .paper-header span {
  font-size: 18px;
}

.kk-translation-page {
  font-family: "Noto Sans JP", Inter, sans-serif;
  font-size: 11px;
  line-height: 1.35;
}

.kk-title-block {
  margin-bottom: 14px;
  text-align: center;
}

.kk-title-block p,
.kk-title-block h3 {
  margin: 0;
}

.kk-title-block h3 {
  margin-top: 3px;
  font-size: 20px;
}

.kk-title-block span {
  display: block;
  margin-top: 6px;
  color: #596579;
  font-size: 11px;
}

.kk-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.kk-summary-grid div {
  min-height: 54px;
  padding: 8px;
  border: 1px solid #dfe4ec;
  background: #fbfcfe;
}

.kk-summary-grid span {
  display: block;
  margin-bottom: 5px;
  color: #596579;
  font-size: 10px;
  font-weight: 700;
}

.kk-summary-grid strong {
  font-size: 13px;
}

.kk-member-preview {
  font-size: 9.5px;
  table-layout: fixed;
}

.kk-member-preview th,
.kk-member-preview td {
  padding: 5px;
  word-break: break-word;
}

.kk-member-preview.secondary {
  margin-top: -6px;
}

.translation-cert {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1.2px solid #111827;
  font-family: "Noto Sans JP", sans-serif;
  font-size: 11px;
}

.translation-cert h3 {
  margin: 0 0 6px;
  font-size: 13px;
}

.translation-cert p {
  margin: 0 0 8px;
}

.translation-cert div {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.kk-reference-page {
  font-family: Arial, "Noto Sans JP", sans-serif;
  color: #000000;
  font-size: 8.2px;
  line-height: 1.12;
}

.kk-ref-header {
  display: grid;
  grid-template-columns: 1fr 270px 1fr;
  align-items: start;
  min-height: 66px;
}

.kk-ref-title {
  text-align: center;
}

.kk-ref-title h3,
.kk-ref-title strong,
.kk-ref-title em,
.kk-ref-title span {
  display: block;
  margin: 0;
  font-style: normal;
}

.kk-ref-title h3 {
  font-size: 13px;
  font-weight: 800;
}

.kk-ref-title span {
  margin-top: 1px;
  font-size: 7px;
}

.kk-ref-title strong {
  margin-top: 3px;
  font-size: 8px;
  font-weight: 800;
}

.kk-ref-title em {
  margin-top: 2px;
  font-size: 8px;
  font-weight: 700;
}

.kk-ref-serial {
  padding-top: 26px;
  text-align: left;
  font-weight: 700;
  white-space: nowrap;
}

.kk-ref-identity {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 88px;
  margin: -15px 28px 12px;
}

.kk-ref-info-list {
  display: grid;
  gap: 3px;
}

.kk-ref-info-list div {
  display: grid;
  grid-template-columns: 145px 10px minmax(0, 1fr);
  align-items: start;
}

.kk-ref-info-list span {
  font-weight: 700;
}

.kk-ref-info-list small {
  display: block;
  margin-top: 1px;
  font-size: 7px;
  font-weight: 700;
}

.kk-ref-info-list b,
.kk-ref-info-list strong {
  font-size: 8px;
}

.kk-ref-info-list strong {
  min-height: 11px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.kk-ref-table {
  width: 100%;
  margin: 0 0 13px;
  border-collapse: collapse;
  table-layout: fixed;
  border: 2px solid #000000;
  font-size: 7.5px;
}

.kk-ref-table th,
.kk-ref-table td {
  height: 14px;
  padding: 2px 3px;
  border: 1px solid #000000;
  color: #000000;
  text-align: center;
  vertical-align: middle;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.kk-ref-table th {
  background: #ffffff;
  font-weight: 800;
}

.kk-ref-table small {
  font-size: 6.6px;
  font-weight: 700;
}

.kk-ref-table tbody td {
  font-weight: 700;
}

.kk-ref-family-table {
  margin-top: 0;
}

.kk-col-no {
  width: 3.2%;
}

.kk-col-name {
  width: 18%;
}

.kk-col-nik {
  width: 11.5%;
}

.kk-col-gender {
  width: 7.5%;
}

.kk-col-place,
.kk-col-date,
.kk-col-religion {
  width: 10%;
}

.kk-col-education {
  width: 14.5%;
}

.kk-col-job {
  width: 15.3%;
}

.kk-col-marital {
  width: 18%;
}

.kk-col-relation {
  width: 11.5%;
}

.kk-col-nationality {
  width: 17.5%;
}

.kk-col-passport,
.kk-col-kitas {
  width: 10%;
}

.kk-col-parent {
  width: 14.9%;
}

.kk-ref-footer {
  display: grid;
  grid-template-columns: 1fr 1.05fr 1.55fr;
  gap: 26px;
  padding: 18px 30px 0;
  font-size: 7.4px;
}

.kk-ref-footer p {
  margin: 0 0 4px;
}

.kk-ref-issued strong {
  margin-left: 50px;
}

.kk-ref-page-list {
  display: grid;
  grid-template-columns: 18px auto;
  gap: 2px 20px;
  margin-left: 145px;
  font-weight: 700;
}

.kk-ref-signature {
  display: grid;
  min-height: 110px;
  text-align: center;
}

.kk-ref-signature p {
  font-weight: 700;
}

.kk-ref-signature strong {
  align-self: end;
  display: block;
  text-decoration: underline;
  font-size: 7.5px;
}

.kk-ref-signature small {
  font-size: 6.5px;
  font-weight: 700;
}

.kk-paper .kk-reference-page {
  font-size: 0.84cqw;
}

.kk-paper .kk-ref-header {
  grid-template-columns: 1fr 27.5cqw 1fr;
  min-height: 6.73cqw;
}

.kk-paper .kk-ref-title h3 {
  font-size: 1.33cqw;
}

.kk-paper .kk-ref-title span,
.kk-paper .kk-ref-info-list small,
.kk-paper .kk-ref-table small,
.kk-paper .kk-ref-signature small {
  font-size: 0.67cqw;
}

.kk-paper .kk-ref-title strong,
.kk-paper .kk-ref-title em,
.kk-paper .kk-ref-info-list b,
.kk-paper .kk-ref-info-list strong {
  font-size: 0.82cqw;
}

.kk-paper .kk-ref-serial {
  padding-top: 2.65cqw;
}

.kk-paper .kk-ref-identity {
  gap: 8.98cqw;
  margin: -1.53cqw 2.86cqw 1.22cqw;
}

.kk-paper .kk-ref-info-list {
  gap: 0.31cqw;
}

.kk-paper .kk-ref-info-list div {
  grid-template-columns: 14.8cqw 1.02cqw minmax(0, 1fr);
}

.kk-paper .kk-ref-table {
  margin-bottom: 1.33cqw;
  border-width: 0.2cqw;
  font-size: 0.76cqw;
}

.kk-paper .kk-ref-table th,
.kk-paper .kk-ref-table td {
  height: 1.43cqw;
  padding: 0.2cqw 0.31cqw;
}

.kk-paper .kk-ref-footer {
  gap: 2.65cqw;
  padding: 1.84cqw 3.06cqw 0;
  font-size: 0.76cqw;
}

.kk-paper .kk-ref-footer p {
  margin-bottom: 0.41cqw;
}

.kk-paper .kk-ref-issued strong {
  margin-left: 5.1cqw;
}

.kk-paper .kk-ref-page-list {
  grid-template-columns: 1.84cqw auto;
  gap: 0.2cqw 2.04cqw;
  margin-left: 14.8cqw;
}

.kk-paper .kk-ref-signature {
  min-height: 11.22cqw;
}

.kk-paper .kk-ref-signature strong {
  font-size: 0.77cqw;
}

.jp-row {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  border-bottom: 1px solid #e5e9f0;
  font-family: "Noto Sans JP", sans-serif;
  font-size: 14px;
}

.jp-row span,
.jp-row strong {
  padding: 8px 10px;
}

.jp-row span {
  color: #596579;
  font-weight: 500;
}

.jp-row strong {
  font-weight: 600;
}

.score-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
}

.score-card strong {
  display: block;
  margin: 6px 0 10px;
  font-size: 32px;
}

.score-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4e8f0;
}

.score-bar span {
  display: block;
  width: 86%;
  height: 100%;
  background: var(--accent);
}

.checklist {
  display: grid;
  gap: 11px;
  margin: 16px 0;
}

.format-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.format-list button {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: #2d384a;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
}

.format-list span {
  color: #9aa5b5;
  font-weight: 800;
}

.format-list strong {
  padding: 4px 7px;
  border-radius: 6px;
  background: #eef8f1;
  color: #20804c;
  font-size: 11px;
}

.format-list button:nth-child(3) strong {
  background: #fff4df;
  color: #9d6400;
}

.format-list button:nth-child(4) strong {
  background: #fff0f0;
  color: #b22a2a;
}

.checklist label {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #3d4758;
  font-size: 13px;
  font-weight: 600;
}

.checklist input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.template-box {
  padding: 14px;
  border-radius: var(--radius);
  background: #111827;
  color: white;
}

.template-box span {
  color: #aeb8c8;
}

.template-box strong {
  display: block;
  margin-top: 6px;
  font-size: 16px;
}

.template-box p {
  margin-top: 8px;
  color: #d4dbe7;
  font-size: 13px;
  line-height: 1.55;
}

.template-builder {
  display: grid;
  gap: 14px;
}

.template-blank-stage,
.template-blank-preview {
  min-height: 70vh;
  background: #ffffff;
}

.template-start-empty {
  display: grid;
  gap: 12px;
}

.template-start-empty-card {
  display: grid;
  gap: 10px;
  padding: 20px;
  border: 1px solid #d9dfeb;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, #f8faff);
  box-shadow: 0 10px 24px rgba(15, 29, 51, 0.04);
}

.template-start-empty-kicker {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.template-start-empty-card h4 {
  color: #18202f;
  font-size: 24px;
  font-weight: 800;
}

.template-start-empty-card p {
  max-width: 720px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.template-start-empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.template-empty-canvas {
  display: grid;
  gap: 10px;
  place-items: center;
  min-height: 280px;
  padding: 28px 20px;
  border: 1px dashed #c9d2e1;
  border-radius: 12px;
  background: #fbfcfe;
  text-align: center;
}

.template-empty-canvas strong {
  color: #18202f;
  font-size: 18px;
  font-weight: 800;
}

.template-empty-canvas p {
  max-width: 520px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.template-empty-canvas-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.template-gallery-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border: 1px solid #d9dfeb;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, #f8faff);
}

.template-gallery-head span {
  display: block;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.template-gallery-head h3 {
  margin-top: 4px;
  color: #18202f;
  font-size: 24px;
  font-weight: 800;
}

.template-gallery-head p {
  max-width: 720px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.template-gallery-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.template-preset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.template-preset-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #d9dfeb;
  border-radius: var(--radius);
  background: #ffffff;
  text-align: left;
  box-shadow: 0 8px 20px rgba(15, 29, 51, 0.04);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.template-preset-card:hover {
  transform: translateY(-1px);
  border-color: rgba(52, 71, 212, 0.34);
  box-shadow: 0 14px 30px rgba(15, 29, 51, 0.08);
}

.template-preset-card.is-selected {
  border-color: rgba(52, 71, 212, 0.72);
  box-shadow: 0 16px 36px rgba(52, 71, 212, 0.12);
  background: linear-gradient(180deg, #ffffff, #f5f8ff);
}

.template-preset-card-thumb {
  position: relative;
  min-height: 126px;
  padding: 12px;
  border: 1px solid #d9dfeb;
  border-radius: 12px;
  background: linear-gradient(180deg, #fbfcff, #f2f5fb);
  overflow: hidden;
}

.template-preset-card.is-selected .template-preset-card-thumb {
  border-color: rgba(52, 71, 212, 0.48);
  background: linear-gradient(180deg, #ffffff, #eef3ff);
}

.template-preset-card-thumb::before {
  content: "";
  position: absolute;
  inset: 10px 10px auto auto;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(214, 31, 44, 0.18), rgba(8, 31, 61, 0.12));
}

.thumb-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid #192033;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 800;
  color: #18202f;
  background: #ffffff;
}

.thumb-title {
  display: block;
  margin-top: 14px;
  color: #18202f;
  font-size: 13px;
  font-weight: 800;
}

.thumb-rule {
  display: block;
  margin-top: 12px;
  width: 100%;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, #d8ecf8, #c4dfef);
}

.thumb-block {
  position: absolute;
  left: 12px;
  right: 12px;
  border-radius: 4px;
  background: rgba(24, 32, 47, 0.08);
}

.thumb-block-wide {
  bottom: 28px;
  height: 18px;
}

.thumb-block-slim {
  bottom: 52px;
  height: 10px;
  right: 36%;
}

.thumb-block-grid {
  bottom: 74px;
  height: 8px;
  right: 24%;
}

.template-preset-card-body strong {
  display: block;
  color: #18202f;
  font-size: 15px;
}

.template-preset-card-body p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.template-preset-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.template-preset-card-meta span,
.template-reference-details summary,
.template-gallery-head-actions .template-pill {
  font-size: 12px;
}

.template-preset-card-meta span {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid #d9dfeb;
  border-radius: 999px;
  background: #f7f8fb;
  color: #33405a;
  font-weight: 700;
}

.template-reference-details {
  padding: 0;
  border: 1px solid #d9dfeb;
  border-radius: var(--radius);
  background: #fbfcfe;
  overflow: hidden;
}

.template-reference-details summary {
  padding: 14px 16px;
  color: #18202f;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

.template-reference-details summary::-webkit-details-marker {
  display: none;
}

.template-reference-details[open] summary {
  border-bottom: 1px solid #e1e7f2;
}

.template-reference-mini-grid {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.template-reference-drop.has-file {
  border-color: rgba(52, 71, 212, 0.42);
  background: linear-gradient(180deg, #f8faff, #f4f7ff);
}

.template-reference-drop {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px dashed #aeb8c8;
  border-radius: var(--radius);
  background: #fbfcfe;
}

.template-reference-drop:hover,
.template-reference-drop.dragging {
  border-color: rgba(52, 71, 212, 0.75);
  background: #f6f8ff;
}

.template-reference-drop > input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 0;
}

.template-reference-drop > *:not(input) {
  position: relative;
  z-index: 1;
}

.template-reference-drop .scan-icon {
  width: 42px;
  height: 42px;
}

.template-reference-copy strong {
  display: block;
  font-size: 15px;
}

.template-reference-copy p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.template-reference-drop button.ready {
  border-color: rgba(52, 71, 212, 0.36);
  background: #3447d4;
  color: #ffffff;
}

.template-reference-drop button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.template-reference-drop .template-reference-copy {
  min-width: 0;
}

.template-reference-drop .template-reference-copy strong {
  color: #18202f;
}

.template-reference-drop .template-reference-copy p {
  max-width: 780px;
}

.template-reference-drop .template-reference-mini-grid {
  grid-column: 1 / -1;
  padding: 0;
}

.template-reference-drop .template-notes-field {
  grid-column: 1 / -1;
}

.template-meta-grid {
  grid-template-columns: 1fr;
}

.template-notes-field {
  grid-column: 1 / -1;
}

.template-notes-field textarea {
  min-height: 120px;
}

.template-field-note {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.template-link-field {
  gap: 8px;
}

.template-link-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.template-link-head label {
  margin-bottom: 0;
}

.template-link-head button {
  flex: 0 0 auto;
  min-width: 88px;
  border: 0;
  background: linear-gradient(135deg, #162f7a, #c9252d);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(22, 47, 122, 0.22);
}

.template-link-head button.ready {
  background: linear-gradient(135deg, #243baf, #b91c1c);
  color: #ffffff;
  box-shadow: 0 14px 30px rgba(22, 47, 122, 0.24);
  animation: template-scan-button-pulse 1.5s ease-in-out infinite;
}

.template-link-head button:hover:not(:disabled) {
  filter: brightness(1.03);
  box-shadow: 0 12px 28px rgba(22, 47, 122, 0.28);
}

.template-link-head button:disabled {
  background: linear-gradient(135deg, #8c96a9, #b6bdca);
  color: #ffffff;
  opacity: 0.72;
}

.template-preview-mini select,
.template-meta-grid input,
.template-meta-grid textarea {
  width: 100%;
}

.template-hint {
  padding: 12px 14px;
  border: 1px solid rgba(52, 71, 212, 0.18);
  border-radius: var(--radius);
  background: #f7f8ff;
}

.template-hint span {
  display: block;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.template-hint p {
  margin-top: 6px;
  color: #1f2d57;
  font-size: 13px;
  line-height: 1.5;
}

.template-editor-shell {
  display: grid;
  gap: 16px;
}

.template-editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8faff;
}

.template-editor-toolbar-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.template-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef1f6;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

.template-editor-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ghost-button.icon-only {
  min-width: 38px;
  width: 38px;
  padding-inline: 0;
  display: inline-grid;
  place-items: center;
}

.template-editor-canvas {
  overflow: auto;
  padding: 18px;
  border: 1px solid #dce3ef;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.88)),
    linear-gradient(180deg, #eef3fb, #e8edf7);
}

.template-editor-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.template-page-frame {
  width: min(100%, var(--template-page-width));
  margin: 0 auto;
  border: 1px solid #d9dfeb;
  border-radius: 10px;
  background: var(--template-page-background, #ffffff);
  box-shadow: 0 18px 44px rgba(24, 32, 47, 0.09);
}

.template-page-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.template-page-surface {
  position: relative;
  width: 100%;
  height: var(--template-page-height);
  min-height: var(--template-page-height);
  margin-top: 12px;
  overflow: hidden;
}

.template-page-trace-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: #ffffff;
}

.template-page-reference-image,
.template-page-reference-pdf {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: contain;
  background: #ffffff;
}

.template-canvas-block {
  position: absolute;
  display: grid;
  gap: 8px;
  overflow: hidden;
  border: 1px solid rgba(215, 220, 229, 0.92);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(1px);
  z-index: 1;
}

.template-canvas-block.is-selected,
.template-canvas-table.is-selected,
.template-canvas-checkbox.is-selected,
.template-canvas-image.is-selected,
.template-canvas-heading.is-selected,
.template-canvas-note-card.is-selected,
.template-canvas-number-card.is-selected,
.template-canvas-text.is-selected,
.template-canvas-line.is-selected {
  box-shadow: 0 0 0 2px rgba(68, 93, 255, 0.28);
  border-color: #445dff !important;
}

.template-canvas-block-head {
  position: absolute;
  top: 4px;
  left: 4px;
  right: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.template-canvas-block:hover .template-canvas-block-head,
.template-canvas-block:focus-within .template-canvas-block-head {
  opacity: 1;
  pointer-events: auto;
}

.template-canvas-block-head strong {
  flex: 1;
  min-width: 0;
  color: #18202f;
  font-size: 14px;
}

.template-canvas-image {
  padding-bottom: 10px;
}

.template-canvas-header {
  background: rgba(255, 255, 255, 0.82);
}

.template-canvas-grip {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: #eef1f6;
  color: #475569;
  font-size: 14px;
  font-weight: 900;
  cursor: grab;
}

.template-canvas-block-body {
  display: grid;
  gap: 8px;
  padding: 0 10px 10px;
}

.template-canvas-heading {
  display: block;
  background: transparent;
  border: 0;
  overflow: visible;
}

.template-canvas-heading-text {
  min-height: 1em;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: inherit;
  font-size: 100%;
  font-weight: inherit;
  line-height: 1.1;
  text-align: center;
}

.template-canvas-plain {
  display: block;
  background: transparent;
  border: 0;
  overflow: visible;
}

.template-canvas-plain-text {
  min-height: 1em;
  width: 100%;
  height: 100%;
  display: block;
  color: inherit;
  font-size: 100%;
  font-weight: inherit;
  line-height: 1.35;
  text-align: inherit;
}

.template-canvas-number-card {
  display: grid;
  grid-template-rows: auto 1fr;
  align-content: stretch;
  background: #fff;
}

.template-canvas-number-card-label {
  border-bottom: 1px solid currentColor;
  min-height: 20px;
  padding: 2px 6px;
  font-size: 11px;
  line-height: 1.1;
  text-align: center;
}

.template-canvas-number-card-value {
  display: grid;
  place-items: center;
  min-height: 0;
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
  padding: 2px 6px 8px;
}

.template-canvas-note-card {
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.96);
}

.template-canvas-note-card-head {
  padding: 4px 8px 6px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  border-bottom: 1px solid currentColor;
}

.template-canvas-note-card-body {
  padding: 8px 10px 10px;
  min-height: 0;
  font-size: 14px;
  line-height: 1.5;
}

.template-canvas-block-label {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.template-canvas-block-value {
  min-height: 42px;
  padding: 8px 10px;
  border: 1px dashed #cdd5e1;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  color: #18202f;
  font-size: 13px;
  line-height: 1.45;
}

.template-canvas-block-value:empty::before {
  content: attr(data-placeholder);
  color: #94a3b8;
}

.template-canvas-table {
  padding-bottom: 10px;
}

.template-canvas-table-grid {
  margin: 0 10px 10px;
  border: 1px solid #d9dfeb;
  overflow: hidden;
}

.template-canvas-table-actual {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.template-canvas-table-actual td {
  min-height: 34px;
  vertical-align: middle;
  padding: 7px 8px;
  border-right: 1px solid #d9dfeb;
  border-bottom: 1px solid #d9dfeb;
  background: rgba(255, 255, 255, 0.88);
  color: #18202f;
  font-size: 12px;
}

.template-canvas-table-actual td.label {
  background: #eef1f6;
  font-weight: 700;
}

.template-canvas-table-actual td:last-child {
  border-right: 0;
}

.template-canvas-table-actual td span {
  display: block;
  min-height: 18px;
  outline: none;
  white-space: pre-line;
}

.template-choice-stack {
  display: grid;
  gap: 6px;
  align-content: start;
}

.template-choice-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.template-choice-box {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  border: 1.5px solid #1f2937;
  border-radius: 2px;
  background: #fff;
  padding: 0;
  flex: 0 0 auto;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
}

.template-choice-box span {
  width: 8px;
  height: 8px;
  border-radius: 1px;
  background: transparent;
  display: block;
}

.template-choice-item.is-checked .template-choice-box span {
  background: #111827;
}

.template-choice-label {
  min-width: 0;
  outline: none;
  white-space: pre-wrap;
  line-height: 1.4;
}

.template-choice-item.is-checked .template-choice-label {
  color: #111827;
}

.template-canvas-table-actual td.photo-cell {
  padding: 0;
}

.template-table-image-slot {
  position: relative;
  display: grid;
  align-items: stretch;
  justify-items: stretch;
  width: 100%;
  height: 100%;
  min-height: 100%;
  cursor: pointer;
}

.template-table-image-slot input {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.template-table-image-placeholder,
.template-table-image-preview {
  width: 100%;
  height: 100%;
  min-height: 100%;
}

.template-table-image-preview {
  object-fit: cover;
}

.template-table-image-placeholder {
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 10px;
  color: #64748b;
  text-align: center;
}

.template-table-image-placeholder strong {
  color: #0f172a;
  font-size: 12px;
}

.template-canvas-checkbox-list {
  display: grid;
  gap: 8px;
  padding: 0 10px 10px;
}

.template-canvas-checkbox-sheet {
  gap: 10px;
}

.template-canvas-checkbox-row {
  display: grid;
  gap: 8px;
}

.template-canvas-checkbox-row .template-choice-stack {
  padding-left: 2px;
}

.template-format-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 120;
}

.template-editor-modal {
  width: min(96vw, 1480px);
  height: min(94vh, 980px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  border-radius: 24px;
  background: #ffffff;
  border: 1px solid #d7dce5;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.22);
  padding: 20px;
}

.template-editor-modal-rich .template-editor-modal-body {
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.8fr);
}

.template-editor-modal-editor {
  min-height: 0;
}

.template-editor-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.template-editor-modal-head span {
  display: block;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.template-editor-modal-head h4 {
  margin: 4px 0 0;
  font-size: 24px;
  line-height: 1.2;
  color: #111827;
}

.template-editor-modal-lead,
.template-format-modal-note,
.template-format-help,
.template-format-mini-note {
  margin: 8px 0 0;
  color: #64748b;
  font-size: 13px;
  line-height: 1.55;
}

.template-editor-modal-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.template-editor-modal-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid #e2e8f0;
}

.template-editor-modal-body {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.85fr);
  gap: 16px;
  min-height: 0;
  margin-top: 16px;
}

.template-editor-modal-canvas {
  min-height: 0;
  overflow: auto;
  border-radius: 18px;
  border: 1px solid #e2e8f0;
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
}

.template-editor-canvas-modal {
  min-height: 100%;
  padding: 24px;
}

.template-page-frame-modal {
  width: min(100%, 920px);
}

.template-tip-tap-shell {
  display: grid;
  gap: 14px;
  min-height: 0;
}

.template-tip-tap-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #ffffff;
}

.template-tip-tap-surface {
  position: relative;
  min-height: 0;
  border: 1px solid #d7dce5;
  border-radius: 20px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  overflow: auto;
  padding: 18px;
}

.template-tip-tap-root {
  min-height: 100%;
  max-width: 100%;
}

.template-tip-tap-editor {
  outline: none;
  min-height: 68vh;
  padding: 24px;
  margin: 0 auto;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
}

.template-tip-tap-editor :is(h1, h2, h3, p) {
  margin: 0 0 0.65em;
}

.template-tip-tap-editor p {
  font-family: "Inter", "Noto Sans JP", sans-serif;
  font-size: 14px;
  line-height: 1.7;
  color: #18202f;
}

.template-tip-tap-editor h1,
.template-tip-tap-editor h2,
.template-tip-tap-editor h3 {
  font-family: "Noto Sans JP", "Inter", sans-serif;
  color: #111827;
}

.template-tip-tap-editor h1 {
  font-size: 28px;
}

.template-tip-tap-editor h2 {
  font-size: 22px;
}

.template-tip-tap-editor h3 {
  font-size: 18px;
}

.template-tip-tap-editor table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  margin: 14px 0;
}

.template-tip-tap-editor table td,
.template-tip-tap-editor table th {
  border: 1px solid #d7dce5;
  padding: 8px 10px;
  vertical-align: top;
}

.template-tip-tap-editor table th {
  background: #d8ecf8;
  font-weight: 700;
}

.template-tip-tap-loading {
  position: absolute;
  inset: 18px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  text-align: center;
  border: 1px dashed #d7dce5;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  color: #64748b;
  z-index: 2;
}

.template-tip-tap-loading strong {
  color: #18202f;
  font-size: 16px;
}

.template-tip-tap-loading span {
  max-width: 320px;
  font-size: 13px;
  line-height: 1.6;
}

.template-tip-tap-loading.is-error {
  color: #b91c1c;
}

.template-rich-preview-shell {
  display: grid;
  gap: 16px;
}

.template-rich-preview-page {
  width: min(100%, 920px);
  margin: 0 auto;
  border: 1px solid #d9dfeb;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(24, 32, 47, 0.09);
}

.template-rich-preview-body {
  padding: 24px;
}

.template-rich-document {
  display: grid;
  gap: 14px;
}

.template-rich-document-head span {
  display: inline-flex;
  margin-bottom: 6px;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.template-rich-document-head h1 {
  margin: 0;
  font-family: "Noto Sans JP", "Inter", sans-serif;
  font-size: 28px;
  line-height: 1.2;
  color: #111827;
}

.template-rich-document-head p {
  margin: 8px 0 0;
  color: #475569;
  line-height: 1.6;
}

.template-rich-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.template-rich-meta span {
  padding: 4px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3447d4;
  font-size: 12px;
  font-weight: 700;
}

.template-rich-section-card,
.template-rich-section {
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 14px;
  background: #f8fafc;
}

.template-rich-section {
  display: grid;
  gap: 12px;
}

.template-rich-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #334155;
  font-size: 12px;
}

.template-rich-block-head strong {
  font-size: 14px;
  color: #111827;
}

.template-rich-table-view {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: #ffffff;
}

.template-rich-table-view td,
.template-rich-table-view th {
  border: 1px solid #d7dce5;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.45;
  vertical-align: top;
}

.template-rich-table-view th {
  background: #d8ecf8;
}

.template-rich-photo-slot {
  min-height: 180px;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  background: #ffffff;
  overflow: hidden;
}

.template-rich-photo-slot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.template-rich-photo-slot div {
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: 16px;
  text-align: center;
  color: #64748b;
}

.template-rich-choice-list {
  display: grid;
  gap: 8px;
}

.template-rich-choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.template-rich-choice-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  font-size: 13px;
}

.template-rich-text-body {
  color: #111827;
  line-height: 1.65;
  white-space: pre-wrap;
}

.template-editor-modal-inspector {
  min-height: 0;
  overflow: auto;
  display: grid;
  gap: 14px;
  align-content: start;
  padding-right: 4px;
}

.template-format-panel {
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  padding: 14px;
  background: #f8fafc;
}

.template-format-panel-wide {
  grid-column: 1 / -1;
}

.template-format-panel h5 {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.25;
  color: #111827;
}

.template-format-field {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.template-format-field span {
  font-size: 12px;
  font-weight: 700;
  color: #334155;
}

.template-format-select,
.template-format-field input[type="range"],
.template-format-field input[type="color"] {
  width: 100%;
}

.template-format-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.template-format-row-compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.template-format-tight {
  min-width: 82px;
}

.template-format-toggle {
  min-height: 40px;
  border-radius: 12px;
  border: 1px solid #d7dce5;
  background: #fff;
  color: #111827;
  font-weight: 700;
  padding: 0 14px;
}

.template-format-toggle.is-active {
  border-color: #445dff;
  color: #445dff;
  background: rgba(68, 93, 255, 0.08);
}

.template-format-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

@media (max-width: 900px) {
  .template-editor-modal {
    width: min(100vw - 16px, 1480px);
    height: min(96vh, 980px);
    padding: 16px;
  }
  .template-editor-modal-head {
    flex-direction: column;
  }
  .template-editor-modal-body {
    grid-template-columns: 1fr;
  }
  .template-editor-modal-canvas {
    max-height: 44vh;
  }
  .template-tip-tap-editor {
    min-height: 52vh;
    padding: 18px;
  }
  .template-format-row {
    grid-template-columns: 1fr;
  }
  .template-format-row-compact {
    grid-template-columns: 1fr;
  }
}

.template-canvas-image-placeholder {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  min-height: 100%;
  padding: 12px;
  color: var(--muted);
  text-align: center;
  background: rgba(248, 250, 252, 0.86);
}

.template-canvas-image-placeholder strong {
  color: #18202f;
}

.template-canvas-image-slot {
  position: relative;
  display: grid;
  place-items: stretch;
  width: calc(100% - 20px);
  min-height: 0;
  margin: 0 10px 10px;
  border: 1px dashed #cdd5e1;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.94);
  cursor: pointer;
}

.template-canvas-image-slot input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.template-canvas-image-preview {
  width: 100%;
  height: 100%;
  min-height: 100%;
  object-fit: cover;
  display: block;
}

.template-canvas-line-inner {
  width: 100%;
  height: 1px;
  margin-top: calc(50% - 1px);
  background: #1f2937;
}

.template-canvas-block.dragging {
  opacity: 0.72;
}

.template-canvas-block.focused {
  box-shadow: 0 0 0 3px rgba(52, 71, 212, 0.18);
}

.template-document--editable {
  width: min(100%, 920px);
  margin: 0 auto;
  border: 1px solid #d9dfeb;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(24, 32, 47, 0.09);
}

.template-document-frame {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.template-document-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.template-document-body {
  display: grid;
  gap: 16px;
}

.template-block {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid #e3e8f0;
  border-radius: 10px;
  background: #fbfcfe;
}

.template-block-header {
  border-color: rgba(52, 71, 212, 0.16);
  background: linear-gradient(180deg, #f7f9ff, #ffffff);
}

.template-block-kicker {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.template-block-header h4,
.template-section-head-text h5,
.template-empty-shell strong,
.template-missing-shell strong {
  margin: 0;
}

.template-block-header h4,
.template-section-head-text h5 {
  color: #18202f;
  font-size: 18px;
  line-height: 1.25;
}

.template-block-header p,
.template-section-head-text p,
.template-empty-shell p,
.template-missing-shell p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.template-block-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.template-block-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef1f6;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

.template-block-stack {
  display: grid;
  gap: 14px;
}

.template-editable-card {
  background: #ffffff;
}

.template-editable-card.dragging {
  opacity: 0.55;
  transform: scale(0.996);
  box-shadow: 0 10px 20px rgba(24, 32, 47, 0.12);
}

.template-section-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.template-drag-handle {
  display: grid;
  place-items: center;
  width: 34px;
  min-width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #eef1f6;
  color: #475569;
  font-size: 15px;
  font-weight: 900;
  cursor: grab;
  user-select: none;
}

.template-section-head-text {
  flex: 1;
  min-width: 0;
}

.template-section-head-text h5[contenteditable="true"],
.template-section-head-text p[contenteditable="true"],
.template-block-header h4[contenteditable="true"],
.template-block-header p[contenteditable="true"],
.template-field-block label[contenteditable="true"],
.template-field-value[contenteditable="true"] {
  outline: none;
  border-radius: 6px;
}

.template-section-head-text h5[contenteditable="true"]:focus,
.template-section-head-text p[contenteditable="true"]:focus,
.template-block-header h4[contenteditable="true"]:focus,
.template-block-header p[contenteditable="true"]:focus,
.template-field-block label[contenteditable="true"]:focus,
.template-field-value[contenteditable="true"]:focus {
  box-shadow: 0 0 0 2px rgba(52, 71, 212, 0.14);
  background: rgba(52, 71, 212, 0.03);
}

.template-section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.icon-button.tiny {
  width: 32px;
  min-height: 32px;
  padding: 0;
  font-size: 15px;
}

.icon-button.danger {
  border-color: rgba(220, 38, 38, 0.22);
  background: #fff1f2;
  color: #b4232c;
}

.template-section-fields-editable {
  display: grid;
  gap: 10px;
}

.template-field-block {
  display: grid;
  gap: 6px;
  padding: 10px 11px;
  border: 1px solid #e5ebf3;
  border-radius: 8px;
  background: #fbfdff;
}

.template-field-block.table-field {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.4fr);
  align-items: start;
}

.template-field-block label {
  color: #1f2a3d;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.template-field-value {
  min-height: 42px;
  padding: 9px 10px;
  border: 1px dashed #cdd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #18202f;
  font-size: 13px;
  line-height: 1.5;
}

.template-empty-shell,
.template-missing-shell {
  padding: 16px;
  border: 1px dashed #aeb8c8;
  border-radius: var(--radius);
  background: #fff;
}

.template-missing-shell {
  border-color: rgba(245, 158, 11, 0.28);
  background: #fff9ec;
}

.template-missing-shell strong {
  color: #9a5800;
}

.template-missing-shell p {
  color: #7c4a04;
}

.template-empty-shell strong {
  display: block;
  margin-bottom: 6px;
  color: #18202f;
}

.template-copy-panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.template-copy-panel h4 {
  margin-bottom: 10px;
  font-size: 16px;
}

.template-blueprint {
  display: grid;
  gap: 16px;
}

.template-scan-strip {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid rgba(52, 71, 212, 0.18);
  border-radius: var(--radius);
  background: #f7f8ff;
}

.template-scan-strip span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.template-scan-track {
  position: relative;
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: #e6eaf5;
}

.template-scan-track i {
  position: absolute;
  inset: 0;
  width: 36%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(52, 71, 212, 0.1), rgba(52, 71, 212, 0.9), rgba(216, 58, 58, 0.9));
  animation: template-scan-move 1.2s linear infinite;
}

@keyframes template-scan-move {
  0% {
    transform: translateX(-120%);
  }

  100% {
    transform: translateX(320%);
  }
}

.template-blueprint-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.template-blueprint-head span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.template-blueprint-head h3 {
  margin-top: 4px;
  font-size: 20px;
}

.template-blueprint-head p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.template-score {
  min-width: 120px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #f6f8ff;
  text-align: center;
}

.template-score small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.template-score strong {
  display: block;
  margin-top: 4px;
  color: var(--accent);
  font-size: 24px;
}

.template-blueprint-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.template-reference-panel,
.template-palette-panel,
.template-sections-panel,
.template-notes-grid section {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.template-reference-image {
  display: block;
  width: 100%;
  min-height: 220px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #e6ebf2;
}

.template-reference-placeholder {
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px dashed #aeb8c8;
  border-radius: 6px;
  color: var(--muted);
  text-align: center;
  padding: 20px;
  line-height: 1.5;
}

.template-reference-placeholder-file {
  align-content: center;
  gap: 8px;
}

.template-reference-placeholder-file strong {
  font-size: 15px;
}

.template-reference-placeholder-file span {
  display: block;
  color: var(--accent);
  font-size: 12px;
  word-break: break-all;
}

.template-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.template-meta-row span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef1f6;
  color: #34447d;
  font-size: 12px;
  font-weight: 700;
}

.template-source-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.template-palette-panel h4,
.template-sections-panel h4,
.template-notes-grid h4 {
  margin-bottom: 10px;
  font-size: 16px;
}

.template-palette-list {
  display: grid;
  gap: 8px;
}

.template-swatch {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.template-swatch span {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid rgba(15, 23, 42, 0.1);
}

.template-swatch strong {
  font-size: 12px;
  text-transform: uppercase;
}

.template-swatch small {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
}

.template-section-grid {
  display: grid;
  gap: 10px;
}

.template-section-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #e3e8f0;
  border-radius: var(--radius);
  background: #fbfcfe;
}

.template-section-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.template-section-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.template-section-fields span {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #eef1f6;
  color: #18202f;
  font-size: 12px;
  font-weight: 700;
}

.template-section-fields small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.template-empty {
  padding: 18px;
  border: 1px dashed #aeb8c8;
  border-radius: var(--radius);
  color: var(--muted);
  line-height: 1.5;
}

.template-notes-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.template-notes-grid p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.template-copy-panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.template-copy-panel h4 {
  margin-bottom: 10px;
  font-size: 16px;
}

.template-copy-grid {
  display: grid;
  gap: 10px;
}

.template-copy-card {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid #e3e8f0;
  border-radius: 8px;
  background: #fbfcfe;
}

.template-copy-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.template-copy-card span {
  color: #22304b;
  font-weight: 700;
}

.template-copy-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

@keyframes template-scan-button-pulse {
  0%,
  100% {
    box-shadow: 0 10px 24px rgba(22, 47, 122, 0.22);
    transform: translateY(0);
  }

  50% {
    box-shadow: 0 14px 30px rgba(22, 47, 122, 0.34);
    transform: translateY(-1px);
  }
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
    padding: 16px 20px;
  }

  .nav-list {
    display: none;
  }

  .sidebar .document-strip {
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    overflow-x: auto;
  }

  .sidebar-note {
    display: none;
  }

  .workspace-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .quality-panel {
    grid-column: 1 / -1;
  }

  .template-blueprint-body,
  .template-notes-grid {
    grid-template-columns: 1fr;
  }

  .member-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .main-panel {
    padding: 18px;
  }

  .topbar,
  .panel-heading {
    flex-direction: column;
  }

  .topbar-actions,
  .preview-actions {
    width: 100%;
  }

  .topbar-actions button,
  .preview-actions button {
    flex: 1;
  }

  .document-strip,
  .workspace-grid,
  .workspace-grid:has(.kk-paper),
  .field-grid,
  .three-cols,
  .four-cols,
  .six-cols {
    grid-template-columns: 1fr;
  }

  .template-meta-grid {
    grid-template-columns: 1fr;
  }

  .template-reference-drop {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .template-reference-drop button {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .template-blueprint-head {
    flex-direction: column;
  }

  .template-score {
    width: 100%;
  }

  .template-editor-workspace {
    grid-template-columns: 1fr;
  }

  .template-page-frame {
    width: 100%;
    min-width: 0;
  }

  .workspace-grid:has(.kk-paper) .quality-panel {
    grid-column: auto;
  }

  .preview-panel {
    max-width: 100%;
    overflow-x: auto;
  }

  .preview-panel:has(.kk-paper) {
    padding: 12px;
  }

  .preview-panel:has(.kk-paper)::before {
    content: "Geser kiri-kanan untuk cek kertas KK. Pakai tombol mata untuk lihat lebih besar.";
    display: block;
    margin-bottom: 10px;
    padding: 10px 12px;
    border: 1px solid rgba(52, 71, 212, 0.22);
    border-radius: var(--radius);
    background: #f6f8ff;
    color: #2535aa;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.35;
  }

  .document-paper.kk-paper {
    width: 920px;
    max-width: none;
  }

  .preview-modal-backdrop {
    padding: 0;
  }

  .preview-modal {
    width: 100%;
    height: 100vh;
    max-height: none;
    border-radius: 0;
  }

  .preview-modal-scroll {
    padding: 12px;
  }

  .preview-modal-scroll .document-paper.kk-paper {
    width: 920px;
    min-width: 920px;
  }

  .photo-drop {
    grid-template-columns: 74px minmax(0, 1fr);
    min-height: 112px;
  }

  .photo-frame {
    width: 66px;
  }

  .sidebar {
    grid-template-columns: 1fr;
  }

  .jp-row {
    grid-template-columns: 1fr;
  }

  .paper-meta {
    grid-template-columns: 1fr 1fr;
  }

  .kk-scan-drop,
  .member-grid,
  .kk-summary-grid,
  .translation-cert div {
    grid-template-columns: 1fr;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  @page kk-landscape {
    size: A4 landscape;
    margin: 0;
  }

  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  html,
  body {
    width: auto;
    min-height: 297mm;
    margin: 0;
    background: #ffffff;
  }

  html:has(body.printing-kk),
  body.printing-kk {
    width: 297mm;
    height: 210mm;
    min-height: 210mm;
  }

  body.printing-document * {
    visibility: hidden;
  }

  body.printing-document .document-paper,
  body.printing-document .document-paper * {
    visibility: visible;
  }

  body.printing-document .document-paper {
    position: absolute;
    inset: 0 auto auto 0;
  }

  body.printing-document .template-notes-grid,
  body.printing-document .template-copy-panel,
  body.printing-document .template-editor-toolbar,
  body.printing-document .template-blueprint-head,
  body.printing-document .template-blueprint-body,
  body.printing-document .template-source-note,
  body.printing-document .template-scan-strip,
  body.printing-document .template-format-backdrop {
    display: none !important;
  }

  body.printing-document .template-editor-shell > :not(.template-editor-workspace) {
    display: none !important;
  }

  .sidebar,
  .topbar,
  .document-strip,
  .api-status,
  .editor-panel,
  .quality-panel,
  .panel-heading,
  .preview-actions {
    display: none !important;
  }

  .app-shell,
  .main-panel,
  .workspace-grid,
  .preview-panel {
    display: block;
    padding: 0;
    margin: 0;
    box-shadow: none;
    border: 0;
    background: #ffffff;
  }

  .document-paper {
    min-height: 0;
    width: 210mm;
    padding: 8mm 10mm;
    border: 0;
    box-shadow: none;
    background: #ffffff;
  }

  .document-paper.kk-paper {
    page: kk-landscape;
    width: 297mm;
    min-height: 210mm;
    aspect-ratio: auto;
    padding: 7mm 8mm;
  }

  .rirekisho-page {
    font-size: 8.6px;
    line-height: 1.18;
  }

  .kk-translation-page {
    font-size: 7.8px;
    line-height: 1.18;
  }

  .kk-title-block h3 {
    font-size: 17px;
  }

  .kk-member-preview {
    font-size: 6.6px;
  }

  .kk-member-preview th,
  .kk-member-preview td {
    padding: 3px;
  }

  .cv-title-row h3 {
    font-size: 20px;
  }

  .cv-paper .paper-photo {
    width: 30mm;
    min-height: 40mm;
  }

  .cv-main-table th,
  .cv-main-table td,
  .cv-section-table th,
  .cv-section-table td {
    border-color: #111827 !important;
  }

  .cv-main-table th,
  .cv-section-table thead th {
    background: #f7f8fb !important;
  }

  .cv-section-table thead tr:first-child th {
    background: #e8ebf1 !important;
  }
}
