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

body {
  font-family: "Inter Tight", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  max-width: 920px; margin: 0 auto; padding: 1.5rem;
  color: #1a1a1a; background: #fafafa;
  font-size: 15px; line-height: 1.6;
}

header { position: relative; margin-bottom: .75rem; }
header h1 {
  font-family: "Fraunces", Georgia, "Times New Roman", serif;
  font-size: 2.6rem; font-weight: 900;
}
.subtitle { font-size: .95rem; color: #555; margin-top: .1rem; }

#auth { position: absolute; top: 8px; right: 0; }
.auth-btn {
  font-family: "Space Grotesk", sans-serif;
  font-size: .8rem; font-weight: 500;
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .4rem .8rem; border-radius: 6px;
  border: 1px solid #d0d7de; background: #f6f8fa;
  color: #24292f; cursor: pointer; transition: background .15s;
}
.auth-btn:hover { background: #eaeef2; }
.auth-btn-small { font-size: .75rem; padding: .25rem .55rem; }
.auth-user { display: flex; align-items: center; gap: .45rem; }
.auth-avatar { width: 24px; height: 24px; border-radius: 50%; border: 1px solid #d0d7de; }
.auth-name { font-family: "Space Grotesk", sans-serif; font-size: .8rem; font-weight: 500; }

.locked-msg { text-align: center; padding: 4rem 1rem; color: #666; font-size: 1rem; }

.toolbar {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: .5rem; margin-bottom: .5rem;
}
.toolbar-right { display: flex; gap: .5rem; align-items: center; }

#type-tabs { display: flex; gap: .2rem; }
.tab {
  font-family: "Space Grotesk", sans-serif;
  padding: .4rem .85rem; font-size: .85rem; cursor: pointer;
  border: 1px solid #e5e7eb; border-radius: 6px;
  background: #fff; color: #555; transition: all .15s;
}
.tab.active { color: #0969da; border-color: #0969da; font-weight: 700; background: #f0f7ff; }

#search {
  font-family: "Inter Tight", sans-serif;
  padding: .4rem .65rem; font-size: .85rem;
  border: 1px solid #d0d7de; border-radius: 6px; width: 180px;
}
#search:focus { outline: 2px solid #0969da; border-color: transparent; }

.primary-btn {
  font-family: "Space Grotesk", sans-serif;
  padding: .4rem .9rem; font-size: .85rem; font-weight: 600;
  border: none; border-radius: 6px;
  background: #0969da; color: #fff; cursor: pointer; transition: background .15s;
}
.primary-btn:hover { background: #0757b5; }
.primary-btn:disabled { opacity: .5; cursor: not-allowed; }
.secondary-btn {
  font-family: "Space Grotesk", sans-serif;
  padding: .35rem .75rem; font-size: .8rem; font-weight: 500;
  border: 1px solid #d0d7de; border-radius: 6px;
  background: #f6f8fa; color: #24292f; cursor: pointer;
}
.secondary-btn:hover { background: #eaeef2; }
.danger-btn {
  font-family: "Space Grotesk", sans-serif;
  padding: .35rem .75rem; font-size: .8rem; font-weight: 500;
  border: 1px solid #e5b5b5; border-radius: 6px;
  background: #fff5f5; color: #b91c1c; cursor: pointer; margin-left: auto;
}
.danger-btn:hover { background: #fce8e8; }

.stats {
  font-family: "Space Grotesk", sans-serif;
  font-size: .82rem; color: #666; margin-bottom: .75rem;
}

.record-card {
  border: 1px solid #e5e7eb; border-radius: 8px;
  padding: .75rem 1rem; margin-bottom: .5rem;
  background: #fff; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.record-card:hover { border-color: #c0c8d0; box-shadow: 0 1px 4px rgba(0,0,0,.06); }

.card-header { display: flex; align-items: center; gap: .5rem; }
.card-title {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 1.1rem; font-weight: 700; flex: 1;
}
.type-badge {
  font-family: "Space Grotesk", sans-serif;
  font-size: .7rem; font-weight: 600; padding: .1rem .45rem;
  border-radius: 4px; text-transform: uppercase; letter-spacing: .04em;
}
.quote-count { font-family: "Space Grotesk", sans-serif; font-size: .72rem; color: #888; }
.card-subtitle {
  font-family: "Inconsolata", monospace;
  font-size: .82rem; color: #555; margin-top: .2rem;
}
.card-relevance { font-size: .85rem; color: #444; margin-top: .3rem; }
.card-tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem; }
.tag {
  font-family: "Space Grotesk", sans-serif;
  font-size: .68rem; padding: .1rem .4rem; border-radius: 4px;
  background: #f0f0f0; color: #555;
}
.empty { text-align: center; padding: 2rem; color: #888; }

#detail {
  border: 1px solid #d0d7de; border-radius: 8px;
  padding: 1.25rem; margin-top: .75rem; background: #fff;
}
.detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.detail-header h2 {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.4rem; font-weight: 800;
}
.detail-actions { display: flex; gap: .4rem; flex-shrink: 0; }
.detail-url { font-size: .85rem; margin-top: .3rem; }
.detail-url a { color: #0969da; }
.detail-relevance { font-size: .9rem; color: #333; margin-top: .5rem; }

.detail-quotes { margin-top: 1rem; }
.detail-quotes h4, .detail-notes h4 {
  font-family: "Space Grotesk", sans-serif;
  font-size: .85rem; font-weight: 600; color: #555; margin-bottom: .4rem;
}
.quote-block {
  border-left: 3px solid #d0d7de; padding: .4rem .75rem;
  margin-bottom: .6rem; font-size: .88rem; color: #333;
}
.quote-block cite {
  display: block; font-size: .78rem; color: #777; margin-top: .2rem;
  font-style: normal; font-family: "Inconsolata", monospace;
}
.quote-note { display: block; font-size: .75rem; color: #888; font-style: italic; margin-top: .15rem; }

.detail-notes { margin-top: 1rem; }
.detail-notes p { font-size: .88rem; color: #444; }

#form-section {
  border: 1px solid #d0d7de; border-radius: 8px;
  padding: 1rem 1.25rem; margin-bottom: 1rem; background: #fff;
}
.form-row { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem; }
.form-row label, #record-form > label {
  display: flex; flex-direction: column; gap: .2rem;
  font-family: "Space Grotesk", sans-serif;
  font-size: .8rem; font-weight: 500; color: #555;
  min-width: 120px; flex: 1;
}
.flex-1 { flex: 2 !important; }

#record-form input[type="text"],
#record-form input[type="url"],
#record-form input[type="date"],
#record-form textarea,
#record-form select {
  font-family: "Inter Tight", sans-serif;
  font-size: .85rem; padding: .35rem .5rem;
  border: 1px solid #d0d7de; border-radius: 5px;
}
#record-form textarea { resize: vertical; }
#record-form input:focus, #record-form textarea:focus, #record-form select:focus {
  outline: 2px solid #0969da; border-color: transparent;
}

.type-fields[hidden] { display: none !important; }

#quotes-fieldset {
  border: 1px solid #e5e7eb; border-radius: 6px;
  padding: .75rem; margin-top: .5rem;
}
#quotes-fieldset legend {
  font-family: "Space Grotesk", sans-serif;
  font-size: .82rem; font-weight: 600; color: #555; padding: 0 .3rem;
}
.quote-entry {
  margin-bottom: .6rem; padding-bottom: .6rem;
  border-bottom: 1px solid #f0f0f0;
}
.quote-entry:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.quote-entry textarea, .quote-entry input {
  font-family: "Inter Tight", sans-serif;
  font-size: .85rem; padding: .3rem .5rem;
  border: 1px solid #d0d7de; border-radius: 5px; width: 100%;
}
.quote-meta-row { display: flex; gap: .5rem; margin-top: .3rem; }
.quote-meta-row input { flex: 1; }
.remove-quote-btn {
  border: none; background: none; color: #b91c1c;
  font-size: 1.1rem; cursor: pointer; padding: 0 .3rem; line-height: 1;
}
.remove-quote-btn:hover { color: #7f1d1d; }

.form-actions { display: flex; gap: .5rem; margin-top: .75rem; align-items: center; }

a { color: #0969da; text-decoration: none; }
a:hover { text-decoration: underline; }

footer {
  margin-top: 2rem; padding: 1rem 0;
  border-top: 1px solid #e5e7eb;
  font-family: "Space Grotesk", sans-serif;
  font-size: .8rem; color: #888; text-align: center;
}

@media (max-width: 600px) {
  header h1 { font-size: 2rem; }
  .form-row { flex-direction: column; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-right { justify-content: space-between; }
  #search { width: 100%; }
}
