:root {
  --bg: #F7F7F4;
  --panel: #fff;
  --border: #E4E4E0;
  /* デジサポの色（黒と黄色）。ボタンは黒地に黄色の文字、押す前に重ねると黄色地に黒の文字 */
  --primary: #141414;
  --primary-hover: #333333;
  --accent: #FFD000;
  --danger: #c62828;
  --text: #1a2332;
  --muted: #5c6b7a;
  --card-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.header {
  background: var(--primary);
  color: #fff;
  padding: 1.25rem 1.5rem;
}

.header.compact {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
}

.header h1 { margin: 0; font-size: 1.35rem; color: var(--accent); }

.subtitle { margin: 0.25rem 0 0; opacity: 0.9; font-size: 0.9rem; }

.back-link { color: #fff; text-decoration: none; opacity: 0.9; }
.back-link:hover { opacity: 1; text-decoration: underline; }

.header-actions { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }

.container { max-width: 960px; margin: 0 auto; padding: 1.5rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.panel h2 { margin: 0 0 1rem; font-size: 1.1rem; }

.form-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }

input[type="text"], select {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 1rem;
  min-width: 12rem;
}

.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.95rem;
}

.btn.primary { background: var(--primary); color: var(--accent); font-weight: 700; }
.btn.primary:hover { background: var(--accent); color: var(--primary); }
.btn.danger { background: var(--danger); color: #fff; margin-top: 0.5rem; }

.muted { color: var(--muted); font-size: 0.9rem; }

.project-list { display: flex; flex-direction: column; gap: 0.5rem; }

.project-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafbfc;
}

.project-card a { color: var(--primary); font-weight: 600; text-decoration: none; }
.project-card a:hover { text-decoration: underline; }

.project-meta { font-size: 0.85rem; color: var(--muted); }

.designer-body { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

.designer-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 160px 1fr 240px;
  gap: 0;
  min-height: 0;
  border-top: 1px solid var(--border);
}

.tools, .props {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 0.75rem;
  overflow-y: auto;
}

.props { border-right: none; border-left: 1px solid var(--border); }

.tools h3, .props h3 { margin: 0 0 0.75rem; font-size: 0.95rem; }

.tool-btn {
  display: block;
  width: 100%;
  margin-bottom: 0.4rem;
  padding: 0.45rem;
  text-align: left;
  border: 1px solid var(--border);
  background: #f8fafc;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

.tool-btn:hover { background: #e8f0fe; border-color: var(--primary); }

.schema-box {
  font-size: 0.75rem;
  word-break: break-all;
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: #f0f7ff;
  border-radius: 4px;
}

.canvas-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: #dde3ea;
  min-height: 0;
}

.side-tabs { margin-bottom: 0.5rem; }

.side-tab {
  padding: 0.35rem 1rem;
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer;
}

.side-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.canvas-wrap {
  box-shadow: var(--card-shadow);
  background: #fff;
  border-radius: 4px;
}

#card-canvas { display: block; cursor: default; }

.hint { margin: 0.5rem 0 0; font-size: 0.8rem; color: var(--muted); }

.props-form label {
  display: block;
  margin-bottom: 0.65rem;
  font-size: 0.85rem;
}

.props-form input, .props-form select {
  display: block;
  width: 100%;
  margin-top: 0.2rem;
}

.hidden { display: none !important; }

@media (max-width: 900px) {
  .designer-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .tools, .props { border: none; border-bottom: 1px solid var(--border); }
}

.header-row { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 1rem; }
.user-label { font-size: 0.9rem; opacity: 0.95; }
.header-btn { background: rgba(255,255,255,0.2); color: #fff; text-decoration: none; }
.header-btn:hover { background: rgba(255,255,255,0.35); }

.project-nav {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
  padding: 0.5rem 1rem; background: #FFF6CC; border-bottom: 1px solid var(--border);
}
.project-nav a { color: var(--primary); text-decoration: none; padding: 0.25rem 0.6rem; border-radius: 4px; font-size: 0.9rem; }
.project-nav a.active { background: var(--primary); color: var(--accent); }
.project-nav .nav-right { margin-left: auto; }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 0.9rem; }

.container.wide { max-width: 1200px; }
.project-links { margin-top: 0.35rem; font-size: 0.85rem; }
.project-links a { margin-right: 0.75rem; color: var(--primary); }
.project-card-main { flex: 1; }
.warn { color: #e65100; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.85rem; }

.toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; align-items: center; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th, .data-table td { border: 1px solid var(--border); padding: 0.4rem 0.6rem; text-align: left; }
.data-table th { background: #f5f7fa; }
.data-table tr.selected { background: #FFF6CC; }
.data-table tr:hover { background: #f8fafc; }
.badge { background: #e0e0e0; padding: 0.1rem 0.4rem; border-radius: 3px; font-size: 0.8rem; }
.data-table .ok { color: #2e7d32; }
.data-table .err { color: var(--danger); }

dialog { border: 1px solid var(--border); border-radius: 8px; padding: 1rem; max-width: 480px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }
.checkbox { display: flex; align-items: center; gap: 0.4rem; margin: 0.5rem 0; }

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--panel); padding: 2rem; border-radius: 8px; box-shadow: var(--card-shadow); width: 100%; max-width: 360px; }
.login-card label { display: block; margin-bottom: 0.75rem; }
.login-card input { width: 100%; margin-top: 0.25rem; }
.btn.block { width: 100%; margin-top: 0.5rem; }
.error { color: var(--danger); font-size: 0.9rem; }
.result-box { background: #f5f7fa; padding: 0.75rem; border-radius: 4px; white-space: pre-wrap; font-size: 0.85rem; }

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 1.75rem 1rem;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
}
.drop-zone.dragover { border-color: var(--primary); background: #FFF6CC; }
.drop-zone input[type="file"] { display: none; }
.preview-meta { margin: 0.4rem 0; font-weight: 600; }
.warn-list { color: var(--danger); font-size: 0.9rem; padding-left: 1.2rem; }

.print-layout { display: grid; grid-template-columns: 1fr 320px; gap: 1rem; }
@media (max-width: 900px) { .print-layout { grid-template-columns: 1fr; } }
.preview-panel { text-align: center; }
#preview-canvas { box-shadow: var(--card-shadow); margin: 0 auto; display: block; }
/* プレビューの枠（320px）より券面（420px）が大きく、右にはみ出していた。枠に合わせて縮める */
#preview-canvas { max-width: 100%; height: auto !important; }
/* 刷る細かさ（dpi）の選び方 */
.dpi-pick { display: block; margin-bottom: 0.35rem; font-size: 0.9rem; }
/* 全体の select には min-width: 12rem が効いている。スマホの狭い枠では
   それが幅を押し広げてはみ出す（2026-09-24 に発行画面で 10px）ので、ここでは枠に合わせる */
.dpi-pick select { display: block; width: 100%; min-width: 0; margin-top: 0.25rem; padding: 0.25rem 0.4rem; }
.dpi-note { margin-bottom: 0.6rem; font-size: 0.82rem; }

@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area { position: absolute; left: 0; top: 0; }
}
.print-only { display: none; }
@media print { .print-only { display: block; } }

/* 再発行 */
.badge.warn { background: #fbeed6; color: #8a5a06; }
.btn.small { padding: 0.15rem 0.5rem; font-size: 0.8rem; }
.reissue-back {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .35);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.reissue-box {
  background: #fff; border-radius: 8px; padding: 20px; width: min(460px, 100%);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .25); display: grid; gap: 12px;
}
.reissue-box h3 { margin: 0; }
.reissue-reasons { display: flex; flex-wrap: wrap; gap: 8px; }
.reissue-pick.selected { background: var(--primary); color: var(--accent); border-color: var(--primary); }
.reissue-other { display: grid; gap: 4px; font-size: 0.9rem; }
.reissue-other input { padding: 0.4rem; }
.reissue-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* デザイン未保存のときの案内 */
.empty-guide { max-width: 640px; margin: 2rem auto; text-align: center; line-height: 1.8; }
.empty-guide h2 { margin-bottom: 0.5rem; }

/* 設定画面: 狭い画面でも、表がページからはみ出さない・ボタンが縦に潰れない */
#users-panel .data-table { display: block; overflow-x: auto; max-width: 100%; }
#users-panel .data-table .btn { white-space: nowrap; }
#users-panel .data-table th, #users-panel .data-table td { white-space: nowrap; }
#printer-form label.checkbox { display: flex; align-items: center; gap: 0.4rem; }
#printer-form label.checkbox input { width: auto; margin: 0; }
.stack { display: grid; gap: 0.6rem; max-width: 420px; }
.stack label { display: grid; gap: 0.25rem; }
.stack input, .stack select { width: 100%; box-sizing: border-box; padding: 0.4rem; }

/* 体験用の帯（全画面の一番上） */
.trial-banner {
  background: #fff8e1; color: #4e342e; border-bottom: 1px solid #ffe082;
  padding: 0.5rem 1rem; font-size: 0.86rem; line-height: 1.7; text-align: center;
}
.trial-banner-warn { font-weight: 700; color: #b71c1c; margin: 0 0.5rem; }
.trial-banner-note { color: #6d4c41; }
.trial-entry { display: grid; gap: 0.75rem; margin-top: 0.5rem; }
.trial-entry ul { margin: 0; padding-left: 1.2rem; font-size: 0.88rem; line-height: 1.8; color: #455a64; }
.login-divider { margin: 1.25rem 0 0.75rem; text-align: center; font-size: 0.8rem; color: #90a4ae; }

/* 画面の中に出す窓（お知らせ・確認・入力） */
.ui-dialog-back {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.ui-dialog {
  background: #fff; color: #1a1a2e; border-radius: 10px; padding: 22px 22px 18px;
  width: min(440px, 100%); box-shadow: 0 16px 40px rgba(0, 0, 0, .3); display: grid; gap: 14px;
}
.ui-dialog-msg p { margin: 0; line-height: 1.8; font-size: 0.95rem; }
.ui-dialog-msg p + p { margin-top: 0.3rem; }
.ui-dialog-input { width: 100%; box-sizing: border-box; padding: 0.55rem 0.6rem; font-size: 1rem; border: 1px solid #b0bec5; border-radius: 6px; }
.ui-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.ui-dialog-actions { align-items: center; }
.ui-dialog-actions .btn { min-width: 92px; margin: 0; }

/* 名簿の表の中の、小さな写真 */
.cell-thumb { display: block; width: 34px; height: 43px; object-fit: cover; border-radius: 4px; border: 1px solid #cfd8dc; background: #eceff1; }

/* 名簿の編集で、写真の列を「選ぶ」形にするところ */
.photo-control { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.2rem; }
.photo-now { width: 44px; height: 56px; object-fit: cover; border-radius: 4px; border: 1px solid #cfd8dc; background: #eceff1; }
.photo-note { font-size: 0.82rem; line-height: 1.6; }

/* 名簿の編集の入力欄。見出しと入力が横に流れてずれていたので、1項目1行にする */
#edit-fields label { display: block; margin-bottom: 0.7rem; font-size: 0.9rem; color: var(--muted); }
#edit-fields input[type="text"],
#edit-fields input[type="date"],
#edit-fields select { display: block; width: 100%; margin-top: 0.25rem; color: var(--text); }
