:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #f1f5f9;
  --line: #e2e8f0;
  --line-soft: #eef2f7;
  --ink: #1e293b;
  --muted: #64748b;
  --faint: #94a3b8;
  --primary: #4f46e5;
  --primary-strong: #4338ca;
  --primary-soft: #eef2ff;
  --emerald: #059669;
  --amber: #d97706;
  --rose: #e11d48;
  --sky: #0284c7;
  --danger: #dc2626;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans KR", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.auth-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 18px;
}

.auth-shell {
  width: min(420px, 100%);
}

.brand-stack {
  text-align: center;
  margin-bottom: 28px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  margin: 0 auto 8px;
  display: grid;
  place-items: center;
  color: var(--primary);
}

.brand-mark.small {
  width: 28px;
  height: 28px;
  margin: 0;
}

.brand-mark svg {
  width: 100%;
  height: 100%;
}

.brand-stack h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
}

.brand-stack p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.auth-card,
.settings-section,
.detail-card,
.paper-card,
.stat-card,
.search-panel {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-card {
  padding: 28px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: var(--surface-soft);
  margin-bottom: 22px;
}

.segmented button {
  border: 0;
  border-radius: 6px;
  padding: 9px 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
}

.segmented button.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.form-stack,
.form-grid {
  display: grid;
  gap: 14px;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-stack.compact {
  gap: 16px;
}

.field {
  display: grid;
  gap: 7px;
}

.field.inline {
  min-width: 280px;
  flex: 1;
}

.search-scope-field {
  width: 150px;
}

.field span,
.caption {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

input,
select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

input:disabled,
button:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.check-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.check-field input {
  width: 15px;
  height: 15px;
}

.link-button {
  border: 0;
  padding: 0;
  color: var(--primary);
  background: transparent;
  font-size: 13px;
}

.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.button.primary {
  color: #fff;
  background: var(--primary);
}

.button.primary:hover {
  background: var(--primary-strong);
}

.button.secondary {
  color: #fff;
  background: var(--sky);
}

.button-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-top-color: #fff;
  border-radius: 999px;
  animation: spin 0.75s linear infinite;
}

.button.dark {
  color: #fff;
  background: var(--ink);
}

.button.danger {
  color: #fff;
  background: var(--danger);
}

.button.disabled {
  color: var(--faint);
  background: var(--surface-soft);
  border-color: var(--line);
  cursor: not-allowed;
}

.button.ghost {
  color: var(--ink);
  border-color: var(--line);
  background: #fff;
}

.button.full {
  width: 100%;
}

.button.fit {
  width: fit-content;
}

.divider {
  position: relative;
  display: grid;
  place-items: center;
  margin: 20px 0;
  color: var(--faint);
  font-size: 12px;
}

.divider::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 1px solid var(--line);
}

.divider span {
  position: relative;
  padding: 0 10px;
  background: #fff;
}

.message {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.message.error {
  color: var(--danger);
}

.app-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid var(--line-soft);
}

.sidebar-brand {
  height: 68px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink);
}

.nav-list {
  display: grid;
  gap: 4px;
  padding: 16px 12px;
}

.nav-item,
.keyword-nav {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--muted);
  background: transparent;
  font-size: 14px;
  text-align: left;
}

.nav-item.active,
.nav-item:hover,
.keyword-nav.active,
.keyword-nav:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

.nav-icon {
  width: 18px;
  display: inline-grid;
  place-items: center;
  color: currentColor;
}

.keyword-block {
  margin-top: auto;
  padding: 8px 16px 18px;
}

.keyword-block p {
  margin: 0 0 8px;
  padding: 0 4px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.sidebar-keywords {
  display: grid;
  gap: 2px;
}

.keyword-nav {
  padding: 7px 8px;
  font-size: 12px;
}

.dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--primary);
}

.dot.emerald {
  background: #34d399;
}

.dot.amber {
  background: #f59e0b;
}

.dot.rose {
  background: #fb7185;
}

.dot.sky {
  background: #38bdf8;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--line-soft);
}

.sidebar-user > div:nth-child(2) {
  min-width: 0;
  flex: 1;
}

.sidebar-user strong,
.sidebar-user span {
  display: block;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user strong {
  font-size: 14px;
}

.sidebar-user span {
  color: var(--faint);
  font-size: 12px;
}

.sidebar-logout {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  font-size: 16px;
  font-weight: 800;
}

.sidebar-logout:hover {
  color: var(--danger);
  border-color: #fecdd3;
  background: #fff1f2;
}

.avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--primary);
  background: var(--primary-soft);
  font-weight: 800;
}

