/* ================= テーマ変数 ================= */
:root {
  /* ライトテーマ (デフォルト) */
  --bg: #f2f5f9;
  --bg-panel: #ffffff;
  --bg-elev: #f7f9fc;
  --bg-hover: #eef2f8;
  --border: #dfe5ee;
  --border-strong: #c9d2e0;
  --text: #1e2635;
  --text-sub: #5a6478;
  --text-faint: #98a1b3;
  --accent: #3b6cf6;
  --accent-hover: #2f5be0;
  --accent-soft: #e8eeff;
  --accent-text: #3b6cf6;
  --green: #189d68;
  --green-soft: #e2f5ec;
  --red: #d64545;
  --star: #e8a413;
  --star-soft: #fdf3dc;
  --customer-bubble: #ffffff;
  --customer-border: #dfe5ee;
  --staff-bubble: #e8eeff;
  --staff-border: #c9d8ff;
  --badge-en-bg: #dcebff; --badge-en-fg: #1d6dd8;
  --badge-zh-bg: #ffe4d6; --badge-zh-fg: #c85a1e;
  --badge-ja-bg: #dcf5e7; --badge-ja-fg: #178552;
  --badge-ko-bg: #f0e0ff; --badge-ko-fg: #8a3ec9;
  --shadow: 0 1px 3px rgba(30, 40, 70, .08);
  --shadow-lg: 0 8px 32px rgba(30, 40, 70, .18);
}

[data-theme="dark"] {
  --bg: #0f1117;
  --bg-panel: #171a24;
  --bg-elev: #1c2030;
  --bg-hover: #222736;
  --border: #262b3a;
  --border-strong: #343b4f;
  --text: #e6e8ee;
  --text-sub: #9aa1b4;
  --text-faint: #626a7e;
  --accent: #5b7cfa;
  --accent-hover: #6f8cff;
  --accent-soft: #232c48;
  --accent-text: #a8bdfd;
  --green: #2e9e6b;
  --green-soft: #1b3229;
  --red: #e06060;
  --star: #f5b83d;
  --star-soft: #3a3220;
  --customer-bubble: #1e2230;
  --customer-border: #2c3040;
  --staff-bubble: #23324f;
  --staff-border: #33456b;
  --badge-en-bg: #1e3a5f; --badge-en-fg: #7db8f0;
  --badge-zh-bg: #4a2a2a; --badge-zh-fg: #f0a07d;
  --badge-ja-bg: #1e3d2f; --badge-ja-fg: #7de0a8;
  --badge-ko-bg: #3a2a4f; --badge-ko-fg: #c99df0;
  --shadow: 0 1px 3px rgba(0, 0, 0, .3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, .5);
}

/* ちいかわ風 (やわらかクリーム×パステル) */
[data-theme="cute"] {
  --bg: #fdf6ec;
  --bg-panel: #fffdf9;
  --bg-elev: #fdf3e7;
  --bg-hover: #fcecd8;
  --border: #f0e2cf;
  --border-strong: #e6d3b8;
  --text: #6b5847;
  --text-sub: #a08a72;
  --text-faint: #c4b299;
  --accent: #f5a3b8;
  --accent-hover: #ef8ba6;
  --accent-soft: #fde6ec;
  --accent-text: #e07a97;
  --green: #8ecdb0;
  --green-soft: #e2f4ec;
  --red: #ec9393;
  --star: #f5c86b;
  --star-soft: #fbf0d8;
  --customer-bubble: #fffdf9;
  --customer-border: #f0e2cf;
  --staff-bubble: #fde6ec;
  --staff-border: #f7c6d3;
  --badge-en-bg: #d8ecf7; --badge-en-fg: #4a97bf;
  --badge-zh-bg: #fbe0d0; --badge-zh-fg: #c9805a;
  --badge-ja-bg: #e0f2e2; --badge-ja-fg: #6aae78;
  --badge-ko-bg: #f0e2fb; --badge-ko-fg: #a877cf;
  --shadow: 0 2px 6px rgba(200, 160, 130, .18);
  --shadow-lg: 0 10px 34px rgba(200, 160, 130, .28);
}

