* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #ffffff;
  color: #202123;
  font-family: "Yu Gothic", "Meiryo", sans-serif;
}

.chat-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 300px;
  height: 100vh;
  padding: 18px 14px;
  background: #f7f7f8;
  border-right: 1px solid #ddd;
  overflow-y: auto;
}

.sidebar h1 {
  margin: 0 0 18px;
  font-size: 24px;
}

.search-input {
  width: 100%;
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid #d9d9e3;
  border-radius: 10px;
  font-size: 14px;
}

.filter-area {
  margin-bottom: 18px;
}

.filter-area p {
  margin: 0 0 8px;
  color: #6b6c7b;
  font-size: 13px;
  font-weight: bold;
}

.genre-button,
.sort-button {
  margin: 0 4px 8px 0;
  padding: 8px 10px;
  border: none;
  border-radius: 999px;
  background: #ececf1;
  color: #202123;
  cursor: pointer;
  font-size: 13px;
}

.genre-button.active,
.sort-button.active {
  background: #202123;
  color: #fff;
}

.log-list {
  margin-top: 10px;
}

.log-button {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: #202123;
  text-align: left;
  cursor: pointer;
}

.log-button:hover,
.log-button.active {
  background: #ececf1;
}

.log-button span {
  display: block;
  font-weight: bold;
  font-size: 14px;
}

.log-button small {
  display: block;
  margin-top: 5px;
  color: #6b6c7b;
  font-size: 12px;
}

.home-button {
  display: block;
  margin-top: 28px;
  padding: 14px;
  border-radius: 12px;
  background: #202123;
  color: #fff;
  text-align: center;
  text-decoration: none;
  font-weight: bold;
}

.chat-main {
  flex: 1;
  margin-left: 300px;
  padding: 36px 28px 80px;
}

.thread-header {
  max-width: 980px;
  margin: 0 auto 34px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e5e5e5;
}

.thread-header h2 {
  margin: 0 0 10px;
  font-size: 32px;
}

.thread-header p {
  margin: 0;
  color: #6b6c7b;
}

.chat-content {
  max-width: 980px;
  margin: 0 auto;
}

.message {
  display: flex;
  flex-direction: column;
  margin-bottom: 28px;
}

.meta {
  margin-bottom: 8px;
  font-weight: bold;
  font-size: 14px;
}

.meta span {
  margin-left: 10px;
  color: #8a8b95;
  font-weight: normal;
}

.bubble {
  max-width: 72%;
  padding: 18px 22px;
  border-radius: 16px;
  line-height: 1.9;
  font-size: 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}

.message.user {
  align-items: flex-end;
}

.message.user .meta {
  color: #7a2f8f;
}

.message.user .bubble {
  background: #ffe4f3;
  border: 1px solid #f3c3df;
}

.message.ai {
  align-items: flex-start;
}

.message.ai .meta {
  color: #168a5b;
}

.message.ai .bubble {
  background: #f4f4f6;
  border: 1px solid #e1e1e6;
}

.loading-text {
  color: #6b6c7b;
}

@media (max-width: 768px) {
  .chat-layout {
    display: block;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid #ddd;
  }

  .chat-main {
    margin-left: 0;
    padding: 24px 16px 60px;
  }

  .thread-header h2 {
    font-size: 24px;
  }

  .bubble {
    max-width: 92%;
    font-size: 15px;
  }
}

.menu-open,
.menu-close,
.menu-overlay {
  display: none;
}

@media (max-width: 768px) {
  .menu-open {
    display: block;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 1001;

    padding: 10px 14px;
    border: none;
    border-radius: 999px;
    background: #202123;
    color: #fff;
    font-weight: bold;
  }

  .menu-close {
    display: block;
    position: absolute;
    top: 18px;
    right: 16px;

    border: none;
    background: transparent;
    color: #202123;
    font-size: 28px;
    cursor: pointer;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1002;

    width: min(84vw, 320px);
    height: 100vh;

    transform: translateX(-105%);
    transition: transform 0.25s ease;
    box-shadow: 8px 0 28px rgba(0,0,0,0.18);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0.35);
  }

  .menu-overlay.open {
    display: block;
  }

  .chat-main {
    padding-top: 70px;
  }
}