:root {
  --line-green: #06C755;
  --line-green-dark: #05a847;
  --rail-bg: #2B303B;
  --rail-text: #9AA4B2;
  --pane-bg: #FFFFFF;
  --pane-sub-bg: #F6F7F9;
  --pane-border: #E5E8EC;
  --text-main: #111827;
  --text-muted: #6B7280;
  --chat-bg: #7494C0;
  --bubble-mine: #8DE055;
  --bubble-mine-text: #111827;
  --bubble-theirs: #FFFFFF;
  --bubble-theirs-text: #111827;
  --chat-hdr-bg: rgba(255, 255, 255, 0.94);
  --composer-bg: #FFFFFF;
  --meta-text: rgba(255, 255, 255, 0.92);
}

body.theme-tracen {
  --chat-bg: #7FA88E;
  --bubble-mine: #9CE76B;
}

body.theme-dark {
  --pane-bg: #1E2128;
  --pane-sub-bg: #17191E;
  --pane-border: #2D313C;
  --text-main: #F3F4F6;
  --text-muted: #9CA3AF;
  --chat-bg: #13161B;
  --bubble-mine: #2E7D32;
  --bubble-mine-text: #FFFFFF;
  --bubble-theirs: #272B34;
  --bubble-theirs-text: #F3F4F6;
  --chat-hdr-bg: rgba(30, 33, 40, 0.95);
  --composer-bg: #1E2128;
  --meta-text: #9CA3AF;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  background: var(--pane-bg);
  color: var(--text-main);
  font-size: 14px;
}

button, input, textarea {
  font-family: inherit;
}

/* ================= スマホ起動ステージ ================= */
#boot-stage {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 25%, #1f2d47 0%, #090e1a 72%);
  transition: opacity 0.35s ease;
}

#boot-stage.fade-out {
  opacity: 0;
  pointer-events: none;
}

#boot-stage[hidden] {
  display: none;
}

#phone-shell {
  position: relative;
  width: 360px;
  height: min(740px, 90dvh);
  border-radius: 46px;
  border: 10px solid #161d2b;
  background: linear-gradient(155deg, #1b4332 0%, #0f766e 42%, #0c4a6e 100%);
  box-shadow: 0 32px 96px rgba(0, 0, 0, 0.72), inset 0 0 0 2px rgba(255, 255, 255, 0.14);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition:
    width 0.65s cubic-bezier(0.22, 1, 0.36, 1),
    height 0.65s cubic-bezier(0.22, 1, 0.36, 1),
    border-radius 0.55s ease,
    border-width 0.45s ease;
}

#phone-shell.expanding {
  width: 100vw !important;
  height: 100dvh !important;
  border-radius: 0 !important;
  border-width: 0 !important;
  box-shadow: none !important;
}

.phone-notch {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 112px;
  height: 22px;
  background: #0b0f17;
  border-radius: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.25s ease;
}

#phone-shell.expanding .phone-notch,
#phone-shell.expanding .phone-status-bar,
#phone-shell.expanding .phone-home-bar {
  opacity: 0;
}

.notch-speaker {
  width: 38px;
  height: 4px;
  border-radius: 4px;
  background: #273247;
}

.notch-cam {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1d3b5c;
}

.phone-status-bar {
  position: relative;
  z-index: 15;
  height: 36px;
  padding: 10px 22px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

#phone-home {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 20px 20px 18px;
  color: #ffffff;
}

#boot-skip-btn {
  position: absolute;
  top: 6px;
  right: 14px;
  background: rgba(0, 0, 0, 0.38);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  z-index: 30;
}

#boot-skip-btn:hover {
  background: rgba(0, 0, 0, 0.65);
}

.phone-date-widget {
  text-align: center;
  margin-top: 8px;
  margin-bottom: 14px;
}

.phone-widget-time {
  font-size: 48px;
  font-weight: 300;
  letter-spacing: -1px;
  line-height: 1.05;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.phone-widget-date {
  font-size: 12px;
  opacity: 0.92;
  margin-top: 3px;
  font-weight: 600;
}

.phone-weather-card {
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 16px;
  padding: 10px 14px;
  margin-bottom: 20px;
  font-size: 12.5px;
  font-weight: 700;
}

.phone-weather-card small {
  display: block;
  margin-top: 2px;
  font-weight: 500;
  font-size: 11px;
  opacity: 0.9;
}

.phone-app-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px 10px;
  margin-bottom: auto;
}

.phone-app-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  color: #ffffff;
  text-decoration: none;
  cursor: pointer;
  position: relative;
}

.phone-app-tile.decorative {
  cursor: default;
  opacity: 0.88;
}

