/* =====================================================
   kct-kanri — style.css
   デジタル庁デザインシステムの配色・考え方に準拠
   ===================================================== */

:root {
  --blue: #0017c1;
  --blue-dark: #00118f;
  --blue-light: #e8f1fe;
  --text: #1a1a1c;
  --text-sub: #626264;
  --border: #949497;
  --divider: #d8d8db;
  --bg-sub: #f2f2f2;
  --red: #ce0000;
  --green: #197a4b;
  --gray: #626264;
  --focus: #ffd43d;
  --radius: 8px;
  --max: 880px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Noto Sans JP", sans-serif;
  color: var(--text);
  background: #fff;
  font-size: 16px;
  line-height: 1.7;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); text-underline-offset: 3px; }
a:hover { color: var(--blue-dark); }

:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 0;
  box-shadow: 0 0 0 6px var(--text);
}

/* Icons: Material Symbols Outlined（線アイコン） */
.icon {
  font-size: 20px;
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  flex-shrink: 0;
  vertical-align: middle;
}

/* ───── PIN screen ───── */
.pin-screen {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 14vh 16px 32px;
  background: var(--bg-sub);
}
.pin-wrap {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 32px 24px;
}
.pin-org { font-size: 15px; font-weight: 700; color: var(--text-sub); }
.pin-title { font-size: 24px; font-weight: 700; line-height: 1.4; margin-bottom: 24px; }
.pin-input { font-size: 20px; letter-spacing: .2em; }

/* ───── Header ───── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #fff;
  border-bottom: 1px solid var(--divider);
}
.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.site-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.site-org { font-size: 18px; font-weight: 700; white-space: nowrap; }
.site-name { font-size: 14px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ───── Tabs (mobile: bottom / PC: top) ───── */
.tab-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  background: #fff;
  border-top: 1px solid var(--divider);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tab-btn {
  background: none;
  border: 0;
  border-top: 3px solid transparent;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  color: var(--text-sub);
  cursor: pointer;
}
.tab-btn .icon { font-size: 24px; }
.tab-btn[aria-current="page"] { color: var(--blue); border-top-color: var(--blue); font-weight: 700; }

@media (min-width: 768px) {
  .tab-nav {
    position: sticky;
    top: 56px;
    bottom: auto;
    border-top: 0;
    border-bottom: 1px solid var(--divider);
    display: flex;
    padding: 0 max(8px, calc((100% - var(--max)) / 2 + 8px));
  }
  .tab-btn {
    flex-direction: row;
    gap: 6px;
    font-size: 15px;
    padding: 12px 16px 9px;
    border-top: 0;
    border-bottom: 3px solid transparent;
  }
  .tab-btn .icon { font-size: 20px; }
  .tab-btn[aria-current="page"] { border-bottom-color: var(--blue); }
  .tab-btn:hover { color: var(--text); }
}

/* ───── Main ───── */
.main { max-width: var(--max); margin: 0 auto; padding: 24px 16px 104px; }
@media (min-width: 768px) { .main { padding-bottom: 56px; } }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.page-head h2 { font-size: 24px; font-weight: 700; line-height: 1.4; }
.page-sub { color: var(--text-sub); font-size: 15px; margin-top: -8px; margin-bottom: 16px; }
.list-heading { font-size: 17px; font-weight: 700; margin: 24px 0 8px; }
.list-heading:first-child { margin-top: 0; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 0;
  color: var(--blue);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 4px 0;
  margin-bottom: 8px;
  font-size: 15px;
}

.notice {
  border-left: 4px solid var(--blue);
  background: var(--blue-light);
  padding: 12px 16px;
  font-size: 15px;
  margin-bottom: 16px;
}
.notice p + p { margin-top: 4px; }

/* ───── Buttons ───── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-outline { background: #fff; color: var(--blue); border-color: var(--blue); }
.btn-outline:hover { background: var(--blue-light); }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { min-height: 36px; padding: 4px 12px; font-size: 14px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-outline.is-admin { background: var(--text); color: #fff; border-color: var(--text); }

.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  border-radius: 6px;
  color: var(--text-sub);
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-sub); color: var(--text); }

/* ───── Forms ───── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.req { color: var(--red); font-size: 13px; font-weight: 400; margin-left: 6px; }
.form-control {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  font-size: 16px;
}
.form-control:hover { border-color: var(--text); }
textarea.form-control { min-height: 96px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.help { font-size: 14px; color: var(--text-sub); margin-top: 4px; }
.error-text { color: var(--red); font-size: 14px; min-height: 1.6em; margin-top: 4px; }

/* ───── Lists ───── */
.panel { border: 1px solid var(--divider); border-radius: var(--radius); background: #fff; }
.row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--divider);
}
.row:last-child { border-bottom: 0; }
.row-main { flex: 1; min-width: 0; display: block; }
.row-title { display: block; font-weight: 700; }
.row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 16px;
  font-size: 14px;
  color: var(--text-sub);
  margin-top: 2px;
}
.meta-item { display: inline-flex; align-items: center; gap: 4px; }
.meta-item .icon { font-size: 18px; }
.row-text { display: block; font-size: 15px; margin-top: 4px; white-space: pre-wrap; }
.row-label { display: block; font-size: 14px; color: var(--text-sub); font-weight: 700; }
.row-actions { display: flex; gap: 2px; margin: -6px -8px -6px 0; }