/* さくら (桜ピンク) */
[data-theme="sakura"] {
  --bg: #fff0f4;
  --bg-panel: #fffafc;
  --bg-elev: #ffeef3;
  --bg-hover: #ffe3ec;
  --border: #f9d9e3;
  --border-strong: #f2c2d2;
  --text: #6a4652;
  --text-sub: #a67c8b;
  --text-faint: #ceb0bb;
  --accent: #ef7ba3;
  --accent-hover: #e86392;
  --accent-soft: #ffe0ea;
  --accent-text: #d95e8a;
  --green: #7fc9a4;
  --green-soft: #e2f4ec;
  --red: #e86a6a;
  --star: #f3b94e;
  --star-soft: #fbeecf;
  --customer-bubble: #fffafc;
  --customer-border: #f9d9e3;
  --staff-bubble: #ffe0ea;
  --staff-border: #f7bcd0;
  --badge-en-bg: #dcebff; --badge-en-fg: #1d6dd8;
  --badge-zh-bg: #ffe4d6; --badge-zh-fg: #c85a1e;
  --badge-ja-bg: #dcf5e7; --badge-ja-fg: #178552;
  --badge-ko-bg: #f0e0ff; --badge-ko-fg: #8a3ec9;
  --shadow: 0 2px 6px rgba(220, 150, 175, .18);
  --shadow-lg: 0 10px 34px rgba(220, 150, 175, .28);
}

/* ミント (やさしい緑) */
[data-theme="mint"] {
  --bg: #eef8f2;
  --bg-panel: #fbfefc;
  --bg-elev: #e8f5ee;
  --bg-hover: #ddf0e6;
  --border: #d2ebde;
  --border-strong: #b8ddca;
  --text: #3f5c4e;
  --text-sub: #6e9182;
  --text-faint: #a3c2b3;
  --accent: #34b382;
  --accent-hover: #2a9d70;
  --accent-soft: #d8f2e5;
  --accent-text: #269168;
  --green: #34b382;
  --green-soft: #d8f2e5;
  --red: #e07575;
  --star: #efb64a;
  --star-soft: #f8eccf;
  --customer-bubble: #fbfefc;
  --customer-border: #d2ebde;
  --staff-bubble: #d8f2e5;
  --staff-border: #a9ddc4;
  --badge-en-bg: #dcebff; --badge-en-fg: #1d6dd8;
  --badge-zh-bg: #ffe4d6; --badge-zh-fg: #c85a1e;
  --badge-ja-bg: #dcf5e7; --badge-ja-fg: #178552;
  --badge-ko-bg: #f0e0ff; --badge-ko-fg: #8a3ec9;
  --shadow: 0 2px 6px rgba(120, 180, 150, .18);
  --shadow-lg: 0 10px 34px rgba(120, 180, 150, .28);
}

/* うみ (爽やかブルー) */
[data-theme="ocean"] {
  --bg: #eaf4fb;
  --bg-panel: #fbfdff;
  --bg-elev: #e4f1fa;
  --bg-hover: #d8ebf7;
  --border: #cfe4f2;
  --border-strong: #b3d4ea;
  --text: #37505f;
  --text-sub: #648198;
  --text-faint: #9cbcd2;
  --accent: #2f96d6;
  --accent-hover: #2380c0;
  --accent-soft: #d6ecfa;
  --accent-text: #1f7fbf;
  --green: #35b39a;
  --green-soft: #d6f2ea;
  --red: #e37272;
  --star: #f0b74e;
  --star-soft: #f8edd0;
  --customer-bubble: #fbfdff;
  --customer-border: #cfe4f2;
  --staff-bubble: #d6ecfa;
  --staff-border: #a9d3ee;
  --badge-en-bg: #d8ecff; --badge-en-fg: #1d6dd8;
  --badge-zh-bg: #ffe4d6; --badge-zh-fg: #c85a1e;
  --badge-ja-bg: #dcf5e7; --badge-ja-fg: #178552;
  --badge-ko-bg: #f0e0ff; --badge-ko-fg: #8a3ec9;
  --shadow: 0 2px 6px rgba(90, 150, 200, .18);
  --shadow-lg: 0 10px 34px rgba(90, 150, 200, .28);
}

