:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --ink: #1d2733;
  --sub: #5b6b7c;
  --line: #dde4ec;
  --brand: #0e6e5c;
  --brand-dark: #0a5546;
  --accent: #eef7f4;
  --danger: #c0392b;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.65;
}
.wrap { max-width: 880px; margin: 0 auto; padding: 16px; }
header.app {
  background: var(--brand);
  color: #fff;
  padding: 14px 0;
}
header.app .wrap { display: flex; align-items: center; justify-content: space-between; padding-top: 0; padding-bottom: 0; }
header.app h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: .02em; }
header.app .who { font-size: 13px; opacity: .92; }
header.app button { background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.4); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin: 16px 0;
}
.card h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--sub); font-size: 13px; }

label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; }
input[type=text], input[type=password], input[type=url], input[type=number], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }

button {
  font-family: inherit;
  font-size: 15px;
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}
button:hover { background: var(--brand-dark); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.ghost { background: #fff; color: var(--brand); }
button.ghost:hover { background: var(--accent); }
button.small { font-size: 13px; padding: 6px 12px; }
button.danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn-row { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; }

.error { color: var(--danger); font-size: 13px; margin-top: 8px; white-space: pre-wrap; }

.loading { display: flex; align-items: center; gap: 12px; color: var(--sub); padding: 8px 0; }
.spinner {
  width: 22px; height: 22px; flex: none;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.badge {
  display: inline-block;
  background: var(--accent);
  color: var(--brand-dark);
  border-radius: 999px;
  padding: 2px 12px;
  font-size: 12.5px;
  font-weight: 600;
  margin: 2px 4px 2px 0;
}
.badge.gray { background: #eef1f5; color: var(--sub); }

.talk {
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 10px 0;
  background: #fff;
}
.talk .head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.talk .title { font-weight: 700; font-size: 15px; }
.talk .stars { color: #d99a00; font-size: 13px; white-space: nowrap; }
.talk .reason { font-size: 13.5px; color: var(--sub); margin-top: 6px; }
.talk .lp { margin-top: 8px; font-size: 13.5px; }
.talk .lp a { color: var(--brand); font-weight: 600; word-break: break-all; }

.notice {
  background: #fff8e6;
  border: 1px solid #f0dfa8;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12.5px;
  color: #7a5b00;
  margin-top: 14px;
}

/* モーダル */
.modal-back {
  position: fixed; inset: 0;
  background: rgba(20, 30, 40, .5);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 22px;
}
.candidate {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 10px 0;
  cursor: pointer;
}
.candidate:hover { border-color: var(--brand); background: var(--accent); }
.candidate .name { font-weight: 700; }
.candidate .meta { font-size: 13px; color: var(--sub); word-break: break-all; }

/* チャット */
.chat-log { margin-bottom: 12px; }
.msg { margin: 10px 0; display: flex; }
.msg .bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14.5px;
}
.msg.user { justify-content: flex-end; }
.msg.user .bubble { background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai .bubble { background: #eef1f5; border-bottom-left-radius: 4px; }
.chat-input { display: flex; gap: 8px; }
.chat-input textarea { flex: 1; min-height: 44px; max-height: 140px; }

/* テーブル（管理画面） */
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
th { background: #f7f9fb; font-size: 12.5px; color: var(--sub); white-space: nowrap; }
td .code { font-family: ui-monospace, Menlo, monospace; font-weight: 700; letter-spacing: .05em; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 16px; }
.tabs button {
  background: #e6ebf1; color: var(--sub); border: none; border-radius: 8px 8px 0 0;
  padding: 10px 18px; font-size: 14px;
}
.tabs button.active { background: var(--card); color: var(--brand-dark); border: 1px solid var(--line); border-bottom: none; }
.tab-body { background: var(--card); border: 1px solid var(--line); border-radius: 0 var(--radius) var(--radius) var(--radius); padding: 20px; }

.hidden { display: none !important; }

@media (max-width: 600px) {
  .wrap { padding: 10px; }
  .card { padding: 14px; }
  .msg .bubble { max-width: 95%; }
}