.app-icon-box {
  width: 56px;
  height: 56px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  position: relative;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.28);
  transition: transform 0.18s ease;
}

.icon-lane {
  background: linear-gradient(145deg, #09d65d 0%, #05b44c 100%);
}

.lane-speech-bubble {
  background: #ffffff;
  color: #06C755;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.4px;
  padding: 6px 8px;
  border-radius: 50% 50% 50% 45%;
  position: relative;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

.app-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  background: #ef4444;
  color: #ffffff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
}

.icon-umatter { background: linear-gradient(145deg, #fb923c, #ea580c); }
.icon-music   { background: linear-gradient(145deg, #f472b6, #db2777); }
.icon-portal  { background: linear-gradient(145deg, #34d399, #059669); }
.icon-keiba   { background: linear-gradient(145deg, #22c55e, #15803d); }
.icon-gacha   { background: linear-gradient(145deg, #a78bfa, #7c3aed); }
.icon-calendar{ background: linear-gradient(145deg, #60a5fa, #2563eb); }
.icon-settings{ background: linear-gradient(145deg, #94a3b8, #475569); }

.app-label {
  font-size: 11px;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
}

.phone-app-tile.tapped .app-icon-box {
  transform: scale(0.86);
}

.phone-app-tile.tapped::after {
  content: "";
  position: absolute;
  top: 28px;
  left: 50%;
  width: 58px;
  height: 58px;
  transform: translate(-50%, -50%) scale(0.8);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  animation: tap-ripple 0.48s ease-out forwards;
  pointer-events: none;
}

@keyframes tap-ripple {
  0% { opacity: 0.9; transform: translate(-50%, -50%) scale(0.7); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.9); }
}

.phone-home-hint {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.35);
  padding: 6px 14px;
  border-radius: 999px;
  margin: 0 auto 12px;
}

.phone-dock {
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(12px);
  border-radius: 24px;
  padding: 10px 16px;
  display: flex;
  justify-content: space-around;
}

.dock-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.dock-icon.active {
  background: var(--line-green);
}

/* Splash Screen inside Phone Shell */
#phone-splash {
  position: absolute;
  inset: 0;
  background: var(--line-green);
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.35);
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

#phone-splash.visible {
  opacity: 1;
  transform: scale(1);
}

.splash-logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #ffffff;
}

.splash-bubble {
  background: #ffffff;
  color: var(--line-green);
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 1px;
  padding: 18px 26px;
  border-radius: 50%;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  margin-bottom: 14px;
}

.splash-title {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 3px;
}

.splash-sub {
  font-size: 11px;
  opacity: 0.9;
  margin-top: 3px;
}

.splash-dots {
  display: flex;
  gap: 6px;
  margin-top: 22px;
}

.splash-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  animation: dot-bounce 0.9s infinite ease-in-out;
}

.splash-dots span:nth-child(2) { animation-delay: 0.15s; }
.splash-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes dot-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1.15); opacity: 1; }
}

.phone-home-bar {
  position: absolute;
  bottom: 7px;
  left: 50%;
  transform: translateX(-50%);
  width: 114px;
  height: 4px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 4px;
  z-index: 30;
}

/* ================= 端末別スマホテーマ（閲覧端末に合わせる） ================= */
@media (min-width: 768px) {
  #phone-shell.device-ios {
    border-radius: 56px;
    border: 11px solid #2b2b30;
    box-shadow: 0 32px 96px rgba(0, 0, 0, 0.72), inset 0 0 0 2px rgba(255, 255, 255, 0.22);
  }

  #phone-shell.device-android {
    border-radius: 38px;
    border-width: 8px;
    border-color: #101418;
  }
}

/* iOS: Dynamic Island + iOS風の壁紙・ドック */
#phone-shell.device-ios {
  background: linear-gradient(165deg, #2e3a67 0%, #5b4a8a 48%, #a24a7a 100%);
}

#phone-shell.device-ios .phone-notch {
  top: 10px;
  width: 96px;
  height: 24px;
  border-radius: 20px;
  background: #000000;
}

#phone-shell.device-ios .notch-speaker {
  display: none;
}

#phone-shell.device-ios .app-icon-box {
  border-radius: 14px;
}

#phone-shell.device-ios .phone-dock {
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.28);
}

#phone-shell.device-ios .phone-home-bar {
  width: 134px;
  height: 5px;
}

/* Android: パンチホールカメラ + Pixel風の壁紙・円形アイコン */
#phone-shell.device-android {
  background: linear-gradient(160deg, #1c2b4a 0%, #3d5a80 55%, #7fb0c9 100%);
}

