@font-face {
    font-family: 'Pretendard';
    src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/pretendard@1.0/Pretendard-Thin.woff2') format('woff2');
    font-weight: 100;
    font-display: swap;
}

@font-face {
    font-family: 'Pretendard';
    src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/pretendard@1.0/Pretendard-ExtraLight.woff2') format('woff2');
    font-weight: 200;
    font-display: swap;
}

@font-face {
    font-family: 'Pretendard';
    src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/pretendard@1.0/Pretendard-Light.woff2') format('woff2');
    font-weight: 300;
    font-display: swap;
}

@font-face {
    font-family: 'Pretendard';
    src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/pretendard@1.0/Pretendard-Regular.woff2') format('woff2');
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: 'Pretendard';
    src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/pretendard@1.0/Pretendard-Medium.woff2') format('woff2');
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: 'Pretendard';
    src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/pretendard@1.0/Pretendard-SemiBold.woff2') format('woff2');
    font-weight: 600;
    font-display: swap;
}

@font-face {
    font-family: 'Pretendard';
    src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/pretendard@1.0/Pretendard-Bold.woff2') format('woff2');
    font-weight: 700;
    font-display: swap;
}

@font-face {
    font-family: 'Pretendard';
    src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/pretendard@1.0/Pretendard-ExtraBold.woff2') format('woff2');
    font-weight: 800;
    font-display: swap;
}

@font-face {
    font-family: 'Pretendard';
    src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/pretendard@1.0/Pretendard-Black.woff2') format('woff2');
    font-weight: 900;
    font-display: swap;
}

:root{
  --bg:#f4f6fb;
  --panel:#ffffff;
  --line:#e7ebf3;
  --text:#0f172a;
  --muted:#1d54a4;
  --blue:#2563eb;
  --blue2:#1d4ed8;
  --soft:#f1f5ff;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  --radius:14px;
}

:root, body, button, input, textarea {
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", Arial, sans-serif;
}


