/* ==========================================================================
   Long Equity: Academic Research (SSRN)
   Warm-stone and emerald styling consistent with Fund Overlap & Raw Financials
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  --bg: #FFFFFF;
  --surface: #FAF9F7;
  --surface2: #F2EFEB;
  --border: #E5E0D8;
  --border-subtle: #EAE6DF;
  --text: #1C1917;
  --text2: #57534E;
  --text3: #78716C;
  --accent: #047857;
  --green: #10B981;
  --green-dark: #047857;
  --green-bg: #ECFDF5;
  --radius: 16px;
  --shadow-sm: 0 1px 3px rgba(28, 25, 23, 0.04);
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Header Banner */
.top-header {
  max-width: 1380px;
  margin: 0 auto;
  padding: 26px 20px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
}

.page-title {
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  font-size: clamp(28px, 3.4vw, 44px);
  font-weight: 400;
  letter-spacing: -0.03em;
  color: #18181B;
  line-height: 1.14;
  margin: 0;
}

.page-title-bold {
  font-weight: 600;
  color: #171717;
}

.ar-subtitle {
  max-width: 740px;
  margin: 0;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text2);
}

/* Workspace */
.ar-workspace {
  max-width: 1380px;
  margin: 0 auto;
  padding: 12px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.ar-controls-panel {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ar-controls-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.ar-search-col {
  flex: 1 1 460px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

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

.ar-search-icon {
  position: absolute;
  left: 13px;
  color: var(--text3);
  pointer-events: none;
}

#ar-search-input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 8px 14px 8px 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #ffffff;
  font-family: 'Manrope', sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#ar-search-input:focus {
  border-color: #1C1917;
  box-shadow: 0 0 0 3px rgba(28, 25, 23, 0.08);
}

.ar-search-submit {
  height: 40px;
  padding: 0 16px;
  border: none;
  border-radius: 10px;
  background: #1C1917;
  color: #ffffff;
  font-family: 'Manrope', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.ar-search-submit:hover {
  background: #292524;
}

.ar-clear-btn {
  height: 40px;
  padding: 0 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #ffffff;
  font-family: 'Manrope', sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  white-space: nowrap;
}

.ar-clear-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

.ar-quick-topics {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.ar-quick-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3);
  margin-right: 2px;
}

.ar-topic-chip {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #ffffff;
  font-family: 'Manrope', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.14s ease;
}

.ar-topic-chip:hover {
  border-color: #1C1917;
  color: #1C1917;
  background: var(--surface2);
}

/* Right Action Controls */
.ar-actions-col {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.ar-sort-wrap {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  height: 40px;
}

.ar-toolbar-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3);
  white-space: nowrap;
}

.ar-pill-tray {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  gap: 2px;
}

.ar-tray-btn {
  height: 100%;
  display: inline-flex;
  align-items: center;
  padding: 0 13px;
  border: none;
  border-radius: 7px;
  background: transparent;
  font-family: 'Manrope', sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.ar-tray-btn.active {
  background: #ffffff;
  color: #1C1917;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Sub-bar: Pillar Tabs & Status */
.ar-subbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.ar-pillar-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ar-pillar-tab {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #ffffff;
  font-family: 'Manrope', sans-serif;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s ease;
}

.ar-pillar-tab:hover {
  border-color: #1C1917;
  color: #1C1917;
}

.ar-pillar-tab.active {
  background: #1C1917;
  border-color: #1C1917;
  color: #ffffff;
}

.ar-meta-status {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text3);
}

.ar-error-box {
  padding: 14px 18px;
  border-radius: 12px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: #991B1B;
  font-size: 13.5px;
  font-weight: 600;
}

/* Loading State */
.ar-loading-card {
  padding: 38px 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text2);
}

.ar-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid #D6D3D1;
  border-top-color: #047857;
  animation: ar-spin 0.8s linear infinite;
}

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

/* Pillar Sections */
.ar-pillars-container {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.ar-pillar-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.ar-pillar-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.ar-pillar-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #047857;
  margin-bottom: 4px;
}

.ar-pillar-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.ar-pillar-question {
  margin: 4px 0 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text2);
}

.ar-pillar-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--text2);
  white-space: nowrap;
}

.ar-back-btn {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #ffffff;
  font-family: 'Manrope', sans-serif;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
}

.ar-back-btn:hover {
  background: var(--surface2);
}

/* Articles 2-Column Grid */
.ar-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 900px) {
  .ar-cards-grid {
    grid-template-columns: 1fr;
  }
}

.ar-paper-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.ar-paper-card:hover {
  border-color: #C4BDB0;
  box-shadow: 0 8px 22px -8px rgba(28, 25, 23, 0.1);
}

.ar-paper-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ar-paper-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.ar-rank-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: #1C1917;
  color: #ffffff;
}

.ar-date-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--green-bg);
  border: 1px solid #A7F3D0;
  color: #065F46;
}

.ar-ssrn-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text3);
}

.ar-cite-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: #F4F4F5;
  border: 1px solid #E4E4E7;
  color: #3F3F46;
}

.ar-paper-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.38;
  letter-spacing: -0.015em;
  color: var(--text);
}

.ar-paper-title a {
  color: inherit;
  text-decoration: none;
}

.ar-paper-title a:hover {
  color: #047857;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ar-paper-authors {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text2);
  margin: 0;
}

.ar-paper-abstract {
  margin: 0;
  font-size: 13px;
  line-height: 1.58;
  color: #44403C;
}

.ar-paper-abstract.is-clamped {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ar-paper-abstract.is-missing {
  font-style: italic;
  color: var(--text3);
}

.ar-toggle-abs {
  align-self: flex-start;
  padding: 0;
  border: none;
  background: none;
  font-family: 'Manrope', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: #047857;
  cursor: pointer;
}

.ar-toggle-abs:hover {
  text-decoration: underline;
}

.ar-paper-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.ar-matched-terms {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.ar-term-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text2);
}

.ar-paper-links {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
}

.ar-ext-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  transition: all 0.14s ease;
}

.ar-ext-link:hover {
  border-color: #1C1917;
  background: var(--surface2);
}

.ar-ext-link.is-ssrn {
  background: var(--green-bg);
  border-color: #A7F3D0;
  color: #065F46;
}

.ar-ext-link.is-ssrn:hover {
  background: #D1FAE5;
  border-color: #6EE7B7;
}

/* Notice Box */
.ar-notice-box {
  padding: 14px 18px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text2);
}

.ar-notice-box code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  background: #EDE9E3;
  padding: 1px 5px;
  border-radius: 4px;
}

@media (max-width: 640px) {
  .top-header {
    padding: 18px 14px 10px;
  }
  .ar-workspace {
    padding: 8px 14px 36px;
  }
  .panel, .ar-pillar-section {
    padding: 14px;
  }
  .ar-search-wrap {
    flex-wrap: wrap;
  }
  #ar-search-input {
    flex: 1 1 100%;
  }
}