#phone-shell.device-android .phone-notch {
  top: 12px;
  left: 26px;
  transform: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #0b0f17;
}

#phone-shell.device-android .phone-status-bar {
  padding-left: 48px;
}

#phone-shell.device-android .notch-speaker,
#phone-shell.device-android .notch-cam {
  display: none;
}

#phone-shell.device-android .app-icon-box {
  border-radius: 50%;
}

#phone-shell.device-android .phone-dock {
  background: transparent;
  backdrop-filter: none;
}

#phone-shell.device-android .dock-icon {
  border-radius: 50%;
}

#phone-shell.device-android .phone-home-bar {
  width: 96px;
}

/* ================= 端末内アプリ画面（カレンダー / 設定） ================= */
#phone-app-screen {
  position: absolute;
  left: 0;
  right: 0;
  top: 36px;
  bottom: 0;
  z-index: 18;
  background: #f8fafc;
  color: #0f172a;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(4%);
  pointer-events: none;
  transition: opacity 0.24s ease, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

#phone-app-screen.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#phone-app-screen[hidden] {
  display: none;
}

.pas-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}

#pas-back-btn {
  border: none;
  background: transparent;
  color: #2563eb;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 6px;
  font-family: inherit;
}

.pas-title {
  flex: 1;
  text-align: center;
  font-size: 14.5px;
  font-weight: 800;
  color: #0f172a;
}

.pas-header-spacer {
  width: 64px;
}

.pas-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 28px;
}

/* ---- レースカレンダー ---- */
.cal-head {
  padding: 16px 16px 4px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.cal-year {
  font-size: 17px;
  font-weight: 800;
  color: #0f172a;
}

.cal-count {
  font-size: 11.5px;
  color: #64748b;
}

.cal-chips {
  display: flex;
  gap: 6px;
  padding: 10px 16px 6px;
  flex-wrap: wrap;
}

.cal-chip {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.cal-chip.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

.cal-month {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(248, 250, 252, 0.95);
  backdrop-filter: blur(6px);
  padding: 10px 16px 6px;
  font-size: 13px;
  font-weight: 900;
  color: #1e293b;
}

.cal-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  background: #ffffff;
  border-bottom: 1px solid #eef2f7;
}

.cal-row.past {
  opacity: 0.45;
}

.cal-row.next {
  background: #eff6ff;
}

.cal-date {
  width: 40px;
  text-align: center;
  flex-shrink: 0;
}

.cal-md {
  display: block;
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
}

.cal-dow {
  display: block;
  font-size: 10px;
  color: #64748b;
}

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

.cal-name {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
}

.cal-next-tag {
  margin-left: 6px;
  background: #2563eb;
  color: #ffffff;
  font-size: 9.5px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 999px;
  vertical-align: 2px;
}

.cal-meta {
  font-size: 11px;
  color: #64748b;
  margin-top: 1px;
}

.cal-badge {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 900;
  padding: 3px 7px;
  border-radius: 6px;
  color: #ffffff;
  background: #94a3b8;
}

.cal-badge.cls-G1 { background: #dc2626; }
.cal-badge.cls-G2 { background: #2563eb; }
.cal-badge.cls-G3 { background: #16a34a; }
.cal-badge.cls-JG { background: #7c3aed; }
.cal-badge.cls-L { background: #0d9488; }
.cal-badge.cls-OP { background: #64748b; }

.cal-loading {
  padding: 40px 16px;
  text-align: center;
  color: #64748b;
  font-size: 13px;
}

/* ---- 端末設定（共通） ---- */
.set-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 16px 4px;
  padding: 14px;
  background: #ffffff;
  border-radius: 16px;
}

.set-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(145deg, #f59e0b, #ef4444);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 900;
  flex-shrink: 0;
}

.set-profile-name {
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
}

.set-profile-sub {
  font-size: 11.5px;
  color: #64748b;
}

.set-chevron {
  margin-left: auto;
  color: #94a3b8;
  font-size: 20px;
}

.set-group-label {
  margin: 18px 28px 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: #64748b;
}

.set-group {
  margin: 0 16px;
  background: #ffffff;
  border-radius: 16px;
  overflow: hidden;
}

.set-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
}

.set-row + .set-row {
  border-top: 1px solid #eef2f7;
}

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

.set-row-title {
  font-size: 13.5px;
  font-weight: 600;
  color: #0f172a;
}

.set-row-sub {
  font-size: 11px;
  color: #64748b;
  margin-top: 1px;
}

.set-row-value {
  font-size: 12.5px;
  color: #64748b;
  flex-shrink: 0;
}

.set-seg-row {
  display: flex;
  gap: 6px;
  padding: 0 14px 14px;
}

.set-seg {
  flex: 1;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  border-radius: 10px;
  padding: 7px 0;
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
  font-family: inherit;
}

.set-seg.active {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}

.set-switch {
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: #cbd5e1;
  border: none;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s ease;
  padding: 0;
}

.set-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease, width 0.2s ease, height 0.2s ease, top 0.2s ease;
}

.set-switch.on {
  background: #16a34a;
}

.set-switch.on::after {
  transform: translateX(20px);
}

/* ---- 設定: iOS風 ---- */
#phone-app-screen.kind-ios {
  background: #f2f2f7;
}

#phone-app-screen.kind-ios .pas-header {
  background: rgba(249, 249, 249, 0.94);
  border-bottom: 0.5px solid #c6c6c8;
}

#phone-app-screen.kind-ios .set-group {
  border-radius: 12px;
}

#phone-app-screen.kind-ios .set-group-label {
  color: #6d6d72;
  margin-left: 32px;
}

