:root {
  --bg: #f4f5f7;
  --card-bg: #ffffff;
  --border: #dde1e6;
  --text: #2b2f36;
  --muted: #6b7280;
  --accent: #06c755; /* LINEグリーン */
  --self-bubble: #e4f9e9;
  --other-bubble: #ffffff;
  --danger: #d64545;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
}
.topbar .brand { font-weight: bold; color: var(--text); }
.topbar nav { display: flex; gap: 16px; align-items: center; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  max-width: 480px;
}

.centered-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.login-card { width: 100%; }

label { display: block; margin-bottom: 14px; font-size: 14px; }
input[type="text"], input[type="password"], input[type="search"],
input[type="number"], input[type="date"], input[type="file"] {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}

fieldset { border: 1px solid var(--border); border-radius: 6px; margin-bottom: 14px; }
legend { font-size: 13px; color: var(--muted); padding: 0 6px; }
.radio-label, .checkbox-label { display: block; font-size: 14px; margin: 6px 0; }

button, .button {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 18px;
  font-size: 14px;
  cursor: pointer;
}
button:hover, .button:hover { opacity: 0.9; text-decoration: none; }

.linklike {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
}
.linklike.danger { color: var(--danger); }
.inline-form { display: inline; }

.hint { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); font-size: 14px; }

.talk-table { width: 100%; border-collapse: collapse; background: var(--card-bg); }
.talk-table th, .talk-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.viewer-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.viewer-toolbar h1 { flex: 1 0 100%; font-size: 20px; margin: 0 0 4px; }
.search-form { display: flex; gap: 6px; }
.search-form input { width: 240px; margin: 0; }
.toolbar-actions { display: flex; gap: 12px; align-items: center; margin-left: auto; }

.messages { display: flex; flex-direction: column; gap: 6px; }
.date-divider {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin: 18px 0 6px;
}
.message {
  max-width: 70%;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--other-bubble);
}
.message.from-self {
  align-self: flex-end;
  background: var(--self-bubble);
  border-color: #bfe9cc;
}
.message.matched { outline: 2px solid #f5a623; }
.message .meta { font-size: 11px; color: var(--muted); margin-bottom: 2px; display: flex; gap: 8px; }
.message .body { white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.message .body.type-stamp,
.message .body.type-photo,
.message .body.type-video,
.message .body.type-file,
.message .body.type-voice,
.message .body.type-location,
.message .body.type-call { color: var(--muted); font-style: italic; }

.viewer-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.date-sidebar {
  flex: 0 0 220px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  position: sticky;
  top: 12px;
}
.date-sidebar h2 { font-size: 16px; margin: 0 0 10px; }
.date-sidebar h3 { font-size: 13px; color: var(--muted); margin: 16px 0 6px; }
.date-sidebar .search-form { margin-bottom: 12px; }
.date-sidebar .search-form input { width: 100%; margin: 0 0 6px; }
.date-jump-form select { width: 100%; padding: 6px; border: 1px solid var(--border); border-radius: 6px; }
.date-nav { display: flex; justify-content: space-between; font-size: 13px; margin-top: 8px; }
.date-sidebar .toolbar-actions { margin: 14px 0; }
.sources-box { font-size: 12px; }
.sources-list { list-style: none; padding: 0; margin: 0; }
.sources-list li { padding: 4px 0; border-bottom: 1px dashed var(--border); word-break: break-all; }

.viewer-main { flex: 1; min-width: 0; }

@keyframes flash-highlight-anim {
  0%, 100% { background: #fff3cd; }
  50% { background: #ffe58a; }
}
.message.flash-highlight {
  animation: flash-highlight-anim 1s ease-in-out 2;
  outline: 2px solid #f5a623;
}

.search-results-list { list-style: none; padding: 0; }
.search-result-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--card-bg);
}
.search-result-item a { display: block; padding: 10px 14px; color: var(--text); }
.search-result-item a:hover { background: #f8faf9; text-decoration: none; }
.sr-meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.sr-snippet { font-size: 14px; }
.sr-snippet mark { background: #fff3cd; padding: 0 2px; }

@media (max-width: 700px) {
  .viewer-layout { flex-direction: column; }
  .date-sidebar { flex: none; width: 100%; position: static; }
}

@media print {
  .no-print { display: none !important; }
}