.row-link {
  width: 100%;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--divider);
  text-align: left;
  cursor: pointer;
  align-items: center;
}
.row-link:hover { background: var(--bg-sub); }
.row-link > .icon { color: var(--text-sub); }

.date-box {
  display: block;
  width: 56px;
  flex-shrink: 0;
  text-align: center;
  border: 1px solid var(--divider);
  border-radius: 6px;
  padding: 4px 0;
  line-height: 1.3;
}
.date-box .md { display: block; font-size: 17px; font-weight: 700; }
.date-box .wd { display: block; font-size: 12px; color: var(--text-sub); }

.empty { padding: 32px 16px; text-align: center; color: var(--text-sub); }
.empty p + p { margin-top: 4px; }
.empty .btn { margin-top: 16px; }

.past { margin-top: 24px; }
.past summary { cursor: pointer; font-weight: 700; color: var(--blue); padding: 8px 0; }
.past[open] summary { margin-bottom: 8px; }

/* ───── Roster ───── */
.roster-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  font-size: 15px;
  margin-bottom: 12px;
}
.roster-summary b { font-size: 18px; margin: 0 2px; }
.roster-summary .total { color: var(--text-sub); }

.roster-row { padding: 12px 16px; border-bottom: 1px solid var(--divider); }
.roster-row:last-child { border-bottom: 0; }
.roster-top { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.roster-name { flex: 1; min-width: 7em; font-weight: 700; }
.roster-sub { display: block; font-size: 13px; font-weight: 400; color: var(--text-sub); }

.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.seg button {
  min-height: 40px;
  padding: 4px 12px;
  background: #fff;
  border: 0;
  border-left: 1px solid var(--border);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.seg button:first-child { border-left: 0; }
.seg button:hover { background: var(--bg-sub); }
.seg button[aria-pressed="true"][data-status="来た"] { background: var(--green); color: #fff; }
.seg button[aria-pressed="true"][data-status="来てない"] { background: var(--red); color: #fff; }
.seg button[aria-pressed="true"][data-status="未確認"] { background: var(--gray); color: #fff; }

.roster-extra {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin-top: 12px;
  padding: 12px;
  background: var(--bg-sub);
  border-radius: 6px;
}
.roster-extra .full { grid-column: 1 / -1; }
.roster-extra label { display: block; font-size: 13px; font-weight: 700; color: var(--text-sub); margin-bottom: 2px; }
.roster-extra .form-control { min-height: 40px; padding: 6px 10px; font-size: 15px; }

.roster-foot { margin-top: 12px; }

/* ───── Checklist ───── */
.check-list { border: 1px solid var(--divider); border-radius: var(--radius); margin-bottom: 16px; }
.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
}
.check-row:last-child { border-bottom: 0; }
.check-row:hover { background: var(--bg-sub); }
.check-row input { width: 20px; height: 20px; accent-color: var(--blue); flex-shrink: 0; }
.check-row .sub { margin-left: auto; font-size: 14px; color: var(--text-sub); }

/* ───── Modal ───── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  justify-content: center;
  align-items: flex-start;
  padding: 8vh 16px 16px;
  background: rgba(26, 26, 28, .5);
  overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
.modal-title { font-size: 20px; font-weight: 700; line-height: 1.4; }
.modal-head .icon-btn { margin-right: -8px; }
.modal-meta { margin-bottom: 16px; }
.modal-meta strong { display: block; }
.modal-meta span { font-size: 14px; color: var(--text-sub); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }

/* ───── Toast ───── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%);
  z-index: 200;
  max-width: calc(100% - 32px);
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: 6px;
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.toast.show { opacity: 1; }
@media (min-width: 768px) { .toast { bottom: 32px; } }

@media (max-width: 400px) {
  .site-name { display: none; }
  .seg button { padding: 4px 9px; }
}