/* ちいかわ風・さくらは丸みを強めてやわらかく */
[data-theme="cute"] .btn-primary, [data-theme="cute"] .btn-secondary,
[data-theme="sakura"] .btn-primary, [data-theme="sakura"] .btn-secondary,
[data-theme="cute"] .msg, [data-theme="sakura"] .msg,
[data-theme="cute"] input, [data-theme="cute"] textarea,
[data-theme="sakura"] input, [data-theme="sakura"] textarea {
  border-radius: 16px;
}
[data-theme="cute"] .logo-icon { }
[data-theme="cute"] .logo-icon::after { content: "🐾"; }
[data-theme="sakura"] .logo-icon::after { content: "🌸"; }
[data-theme="mint"] .logo-icon::after { content: "🍀"; }
[data-theme="ocean"] .logo-icon::after { content: "🌊"; }
[data-theme="cute"] .logo-icon, [data-theme="sakura"] .logo-icon,
[data-theme="mint"] .logo-icon, [data-theme="ocean"] .logo-icon { font-size: 0; }
[data-theme="cute"] .logo-icon::after, [data-theme="sakura"] .logo-icon::after,
[data-theme="mint"] .logo-icon::after, [data-theme="ocean"] .logo-icon::after { font-size: 18px; }

/* テーマ選択セレクト */
.theme-select {
  font-family: inherit; font-size: 12px; padding: 5px 8px;
  border-radius: 6px; border: 1px solid var(--border-strong);
  background: var(--bg-panel); color: var(--text); cursor: pointer;
}
.login-box .theme-select { align-self: center; margin-top: 4px; }

/* ================= ベース ================= */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", "Noto Sans JP", sans-serif;
  background: var(--bg); color: var(--text); height: 100vh; overflow: hidden;
  transition: background .2s, color .2s;
}
.hidden { display: none !important; }
button { cursor: pointer; font-family: inherit; transition: background .15s, color .15s, border-color .15s; }
input, textarea {
  font-family: inherit; background: var(--bg-panel); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 10px 12px; font-size: 15px;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ================= ログイン ================= */
.login-screen {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-box {
  background: var(--bg-panel); padding: 40px; border-radius: 16px; width: 350px;
  display: flex; flex-direction: column; gap: 12px;
  border: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.login-box h1 { font-size: 22px; text-align: center; color: var(--accent); }
.login-logo {
  font-family: 'Fredoka', 'Hiragino Sans', sans-serif; font-weight: 700;
  font-size: 44px !important; letter-spacing: 1px;
}
.login-box .sub { text-align: center; color: var(--text-sub); font-size: 13px; margin-bottom: 8px; }
.login-box button {
  background: var(--accent); color: #fff; border: none; padding: 12px; border-radius: 8px; font-size: 15px; font-weight: 600;
}
.login-box button:hover { background: var(--accent-hover); }
.error { color: var(--red); font-size: 13px; text-align: center; min-height: 1em; }

/* ================= レイアウト ================= */
.app { display: grid; grid-template-columns: 250px 1fr 330px; height: 100vh; }
.sidebar-left, .sidebar-right {
  background: var(--bg-panel); display: flex; flex-direction: column;
}
.sidebar-left { border-right: 1px solid var(--border); }
.sidebar-right { border-left: 1px solid var(--border); }
.side-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 12px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 15px;
}
.logo { display: flex; align-items: center; gap: 7px; }
.logo-mascot { width: 26px; height: 26px; flex-shrink: 0; }
.logo-icon { font-size: 18px; line-height: 1; }
.logo-text { display: flex; flex-direction: column; line-height: 1.05; }
.logo-text {
  color: var(--accent); font-size: 20px; letter-spacing: .3px;
  font-family: 'Fredoka', 'Hiragino Sans', sans-serif; font-weight: 600;
}
.logo-tag { font-size: 8px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--text-faint); margin-top: 1px; }
.side-footer {
  padding: 10px 12px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-sub); flex-wrap: wrap;
}

