:root {
  color-scheme: dark;
  --bg: #10110f;
  --panel: #171914;
  --panel-2: #1d201a;
  --ink: #f0efe6;
  --muted: #9b9d91;
  --faint: #65685f;
  --line: #30342b;
  --acid: #c8f168;
  --acid-soft: #91a75e;
  --paper: #e8e4d4;
  --danger: #ff7b78;
  --serif: "Iowan Old Style", "Palatino Linotype", "Noto Serif SC", Georgia, serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% -10%, rgba(200, 241, 104, .075), transparent 35rem),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
}
button, input, textarea, select { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }
.grain {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .23;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.13'/%3E%3C/svg%3E");
}

.topbar {
  width: min(1180px, calc(100% - 40px)); margin: 0 auto; height: 88px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand-mark, .login-mark {
  width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--acid);
  color: var(--acid); font-weight: 800; letter-spacing: -.06em;
}
.brand strong { display: block; font-size: 15px; letter-spacing: .01em; }
.brand small { display: block; margin-top: 2px; color: var(--faint); font-size: 9px; letter-spacing: .17em; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.quiet-button, .icon-button, .prompt-chips button, .import-tabs button {
  border: 0; background: transparent; cursor: pointer;
}
.quiet-button {
  border: 1px solid var(--line); border-radius: 999px; padding: 10px 15px;
  color: var(--paper); transition: .2s ease;
}
.quiet-button:hover { border-color: var(--acid-soft); background: rgba(200,241,104,.04); }
.quiet-button span { color: var(--acid); }
.icon-button {
  width: 40px; height: 40px; border-radius: 50%; color: var(--muted); font-size: 22px;
}
.icon-button:hover { color: var(--ink); background: var(--panel-2); }

main { width: min(1180px, calc(100% - 40px)); margin: auto; }
.hero { min-height: 470px; padding: 104px 0 78px; max-width: 930px; }
.eyebrow {
  margin: 0 0 14px; color: var(--acid); font: 700 10px/1 var(--sans);
  letter-spacing: .21em; text-transform: uppercase;
}
.hero h1 {
  margin: 0; font: 500 clamp(48px, 8vw, 96px)/.98 var(--serif);
  letter-spacing: -.055em;
}
.hero-copy {
  margin: 24px 0 32px; color: var(--muted); max-width: 690px;
  font-size: clamp(15px, 2vw, 18px); line-height: 1.8;
}
.search-shell {
  position: relative; display: flex; align-items: center; min-height: 70px;
  background: var(--paper); border-radius: 4px; color: #181a16;
  box-shadow: 0 24px 70px rgba(0,0,0,.28);
}
.search-shell:focus-within { box-shadow: 0 0 0 3px rgba(200,241,104,.22), 0 24px 70px rgba(0,0,0,.28); }
.search-icon { padding-left: 23px; color: #60645b; font-size: 30px; transform: rotate(-12deg); }
.search-shell input {
  flex: 1; min-width: 0; padding: 20px 18px; border: 0; outline: 0; background: transparent;
  color: #11120f; font-size: 17px;
}
.search-shell input::placeholder { color: #777a70; }
kbd {
  margin-right: 18px; border: 1px solid #b7b6aa; border-bottom-width: 2px;
  border-radius: 5px; padding: 4px 8px; color: #66685f; font: 12px var(--sans);
}
.prompt-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.prompt-chips button {
  padding: 7px 10px; color: var(--faint); border-bottom: 1px dotted #4a4d45;
  font-size: 12px;
}
.prompt-chips button:hover { color: var(--acid); border-color: var(--acid-soft); }

.library-section { padding: 24px 0 100px; border-top: 1px solid var(--line); }
.section-heading {
  display: flex; justify-content: space-between; align-items: end; gap: 24px; margin: 30px 0;
}
.section-heading h2 { margin: 0; font: 500 32px/1.2 var(--serif); letter-spacing: -.025em; }
.stats { display: flex; gap: 20px; color: var(--faint); font-size: 12px; }
.stats strong { color: var(--paper); font-size: 18px; margin-right: 5px; }
.paper-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.paper-card {
  min-width: 0; min-height: 310px; border: 1px solid var(--line); background: rgba(23,25,20,.72);
  transition: transform .2s ease, border-color .2s ease, background .2s ease;
}
.paper-card:hover {
  transform: translateY(-3px); border-color: #555b48;
  background: rgba(29,32,26,.95);
}
.paper-open {
  width: 100%; height: 100%; padding: 24px; border: 0; background: transparent;
  color: inherit; text-align: left; cursor: pointer; display: flex; flex-direction: column;
}
.card-top, .card-footer {
  display: flex; justify-content: space-between; gap: 16px; align-items: center;
}
.paper-year, .paper-status { color: var(--faint); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.paper-status { color: var(--acid-soft); }
.paper-title {
  margin: 28px 0 8px; font: 500 23px/1.27 var(--serif); letter-spacing: -.02em;
}
.paper-authors, .paper-abstract, .paper-venue { color: var(--muted); }
.paper-authors { margin: 0 0 18px; font-size: 12px; }
.paper-abstract {
  margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; font-size: 13px; line-height: 1.65;
}
.latest-memory {
  margin: 18px 0 0; padding: 11px 13px; border-left: 2px solid var(--acid-soft);
  background: rgba(200,241,104,.045); color: #cfd2c4; font-size: 12px; line-height: 1.6;
}
.paper-tags, .detail-tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 18px 0; }
.tag {
  display: inline-flex; padding: 4px 8px; border: 1px solid #34392e;
  color: #aeb2a5; font-size: 10px; border-radius: 999px;
}
.card-footer { margin-top: auto; padding-top: 18px; border-top: 1px solid #292c26; }
.paper-venue { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 11px; }
.open-hint { color: var(--acid); font-size: 11px; opacity: 0; transition: opacity .2s; }
.paper-card:hover .open-hint { opacity: 1; }
.empty-state { padding: 84px 20px; text-align: center; border: 1px dashed var(--line); }
.empty-state h3 { margin: 24px 0 8px; font: 500 30px var(--serif); }
.empty-state p { margin: 0 auto 24px; max-width: 520px; color: var(--muted); line-height: 1.7; }
.empty-orbit {
  display: inline-block; width: 54px; height: 54px; border: 1px solid var(--acid-soft);
  border-radius: 50%; box-shadow: 18px 8px 0 -17px var(--acid), -16px -12px 0 -17px var(--acid);
}

.primary-button, .secondary-button {
  border: 0; border-radius: 3px; padding: 12px 17px; cursor: pointer; font-weight: 700;
}
.primary-button { background: var(--acid); color: #171a11; }
.primary-button:hover { background: #d6fa7d; }
.primary-button:disabled { opacity: .55; cursor: wait; }
.secondary-button { border: 1px solid var(--line); background: var(--panel-2); color: var(--paper); }

dialog {
  color: var(--ink); border: 0; padding: 0; background: transparent;
}
dialog::backdrop { background: rgba(4,5,4,.76); backdrop-filter: blur(8px); }
.paper-dialog { width: min(820px, calc(100% - 28px)); max-height: calc(100vh - 30px); }
.dialog-card, .detail-card {
  background: #161813; border: 1px solid #363a31; box-shadow: 0 30px 100px #000a;
}
.dialog-card { padding: 30px; overflow: auto; max-height: calc(100vh - 30px); }
.dialog-heading, .dialog-actions, .detail-section-heading {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.dialog-heading h2 { margin: 0; font: 500 34px var(--serif); }
.import-tabs { display: flex; gap: 4px; margin: 28px 0 20px; border-bottom: 1px solid var(--line); }
.import-tabs button { padding: 11px 14px; color: var(--faint); border-bottom: 2px solid transparent; }
.import-tabs button.active { color: var(--acid); border-bottom-color: var(--acid); }
.drop-zone {
  min-height: 170px; display: grid; place-items: center; align-content: center; gap: 7px;
  border: 1px dashed #4b5044; background: #12140f; cursor: pointer;
}
.drop-zone.dragging { border-color: var(--acid); background: rgba(200,241,104,.04); }
.drop-zone input { position: absolute; opacity: 0; pointer-events: none; }
.drop-glyph { color: var(--acid); font-size: 32px; }
.drop-zone small { color: var(--faint); }
.file-name { color: var(--acid-soft); font-size: 12px; }
.auto-promise {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px;
  margin-top: 10px; background: var(--line);
}
.auto-promise span {
  padding: 10px 8px; background: #12140f; color: var(--muted);
  text-align: center; font-size: 10px;
}
.auto-promise span::before { content: "✓ "; color: var(--acid); }
.optional-details { margin-top: 20px; }
.optional-details summary {
  color: var(--faint); cursor: pointer; font-size: 11px;
}
.metadata-grid {
  display: grid; grid-template-columns: 1fr 180px; gap: 16px; margin-top: 22px;
}
label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; }
label.wide { grid-column: 1 / -1; }
input, textarea, select {
  width: 100%; border: 1px solid #363a31; border-radius: 2px; padding: 11px 12px;
  outline: none; background: #10120e; color: var(--paper);
}
input:focus, textarea:focus, select:focus { border-color: var(--acid-soft); }
textarea { resize: vertical; line-height: 1.6; }
.memory-first textarea { border-color: #536039; background: rgba(200,241,104,.035); }
.field-action { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.dialog-actions { margin-top: 24px; }
.form-message { margin: 0; color: var(--muted); font-size: 12px; }
.form-message.error { color: var(--danger); }

.detail-dialog { width: min(980px, calc(100% - 24px)); max-height: calc(100vh - 24px); }
.detail-card { position: relative; max-height: calc(100vh - 24px); overflow: auto; }
.close-detail { position: sticky; top: 16px; float: right; margin: 12px 12px -52px 0; z-index: 3; background: #20231c; }
.detail-header { padding: 58px clamp(24px, 6vw, 72px) 48px; border-bottom: 1px solid var(--line); }
.detail-title {
  max-width: 820px; margin: 0; font: 500 clamp(36px, 6vw, 64px)/1.06 var(--serif);
  letter-spacing: -.045em;
}
.detail-authors { color: var(--muted); margin: 22px 0 10px; line-height: 1.6; }
.detail-meta { color: var(--faint); font-size: 12px; }
.detail-actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 22px; }
.detail-actions a { text-decoration: none; }
.detail-section { padding: 42px clamp(24px, 6vw, 72px); border-bottom: 1px solid var(--line); }
.detail-section h2 { margin: 0; font: 500 28px var(--serif); }
.detail-abstract { color: #c5c7bb; font: 16px/1.9 var(--serif); }
.profile-section { background: rgba(200,241,104,.025); }
.profile-gist {
  margin: 24px 0; padding: 20px 22px; border-left: 3px solid var(--acid);
  background: #12140f; color: #e2e5d8; font: 18px/1.75 var(--serif);
}
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.profile-block { padding: 17px; border: 1px solid var(--line); background: #12140f; }
.profile-block h3 {
  margin: 0 0 10px; color: var(--acid-soft); font-size: 10px;
  letter-spacing: .12em; text-transform: uppercase;
}
.profile-block ul { margin: 0; padding-left: 18px; color: #c6c9bd; font-size: 12px; line-height: 1.65; }
.profile-block p { margin: 0; color: #c6c9bd; font-size: 12px; line-height: 1.65; }
.memory-form {
  display: grid; grid-template-columns: 120px 1fr 100px auto; gap: 8px;
  margin: 24px 0;
}
.memory-list, .anchor-list { display: grid; gap: 9px; }
.memory-item, .anchor-item {
  position: relative; padding: 17px 44px 17px 18px; border: 1px solid #30342b; background: #12140f;
}
.memory-item p, .anchor-item p { margin: 0; color: #d4d6cb; line-height: 1.65; }
.memory-meta { margin-top: 9px; color: var(--faint); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.delete-memory {
  position: absolute; top: 12px; right: 10px; border: 0; background: transparent;
  color: var(--faint); cursor: pointer;
}
.delete-memory:hover { color: var(--danger); }
.section-note { color: var(--faint); font-size: 12px; }
.anchors-section { background: rgba(255,255,255,.012); }
.anchor-item { border-left: 2px solid #525b40; }
.danger-section { padding: 28px clamp(24px, 6vw, 72px); text-align: right; }
.delete-paper-button { border: 0; background: transparent; color: #866765; cursor: pointer; font-size: 12px; }
.delete-paper-button:hover { color: var(--danger); }

.login-view {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.login-mark { position: fixed; top: 28px; left: 32px; }
.login-card {
  width: min(460px, 100%); padding: 42px; border: 1px solid var(--line); background: rgba(23,25,20,.85);
}
.login-card h1 { margin: 0; font: 500 58px/1 var(--serif); letter-spacing: -.05em; }
.login-copy { margin: 20px 0 30px; color: var(--muted); line-height: 1.8; }
.login-card .primary-button { margin-top: 12px; width: 100%; }

@media (max-width: 760px) {
  .topbar, main { width: min(100% - 28px, 1180px); }
  .topbar { height: 72px; }
  .brand small { display: none; }
  .quiet-button { font-size: 12px; }
  .hero { min-height: 430px; padding: 76px 0 60px; }
  .hero h1 { font-size: 52px; }
  .search-shell { min-height: 62px; }
  .search-shell input { padding: 16px 10px; font-size: 15px; }
  kbd { display: none; }
  .prompt-chips { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 6px; }
  .prompt-chips button { flex: 0 0 auto; }
  .section-heading { align-items: start; flex-direction: column; }
  .paper-grid { grid-template-columns: 1fr; }
  .paper-card { min-height: 290px; }
  .metadata-grid { grid-template-columns: 1fr; }
  label.wide { grid-column: auto; }
  .dialog-card { padding: 22px; }
  .field-action { grid-template-columns: 1fr; }
  .memory-form { grid-template-columns: 1fr 100px; }
  .memory-form textarea { grid-column: 1 / -1; }
  .detail-header { padding-top: 48px; }
  .auto-promise, .profile-grid { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
