/* AI社員マップ（/map/・街版）。文字は最小13.5px・説明の灰色は --gray の1色だけ */
:root {
  --text: #1A2332;
  --gray: #45484d;
  --line: #D4DAE4;
  --blue: #2D63C8;
  --bg: #F6F7FA;
  --ok: #22A36F;
  --danger: #C0392B;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif; font-size: 15px; line-height: 1.6; color: var(--text); background: var(--bg); font-feature-settings: "palt"; }
[hidden] { display: none !important; }

.top { background: #fff; border-bottom: 1px solid var(--line); padding: 14px 24px; display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.top h1 { font-size: 20px; font-weight: 700; }
.top .date { font-size: 14px; color: var(--gray); }
.top .sum { font-size: 15px; display: flex; gap: 14px; flex-wrap: wrap; }
.top .sum b { font-size: 17px; }
.top .back { font-size: 14px; color: var(--blue); }
.demo { background: #FFF6DE; border-bottom: 1px solid #F0E2B6; padding: 7px 24px; font-size: 13.5px; }
.error { margin: 12px 24px 0; font-size: 14px; color: var(--danger); }

.wrap { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; padding: 18px 24px 24px; max-width: 1440px; margin: 0 auto; }

/* 街（絵は 1344×768） */
.town { position: relative; width: 100%; aspect-ratio: 1344 / 768; border-radius: 14px; overflow: hidden; border: 1px solid #9CC58A;
        background: #7CC05A url("img/town.webp") center / 100% 100% no-repeat; }
.bldg { position: absolute; transform: translate(-50%, -50%); z-index: 1; background: rgba(255,255,255,.94); border: 2px solid #6B8F5A;
        border-radius: 8px; padding: 1px 9px 2px; text-align: center; line-height: 1.35; pointer-events: none; white-space: nowrap; }
.bldg b { display: block; font-size: 14.5px; }
.bldg span { display: block; font-size: 13.5px; color: var(--gray); }

/* AI社員（歩くキャラ） */
.walker { position: absolute; width: 4.4%; transform: translate(-50%, -100%); background: none; border: none; padding: 0; cursor: pointer; font: inherit; color: inherit; }
.walker .sprite { position: relative; }
.walker img { display: block; width: 100%; height: auto; animation: idle 1.6s steps(2) infinite; }
.walker.left img { animation-name: idleL; }
.walker.moving img { animation: walk .34s steps(2) infinite; }
.walker.left.moving img { animation-name: walkL; }
.walker.hop .sprite { animation: hop .45s ease; }
@keyframes idle  { from { transform: translateY(0); } to { transform: translateY(-1.5px); } }
@keyframes idleL { from { transform: scaleX(-1) translateY(0); } to { transform: scaleX(-1) translateY(-1.5px); } }
@keyframes walk  { from { transform: translateY(0) rotate(-3deg); } to { transform: translateY(-4px) rotate(3deg); } }
@keyframes walkL { from { transform: scaleX(-1) translateY(0) rotate(-3deg); } to { transform: scaleX(-1) translateY(-4px) rotate(3deg); } }
@keyframes hop { 0% { transform: translateY(0); } 40% { transform: translateY(-14px); } 100% { transform: translateY(0); } }
/* 急ぎ（緊急度「高」の返信・今日が期限のタスク）がある係：頭の上に赤い「!」、足の動きを速く */
.walker.rush .sprite::after { content: "!"; position: absolute; top: -22px; right: -8px; z-index: 2; width: 22px; height: 22px; border-radius: 50%;
                              background: var(--danger); border: 2px solid #fff; color: #fff; font-size: 15px; font-weight: 700; line-height: 18px; text-align: center;
                              animation: blink 1s steps(2) infinite; }
.walker.rush.moving img { animation-duration: .18s; }
@keyframes blink { from { opacity: 1; } to { opacity: .55; } }
.walker.working .sprite::before { content: ""; position: absolute; top: -7px; left: 50%; transform: translateX(-50%); width: 9px; height: 9px; border-radius: 50%; background: var(--ok); border: 2px solid #fff; z-index: 2; }
.walker .plate { display: none; position: absolute; left: 50%; top: 100%; transform: translateX(-50%); margin-top: 1px; white-space: nowrap; z-index: 3;
                 font-size: 13.5px; font-weight: 700; line-height: 1.3; background: rgba(255,255,255,.95); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; }
.walker:hover .plate, .walker.selected .plate { display: block; }
.walker.selected .plate { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(45,99,200,.35); }
/* 吹き出しは飾り。重なったほかのキャラを押せるよう、クリックは下へ素通りさせる */
.walker .bubble { pointer-events: none; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); width: max-content; max-width: 170px; text-wrap: balance;
                  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 4px 8px; font-size: 13.5px; line-height: 1.45; font-weight: 400;
                  box-shadow: 0 2px 6px rgba(11,31,58,.12); animation: fadein .3s ease; }
.walker .bubble b { display: block; font-size: 13.5px; }
.walker .bubble::after { content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 6px solid transparent; border-top-color: #fff; }
.walker.talking { z-index: 2000 !important; }
@keyframes fadein { from { opacity: 0; transform: translate(-50%, 4px); } to { opacity: 1; transform: translate(-50%, 0); } }

.legend { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin-top: 10px; font-size: 14px; color: var(--gray); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; background: var(--ok); }
.legend .rush-mark { display: inline-block; width: 20px; height: 20px; border-radius: 50%; margin-right: 6px; background: var(--danger); color: #fff;
                     font-size: 13.5px; font-weight: 700; line-height: 20px; text-align: center; }

/* 最近の動き */
.log { margin-top: 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.log h2 { font-size: 16px; margin-bottom: 6px; }
.log ul { list-style: none; }
.log li { display: grid; grid-template-columns: 52px 132px 1fr; gap: 8px; padding: 5px 0; border-top: 1px solid #EEF0F3; font-size: 14px; }
.log li:first-child { border-top: none; }
.log li.empty { display: block; color: var(--gray); }
.log li.new { animation: slidein .5s ease; background: #FFFBEA; }
.log .t { color: var(--gray); }
.log .who { font-weight: 700; }
/* 元（メール・Slack など）を開くリンク */
a.src { color: var(--blue); text-decoration: underline; text-decoration-color: rgba(45,99,200,.35); text-underline-offset: 3px; word-break: break-word; }
a.src:hover { text-decoration-color: var(--blue); }
@keyframes slidein { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* 右の欄 */
.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; align-self: start; position: sticky; top: 16px; }
.panel .p-head { display: flex; gap: 12px; align-items: center; }
.panel .p-head img { height: 72px; width: auto; }
.panel .p-name { font-size: 18px; font-weight: 700; }
.panel .p-room { font-size: 14px; color: var(--gray); }
.panel .p-label { margin-top: 14px; font-size: 14px; color: var(--gray); font-weight: 700; }
.panel p { font-size: 15px; margin-top: 2px; }
.panel ul { list-style: none; margin-top: 4px; }
.panel li { font-size: 14px; padding: 4px 0; border-top: 1px solid #EEF0F3; display: grid; grid-template-columns: 52px 1fr; gap: 6px; }
.panel li:first-child { border-top: none; }
.panel li .t { color: var(--gray); }
.panel .count { margin-top: 10px; font-size: 15px; font-weight: 700; }
.panel { max-height: calc(100vh - 32px); overflow-y: auto; }   /* 返信候補が多くても欄の中でスクロール */
.panel .note { font-size: 14px; color: var(--gray); background: #FFF6DE; border-radius: 8px; padding: 4px 8px; margin-top: 6px; }

/* 返信候補（メール係・Slack係の欄） */
.rcard { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-top: 10px; background: #fff; }
.rcard.waiting { background: #E7F6F2; border-color: #BFE5DA; }
.rcard .r-who { font-size: 14px; color: var(--gray); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rcard .r-what { font-size: 15px; font-weight: 700; line-height: 1.5; margin-top: 2px; word-break: break-word; }
.rcard .r-meta { font-size: 14px; color: var(--gray); margin-top: 2px; }
.rcard .r-meta.urgent { color: var(--danger); font-weight: 700; }
.rcard .tag { font-size: 13.5px; line-height: 1.4; padding: 0 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--gray); }
.rcard .draft { margin-top: 6px; background: #F5F7FA; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 14px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; max-height: 180px; overflow-y: auto; }
.rcard .draft-edit { margin-top: 6px; width: 100%; min-height: 160px; border: 1px solid var(--blue); border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 15px; line-height: 1.65; color: var(--text); resize: vertical; }
.rcard .r-err, .drow .r-err { margin-top: 6px; font-size: 14px; color: var(--danger); }
.rcard .btn-row, .drow .btn-row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; align-items: center; justify-content: flex-start; }
.rcard .btn, .drow .btn { min-height: 40px; padding: 0 14px; border-radius: 10px; font: inherit; font-size: 14.5px; font-weight: 700; cursor: pointer; border: 1px solid var(--blue); background: var(--blue); color: #fff; }
.rcard .btn.sub, .drow .btn.sub { background: #fff; color: var(--blue); }
.rcard .wait-note, .drow .wait-note { font-size: 14px; color: var(--gray); }

/* 期限切れのタスク（期限見張り係の欄） */
.drow { padding: 8px 0 10px; border-top: 1px solid #EEF0F3; }
.drow:first-child { border-top: none; }
.drow.done { background: #E7F6F2; border-radius: 8px; padding: 8px 10px; border-top: none; margin-bottom: 6px; }
.drow .d-line { display: grid; grid-template-columns: 52px 1fr; gap: 6px; font-size: 14px; }
.drow.done .d-line { display: block; font-weight: 700; }
.drow .d-line .t { color: var(--gray); }
.drow .d-date { min-height: 40px; border: 1px solid var(--blue); border-radius: 10px; padding: 0 10px; font: inherit; font-size: 15px; color: var(--text); }

/* 幅の狭い画面では、街と右の欄を縦に並べる */
@media (max-width: 1000px) {
  .wrap { grid-template-columns: 1fr; }
  .panel { position: static; }
}

/* ===== スマホ（幅767px以下） =====
   上の件数は1行・街は幅いっぱいで札は名前だけ・係のボタン（3×3）・係を選ぶと詳細（#panel）が下から出る・最近の動きは2段 */
.sp-only { display: none !important; }
.sheet-close, .sheet-handle { display: none; }
.roles-sec h2 { font-size: 15px; margin-bottom: 6px; }
.roles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.role-btn { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 6px 6px; text-align: center;
            font: inherit; color: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; }
.role-btn img { height: 40px; width: auto; display: block; margin-bottom: 2px; }
.role-btn .n { font-size: 14px; font-weight: 700; line-height: 1.3; }
.role-btn .s { font-size: 13.5px; color: var(--gray); line-height: 1.35; }
.role-btn .s.hot { color: var(--danger); font-weight: 700; }
.role-btn.on { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(45,99,200,.3); }
.role-btn .dot { position: absolute; top: 6px; left: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); }

@media (max-width: 767px) {
  .pc-only { display: none !important; }
  .legend.sp-only { display: flex !important; }
  .roles-sec.sp-only { display: block !important; }

  .top { padding: 10px 16px; gap: 2px 10px; }
  .top h1 { font-size: 18px; }
  .top .date { font-size: 13.5px; }
  .top .sum { width: 100%; order: 3; font-size: 14px; gap: 12px; }
  .top .sum b { font-size: 16px; }
  .top .back { margin-left: auto; font-size: 13.5px; }
  .demo { padding: 6px 16px; }
  .error { margin: 10px 16px 0; }

  .wrap { grid-template-columns: 1fr; gap: 0; padding: 0 0 20px; }
  .town { border-radius: 0; border-left: none; border-right: none; }
  .bldg { padding: 0 5px; border-width: 1.5px; border-radius: 6px; }
  .bldg b { font-size: 13.5px; }
  .bldg span { display: none; }
  .walker { width: 6.5%; }
  .walker .bubble { max-width: 150px; }
  .walker.rush .sprite::after { top: -16px; right: -10px; width: 18px; height: 18px; font-size: 13.5px; line-height: 14px; }
  .legend { margin-top: 0; padding: 6px 16px 0; gap: 12px; font-size: 13.5px; }
  .legend .rush-mark { width: 18px; height: 18px; line-height: 18px; }
  .roles-sec { padding: 12px 16px 0; }

  /* 最近の動き：「時刻・係」と「中身」の2段 */
  .log { margin: 12px 16px 0; padding: 10px 14px; }
  .log li { grid-template-columns: 46px 1fr; gap: 0 8px; }
  .log li > :nth-child(3) { grid-column: 1 / -1; font-size: 14.5px; line-height: 1.5; }

  /* 係の詳細：下から出る */
  .panel { position: fixed; left: 0; right: 0; bottom: 0; top: 18vh; z-index: 5000; max-height: none; overflow-y: auto; align-self: stretch;   /* パソコン用の align-self: start を外す（外さないと中身の高さまで伸びる） */
           border: none; border-radius: 18px 18px 0 0; padding: 0 16px 24px; box-shadow: 0 -4px 16px rgba(11,31,58,.18);
           transform: translateY(105%); visibility: hidden; transition: transform .25s ease, visibility .25s; }
  body.sheet-open { overflow: hidden; }
  body.sheet-open .panel { transform: none; visibility: visible; }
  .shade { position: fixed; inset: 0; z-index: 4999; background: rgba(26,35,50,.35); }
  .sheet-handle { display: block; width: 44px; height: 5px; border-radius: 3px; background: #C9CED8; margin: 8px auto 0; }
  .panel .p-head { position: sticky; top: 0; z-index: 1; background: #fff; padding: 8px 0 8px; border-bottom: 1px solid #EEF0F3; }
  .panel .p-head img { height: 48px; }
  .sheet-close { display: inline-block; margin-left: auto; min-height: 44px; padding: 0 14px; border-radius: 10px; font: inherit; font-size: 14.5px;
                 font-weight: 700; border: 1px solid var(--blue); background: #fff; color: var(--blue); cursor: pointer; }
}