#phone-app-screen.kind-ios .set-switch {
  width: 51px;
  height: 31px;
  background: #e9e9ea;
}

#phone-app-screen.kind-ios .set-switch::after {
  width: 27px;
  height: 27px;
}

#phone-app-screen.kind-ios .set-switch.on {
  background: #34c759;
}

#phone-app-screen.kind-ios .set-seg {
  border-radius: 8px;
}

#phone-app-screen.kind-ios .set-seg.active {
  background: #007aff;
  border-color: #007aff;
}

#phone-app-screen.kind-ios .cal-month {
  background: rgba(242, 242, 247, 0.95);
}

/* ---- 設定: Android風 (Material 3) ---- */
#phone-app-screen.kind-android {
  background: #f0f4f9;
}

#phone-app-screen.kind-android .pas-header {
  background: #f0f4f9;
  border-bottom: none;
}

#phone-app-screen.kind-android .pas-title {
  text-align: left;
  font-size: 16px;
}

#phone-app-screen.kind-android #pas-back-btn {
  color: #6750a4;
}

#phone-app-screen.kind-android .set-group {
  border-radius: 20px;
}

#phone-app-screen.kind-android .set-profile {
  border-radius: 24px;
}

#phone-app-screen.kind-android .set-switch {
  width: 52px;
  height: 32px;
  background: #e6e0e9;
  border: 2px solid #79747e;
}

#phone-app-screen.kind-android .set-switch::after {
  width: 16px;
  height: 16px;
  top: 6px;
  left: 6px;
  background: #79747e;
  box-shadow: none;
}

#phone-app-screen.kind-android .set-switch.on {
  background: #6750a4;
  border-color: #6750a4;
}

#phone-app-screen.kind-android .set-switch.on::after {
  transform: translateX(20px);
  width: 24px;
  height: 24px;
  top: 2px;
  background: #ffffff;
}

#phone-app-screen.kind-android .set-seg {
  border-radius: 999px;
}

#phone-app-screen.kind-android .set-seg.active {
  background: #6750a4;
  border-color: #6750a4;
}

#phone-app-screen.kind-android .cal-chip.active {
  background: #6750a4;
  border-color: #6750a4;
}

#phone-app-screen.kind-android .cal-month {
  background: rgba(240, 244, 249, 0.95);
}

#phone-app-screen.kind-android .cal-row.next {
  background: #f3eefc;
}

#phone-app-screen.kind-android .cal-next-tag {
  background: #6750a4;
}

/* ================= メインアプリ本体 (PC 3ペイン / スマホ 1ペイン) ================= */
#lane-app {
  display: flex;
  width: 100vw;
  height: 100dvh;
  background: var(--pane-bg);
  opacity: 1;
  transition: opacity 0.28s ease;
}

#lane-app.app-hidden {
  opacity: 0;
}

/* 左レール */
.left-rail {
  width: 64px;
  flex-shrink: 0;
  background: var(--rail-bg);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  user-select: none;
}

.rail-top, .rail-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.rail-avatar-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--line-green);
  background: #ffffff;
  font-size: 22px;
  cursor: pointer;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rail-nav-btn {
  width: 52px;
  padding: 7px 2px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--rail-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  position: relative;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.rail-nav-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.rail-nav-btn.active {
  color: #ffffff;
  background: rgba(6, 199, 85, 0.22);
}

.rail-ico { font-size: 19px; line-height: 1.1; }
.rail-lbl { font-size: 10px; font-weight: 700; }

.rail-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rail-badge[hidden] { display: none; }

/* 中央ペイン */
.middle-pane {
  width: 330px;
  flex-shrink: 0;
  border-right: 1px solid var(--pane-border);
  background: var(--pane-bg);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
}

.middle-header {
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--pane-border);
  background: var(--pane-bg);
}

