:root {
  --accent: #1e90ff;
  --accent-dark: #1675d6;
  --bg: #f7f8fa;
  --panel: #eef0f3;
  --text: #1d2733;
  --muted: #6b7785;
  --danger: #e0483e;
  --green: #28a564;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 6px 18px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: 'Open Sans', system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}

h1,
h2,
h3,
.brand {
  font-family: 'Quicksand', system-ui, sans-serif;
}

a {
  color: var(--accent);
  cursor: pointer;
}

button {
  font: inherit;
  cursor: pointer;
}

/* ---------- Layout ---------- */
.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  flex: 0 0 240px;
  background: #fff;
  border-right: 1px solid #e6e9ee;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.main {
  flex: 1 1 auto;
  padding: 32px clamp(16px, 5vw, 64px);
  overflow-x: hidden;
}

.brand {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}

.brand small {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.sidebar .spacer {
  flex: 1;
}

.sidebar .side-link {
  border: none;
  background: none;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text);
  font-weight: 600;
}

.sidebar .side-link:hover {
  background: var(--panel);
}

.sidebar-email {
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

/* Export options group — inline on desktop, collapses to a dropdown on mobile. */
.export-group {
  position: relative;
}

.export-toggle {
  display: none;
}

.export-menu {
  display: flex;
  flex-direction: column;
}

.page-title {
  text-align: center;
  margin-bottom: 28px;
}

.page-title h1 {
  font-size: 2.2rem;
  margin: 0 0 4px;
}

.page-title p {
  color: var(--muted);
  margin: 0;
}

.style-picker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.style-picker label {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.style-picker select {
  min-width: 180px;
  padding: 8px 14px;
}

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  box-shadow: var(--shadow);
  transition: transform 0.05s ease, background 0.15s ease;
}

.btn:hover {
  background: var(--accent-dark);
}

.btn:active {
  transform: translateY(1px);
}

.btn.green {
  background: var(--green);
}

.btn.ghost {
  background: #fff;
  color: var(--text);
  border: 1px solid #d8dde4;
  box-shadow: none;
}

.btn.danger {
  background: var(--danger);
}

.btn.small {
  padding: 7px 14px;
  font-size: 0.85rem;
}

.btn.block {
  width: 100%;
}

/* Primary "create" action — distinct via gradient/size/shadow, in the blue theme. */
.btn.create {
  background: linear-gradient(135deg, #45a3ff 0%, var(--accent-dark) 100%);
  color: #fff;
  font-size: 1.02rem;
  padding: 14px 22px;
  letter-spacing: 0.01em;
  box-shadow: 0 4px 14px rgba(30, 144, 255, 0.35);
}

.btn.create:hover {
  background: linear-gradient(135deg, #1e90ff 0%, #1163b8 100%);
}

/* ---------- Forms ---------- */
input,
select {
  font: inherit;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1px solid #d8dde4;
  background: #fff;
  min-width: 220px;
}

input:focus,
select:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

label {
  display: block;
  font-weight: 600;
  margin: 14px 0 6px;
}

.field {
  margin-right: 14px;
}

.form-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 0;
}

.panel {
  background: var(--panel);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 28px;
  overflow: hidden;
}

.panel-head {
  background: var(--accent);
  color: #fff;
  padding: 14px 18px;
  font-size: 1.3rem;
  font-weight: 600;
  font-family: 'Quicksand', sans-serif;
}

.panel-body {
  padding: 22px;
}

.actions {
  text-align: center;
  margin-top: 22px;
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------- Chips ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.chip {
  border: 1px solid #d2d8df;
  background: #fff;
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 600;
  color: var(--text);
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- Authors ---------- */
.author-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.author-row input {
  min-width: 150px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 600;
  padding: 4px 0;
}

/* ---------- Auto-fill ---------- */
.autofill-primary {
  background: #fff;
  border: 1px solid #dbe6f5;
  border-radius: var(--radius);
  padding: 16px 18px;
}

.autofill-primary > label {
  margin-top: 0;
}

.autofill-input-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.autofill-input-row input {
  flex: 1;
  min-width: 0;
}

.autofill-input-row .btn {
  white-space: nowrap;
}

.autofill-hint {
  font-size: 0.8rem;
  margin: 8px 0 0;
}

.form-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 20px 0 6px;
}

.form-divider::before,
.form-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid #d8dde4;
}

.form-divider span {
  padding: 0 12px;
}

/* ---------- Drag-to-cite ---------- */
.dropzone {
  border: 2px dashed #c4ccd6;
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 20px;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.main.drag-over .dropzone {
  border-color: var(--accent);
  background: #eaf3ff;
  color: var(--accent);
}

.main.drag-over {
  outline: 2px solid var(--accent);
  outline-offset: -8px;
  border-radius: var(--radius);
}

/* ---------- Project grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}

.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card h3 {
  margin: 0;
  font-size: 1.2rem;
}

.card .meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.card .card-actions {
  margin-top: auto;
  display: flex;
  gap: 8px;
  padding-top: 8px;
}

/* ---------- Citation list ---------- */
.citation {
  background: #fff;
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 16px;
  overflow-wrap: anywhere;
}

.citation .text {
  line-height: 1.6;
  margin-bottom: 12px;
}

.citation i {
  font-style: italic;
}

.citation .row-actions {
  display: flex;
  gap: 16px;
}

.row-actions button {
  background: none;
  border: none;
  color: var(--muted);
  font-weight: 600;
}

.row-actions button:hover {
  color: var(--accent);
}

.row-actions button.del:hover {
  color: var(--danger);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
}

/* ---------- Auth ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #eaf3ff 0%, #f7f8fa 60%);
}

.auth-card {
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 34px;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.auth-card .brand {
  font-size: 2rem;
}

.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 20px 0;
}

.auth-card input {
  width: 100%;
}

.auth-error {
  color: var(--danger);
  font-weight: 600;
  min-height: 1.2em;
}

.muted {
  color: var(--muted);
}

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  margin: 8px 0;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid #e0e4ea;
}

.auth-divider span {
  padding: 0 12px;
}

.google-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.google-g {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #d8dde4;
  color: #4285f4;
  font-weight: 800;
  font-family: 'Quicksand', sans-serif;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1d2733;
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 50;
}

.toast.error {
  background: var(--danger);
}

/* ---------- Landing / home ---------- */
.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 460px at 88% -8%, rgba(30, 144, 255, 0.16), transparent 60%),
    radial-gradient(700px 400px at 0% 100%, rgba(40, 165, 100, 0.1), transparent 55%),
    linear-gradient(160deg, #eaf3ff 0%, #f7f8fa 55%);
}

.landing-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px clamp(20px, 6vw, 72px);
}

.landing-top .brand {
  font-size: 1.8rem;
}

.eyebrow {
  display: inline-block;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.8rem;
  margin-bottom: 10px;
}

.hero {
  flex: 1;
  display: flex;
  gap: clamp(24px, 5vw, 64px);
  align-items: flex-start;
  justify-content: center;
  padding: 8px clamp(20px, 6vw, 72px) 48px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.hero-copy {
  flex: 1 1 0;
  max-width: 520px;
}

.hero-copy h1 {
  font-size: clamp(1.9rem, 3.6vw, 2.9rem);
  line-height: 1.12;
  margin: 0 0 28px;
  background: linear-gradient(95deg, var(--text) 35%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.feature {
  margin-bottom: 16px;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  backdrop-filter: blur(6px);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.feature:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.feature h3 {
  margin: 0 0 4px;
  font-size: 1.15rem;
}

.feature p {
  margin: 0;
  color: var(--muted);
}

.seg {
  display: inline-flex;
  margin-top: 14px;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #fff;
}

.seg-item {
  border: none;
  background: #fff;
  color: var(--text);
  font-weight: 600;
  font-family: 'Quicksand', sans-serif;
  padding: 12px 22px;
  border-right: 1px solid #e6e9ee;
  transition: background 0.15s ease, color 0.15s ease;
}

.seg-item:last-child {
  border-right: none;
}

.seg-item:hover:not(.active) {
  background: var(--panel);
}

.seg-item.active {
  background: var(--accent);
  color: #fff;
}

.hero-cta {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.hero-cta .btn {
  padding: 15px 36px;
  font-size: 1.08rem;
  background: linear-gradient(135deg, #2fb56f 0%, #1f8f54 100%);
  box-shadow: 0 6px 20px rgba(40, 165, 100, 0.35);
}

.hero-cta .btn:hover {
  background: linear-gradient(135deg, #29a865 0%, #1b7e4a 100%);
}

/* The sample "paper" sheet */
.paper {
  flex: 1 1 0;
  max-width: 460px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.16);
  border-radius: 6px;
  padding: 48px 44px;
  font-family: 'Times New Roman', Times, serif;
  min-height: 70vh;
  transform: rotate(0.4deg);
  transition: transform 0.2s ease;
}

.paper:hover {
  transform: rotate(0);
}

.paper .ref {
  font-size: 0.95rem;
  line-height: 1.9;
  margin: 0 0 12px;
  padding-left: 2.5em;
  text-indent: -2.5em; /* hanging indent, like a real Works Cited page */
}

.paper .paper-title {
  text-align: center;
  padding-left: 0;
  text-indent: 0;
  margin-bottom: 20px;
}

.paper .ref i {
  font-style: italic;
}

.landing-footer {
  text-align: center;
  padding: 18px;
  color: var(--muted);
  font-size: 0.8rem;
}

@media (max-width: 880px) {
  .hero {
    flex-direction: column;
    align-items: stretch;
  }
  .hero-copy,
  .paper {
    max-width: none;
  }
  .paper {
    min-height: auto;
  }
  .seg {
    width: 100%;
  }
  .seg-item {
    flex: 1;
    padding: 12px 8px;
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .shell {
    flex-direction: column;
  }
  .sidebar {
    flex-basis: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
  }
  /* Narrow viewport: drop the logo and email to save horizontal space. */
  .sidebar .brand,
  .sidebar-email {
    display: none;
  }
  .sidebar .spacer {
    flex: 1 1 auto;
    flex-basis: auto;
    height: auto;
  }
  .sidebar .btn.block {
    width: auto;
  }
  .export-group {
    width: auto;
  }
  .export-toggle {
    display: inline-block;
    width: auto;
  }
  .export-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 30;
    min-width: 220px;
    background: #fff;
    border: 1px solid #e6e9ee;
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 6px;
  }
  .export-group.open .export-menu {
    display: flex;
  }
  input,
  select {
    min-width: 0;
    width: 100%;
  }
  .field {
    margin-right: 0;
    flex: 1 1 100%;
  }
  .autofill-input-row {
    flex-direction: column;
  }
  .autofill-input-row .btn {
    width: 100%;
  }
}