*{ box-sizing:border-box; }
body{
  margin:0;
  font-family: 'Pretendard',system-ui,-apple-system,Segoe UI,Roboto,"Noto Sans KR",sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app{
  display:grid;
  grid-template-columns: 320px minmax(0,1fr) 300px;
  min-height: 100vh;
  gap: 14px;
  padding: 14px;
}

/* 1100px 이하: 판례 패널 숨김 */
@media (max-width: 1100px){
  .app{ grid-template-columns: 320px minmax(0,1fr); }
  .case-panel{
    display: none;
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 320px;
    z-index: 100;
    transform: translateX(100%);
    transition: transform 0.3s ease;
  }
  .case-panel.is-open{
    display: flex;
    transform: translateX(0);
  }
}

/* 860px 이하: 1단 레이아웃 */
@media (max-width: 860px){
  .app{ grid-template-columns: 1fr; }
  .sidebar{ order: 2; }
  .main{ order: 1; }
  .case-panel{
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    z-index: 200;
    transform: translateY(100%);
  }
  .case-panel.is-open{
    transform: translateY(0);
  }
}

/* LEFT */
.sidebar{
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display:flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}
.brand-row{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
}
.brand{ display:flex; align-items:center; gap:10px; }
.brand-logo{
  width: 38px; height: 38px; border-radius: 12px;
  display:flex; align-items:center; justify-content:center;
  background: var(--blue);
  color: #fff;
  font-weight: 500;
}
.brand-name{ font-weight: 500; letter-spacing: -0.2px; }
.brand-sub{ color: var(--muted); font-size: 12px; margin-top: 2px; }

.side-title{
  font-weight: 500;
  letter-spacing: -0.2px;
  margin-top: 4px;
}

.topic-list{ overflow:auto; padding-right: 2px; min-height: 0; }
.cat-block{ margin-bottom: 14px; }
.cat-label{
  font-size: 15px;
  color: var(--muted);
  font-weight: 500;
  margin: 8px 0;
}
.cat-topics{ display:flex; flex-direction:column; gap:8px; }
.topic-btn{
  text-align:left;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 10px 12px;
  cursor:pointer;
  font-weight: 500;
  color: #111827;
  font-size: 15px;
}
.topic-btn:hover{ border-color: #cfd7ea; background: #fbfcff; }
.topic-btn.active{
  border-color: rgba(37,99,235,0.35);
  background: var(--soft);
  color: var(--blue2);
}

.ghost{
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  cursor:pointer;
  font-weight: 500;
}
.ghost.small{
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12px;
}
.side-foot{
  margin-top: auto;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

/* MAIN */
.main{
  display:flex;
  flex-direction:column;
  gap: 14px;
  min-height: 0;
}
.topbar{
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.top-title{ font-weight: 500; font-size: 16px; letter-spacing: -0.3px; }
.top-sub{ margin-top: 4px; color: var(--muted); font-size: 14px; line-height: 1.45; }

.chat-card{
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
  display:flex;
  flex-direction:column;
  min-height: 0;
  box-sizing: border-box;
  padding: 30px;
  height: calc(100vh - 14px - 14px - 88px); /* 화면 높이 기반 */
}
@media (max-width: 860px){
  .chat-card{ height: calc(100vh - 14px - 14px - 88px); }
}

.chat{
  padding: 16px;
  overflow:auto;
  flex:1;
  min-height: 0;
  margin: 0 auto;
  width:100%;
  max-width: 820px;

}
.msg{ display:flex; gap: 10px; margin: 10px 0; }
.avatar{
  width: auto; height: 34px; border-radius: 12px;
  display:flex; align-items:center; justify-content:center;
  font-weight: 500;
  flex: 0 0 34px;
  color: #2563eb;
}
.msg.user .avatar {
    background: #333;
    color: #fff;
    width: 34px;
}
.msg.ai .avatar{ background: #dbeafe; color: var(--blue2); }

.bubble{
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 12px;
  background: #fff;
  line-height: 1.6;
  white-space: pre-wrap;
  max-width: 920px;
}
.msg.user .bubble{ background: #f5f5f5; }

/* ✅ 입력창 하단 고정(스크롤 내려도 항상 보이게) */
.composer{
  position: sticky;
  bottom: 0;
  display:flex;
  gap: 10px;
  background: var(--panel);
}

.composer .msg-input{border: 0;}


.msg-input{
  flex:1;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 12px;
  outline:none;
  font-size: 15px;
  line-height: 145%;



}
.send{
  border: none;
  background: var(--blue);
  color: #fff;
  font-weight: 500;
  border-radius: 12px;
  padding: 0 16px;
  cursor:pointer;
  font-size: 16px;
}
.send:disabled{ opacity: 0.6; cursor:not-allowed; }


/* === 로딩 스피너 === */
.bubble.is-loading{
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.bubble .loading-spinner{
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  animation: chatSpin 0.9s linear infinite;
}
@keyframes chatSpin{ to { transform: rotate(360deg); } }

/* === AI 답변 렌더 스타일(스크린샷 느낌) === */
.msg.ai .bubble{
  text-align: left;
}

.ai-answer{
  line-height: 1.7;
  font-size: 14px;
}

.ai-title{
  font-size: 18px;
  font-weight: 800;
  margin: 0 0 10px;
  letter-spacing: -0.2px;
}

.ai-heading{
  font-size: 16px;
  font-weight: 800;
  margin: 16px 0 8px;
  letter-spacing: -0.1px;
}

.ai-p{
  margin: 0 0 10px;
  white-space: normal;
}

.ai-foot{
  margin-top: 12px;
  font-size: 12.5px;
  line-height: 1.6;
  opacity: 0.85;
}

/* 각주(숫자) 뱃지 */
.ai-cite{
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-width: 18px;
  height: 18px;
  padding: 0 6px;

  border-radius: 7px;
  border: 1px solid rgba(0,0,0,0.12);
  background: rgba(0,0,0,0.04);

  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  margin-left: 4px;
}


.songbly-rt p {
    font-family: 'Pretendard';
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: normal;
    letter-spacing: -.01rem;
    line-height: 1.625rem;
    margin-top: 12px;
}


.songbly-rt .rt-title{
    font-size: 18px;
    letter-spacing: normal;
    letter-spacing: -.015rem;
    line-height: 2rem;
    font-family: 'Pretendard';
    font-weight: 600;
    margin-top: 12px;
}

.bubble.songbly-rt{padding: 12px 30px;}
.main-chat-textarea{
    background: linear-gradient(-90deg, #2e90fa, #444ce7);
    background-color: var(--gray-50);
    border-radius: 16px;
    box-shadow: 0 1px 3px #00000026, 0 4px 8px 3px #0000000d;
    max-width: 820px;
    min-height: 56px;
    padding: 2px;
    position: relative;
    width: 100%;
    margin: 0 auto;
}


.main-chat-textarea-inner{
    background: #fff;
    border-radius: 14px;
    padding: 8px 8px 8px 16px;
}
.main-chat-textarea-inner{
    background: #fff;
    border-radius: 14px;
    padding: 8px 8px 8px 16px;
}

.msg.user .avatar{width: 34px;}
#selectionGuideBar{display: none;}
@media (max-width: 900px){

  .main {
      display: flex;
      flex-direction: column;
      gap: 14px;
      min-height: 0;
      position: static;
      right: auto;
      width: auto;
  }
  .chat{padding: 0;}
  .chat-card{padding: 10px;}
  #selectionGuideBar{
    display: none;
    font-size: 14px !important;
    padding: 10px 10px !important;
  }

  .msg {
      display: flex;
      gap: 10px;
      margin: 10px 0;
      flex-direction: column;
      align-items: flex-start;
  }
  .bubble.songbly-rt{padding: 10px;}
  .songbly-rt p{font-size: 15px;}
  .msg-input{padding: 0;}
   .msg-input::placeholder { 
    opacity: 0 !important;
  }
  /* iOS Safari 호환 */
  .msg-input::-webkit-input-placeholder {
    opacity: 0 !important;
  }

}

.intake-title{color: #1d4ed8;}


.intake-select.is-filled {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgb(37, 99, 235, 0.15);
    /* background: #ffffff; */
    color: #2563eb;
}

.intake-input.is-filled{
    box-shadow: 0 0 0 3px rgb(37, 99, 235, 0.15);
    background: #eef2f9;
    color: #000;
}

/* ===============================
   판례 패널 스타일
   =============================== */
.case-panel{
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow: hidden;
}

.case-panel-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

.case-panel-title{
  font-weight: 500;
  font-size: 15px;
  letter-spacing: -0.2px;
}

.case-panel-close{
  display: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
}
@media (max-width: 1100px){
  .case-panel-close{ display: block; }
}

.case-panel-status{
  font-size: 13px;
  color: var(--muted);
  padding: 8px 0;
}

.case-panel-list{
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.case-panel-empty{
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 20px 10px;
  line-height: 1.5;
}

/* 판례 카드 */
.case-card{
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.case-card:hover{
  border-color: rgba(37,99,235,0.35);
  box-shadow: 0 2px 8px rgba(37,99,235,0.08);
}

.case-card-court{
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.case-card-name{
  font-weight: 500;
  font-size: 14px;
  line-height: 1.4;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.case-card-meta{
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: #64748b;
}

.case-card-no{
  color: var(--blue);
}

/* 판례 로딩 */
.case-panel-loading{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  color: var(--muted);
  font-size: 13px;
}
.case-panel-loading .loading-spinner{
  width: 16px;
  height: 16px;
  animation: chatSpin 0.9s linear infinite;
}

/* 판례 토글 버튼 (반응형) */
.case-toggle-btn{
  display: none;
  position: fixed;
  right: 16px;
  bottom: 100px;
  z-index: 90;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
@media (max-width: 1100px){
  .case-toggle-btn{ display: flex; }
}

/* 판례 모달 */
.case-modal-overlay{
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.case-modal-overlay.is-open{
  display: flex;
}

.case-modal{
  background: var(--panel);
  border-radius: 16px;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.case-modal-header{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.case-modal-title{
  font-weight: 600;
  font-size: 17px;
  line-height: 1.4;
}

.case-modal-close{
  border: none;
  background: none;
  font-size: 24px;
  cursor: pointer;
  color: #64748b;
  padding: 0;
  line-height: 1;
}
.case-modal-close:hover{
  color: #0f172a;
}

.case-modal-body{
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.case-modal-section{
  margin-bottom: 20px;
}
.case-modal-section:last-child{
  margin-bottom: 0;
}

.case-modal-label{
  font-weight: 500;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.case-modal-content{
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
}

/* 판례 상세 구조 스타일 */
.case-detail-header{
  text-align: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--line);
}
.case-detail-court{
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.case-detail-type{
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 8px;
  color: var(--text);
}

.case-detail-info{
  width: 100%;
  margin-bottom: 24px;
  border-collapse: collapse;
}
.case-detail-info th{
  text-align: left;
  padding: 8px 12px;
  width: 100px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: var(--bg2);
  border: 1px solid var(--line);
  vertical-align: top;
}
.case-detail-info td{
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text);
  border: 1px solid var(--line);
}

.case-detail-section{
  margin-bottom: 24px;
}
.case-detail-section:last-child{
  margin-bottom: 0;
}
.case-detail-label{
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.case-detail-content{
  font-size: 14px;
  line-height: 1.75;
  color: var(--text);
}
.case-detail-fulltext{
  max-height: 400px;
  overflow-y: auto;
  padding: 12px;
  background: var(--bg2);
  border-radius: 8px;
}

.case-modal-meta{
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
  color: #64748b;
  margin-bottom: 16px;
}

.case-modal-footer{
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

.case-modal-link{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.case-modal-link:hover{
  background: var(--blue2);
}

/* 판례 패널 오버레이 배경 */
.case-panel-backdrop{
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.3);
  z-index: 99;
}
.case-panel-backdrop.is-open{
  display: block;
}