.middle-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.middle-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-pill {
  background: var(--line-green);
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
  padding: 2px 7px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.middle-title-row h1 {
  font-size: 18px;
  font-weight: 800;
}

.middle-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  border: none;
  background: transparent;
  color: var(--text-main);
  font-size: 16px;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: rgba(128, 128, 128, 0.14);
}

.icon-btn.active-flag {
  color: var(--line-green);
  background: rgba(6, 199, 85, 0.14);
}

.search-box-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--pane-sub-bg);
  border: 1px solid var(--pane-border);
  border-radius: 999px;
  padding: 6px 12px;
  margin-bottom: 8px;
}

.search-ico { font-size: 13px; color: var(--text-muted); }

.search-box-wrap input {
  border: none;
  background: transparent;
  color: var(--text-main);
  width: 100%;
  outline: none;
  font-size: 13px;
}

.filter-chips {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.filter-chips[hidden] { display: none; }

.chip {
  border: 1px solid var(--pane-border);
  background: var(--pane-sub-bg);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.chip.active {
  background: var(--line-green);
  color: #ffffff;
  border-color: var(--line-green);
}

.middle-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

/* ルームリスト項目 */
.room-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.12s;
}

.room-item:hover {
  background: var(--pane-sub-bg);
}

.room-item.active {
  background: rgba(6, 199, 85, 0.1);
  border-left-color: var(--line-green);
}

.room-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #ffffff;
  font-weight: 800;
  background: #cbd5e1;
}

.room-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.group-grid-avatar {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 1px;
  background: #ffffff;
}

.group-grid-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.room-body {
  flex: 1;
  min-width: 0;
}

.room-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 3px;
}

