/* app.css (09jan26-2) */

:root{
  --brand:#f1992e;
  --muted:#6b7280;
  --ink:#111827;
  --bg:#f8fafc;
  --card:#ffffff;
  --line:#e5e7eb;
  --btn:#fff;
  --btnLine:#e5e7eb;
}

*{box-sizing:border-box}

html,body{height:100%}
body{
  margin:0;
  font:14px/1.5 system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  color:var(--ink);
  background:var(--bg);
}

a{color:inherit}

/* Buttons */
button,.btn{
  background:var(--btn);
  border:1px solid var(--btnLine);
  border-radius:8px;
  padding:8px 12px;
  cursor:pointer;
}
button:active{transform:translateY(1px)}
.btn.nav{padding:6px 10px}
button:disabled,.btn:disabled{opacity:.45;cursor:not-allowed;transform:none}

/* Top bar */
.topbar{
  background:var(--brand);
  color:#fff;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:10px 16px;
  position:sticky;
  top:0;
  z-index:10;
}
.topbar .brand{
  font-weight:700;
  display:flex;
  gap:10px;
  align-items:center;
  min-width:0;
}
.topbar .brand .logo{
  width:18px;height:18px;
  border:2px solid #fff;
  border-radius:3px;
  opacity:.85;
}
.topbar .room{
  font-size:12px;
  opacity:.95;
  white-space:nowrap;
}
.topbar .btn{
  background:#fff;
  border:1px solid #ffffff66;
  border-radius:12px;
  padding:8px 10px;
}

