:root {
  --navy: #1b4f8a;
  --red: #c62828;
  --line: #d7dbe0;
  --bg: #f4f6f8;
  --card: #fff;
  --muted: #667;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: #1a1a1a;
  font: 17px/1.7 system-ui, "Segoe UI", "Yu Gothic UI", sans-serif;
}
header {
  background: var(--navy);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 5;
}
header h1 { font-size: 19px; margin: 0; }
/* 未確認があるときはヘッダーごと赤にする（点滅はしない） */
body.has-alert header { background: var(--red); }
body.has-alert header h1 { font-size: 21px; }
#who { font-size: 15px; display: flex; align-items: center; gap: 10px; }
/* 連絡ノートとの切り替え（Xserver 版だけ表示） */
.switch { display: flex; border: 1px solid #fff; border-radius: 8px; overflow: hidden; font-size: 16px; margin-left: auto; }
.switch > * { padding: 8px 16px; color: #fff; text-decoration: none; }
.switch .here { background: #fff; color: var(--navy); font-weight: 700; }
/* 連絡ノートから来た伝言の札 */
.src-badge { display: inline-block; font-size: 13px; padding: 1px 8px; margin-right: 8px; border-radius: 999px;
  background: #e6f2e8; color: #2f6b3a; border: 1px solid #2f6b3a; }
.src-badge.sys { background: #eef0f3; color: #445; border-color: #889; }
main { max-width: 1000px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.card.unread { border: 2px solid var(--red); background: #fff6f6; }
.card.withdrawn { opacity: .55; }

h2 { font-size: 17px; margin: 22px 0 10px; }
h2:first-child { margin-top: 0; }
.meta { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.body { white-space: pre-wrap; word-break: break-word; }

button {
  font: inherit;
  padding: 12px 18px;
  border-radius: 8px;
  border: 1px solid var(--navy);
  background: var(--navy);
  color: #fff;
  cursor: pointer;
  min-height: 48px;
}
button.sub { background: #fff; color: var(--navy); }
button.big { min-height: 68px; font-size: 20px; padding: 14px 28px; flex: 1; }
button.mini { min-height: auto; padding: 5px 12px; font-size: 14px; margin-right: 4px; }
button.listening { background: var(--red); border-color: var(--red); }
button.warn { background: #fff; color: var(--red); border-color: var(--red); }
button:disabled { opacity: .45; cursor: default; }
.row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

.names { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; }
.name-btn {
  position: relative;
  background: #fff;
  color: #1a1a1a;
  border: 1px solid var(--line);
  min-height: 60px;
  padding: 8px 10px;
  font-size: 17px;
}

/* トップ最上部の「未確認あり」の帯。スクロールしても上に貼り付く */
.alert-strip {
  position: sticky; top: 0; z-index: 5;
  background: var(--red); color: #fff; border-radius: 10px;
  padding: 12px 14px; margin: 0 0 14px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  box-shadow: 0 4px 14px rgba(198, 40, 40, .45);
  animation: strip-glow 1.6s ease-in-out infinite;
}
@keyframes strip-glow {
  0%, 100% { box-shadow: 0 4px 14px rgba(198, 40, 40, .45); }
  50% { box-shadow: 0 4px 26px rgba(198, 40, 40, .9); }
}
.alert-label { font-weight: 700; color: #fff; margin-right: 6px; font-size: 20px; width: 100%; }
.chip {
  min-height: auto; padding: 8px 14px; font-size: 18px; line-height: 1.2; font-weight: 700;
  background: #fff; color: var(--red); border: 2px solid #fff; border-radius: 999px;
}
.chip b { margin-left: 8px; background: var(--red); color: #fff; border-radius: 999px; padding: 0 9px; font-size: 15px; }
.chip.area { color: var(--navy); }
.chip.area b { background: var(--navy); }
.name-btn.has-unread {
  border: 3px solid var(--red); background: #ffe9e9; color: var(--red); font-weight: 700;
  box-shadow: 0 0 0 3px #ffd0d0;
}
.badge {
  position: absolute; top: -12px; right: -12px;
  background: var(--red); color: #fff; border: 2px solid #fff;
  border-radius: 999px; min-width: 36px;
  padding: 4px 10px; font-size: 17px; font-weight: bold;
  animation: badge-pop 1.6s ease-in-out infinite;
}
@keyframes badge-pop {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

input[type=text], input[type=password], textarea, select {
  font: inherit; width: 100%; padding: 12px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
textarea { min-height: 140px; resize: vertical; }
label.check {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 13px; background: #fff; margin: 0 8px 8px 0; cursor: pointer;
}
label.check input { width: 20px; height: 20px; }
label.check:has(input:checked) { border-color: var(--navy); background: #eaf2fb; }

.pin-display { font-size: 40px; letter-spacing: 18px; text-align: center; min-height: 56px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 320px; margin: 0 auto; }
.keypad button { min-height: 64px; font-size: 24px; background: #fff; color: #1a1a1a; border-color: var(--line); }

.err { color: var(--red); font-weight: bold; margin: 10px 0; }
.ok { color: #1b7a3c; font-weight: bold; margin: 10px 0; }
.empty { color: var(--muted); padding: 20px 0; }
.notice { background: #fffbe6; border: 1px solid #e8d98a; }
.notice .body { font-size: 22px; line-height: 1.6; font-weight: 600; }
.shift { background: #eef7ee; border: 1px solid #b9dcb9; }
.shift-line { font-size: 20px; line-height: 1.7; }
.shift-label { display: inline-block; min-width: 9em; font-weight: 700; color: #2b6b2b; }
.shift-part {
  display: inline-block; margin-right: 6px; padding: 1px 8px;
  font-size: 14px; font-weight: 600; color: #2b6b2b;
  background: #fff; border: 1px solid #b9dcb9; border-radius: 6px; vertical-align: 2px;
}
.shift-part.kyukan { color: var(--red); border-color: var(--red); }
.warn-tag {
  display: inline-block; margin-left: 6px; padding: 0 6px;
  font-size: 12px; color: var(--red); border: 1px solid var(--red); border-radius: 4px;
}
.tag { display: inline-block; background: #eef2f7; border-radius: 5px; padding: 2px 8px; font-size: 14px; margin-right: 6px; }
.tag.seen { background: #e6f4ea; }
.tag.unseen { background: #fdeaea; }
.files { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; }
.thumb { display: block; max-width: 240px; border-radius: 8px; border: 1px solid var(--line); }
.files audio { width: 320px; max-width: 100%; }
.file-btn {
  display: inline-block;
  background: #eaf2fb; color: var(--navy);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 14px; min-height: auto;
  font: inherit; font-size: 15px; text-decoration: none; cursor: pointer;
}
.kinds { display: block; margin-top: 5px; font-size: 13px; color: var(--navy); }
.tr {
  margin-top: 10px; padding: 10px 14px;
  background: #f3f6fa; border-left: 4px solid var(--navy); border-radius: 6px;
  font-size: 17px; line-height: 1.6; white-space: pre-wrap;
}
.thumb-btn { padding: 0; border: 0; background: none; min-height: auto; line-height: 0; }
.attached { display: inline-flex; align-items: center; gap: 8px; }
.viewer-body canvas, .viewer-body .full {
  display: block; width: 100%; margin-bottom: 12px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}

table { width: 100%; border-collapse: collapse; }
td, th { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; font-size: 15px; }

/* 電話メモの分割画面 */
#split-stage { position: relative; width: 100%; margin-top: 12px; border: 1px solid var(--line); background: #fff; touch-action: none; }
#split-canvas { display: block; width: 100%; }
#split-lines { position: absolute; inset: 0; }
.split-line { position: absolute; background: rgba(198, 40, 40, .85); touch-action: none; cursor: grab; }
.split-line.v { top: 0; bottom: 0; width: 4px; margin-left: -2px; padding: 0 14px; background-clip: content-box; }
.split-line.h { left: 0; right: 0; height: 4px; margin-top: -2px; padding: 14px 0; background-clip: content-box; }
.split-line.edge { background-color: rgba(27, 79, 138, .85); }
.split-cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.split-cell select { margin-top: 8px; }
.split-thumb { display: block; width: 100%; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.split-cell textarea { margin-top: 8px; min-height: 96px; font-size: 16px; }
.split-cell.is-empty { opacity: .6; }
.split-status { color: var(--red); font-weight: 600; }
.usage-total td { font-weight: 700; border-bottom: 2px solid var(--line); }