/* ================= ボタン ================= */
.btn-primary {
  background: var(--accent); color: #fff; border: none; padding: 10px 16px;
  border-radius: 8px; font-size: 15px; font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-secondary {
  background: var(--green); color: #fff; border: none; padding: 10px 16px;
  border-radius: 8px; font-size: 15px; font-weight: 600;
}
.btn-secondary:disabled { opacity: .5; cursor: default; }
.btn-ghost {
  background: transparent; color: var(--text-sub);
  border: 1px solid var(--border-strong); border-radius: 6px; padding: 6px 10px;
}
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }
.small { font-size: 13px; padding: 5px 10px; }

/* ================= 会話リスト ================= */
.conv-list { flex: 1; overflow-y: auto; }
.conv-item {
  padding: 11px 8px 11px 12px; cursor: pointer; border-left: 3px solid transparent;
  display: flex; align-items: center; gap: 4px;
}
.conv-item:hover { background: var(--bg-hover); }
.conv-main { flex: 1; min-width: 0; }
.unread-dot {
  flex-shrink: 0; width: 9px; height: 9px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 0 3px var(--green-soft);
}
.conv-item.unread .conv-title { font-weight: 800; }
.conv-op {
  flex-shrink: 0; display: none; width: 26px; height: 26px;
  background: transparent; border: none; border-radius: 6px;
  color: var(--text-faint); font-size: 13px;
}
.conv-item:hover .conv-op { display: block; }
.conv-op:hover { background: var(--bg-panel); color: var(--text); }
.conv-del:hover { color: var(--red); }