/* Badges */
.badges{display:flex;gap:8px;align-items:center}
.pill{
  padding:2px 8px;
  border-radius:999px;
  font-size:12px;
  background:#fff;
  color:#111;
  border:1px solid #0000;
}
.pill.net.turn{color:#1f4ed8;border-color:#1f4ed8;background:#eef2ff}
.pill.net.stun{color:#92400e;border-color:#f59e0b;background:#fffbeb}
.pill.stat{background:#fff;border:1px solid #fff3;color:#0a0}
.pill.stat.bad{color:#a00}

/* =========================
   Main page layout (index)
   ========================= */
.wrap{
  display:grid;
  grid-template-columns:320px 1fr;
  gap:10px;
  padding:16px;
  width:100%;
  max-width:none;
  margin:0 auto;
}
@media (max-width:1100px){
  .wrap{grid-template-columns:1fr}
}

/* Panels / cards */
.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:10px;
  overflow:visible; /* critical: do NOT create a scroll container */
}

.panel{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:10px;
  padding:12px;
  position:sticky;
  top:58px;
}
.panelHead{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  margin-bottom:8px;
}
.panelHead h3{margin:0}

/* Header row */
.headrow{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin:4px 2px 8px;
  flex-wrap:wrap;
}
.headrow .count{font-weight:700;color:#111;white-space:nowrap}
.headrow .actions{
  display:flex;
  flex-direction:column;
  gap:6px;
  width:100%;
}
.headrow .actions .meta{
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:wrap;
  min-width:0;
}
#selectedPathLabel{
  max-width:40vw;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
#ourFilterWrap{
  display:flex;
  gap:8px;
  align-items:center;
  flex:1 1 520px;
  min-width:0;
}
#ourFilter{
  display:flex;
  gap:8px;
  align-items:center;
  overflow:auto;
  padding:4px 6px;
  border:1px solid var(--line);
  border-radius:10px;
  background:#fff;
  max-width:100%;
}
.headrow .actions .pager{
  display:flex;
  gap:8px;
  justify-content:flex-start;
  align-items:center;
  width:100%;
}

/* Table */
table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  min-width:980px;
}
thead th{
  background:#fafafa;
  border-bottom:1px solid var(--line);
  text-align:left;
  padding:10px;
  font-weight:700;
  color:#111;
}
tbody td{
  padding:10px;
  border-bottom:1px solid var(--line);
  vertical-align:top;
}
tbody tr:hover{background:#f9fafb}

.mono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
.muted{color:var(--muted)}

/* Date/tel cell */
.dtCell{display:flex;gap:8px;align-items:flex-start}
.dirIcon{
  width:52px;height:52px;
  border-radius:7px;
  display:inline-grid;
  place-items:center;
  font-size:36px;
  color:#fff;
  background:#9ca3af;
  margin-top:2px;
  flex-shrink:0;
}
.dir-in{background:#16a34a}
.dir-out{background:#2563eb}
.tel{white-space:nowrap}
.streak{
  font-size:12px;
  margin-left:4px;
  color:#b45309;
  background:#fffbeb;
  border:1px solid #fcd34d;
  padding:0 6px;
  border-radius:999px;
}
.timebox{font-variant-numeric:tabular-nums}

/* Summary preview */
.preview{
  display:-webkit-box;
  -webkit-line-clamp:4;
  -webkit-box-orient:vertical;
  overflow:hidden;
  max-width:480px;
  line-height:1.4;
  color:#111;
}

/* Icon buttons */
.iconbtn{
  width:28px;height:28px;
  border-radius:6px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border:1px solid var(--line);
  background:#fff;
  cursor:pointer;
  color:#6b7280;
  padding:0;
}
.iconbtn svg{
  width:18px;height:18px;
  display:block;
  stroke:currentColor;
  fill:none;
}
.iconbtn:disabled{opacity:.35;cursor:not-allowed}

/* Folder list rows (scoped to folder panel to avoid chat row conflicts) */
#folderList .row{
  display:flex;
  gap:8px;
  padding:6px;
  border-radius:8px;
  cursor:pointer;
}
#folderList .row:hover{background:#f9fafb}

/* Bit icon */
.bitBox{
  width:52px;height:52px;
  border-radius:7px;
  background:#e5e7eb;
  border:1px solid #d1d5db;
  box-shadow:0 1px 0 rgba(0,0,0,.12);
  display:flex;
  align-items:center;
  justify-content:center;
  margin-right:6px;
  flex-shrink:0;
}
.bitIcon{
  width:44px;height:44px;
  background-repeat:no-repeat;
  background-size:contain;
  background-position:center;
}

/* Debug log */
details.log{margin-top:12px}
details pre{
  white-space:pre-wrap;
  background:#f9fafb;
  border:1px solid var(--line);
  padding:10px;
  border-radius:8px;
  max-height:220px;
  overflow:auto;
}

/* Sidebar collapse */
#toggleFoldersBtn{font-size:16px;line-height:1}
body.folders-collapsed .wrap{grid-template-columns:56px 1fr}
body.folders-collapsed .panelBody{display:none}
body.folders-collapsed .panelHead{justify-content:center}
body.folders-collapsed .panelHead h3{display:none}

/* =========================
   Chat page helpers (chat.html)
   ========================= */
.chatWrap{
  max-width:980px;
  margin:0 auto;
  padding:12px;
  display:flex;
  flex-direction:column;
  gap:12px;
}

details.meta{
  background:#fff;
  border:1px solid var(--line);
  border-radius:12px;
  overflow:hidden;
}
details.meta summary{cursor:pointer;padding:10px 12px;font-weight:600}
.metaGrid{
  padding:0 12px 10px;
  display:grid;
  grid-template-columns:120px 1fr;
  gap:6px 10px;
  font-size:13px;
}
.metaKey{color:var(--muted)}
.status{color:var(--muted);font-size:12px;padding:8px 2px}

.chat{
  display:flex;
  flex-direction:column;
  gap:10px;
}
.chat .row{
  display:flex;
  gap:8px;
  align-items:flex-end;
}
.chat .row.a{justify-content:flex-start}
.chat .row.b{justify-content:flex-end}
.chat .bubble{
  max-width:min(680px,84vw);
  padding:10px 12px;
  border-radius:16px;
  line-height:1.45;
  white-space:pre-wrap;
  word-break:break-word;
  border:1px solid rgba(0,0,0,.06);
}
.chat .row.a .bubble{background:#fff;border-top-left-radius:6px}
.chat .row.b .bubble{background:#d9fdd3;border-top-right-radius:6px}
.chat .time{font-size:11px;color:var(--muted);white-space:nowrap}

/* ---- Bottom mini player ---- */
.playerbar{
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 10px 12px;
  z-index: 20;
}
.playerrow{display:flex;gap:8px;align-items:center;}
.plSeek{flex:1;min-width:120px;}
.plTime{font-size:12px;white-space:nowrap;}
.plTitle{font-size:12px;margin-top:6px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}

/* prevent page content being hidden behind the fixed bar */
body{padding-bottom:90px;}

/* === sticky overrides (keep top bar + head row visible) === */
:root{
  --topbar-h: 58px;    /* fallback; JS will update */
  --headrow-h: 72px;   /* fallback; JS will update */
}

/* top yellow bar: always visible */
.topbar{
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
}

/* keep content from going under the fixed topbar (also keep your bottom padding) */
body{
  padding-top: var(--topbar-h);
  padding-bottom: 90px;
}

/* left folder panel: stay below the fixed topbar */
.panel{
  top: calc(var(--topbar-h) + 16px);
}

/* “47/47 件” + 自店番号チェック: stay below topbar */
.headrow{
  position: sticky;
  top: var(--topbar-h);
  z-index: 900;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

/* allow horizontal scroll on the page for wide tables */
body{ overflow-x:auto; }

/* table header sticks under the CSV/headrow */
thead th{
  position: sticky;
  top: calc(var(--topbar-h) + var(--headrow-h));
  z-index: 850;
  background: #fafafa;
}

/* Momentary highlight for updated rows */
@keyframes flash-update {
  0% { background-color: #ff8000; }
  100% { background-color: transparent; }
}

.row-highlight {
  animation: flash-update 3.0s ease-out;
}