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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  height: 100vh;
  overflow: hidden;
}

/* ── 전체 레이아웃 ── */
#layout {
  display: flex;
  height: 100vh;
}

#paper-section {
  flex: 1;
  overflow-y: auto;
  min-width: 0;
}

#app {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

/* ── Update Banner ── */
#update-banner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 14px;
  margin-bottom: 14px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  font-size: 13px;
}
.update-version {
  font-weight: 700;
  color: #2563eb;
  white-space: nowrap;
}
.update-text {
  color: #1e40af;
  white-space: pre-line;
}

/* ── Header ── */
.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

h1 {
  font-size: 22px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.3px;
}

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

#export-btn {
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  background: #fff;
  color: #3b82f6;
  border: 1.5px solid #3b82f6;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

#export-btn:hover {
  background: #3b82f6;
  color: #fff;
}

#chat-toggle {
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

#chat-toggle:hover {
  background: #2563eb;
}

.search-input-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
  position: relative;
}

.search-field {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-field input {
  width: 100%;
}

#search-clear {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 14px;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
}

#search-clear:hover {
  color: #475569;
}

.search-bar input {
  flex: 1;
  padding: 10px 32px 10px 14px;
  font-size: 15px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}

.search-bar input:focus {
  border-color: #3b82f6;
}

.search-bar input::placeholder {
  color: #94a3b8;
}

.search-mode-seg {
  display: flex;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.seg-btn {
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  background: #fff;
  color: #94a3b8;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.seg-btn + .seg-btn {
  border-left: 1.5px solid #e2e8f0;
}

.seg-btn.active {
  background: #e05a5a;
  color: #fff;
}

/* ── Filters ── */
.filters {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 5px 14px;
  font-size: 13px;
  border: 1.5px solid #e2e8f0;
  border-radius: 20px;
  background: #fff;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover {
  border-color: #3b82f6;
  color: #3b82f6;
}

.filter-btn.active {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #fff;
}

.filter-btn span {
  font-size: 11px;
  opacity: 0.8;
}

/* ── Paper list ── */
#paper-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

#pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 20px 0 12px;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border: 1.5px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  color: #374151;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.page-btn:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.page-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.page-input {
  width: 52px;
  height: 34px;
  text-align: center;
  font-size: 13px;
  border: 1.5px solid #e2e8f0;
  border-radius: 6px;
  outline: none;
  transition: border-color 0.12s;
}

.page-input:focus {
  border-color: #3b82f6;
}

.page-input::-webkit-inner-spin-button,
.page-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.page-total {
  font-size: 13px;
  color: #64748b;
}

/* ── Paper card ── */
.paper-card {
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.card-main {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.paper-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.card-left {
  flex: 1;
  min-width: 0;
}

.paper-number {
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 4px;
}

.paper-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  color: #0f172a;
  margin-bottom: 8px;
}

.paper-num {
  font-size: 13px;
  font-weight: 700;
  color: #94a3b8;
  margin-right: 2px;
}

.paper-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 6px;
}