.room-title-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.room-title {
  font-weight: 700;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-count-tag {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.room-time {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.room-bot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.room-preview {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-badges {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.unread-pill {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--line-green);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.official-shield {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--line-green);
  color: #ffffff;
  font-size: 9px;
  font-weight: 900;
  flex-shrink: 0;
}

.official-shield.blue {
  background: #2563EB;
}
.official-shield[hidden] { display: none; }

/* 友だちセクション */
.friend-section-head {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-muted);
  background: var(--pane-sub-bg);
  border-top: 1px solid var(--pane-border);
  border-bottom: 1px solid var(--pane-border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.friend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
}

.friend-row:hover {
  background: var(--pane-sub-bg);
}

.friend-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: #e2e8f0;
}

.friend-info {
  flex: 1;
  min-width: 0;
}

.friend-name {
  font-weight: 700;
  font-size: 13.5px;
}

.friend-tagline {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 設定パネル */
.settings-box {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-card {
  background: var(--pane-sub-bg);
  border: 1px solid var(--pane-border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-card h3 {
  font-size: 13px;
  font-weight: 800;
}

.field-lbl {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.settings-card input[type="text"],
.lane-modal input[type="text"] {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--pane-border);
  background: var(--pane-bg);
  color: var(--text-main);
  font-size: 13px;
}

.theme-btn-row {
  display: flex;
  gap: 6px;
}

.theme-choice {
  flex: 1;
  padding: 7px 4px;
  border-radius: 8px;
  border: 1px solid var(--pane-border);
  background: var(--pane-bg);
  color: var(--text-main);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}

.theme-choice.active {
  border-color: var(--line-green);
  background: rgba(6, 199, 85, 0.14);
  color: var(--line-green-dark);
}

/* 右トーク画面 */
.chat-pane {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: var(--chat-bg);
  display: flex;
  flex-direction: column;
  position: relative;
}

.chat-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px;
  text-align: center;
  background: var(--pane-sub-bg);
}
.chat-empty-state[hidden] { display: none; }

.empty-logo {
  width: 82px;
  height: 82px;
  border-radius: 26px;
  background: var(--line-green);
  color: #ffffff;
  font-size: 20px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  box-shadow: 0 10px 28px rgba(6, 199, 85, 0.3);
}

.chat-empty-state h2 {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 8px;
}

.chat-empty-state p {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 440px;
  line-height: 1.6;
  margin-bottom: 18px;
}

.empty-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.btn-line-primary {
  background: var(--line-green);
  color: #ffffff;
  border: none;
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.btn-line-primary:hover { background: var(--line-green-dark); }

.btn-line-outline {
  background: var(--pane-bg);
  color: var(--text-main);
  border: 1px solid var(--pane-border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.btn-line-outline:hover { background: var(--pane-sub-bg); }

.chat-active {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.chat-active[hidden] { display: none; }

.chat-header {
  height: 58px;
  flex-shrink: 0;
  padding: 0 12px;
  background: var(--chat-hdr-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--pane-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.mobile-back-btn {
  display: none;
  font-size: 20px;
  font-weight: 800;
}

.chat-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 18px;
  font-weight: 800;
  background: var(--line-green);
}

.chat-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-header-meta { min-width: 0; }

.chat-header-title-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.chat-header-title-row h2 {
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-sub {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.chat-header-desc {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.hdr-pill-btn {
  border: 1px solid var(--line-green);
  background: rgba(6, 199, 85, 0.12);
  color: var(--line-green-dark);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
  margin-right: 4px;
}
.hdr-pill-btn[hidden] { display: none; }

.in-chat-search {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  background: var(--pane-bg);
  border-bottom: 1px solid var(--pane-border);
}
.in-chat-search[hidden] { display: none; }

.in-chat-search input {
  flex: 1;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--pane-border);
  background: var(--pane-sub-bg);
  color: var(--text-main);
}

.btn-mini {
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--pane-border);
  background: var(--pane-sub-bg);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

/* メッセージタイムライン */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.date-sep {
  align-self: center;
  margin: 8px 0;
  padding: 3px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.24);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
}

.system-msg {
  align-self: center;
  margin: 4px 0;
  padding: 4px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
  color: #ffffff;
  font-size: 11.5px;
  text-align: center;
  max-width: 82%;
}

.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  position: relative;
  max-width: 100%;
}

.msg-row.mine {
  flex-direction: row-reverse;
}

.msg-row.grouped {
  margin-top: -2px;
}

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #ffffff;
  font-weight: 800;
  background: var(--line-green);
  cursor: pointer;
}

.msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.msg-avatar.spacer {
  visibility: hidden;
  pointer-events: none;
}

.msg-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: min(74%, 560px);
}

.msg-row.mine .msg-col {
  align-items: flex-end;
}

.msg-sender-name {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--meta-text);
  margin-bottom: 3px;
  padding-left: 2px;
}

.msg-bubble-line {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.msg-row.mine .msg-bubble-line {
  flex-direction: row-reverse;
}

.bubble {
  position: relative;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.msg-row.theirs .bubble {
  background: var(--bubble-theirs);
  color: var(--bubble-theirs-text);
  border-top-left-radius: 4px;
}

.msg-row.theirs:not(.grouped) .bubble::before {
  content: "";
  position: absolute;
  top: 6px;
  left: -6px;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 8px solid var(--bubble-theirs);
}

.msg-row.mine .bubble {
  background: var(--bubble-mine);
  color: var(--bubble-mine-text);
  border-top-right-radius: 4px;
}

.msg-row.mine:not(.grouped) .bubble::after {
  content: "";
  position: absolute;
  top: 6px;
  right: -6px;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 8px solid var(--bubble-mine);
}

.msg-reply-quote {
  border-left: 3px solid var(--line-green);
  padding: 3px 8px;
  margin-bottom: 5px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 4px;
  font-size: 11.5px;
}

.msg-reply-quote strong {
  display: block;
  font-size: 11px;
}

/* スタンプバブル */
.stamp-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 112px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.16);
}

.stamp-emoji { font-size: 38px; line-height: 1.1; }
.stamp-text { font-size: 12px; font-weight: 900; }

/* Flex カードメッセージ */
.flex-card {
  background: var(--pane-bg);
  color: var(--text-main);
  border-radius: 14px;
  overflow: hidden;
  width: min(320px, calc(100vw - 96px));
  max-width: 100%;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.18);
  border: 1px solid var(--pane-border);
}

.flex-card-head {
  padding: 10px 12px;
  color: #ffffff;
}

.flex-card-badge {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.25);
  padding: 1px 6px;
  border-radius: 999px;
  margin-bottom: 3px;
}

.flex-card-title { font-size: 13.5px; font-weight: 800; }
.flex-card-sub { font-size: 11px; opacity: 0.92; }

.flex-card-items {
  display: flex;
  flex-direction: column;
}

.flex-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-top: 1px solid var(--pane-border);
}

.flex-item-img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: #f1f5f9;
}

.flex-item-body {
  flex: 1;
  min-width: 0;
}

.flex-item-ttl {
  font-size: 12.5px;
  font-weight: 700;
  margin-bottom: 2px;
}

.flex-item-sub {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.35;
}

.flex-item-meta {
  font-size: 10.5px;
  color: var(--line-green-dark);
  font-weight: 700;
  margin-top: 2px;
}

.flex-item-actions {
  display: flex;
  gap: 5px;
  margin-top: 4px;
}

.flex-mini-btn {
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--pane-border);
  background: var(--pane-sub-bg);
  color: var(--text-main);
  font-size: 10.5px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.flex-card-footer {
  display: block;
  text-align: center;
  padding: 9px 12px;
  border-top: 1px solid var(--pane-border);
  font-size: 12px;
  font-weight: 800;
  color: var(--line-green-dark);
  text-decoration: none;
  background: var(--pane-sub-bg);
}

/* 時刻＆既読 */
.msg-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  font-size: 10px;
  color: var(--meta-text);
  line-height: 1.25;
  flex-shrink: 0;
}

.msg-row.mine .msg-meta {
  align-items: flex-end;
}

.read-mark {
  font-weight: 700;
}

/* リアクション表示・ツールバー */
.msg-reactions {
  display: flex;
  gap: 4px;
  margin-top: 3px;
  flex-wrap: wrap;
}

.react-pill {
  background: var(--pane-bg);
  border: 1px solid var(--pane-border);
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 11px;
  cursor: pointer;
}

.msg-hover-bar {
  display: none;
  align-items: center;
  gap: 2px;
  background: var(--pane-bg);
  border: 1px solid var(--pane-border);
  border-radius: 999px;
  padding: 2px 5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
  align-self: center;
}

.msg-row:hover .msg-hover-bar {
  display: inline-flex;
}

.msg-act-btn {
  border: none;
  background: transparent;
  color: var(--text-main);
  font-size: 12px;
  padding: 2px 5px;
  border-radius: 6px;
  cursor: pointer;
}
.msg-act-btn:hover { background: var(--pane-sub-bg); }

/* 入力中バブル */
.typing-dots {
  display: inline-flex;
  gap: 4px;
  padding: 4px 2px;
}
.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6B7280;
  animation: dot-bounce 1s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

/* 引用・スタンプ・リッチメニュー・入力欄 */
.reply-preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: var(--pane-sub-bg);
  border-top: 1px solid var(--pane-border);
  font-size: 12px;
}
.reply-preview-bar[hidden] { display: none; }
.reply-preview-body { min-width: 0; }
.reply-preview-body strong { display: block; color: var(--line-green-dark); }
.reply-preview-body span { color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

.stamp-picker {
  background: var(--pane-bg);
  border-top: 1px solid var(--pane-border);
  max-height: 230px;
  display: flex;
  flex-direction: column;
}
.stamp-picker[hidden] { display: none; }

.stamp-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  border-bottom: 1px solid var(--pane-border);
  font-size: 12px;
  font-weight: 800;
}

.stamp-grid {
  padding: 8px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 6px;
}

.stamp-tile {
  border: 1px solid var(--pane-border);
  border-radius: 10px;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
}
.stamp-tile:hover { transform: translateY(-1px); }

.rich-menu-wrap {
  background: var(--pane-bg);
  border-top: 1px solid var(--pane-border);
}
.rich-menu-wrap[hidden] { display: none; }

.rich-menu-toggle {
  width: 100%;
  border: none;
  background: var(--pane-sub-bg);
  color: var(--text-main);
  padding: 6px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.rich-menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--pane-border);
  border-top: 1px solid var(--pane-border);
}
.rich-menu-grid.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}
.rich-menu-grid[hidden] { display: none; }