.conv-tabs {
  display: flex; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.conv-tabs button {
  flex: 1; font-size: 12.5px; font-weight: 600; padding: 6px 0; border-radius: 6px;
  background: transparent; border: 1px solid var(--border-strong); color: var(--text-sub);
}
.conv-tabs button:hover { background: var(--bg-hover); }
.conv-tabs button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.conv-item.active { background: var(--accent-soft); border-left-color: var(--accent); }
.conv-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-sub { font-size: 12px; color: var(--text-sub); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { color: var(--text-faint); font-size: 14px; text-align: center; padding: 24px 12px; }

/* Poko ようこそ画面 */
.welcome {
  margin: auto; text-align: center; color: var(--text-sub);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.welcome-mascot {
  width: 96px; height: 96px; margin-bottom: 8px;
  animation: pokoFloat 3s ease-in-out infinite;
  filter: drop-shadow(0 8px 16px rgba(90,120,255,.25));
}
@keyframes pokoFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.welcome-title {
  font-family: 'Fredoka','Hiragino Sans',sans-serif; font-weight: 600;
  font-size: 20px; color: var(--accent);
}
.welcome-sub { font-size: 13px; }

/* ================= チャット ================= */
.chat-area { display: flex; flex-direction: column; height: 100vh; }
.chat-header {
  padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--bg-panel);
  display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px;
}
.lang-badge {
  background: var(--accent-soft); font-size: 12px; padding: 3px 10px;
  border-radius: 10px; color: var(--accent-text); font-weight: 600;
}
#btn-del-conv { margin-left: auto; }
.messages {
  flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px;
}
/* 背景画像: スクロールしないchat-areaに敷き、messagesは透明にして上に流す */
.chat-area.has-bg { background-size: cover; background-position: center; background-repeat: no-repeat; }
.chat-area.has-bg .messages { background: transparent; }
.chat-area.has-bg .msg { box-shadow: 0 2px 10px rgba(0,0,0,.25); }

/* LINE風: 吹き出し + 時刻を横並び */
.msg-line { display: flex; align-items: flex-end; gap: 6px; max-width: 82%; }
.msg-line.customer { align-self: flex-start; }
.msg-line.staff { align-self: flex-end; flex-direction: row; justify-content: flex-end; }
.msg-time { font-size: 10.5px; color: var(--text-faint); flex-shrink: 0; padding-bottom: 2px; }
.messages.has-bg .msg-time {
  background: rgba(0,0,0,.35); color: #fff; padding: 1px 6px; border-radius: 8px;
}

.msg {
  position: relative; padding: 12px 14px; border-radius: 16px; font-size: 15px;
  line-height: 1.6; box-shadow: var(--shadow);
}
.msg.customer {
  background: var(--customer-bubble); border: 1px solid var(--customer-border);
  border-bottom-left-radius: 4px;
}
.msg.staff {
  background: var(--staff-bubble); border: 1px solid var(--staff-border);
  border-bottom-right-radius: 4px;
}
/* しっぽ */
.msg.customer::before {
  content: ''; position: absolute; left: -6px; bottom: 6px;
  width: 12px; height: 12px; background: var(--customer-bubble);
  border-left: 1px solid var(--customer-border); border-bottom: 1px solid var(--customer-border);
  border-bottom-left-radius: 3px; transform: rotate(45deg);
}
.msg.staff::before {
  content: ''; position: absolute; right: -6px; bottom: 6px;
  width: 12px; height: 12px; background: var(--staff-bubble);
  border-right: 1px solid var(--staff-border); border-top: 1px solid var(--staff-border);
  border-top-right-radius: 3px; transform: rotate(45deg);
}
.msg-original { font-weight: 500; white-space: pre-wrap; }
.msg-label { font-size: 10.5px; font-weight: 700; color: var(--text-faint); margin-bottom: 3px; }
.msg-label.sent { color: var(--green); margin-top: 8px; }
.msg .sent-text {
  border-top: none; margin-top: 0; padding-top: 0;
  color: var(--text); font-weight: 500;
  border-left: 3px solid var(--green); padding-left: 8px;
}
.msg-translated {
  margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border-strong);
  color: var(--text-sub); font-size: 14px; white-space: pre-wrap;
}
.msg-intent { margin-top: 6px; font-size: 12px; color: var(--accent-text); font-weight: 600; }
.translating { color: var(--text-faint); font-style: italic; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: .5; } 50% { opacity: 1; } }
.msg-actions { display: flex; gap: 6px; margin-top: 8px; }
.btn-mini {
  background: transparent; border: 1px solid var(--border-strong);
  color: var(--text-sub); font-size: 12px; padding: 4px 11px; border-radius: 10px;
}
.btn-mini:hover { color: var(--accent-text); border-color: var(--accent); }
.star {
  background: transparent; border: 1px solid var(--border-strong);
  color: var(--text-sub); font-size: 12px; padding: 4px 11px; border-radius: 10px;
}
.star:hover { border-color: var(--star); color: var(--star); }
.star.on { background: var(--star-soft); border-color: var(--star); color: var(--star); font-weight: 600; }