.keyword-tag {
  font-size: 11px;
  color: #e05a5a;
  background: #fff0f0;
  border: 1px solid #f5c0c0;
  border-radius: 4px;
  padding: 1px 6px;
  line-height: 1.6;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.keyword-tag:hover {
  background: #e05a5a;
  border-color: #e05a5a;
  color: #fff;
}

.paper-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.arxiv-id {
  font-size: 12px;
  color: #64748b;
  font-family: monospace;
}

.no-link-badge {
  font-size: 11px;
  color: #94a3b8;
  background: #f1f5f9;
  padding: 2px 7px;
  border-radius: 4px;
}

.card-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-bookmark {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #cbd5e1;
  transition: color 0.15s, transform 0.1s;
  padding: 2px;
  line-height: 1;
}

.btn-bookmark:hover {
  color: #f59e0b;
  transform: scale(1.15);
}

.btn-bookmark.active {
  color: #f59e0b;
}

.btn-ask {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1.5px solid #8b5cf6;
  background: #fff;
  color: #8b5cf6;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.btn-ask:hover {
  background: #8b5cf6;
  color: #fff;
}

.btn-open {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1.5px solid #e2e8f0;
  background: #fff;
  color: #3b82f6;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-open:hover {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #fff;
}

.btn-open.disabled {
  color: #cbd5e1;
  border-color: #f1f5f9;
  background: #f8fafc;
  cursor: default;
  pointer-events: none;
}

.btn-status {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1.5px solid;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.btn-complete {
  border-color: #10b981;
  color: #10b981;
  background: #fff;
}

.btn-complete:hover {
  background: #10b981;
  color: #fff;
}

.btn-revert {
  border-color: #f59e0b;
  color: #f59e0b;
  background: #fff;
}

.btn-revert:hover {
  background: #f59e0b;
  color: #fff;
}

.btn-delete-queue {
  border-color: #ef4444;
  color: #ef4444;
  background: #fff;
}

.btn-delete-queue:hover {
  background: #ef4444;
  color: #fff;
}

/* ── Abstract ── */
.abstract-section {
  margin-top: 12px;
}

.btn-abstract-toggle {
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1.5px solid #bbf7d0;
  background: #ecfdf3;
  color: #166534;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-abstract-toggle:hover {
  border-color: #86efac;
  background: #dcfce7;
}

.abstract-content {
  margin-top: 8px;
  padding: 12px;
  border: 1.5px solid #bbf7d0;
  border-radius: 10px;
  background: #f0fdf4;
}

.abstract-text {
  font-size: 13px;
  line-height: 1.7;
  color: #0f172a;
  white-space: pre-wrap;
}

.btn-translate {
  margin-top: 10px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1.5px solid #3b82f6;
  background: #fff;
  color: #3b82f6;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-translate:hover {
  background: #3b82f6;
  color: #fff;
}

.btn-translate:disabled {
  border-color: #93c5fd;
  color: #93c5fd;
  background: #f8fafc;
  cursor: not-allowed;
}

.translation-result {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  font-size: 13px;
  line-height: 1.6;
  color: #1e293b;
}

/* ── Memo / Q&A ── */
.memo-section {
  margin-top: 12px;
  border-top: 1.5px solid #e0e7ff;
  padding-top: 12px;
}

.memo-header {
  font-size: 11px;
  font-weight: 700;
  color: #6366f1;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.memo-qa-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.memo-qa-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.qa-label {
  font-size: 12px;
  font-weight: 700;
  color: #6366f1;
  min-width: 28px;
  padding-top: 7px;
  flex-shrink: 0;
}

.qa-question {
  flex: 1;
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  border: 1.5px solid #e0e7ff;
  border-radius: 6px;
  background: #eef2ff;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.qa-question:focus {
  border-color: #6366f1;
  background: #fff;
}

.qa-question::placeholder {
  color: #a5b4fc;
}

.qa-answer {
  flex: 2;
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  border: 1.5px solid #e2e8f0;
  border-radius: 6px;
  background: #f8fafc;
  outline: none;
  resize: vertical;
  min-height: 34px;
  line-height: 1.5;
  transition: border-color 0.15s, background 0.15s;
}

.qa-answer:focus {
  border-color: #6366f1;
  background: #fff;
}

.qa-answer::placeholder {
  color: #94a3b8;
  font-size: 12px;
}

.btn-add-question {
  margin-top: 8px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border: 1.5px dashed #a5b4fc;
  border-radius: 6px;
  background: transparent;
  color: #6366f1;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-add-question:hover {
  background: #eef2ff;
  border-color: #6366f1;
}

.btn-remove-question {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  margin-top: 5px;
  padding: 0;
  border: none;
  background: none;
  color: #cbd5e1;
  font-size: 13px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
  line-height: 1;
}

.btn-remove-question:hover {
  background: #fee2e2;
  color: #ef4444;
}

/* ── Similar Papers ── */
.similar-section {
  margin-top: 8px;
}

.btn-similar-toggle {
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1.5px solid #c7d2fe;
  background: #eef2ff;
  color: #4338ca;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-similar-toggle:hover {
  border-color: #818cf8;
  background: #e0e7ff;
}

.similar-content {
  margin-top: 6px;
  border: 1.5px solid #c7d2fe;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

/* count pill bar */
.similar-count-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  border-bottom: 1px solid #e0e7ff;
  background: #f5f3ff;
}

.similar-count-label {
  font-size: 11px;
  color: #7c3aed;
  font-weight: 700;
  margin-right: 4px;
  letter-spacing: 0.3px;
}

.btn-similar-count {
  padding: 3px 11px;
  font-size: 12px;
  font-weight: 600;
  border: 1.5px solid #c4b5fd;
  border-radius: 99px;
  background: #fff;
  color: #6d28d9;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-similar-count:hover {
  border-color: #7c3aed;
  background: #ede9fe;
}

.btn-similar-count.active {
  background: #7c3aed;
  border-color: #7c3aed;
  color: #fff;
}

/* list */
.similar-list {
  max-height: 360px;
  overflow-y: auto;
}

.sim-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 9px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  transition: filter 0.1s;
}

.sim-row:last-child { border-bottom: none; }
.sim-row:hover { filter: brightness(0.96); }

/* 4 pastel color levels */
.sim-lv1 { background: #c8f0e0; } /* 민트: 80%+ */
.sim-lv2 { background: #c8e4f8; } /* 스카이블루: 65-79% */
.sim-lv3 { background: #e0d4f5; } /* 라벤더: 50-64% */
.sim-lv4 { background: #fde8d0; } /* 피치: <50% */

.sim-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* title */
.sim-title {
  flex: 1;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.4;
  color: #1e293b;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* search icon button */
.btn-sim-search {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  border: none;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.09);
  color: #374151;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-sim-search:hover {
  background: rgba(0, 0, 0, 0.18);
}

.sim-row-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sim-pct {
  font-size: 11px;
  font-weight: 700;
  color: #374151;
  min-width: 30px;
  flex-shrink: 0;
}

.sim-gauge-track {
  flex: 1;
  height: 5px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.10);
  overflow: hidden;
}

.sim-gauge-fill {
  height: 100%;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.22);
  transition: width 0.3s ease;
}

.sim-empty {
  padding: 14px;
  font-size: 12px;
  color: #94a3b8;
  text-align: center;
}

/* ── Empty state ── */
#empty-state {
  text-align: center;
  color: #94a3b8;
  font-size: 14px;
  padding: 48px 0;
}

.hidden {
  display: none !important;
}

/* ── Chat Panel ── */
#chat-panel {
  width: 360px;
  min-width: 260px;
  max-width: 720px;
  flex-shrink: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-left: 1.5px solid #e2e8f0;
  height: 100vh;
}

#chat-resize {
  position: absolute;
  left: 0;
  top: 0;
  width: 5px;
  height: 100%;
  cursor: col-resize;
  z-index: 10;
}
#chat-resize:hover, #chat-resize.dragging {
  background: #6366f1;
  opacity: 0.4;
}

#chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1.5px solid #e2e8f0;
  background: #f8fafc;
  flex-shrink: 0;
}

#chat-title {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
}

.chat-header-actions {
  display: flex;
  gap: 8px;
}

#chat-clear {
  font-size: 12px;
  padding: 4px 10px;
  border: 1.5px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
}

#chat-clear:hover {
  border-color: #ef4444;
  color: #ef4444;
}

#chat-close {
  font-size: 16px;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: #94a3b8;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

#chat-close:hover {
  background: #f1f5f9;
  color: #1e293b;
}

#chat-context-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #ede9fe;
  border-bottom: 1px solid #ddd6fe;
  flex-shrink: 0;
}

#chat-context-label {
  font-size: 12px;
  color: #6d28d9;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  margin-right: 8px;
}

#chat-context-clear {
  background: none;
  border: none;
  color: #7c3aed;
  cursor: pointer;
  font-size: 14px;
  flex-shrink: 0;
  padding: 0 2px;
}

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-msg {
  max-width: 90%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg.user {
  background: #3b82f6;
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-msg.assistant {
  background: #f1f5f9;
  color: #1e293b;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-msg.assistant.streaming::after {
  content: "▋";
  animation: blink 0.8s step-start infinite;
}

.chat-msg.loading::after,
.translation-result.loading::after {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-left: 6px;
  border: 2px solid #94a3b8;
  border-top-color: transparent;
  border-radius: 50%;
  vertical-align: middle;
  animation: spin 0.8s linear infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#chat-footer {
  padding: 12px;
  border-top: 1.5px solid #e2e8f0;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  resize: none;
  outline: none;
  transition: border-color 0.15s;
  line-height: 1.5;
}

#chat-input:focus {
  border-color: #3b82f6;
}

#chat-input::placeholder {
  color: #94a3b8;
  font-size: 12px;
}

#chat-btn-wrap {
  display: flex;
  align-self: flex-end;
}

#chat-send, #chat-stop {
  padding: 9px 16px;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

#chat-send { background: #3b82f6; }
#chat-send:hover { background: #2563eb; }
#chat-send:disabled { background: #93c5fd; cursor: not-allowed; }

#chat-stop { background: #ef4444; }
#chat-stop:hover { background: #dc2626; }

/* ── 논문 추천 카드 (챗봇 내부) ── */
.paper-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.paper-results .paper-card {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
}

.paper-results .paper-card a {
  flex: 1;
  color: #1d4ed8;
  text-decoration: none;
  word-break: break-word;
}

.paper-results .paper-card a:hover {
  text-decoration: underline;
}

.paper-results .paper-card .score,
.search-paper-card .score {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: #10b981;
  background: #ecfdf5;
  padding: 1px 6px;
  border-radius: 4px;
}

/* ── 검색 결과 카드 (chat) ── */
.search-paper-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 100%;
  padding: 10px 12px;
}

.search-paper-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.search-paper-title {
  font-size: 12px;
  font-weight: 600;
  color: #1d4ed8;
  text-decoration: none;
  line-height: 1.4;
  flex: 1;
  word-break: break-word;
}

.search-paper-title:hover {
  text-decoration: underline;
}

.btn-explain {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  color: #6366f1;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-explain:hover:not(:disabled) {
  background: #6366f1;
  color: #fff;
  border-color: #6366f1;
}
.btn-explain:disabled {
  color: #94a3b8;
  background: #f1f5f9;
  border-color: #e2e8f0;
  cursor: default;
}

.search-paper-reason {
  font-size: 12px;
  color: #475569;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #e2e8f0;
}

.search-paper-reason.streaming::after {
  content: "▋";
  animation: blink 0.8s step-start infinite;
}