.rich-tile-btn {
  background: var(--pane-bg);
  color: var(--text-main);
  border: none;
  padding: 11px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.rich-tile-btn:hover { background: var(--pane-sub-bg); }
.rich-tile-btn span:first-child { font-size: 20px; }

.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px;
  background: var(--composer-bg);
  border-top: 1px solid var(--pane-border);
}

.composer-tool-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--pane-sub-bg);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  min-height: 38px;
  max-height: 110px;
  line-height: 20px;
  overflow-y: hidden;
  resize: none;
  border: 1px solid var(--pane-border);
  border-radius: 19px;
  padding: 8px 14px;
  background: var(--pane-sub-bg);
  color: var(--text-main);
  font-size: 13.5px;
  outline: none;
}

.btn-send {
  height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  border: none;
  background: var(--line-green);
  color: #ffffff;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
}
.btn-send:hover { background: var(--line-green-dark); }

/* 右ドロワー */
.info-drawer {
  width: 310px;
  flex-shrink: 0;
  background: var(--pane-bg);
  border-left: 1px solid var(--pane-border);
  display: flex;
  flex-direction: column;
  height: 100%;
}
.info-drawer[hidden] { display: none; }

.drawer-head {
  height: 58px;
  padding: 0 14px;
  border-bottom: 1px solid var(--pane-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.drawer-sec h4 {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.note-card {
  background: var(--pane-sub-bg);
  border: 1px solid var(--pane-border);
  border-radius: 10px;
  padding: 9px 11px;
  margin-bottom: 8px;
  font-size: 12.5px;
}

/* モーダル */
.lane-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.52);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.lane-modal[hidden] { display: none; }

.lane-modal-card {
  background: var(--pane-bg);
  color: var(--text-main);
  border-radius: 16px;
  width: min(480px, 100%);
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  position: relative;
}

.modal-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--pane-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 14px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-row { display: flex; gap: 10px; }

.group-picker-list {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--pane-border);
  border-radius: 10px;
}

.picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--pane-border);
  cursor: pointer;
}
.picker-item:last-child { border-bottom: none; }