/* ================= AI提案 ================= */
.suggestions {
  border-top: 1px solid var(--border); padding: 12px 18px;
  background: color-mix(in srgb, var(--bg-elev) 72%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  max-height: 260px; overflow-y: auto;
}
.sug-title { font-size: 14px; font-weight: 700; color: var(--accent-text); margin-bottom: 8px; }
.sug-title .hint { font-weight: 400; color: var(--text-faint); font-size: 12px; }
#sug-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sug-card {
  background: var(--bg-panel); border: 1.5px solid var(--border); border-radius: 10px;
  padding: 10px 12px; cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.sug-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.sug-ja { font-size: 14px; line-height: 1.5; }
.sug-foreign {
  font-size: 12px; color: var(--text-sub); margin-top: 6px; padding-top: 6px;
  border-top: 1px dashed var(--border); line-height: 1.5;
}

/* ================= 入力 ================= */
.input-area {
  border-top: 1px solid var(--border); background: var(--bg-panel);
  padding: 12px 18px; display: flex; flex-direction: column; gap: 8px;
}
.input-row { display: flex; gap: 8px; }
.input-row textarea { flex: 1; resize: none; }
.input-row button { white-space: nowrap; align-self: stretch; }
.reply-btns { display: flex; flex-direction: column; gap: 4px; }
.reply-btns button { flex: 1; }
.reply-btns .btn-ghost { font-size: 12px; padding: 6px 10px; }

/* ================= テンプレート ================= */
.tpl-controls {
  padding: 10px 12px 8px; border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
  position: sticky; top: 0; background: var(--bg-panel); z-index: 5;
}
.tpl-search { font-size: 14px; width: 100%; }
.tpl-langs { display: flex; gap: 4px; }
.tpl-langs button {
  flex: 1; font-size: 12px; padding: 5px 0; border-radius: 6px; font-weight: 600;
  background: transparent; border: 1px solid var(--border-strong); color: var(--text-sub);
}
.tpl-langs button:hover { background: var(--bg-hover); }
.tpl-langs button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.tpl-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }

/* カテゴリ (アコーディオン) */
.tpl-cat {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--accent-text); font-weight: 700;
  padding: 8px 6px; margin-top: 4px; border-radius: 6px; cursor: pointer;
  user-select: none;
}
.tpl-cat:hover { background: var(--bg-hover); }
.tpl-cat-arrow { color: var(--text-faint); font-size: 10px; width: 10px; }
.tpl-cat-count {
  margin-left: auto; background: var(--bg-elev); color: var(--text-sub);
  border: 1px solid var(--border);
  font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 8px;
}

