:root {
  color-scheme: light;
  --black: #000000;
  --white: #ffffff;
  --soft: #f7f7f7;
  --muted: #6a6a6a;
  --line: #000000;
  --focus: #7c3cff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--white);
  color: var(--black);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  background: transparent;
  color: var(--black);
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  position: relative;
  background: var(--white);
}

.page {
  min-height: 100vh;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  inset: 0;
  transform: translateY(28px);
  transition: opacity 520ms ease, transform 520ms ease;
}

.page.is-active {
  opacity: 1;
  pointer-events: auto;
  position: relative;
  transform: translateY(0);
}

.top-bar {
  height: 135px;
  display: flex;
  align-items: center;
  background: var(--black);
  color: var(--white);
  overflow: hidden;
}

.top-bar h1 {
  margin: 0 0 8px 18px;
  font-size: clamp(4.5rem, 11vw, 6.7rem);
  font-weight: 400;
  line-height: 0.9;
  letter-spacing: 0;
  animation: titleIn 760ms ease both;
}

.source-form {
  min-height: calc(100vh - 135px);
  display: grid;
  grid-template-columns: minmax(160px, 280px) minmax(220px, 360px) auto;
  align-items: center;
  justify-content: center;
  gap: 56px;
  padding: 48px 24px 120px;
}

.url-field,
.type-field {
  display: grid;
  gap: 10px;
  animation: riseIn 700ms ease both;
}

.type-field {
  animation-delay: 100ms;
}

.url-field span,
.type-field span {
  font-size: clamp(1.5rem, 3vw, 1.95rem);
  line-height: 1.1;
}

.url-field input,
.type-field select {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-bottom: 2px solid var(--black);
  border-radius: 0;
  background: transparent;
  color: var(--black);
  outline: 0;
  padding: 8px 0;
  font-size: 1rem;
  transition: border-color 180ms ease, transform 180ms ease;
}

.url-field input:focus,
.type-field select:focus {
  border-color: var(--focus);
  transform: translateY(-2px);
}

.generate-button {
  min-width: 110px;
  min-height: 48px;
  align-self: end;
  border: 2px solid var(--black);
  padding: 0 20px;
  font-size: 1rem;
  transition: background 180ms ease, color 180ms ease, transform 180ms ease;
  animation: riseIn 700ms 180ms ease both;
}

.generate-button:hover {
  background: var(--black);
  color: var(--white);
  transform: translateY(-2px);
}

.generate-button:disabled {
  opacity: 0.45;
  cursor: wait;
}

.page-output {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 31%;
  background: var(--white);
}

.output-pane,
.saved-pane {
  min-height: 100vh;
}

.output-pane {
  display: flex;
  align-items: center;
  padding: 64px 7.5vw;
}

.saved-pane {
  border-left: 24px solid var(--black);
  animation: dividerIn 620ms ease both;
}

.output-content {
  width: min(100%, 720px);
  animation: slideFromLeft 700ms ease both;
}

.saved-content {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 295px 32px 42px;
  animation: slideFromRight 700ms 120ms ease both;
}

.status-text {
  min-height: 22px;
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 1rem;
}

.output-content h2 {
  margin: 0;
  font-size: clamp(5rem, 10vw, 7.8rem);
  font-weight: 400;
  line-height: 0.95;
  letter-spacing: 0;
}

.citation-output {
  min-height: 92px;
  margin: 42px 0 38px;
  max-width: 760px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.1rem, 2vw, 1.35rem);
  line-height: 1.65;
  opacity: 0;
  transform: translateY(12px);
  animation: fadeUp 620ms 260ms ease both;
}

.citation-editor {
  display: none;
  width: 100%;
  min-height: 170px;
  margin: 42px 0 38px;
  border: 2px solid var(--black);
  border-radius: 0;
  background: var(--white);
  color: var(--black);
  outline: 0;
  padding: 16px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.1rem, 2vw, 1.35rem);
  line-height: 1.65;
  resize: vertical;
  animation: fadeUp 260ms ease both;
}

.citation-editor:focus {
  border-color: var(--focus);
}

.output-content.is-editing .citation-output {
  display: none;
}

.output-content.is-editing .citation-editor {
  display: block;
}

.explanation {
  min-height: 22px;
  max-width: 640px;
  margin: 0 0 42px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.output-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
}

.output-actions button,
.saved-header button,
.download-button,
.saved-list button {
  min-height: 40px;
  border-bottom: 2px solid transparent;
  padding: 0;
  font-size: clamp(1.2rem, 2vw, 1.9rem);
  transition: border-color 180ms ease, transform 180ms ease;
}

.output-actions button:hover,
.saved-header button:hover,
.download-button:hover,
.saved-list button:hover {
  border-color: var(--black);
  transform: translateY(-2px);
}

.saved-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.saved-header h2 {
  margin: 0;
  font-size: clamp(1.6rem, 2.8vw, 2rem);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: 0;
}

.saved-header button,
.download-button,
.saved-list button {
  font-size: 1rem;
}

.saved-list {
  display: grid;
  gap: 22px;
  margin: 32px 0;
  padding-left: 22px;
}

.saved-list:empty::before {
  content: "No saved sources yet.";
  display: block;
  margin-left: -22px;
  color: var(--muted);
}

.saved-list li {
  animation: fadeUp 360ms ease both;
}

.saved-list p {
  margin: 0 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.download-button {
  align-self: flex-start;
  margin-top: auto;
}

@keyframes titleIn {
  from {
    opacity: 0;
    transform: translateX(-28px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideFromLeft {
  from {
    opacity: 0;
    transform: translateX(-42px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideFromRight {
  from {
    opacity: 0;
    transform: translateX(42px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes dividerIn {
  from {
    border-left-width: 0;
  }
  to {
    border-left-width: 24px;
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

@media (max-width: 900px) {
  .source-form {
    grid-template-columns: minmax(0, 1fr);
    align-content: center;
    gap: 28px;
    padding: 40px 24px 80px;
  }

  .generate-button {
    align-self: start;
    justify-self: start;
  }

  .page-output {
    grid-template-columns: 1fr;
  }

  .output-pane {
    min-height: 68vh;
    padding: 56px 28px;
  }

  .saved-pane {
    min-height: 32vh;
    border-left: 0;
    border-top: 18px solid var(--black);
  }

  .saved-content {
    min-height: 32vh;
    padding: 42px 28px;
  }
}

@media (max-width: 560px) {
  .top-bar {
    height: 112px;
  }

  .top-bar h1 {
    margin-left: 12px;
    font-size: 4.7rem;
  }

  .source-form {
    min-height: calc(100vh - 112px);
  }

  .output-content h2 {
    font-size: 4.2rem;
  }

  .output-actions {
    gap: 18px;
  }
}