.modal-foot {
  padding: 10px 16px;
  border-top: 1px solid var(--pane-border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-float-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.35);
  color: #ffffff;
  z-index: 5;
}

#lane-toast {
  position: fixed;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(17, 24, 39, 0.92);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  z-index: 99999;
}
#lane-toast[hidden] { display: none; }

/* スマホ用ナビ＆レスポンシブ */
.mobile-bottom-nav { display: none; }
.mobile-only { display: none; }

@media (max-width: 767px) {
  #phone-shell {
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    border-width: 0;
  }

  .left-rail { display: none; }
  .mobile-only { display: inline-flex; }

  .middle-pane {
    width: 100%;
    border-right: none;
  }

  .mobile-bottom-nav {
    display: flex;
    height: 58px;
    border-top: 1px solid var(--pane-border);
    background: var(--pane-bg);
    flex-shrink: 0;
  }

  .mob-tab-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 18px;
    position: relative;
    cursor: pointer;
  }
  .mob-tab-btn small { font-size: 10px; font-weight: 700; }
  .mob-tab-btn.active { color: var(--line-green); }

  .mob-badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 22px);
    background: #ef4444;
    color: #ffffff;
    font-style: normal;
    font-size: 9.5px;
    font-weight: 800;
    padding: 0 5px;
    border-radius: 999px;
  }
  .mob-badge[hidden] { display: none; }

  #lane-app { position: relative; }

  /* Chat opens as a sheet sliding in from the right (LINE-style) */
  .chat-pane {
    position: absolute;
    inset: 0;
    z-index: 40;
    width: 100%;
    transform: translateX(103%);
    visibility: hidden;
    transition: transform 0.34s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 0.34s;
    box-shadow: -18px 0 42px rgba(0, 0, 0, 0.25);
  }

  #lane-app.mobile-in-chat .middle-pane { display: none; }
  #lane-app.mobile-in-chat .chat-pane {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.34s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s;
  }
  #lane-app.mobile-in-chat .mobile-back-btn { display: inline-flex; }

  .msg-col {
    max-width: calc(100vw - 78px);
  }

  .msg-row:hover .msg-hover-bar {
    display: none;
  }

  .info-drawer {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: min(320px, 88vw);
    z-index: 8000;
  }
}

@media (prefers-reduced-motion: reduce) {
  #phone-shell, #phone-splash, #boot-stage, #lane-app, .chat-pane {
    transition: none !important;
    animation: none !important;
  }
}

.drawer-trace-chip {
  margin-top: 4px;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--text-muted);
  background: rgba(15, 23, 42, 0.08);
  border: 1px dashed rgba(100, 116, 139, 0.35);
  max-width: 100%;
  word-break: break-word;
}

.drawer-trace-chip summary {
  cursor: pointer;
  font-weight: 600;
}

.trace-detail-grid {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed rgba(100, 116, 139, 0.25);
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 10px;
}

.memory-card {
  background: var(--pane-sub-bg);
  border: 1px solid var(--pane-border);
  border-radius: 10px;
  padding: 7px 9px;
  margin-bottom: 6px;
  font-size: 12px;
}

.memory-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.memory-badge {
  background: rgba(6, 199, 85, 0.16);
  color: var(--line-green);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.memory-topic {
  font-weight: 700;
  font-size: 11.5px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memory-summary {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

body.theme-dark .drawer-trace-chip {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.22);
}

/* Conversation usability */
.lane-notice { margin:0; padding:8px 14px; font-size:12px; line-height:1.5; color:#344451; background:#edf5f1; }
.room-item:focus-visible, button:focus-visible { outline:3px solid #087e4c; outline-offset:-3px; }
.rail-btn { min-height:48px; }
@media(max-width:700px) { .lane-notice { font-size:11px; padding:6px 10px; } }

#rail-replay-intro-btn { display:none; } .rail-nav-btn { min-height:48px; font-size:12px; } .rail-nav-btn.active { background:#176347; color:white; }