/* テンプレ行 */
.tpl-item { border-radius: 8px; margin-bottom: 2px; }
.tpl-item.expanded {
  background: var(--bg-elev); border: 1px solid var(--border-strong);
  margin: 4px 0; box-shadow: var(--shadow);
}
.tpl-row {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 6px; border-radius: 8px; cursor: pointer;
}
.tpl-row:hover { background: var(--bg-hover); }
.tpl-lang-badge {
  flex-shrink: 0; font-size: 10px; font-weight: 700; width: 24px; text-align: center;
  padding: 2px 0; border-radius: 4px;
}
.lang-en { background: var(--badge-en-bg); color: var(--badge-en-fg); }
.lang-zh { background: var(--badge-zh-bg); color: var(--badge-zh-fg); }
.lang-ja { background: var(--badge-ja-bg); color: var(--badge-ja-fg); }
.lang-ko { background: var(--badge-ko-bg); color: var(--badge-ko-fg); }
.tpl-title {
  flex: 1; font-size: 13.5px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tpl-ops { display: none; gap: 2px; flex-shrink: 0; }
.tpl-row:hover .tpl-ops, .tpl-item.expanded .tpl-ops { display: flex; }
.tpl-ops button {
  font-size: 13px; width: 24px; height: 24px; border-radius: 5px;
  background: transparent; border: none; color: var(--text-faint);
}
.tpl-ops button:hover { color: var(--text); background: var(--bg-hover); }

/* プレビュー */
.tpl-preview { padding: 4px 10px 10px; }
.tpl-label { font-size: 11px; font-weight: 700; color: var(--text-faint); margin: 6px 0 3px; }
.tpl-meaning {
  background: var(--accent-soft); border-radius: 8px; padding: 6px 10px 8px; margin-bottom: 6px;
}
.tpl-meaning .tpl-label { color: var(--accent-text); margin-top: 0; }
.tpl-meaning-body {
  font-size: 13.5px; line-height: 1.6; white-space: pre-wrap;
  max-height: 140px; overflow-y: auto;
}
#btn-tpl-translate, #btn-tpl-korean { width: 100%; }
.tpl-preview-body {
  font-size: 13px; color: var(--text-sub); line-height: 1.6;
  white-space: pre-wrap; max-height: 130px; overflow-y: auto;
  border-left: 2px solid var(--accent); padding-left: 8px; margin-bottom: 8px;
}
/* 操作ボタンは常に見えるようプレビュー下部に固定表示 */
.tpl-preview-actions {
  display: flex; gap: 6px; position: sticky; bottom: 0;
  background: var(--bg-elev); padding-top: 6px;
}
.tpl-preview-actions .tpl-use { flex: 1; }
.tpl-preview-actions .tpl-copy { flex-shrink: 0; }

/* ================= モーダル ================= */
.modal {
  position: fixed; inset: 0; background: rgba(15, 20, 35, .5);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-box {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 24px; width: 480px; max-width: 92vw; display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow-lg);
}
.modal-box h3 { font-size: 15px; margin-bottom: 4px; }
.modal-note { font-size: 12.5px; color: var(--text-sub); line-height: 1.6; margin-bottom: 4px; }
.tm-btn {
  text-align: left; padding: 12px 14px; border-radius: 10px; font-size: 14px;
  background: var(--bg-elev); border: 1px solid var(--border-strong); color: var(--text);
}
.tm-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

/* ================= トースト ================= */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--green); color: #fff; padding: 10px 20px; border-radius: 10px;
  font-size: 13px; z-index: 200; box-shadow: var(--shadow-lg);
}
.toast.error { background: var(--red); }

/* ================= 予約フォーム ================= */
.res-box { width: 620px; }
.res-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.res-grid label, .res-full {
  display: flex; flex-direction: column; gap: 3px;
  font-size: 12px; color: var(--text-sub); font-weight: 600;
}
.res-grid input, .res-grid select, .res-full textarea { font-size: 14px; font-weight: 400; color: var(--text); }
.res-full { margin-top: 8px; }

/* ================= 予約台帳 ================= */
.ledger-box { width: 720px; max-width: 94vw; }
.ledger-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.ledger-head h3 { flex-shrink: 0; }
.ledger-search { flex: 1; font-size: 14px; }
.ledger-list { max-height: 65vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.ledger-item {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
}
.ledger-main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.ledger-dt { font-weight: 700; }
.ledger-girl { color: var(--accent-text); font-weight: 600; }
.ledger-cust { color: var(--text-sub); font-size: 13px; }
.ledger-sub { font-size: 12px; color: var(--text-sub); margin-top: 4px; }
.ledger-ops { display: flex; gap: 6px; margin-top: 8px; }
.ledger-ops button {
  font-size: 12px; padding: 4px 10px; border-radius: 6px;
  background: transparent; border: 1px solid var(--border-strong); color: var(--text-sub);
}
.ledger-ops button:hover { color: var(--text); background: var(--bg-hover); }
.res-status {
  font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 10px;
  background: var(--bg-hover); color: var(--text-sub);
}
.res-status.st-tmp { background: var(--star-soft); color: var(--star); }
.res-status.st-ok { background: var(--accent-soft); color: var(--accent-text); }
.res-status.st-done { background: var(--green-soft); color: var(--green); }
.res-status.st-cancel { background: var(--bg-hover); color: var(--text-faint); text-decoration: line-through; }

/* ================= レスポンシブ ================= */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar-left, .sidebar-right { display: none; }
  #sug-cards { grid-template-columns: 1fr; }
  .res-grid { grid-template-columns: 1fr; }
}