.avatar.large {
  width: 56px;
  height: 56px;
  font-size: 20px;
}

.main-pane {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 32px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(8px);
}

.topbar h2 {
  margin: 0;
  font-size: 18px;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--faint);
  font-size: 12px;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-controls select {
  width: auto;
  min-width: 132px;
  font-size: 13px;
}

.content {
  padding: 22px 32px 36px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.stat-card {
  padding: 16px;
}

.stat-card span,
.stat-card em {
  display: block;
  color: var(--faint);
  font-size: 12px;
  font-style: normal;
}

.stat-card strong {
  display: block;
  margin: 4px 0 2px;
  font-size: 28px;
  line-height: 1.1;
}

.action-bar,
.search-panel {
  display: flex;
  align-items: end;
  gap: 10px;
  padding: 14px;
  margin-bottom: 14px;
  background: #fff;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

.search-workspace {
  position: relative;
}

.search-workspace.is-searching .action-bar,
.search-workspace.is-searching .search-panel {
  border-color: #bae6fd;
  box-shadow: 0 10px 30px rgba(2, 132, 199, 0.08);
}

.search-loading-card {
  min-height: 300px;
  display: grid;
  place-items: center;
  gap: 16px;
  padding: 34px 24px;
  margin-bottom: 14px;
  text-align: center;
  background: #fff;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.06);
}

.loader-orbit {
  width: 128px;
  height: 128px;
  position: relative;
  display: grid;
  place-items: center;
}

.loader-orbit span {
  width: 13px;
  height: 28px;
  position: absolute;
  left: 57px;
  top: 8px;
  border-radius: 999px;
  background: var(--sky);
  opacity: 0.18;
  transform: rotate(calc(var(--i) * 30deg)) translateY(46px);
  animation: loader-fade 1.1s linear infinite;
  animation-delay: calc(var(--i) * 0.08s);
}

.loader-orbit strong {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--primary);
  background: #fff;
  font-size: 18px;
  font-weight: 900;
  box-shadow: 0 0 0 1px var(--line-soft), 0 8px 20px rgba(2, 132, 199, 0.08);
}

.search-loading-copy {
  max-width: 560px;
}

.search-loading-copy strong {
  display: block;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.4;
}

.search-loading-copy p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.loading-sources {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.loading-sources span {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  color: #0369a1;
  background: #f0f9ff;
  border: 1px solid #dbeafe;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.loading-sources span.running {
  color: #fff;
  background: var(--sky);
  border-color: var(--sky);
}

.loading-sources span.completed {
  color: #047857;
  background: #ecfdf5;
  border-color: #a7f3d0;
}

.loading-sources span.failed {
  color: var(--danger);
  background: #fff1f2;
  border-color: #fecdd3;
}

.search-results-shell {
  position: relative;
}

.feed-tools {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

.paper-list {
  display: grid;
  gap: 12px;
}

.paper-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.paper-card:hover {
  border-color: #c7d2fe;
  box-shadow: 0 12px 32px rgba(79, 70, 229, 0.08);
}

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

.meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 9px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 700;
}

.chip.keyword {
  color: var(--primary);
  background: var(--primary-soft);
}

.date {
  color: var(--faint);
  font-size: 12px;
}

.paper-title {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.45;
}

.paper-title:hover {
  color: var(--primary);
}

.paper-authors {
  margin: 6px 0 9px;
  color: var(--faint);
  font-size: 12px;
}

.summary-preview,
.summary-detail {
  border-left: 2px solid #a5b4fc;
  border-radius: 8px;
  padding: 10px 12px;
  color: #475569;
  background: var(--primary-soft);
  font-size: 13px;
  line-height: 1.6;
}

.summary-preview.muted {
  border-left-color: var(--line);
  background: #f8fafc;
}

.summary-preview span {
  color: var(--primary);
  font-weight: 800;
}

.paper-side {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.bookmark-button,
.icon-button {
  border: 0;
  background: transparent;
  color: #cbd5e1;
  font-size: 24px;
  line-height: 1;
}

.bookmark-button.saved {
  color: #f59e0b;
}

.empty-state {
  padding: 34px 18px;
  text-align: center;
  color: var(--muted);
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.empty-state.small {
  padding: 18px;
}

.empty-state strong {
  display: block;
  color: var(--ink);
  margin-bottom: 6px;
}

.empty-state p,
.empty-small {
  margin: 0;
  color: var(--faint);
  font-size: 13px;
}

.digest-preview {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 14px;
}

.settings-grid {
  max-width: 850px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.settings-tabs {
  max-width: 850px;
  margin: 0 auto 18px;
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-soft);
}

.settings-tabs button {
  min-width: 120px;
  border: 0;
  border-radius: 6px;
  padding: 9px 12px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 800;
}

.settings-tabs button.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.settings-section.wide {
  overflow: hidden;
}

.settings-section,
.detail-card {
  padding: 22px;
}

.settings-section h3,
.detail-card h3 {
  margin: 0 0 16px;
  font-size: 16px;
}

.admin-dashboard-grid {
  max-width: 1120px;
}

.admin-recommend-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.admin-recommend-grid article {
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fafc;
}

.admin-recommend-grid strong {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 14px;
}

.admin-recommend-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.admin-action-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(6, auto);
  align-items: end;
  gap: 10px;
}

.profile-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-head h3 {
  margin: 0;
}

.section-head span {
  color: var(--faint);
  font-size: 12px;
}

.keyword-add {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.recommend-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 18px;
}

.recommend-chip {
  border: 1px dashed #cbd5e1;
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
}

.recommend-chip:hover {
  color: var(--primary);
  border-color: #a5b4fc;
}

.subscription-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.subscription-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #f8fafc;
}

.subscription-item div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.subscription-item strong {
  font-size: 14px;
}

.subscription-item em {
  color: var(--faint);
  font-size: 12px;
  font-style: normal;
}

.delete-keyword {
  font-size: 20px;
}

.delete-keyword:hover {
  color: var(--rose);
}

.admin-user-list {
  display: grid;
  gap: 8px;
}

.admin-user-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #f8fafc;
}

.admin-user-item strong,
.admin-user-item span {
  display: block;
}

.admin-user-item strong {
  font-size: 14px;
}

.admin-user-item span {
  margin-top: 2px;
  color: var(--faint);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.admin-role-select {
  height: 36px;
  font-size: 13px;
}

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

.switch-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.switch-row strong,
.switch-row small {
  display: block;
}

.switch-row small {
  color: var(--faint);
  font-size: 12px;
}

.switch-row input {
  width: 18px;
  height: 18px;
}

.back-link {
  border: 0;
  padding: 0;
  margin-bottom: 16px;
  color: var(--muted);
  background: transparent;
  font-size: 14px;
  font-weight: 700;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  gap: 18px;
}

.detail-main,
.detail-side {
  display: grid;
  align-content: start;
  gap: 18px;
}

.detail-card h1 {
  margin: 8px 0 10px;
  font-size: 24px;
  line-height: 1.35;
}

.authors {
  color: var(--muted);
  font-size: 14px;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--faint);
  font-size: 12px;
}

.summary-points {
  display: grid;
  gap: 12px;
}

.summary-points div {
  display: flex;
  gap: 10px;
}

.summary-points span {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--primary);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

.summary-points p {
  margin: 0;
}

.abstract-text {
  color: #475569;
  font-size: 14px;
  line-height: 1.75;
}

.info-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.info-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.info-list dt {
  color: var(--faint);
  font-size: 12px;
}

.info-list dd {
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.side-actions {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.link-error {
  margin: -2px 0 4px;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.45;
}

.related-list {
  display: grid;
  gap: 12px;
}

.related-list button {
  border: 0;
  padding: 0;
  color: var(--muted);
  background: transparent;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.related-list button:hover {
  color: var(--primary);
}

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

@keyframes loader-fade {
  0%,
  100% {
    opacity: 0.16;
  }
  35% {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .button-spinner,
  .loader-orbit span {
    animation: none;
  }
}

@media (max-width: 980px) {
  .app-view {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .keyword-block {
    margin-top: 0;
  }

  .sidebar-user {
    display: none;
  }

  .topbar,
  .action-bar,
  .search-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-controls {
    flex-wrap: wrap;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-recommend-grid,
  .admin-action-row {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .auth-card {
    padding: 22px;
  }

  .sidebar-brand {
    height: 58px;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar,
  .content {
    padding-left: 16px;
    padding-right: 16px;
  }

  .stats-grid,
  .form-grid,
  .admin-user-item {
    grid-template-columns: 1fr;
  }

  .paper-card {
    display: grid;
  }

  .paper-side {
    display: flex;
    justify-content: space-between;
    justify-items: stretch;
  }

  .keyword-add {
    display: grid;
  }
}
