:root {
  color-scheme: light dark;
  --bg: #f4f6fb;
  --text: #1d2533;
  --card: #ffffff;
  --muted: #5a687f;
  --accent: #2f6efb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: #0f1728;
  color: #fff;
}

.brand {
  font-weight: 700;
}

nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

nav a,
.link-btn {
  color: #fff;
  text-decoration: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  font: inherit;
}

.search-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s;
}

.search-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
}

.search-expand {
  display: none;
  align-items: center;
  gap: 8px;
  width: 0;
  overflow: hidden;
  transition: width 0.25s ease;
}

.search-form.expanded .search-expand {
  display: flex;
  width: 220px;
  overflow: visible;
}

.search-expand input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  font-size: 14px;
}

.search-expand button[type="submit"] {
  padding: 8px 14px;
  font-size: 14px;
  white-space: nowrap;
}

.container {
  max-width: 980px;
  margin: 30px auto;
  padding: 0 16px 32px;
}

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(18, 26, 46, 0.08);
}

.auth-card {
  max-width: 420px;
  margin: 0 auto;
}

.form-stack,
.add-book-form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

input,
textarea,
button {
  border-radius: 8px;
  border: 1px solid #c9d2e3;
  padding: 10px 12px;
  font: inherit;
}

button {
  background: var(--accent);
  color: #fff;
  border: none;
  font-weight: 600;
}

.user-grid,
.book-grid {
  margin-top: 18px;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.user-card,
.book-card {
  border: 1px solid #e3e8f2;
  border-radius: 10px;
  padding: 12px;
  background: #fff;
}

.book-card img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 8px;
  background: #e7ecf5;
}

.books-title {
  margin-top: 28px;
}

.notes-form {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.delete-form {
  margin-top: 8px;
}

.danger-btn {
  background: #d62f2f;
}

.danger-btn:hover {
  background: #b92525;
}

.notes-readonly {
  margin-top: 10px;
}

.book-actions {
  margin-top: 12px;
}

.edit-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
}

.edit-link svg {
  flex-shrink: 0;
}

.edit-link:hover {
  background: #2563eb;
}

.edit-cover-preview {
  width: 120px;
  height: auto;
  border-radius: 8px;
  display: block;
  margin-bottom: 12px;
}

.cover-hint {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 16px;
}

.edit-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.cancel-btn {
  color: var(--muted);
  text-decoration: none;
}

/* Activity feed */
.activity-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid #e3e8f2;
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-cover {
  width: 80px;
  height: 120px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  background: #e7ecf5;
}

.activity-cover-link {
  line-height: 0;
}

.activity-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid #e3e8f2;
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-cover {
  width: 80px;
  height: 120px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  background: #e7ecf5;
}

.activity-cover-link {
  line-height: 0;
}

.activity-message {
  flex: 1;
  min-width: 0;
}

.notes-preview {
  display: block;
  margin: 8px 0 0;
  padding: 10px 14px;
  background: #f0f4fa;
  border-left: 4px solid #4a90d9;
  font-style: italic;
  color: #374151;
  border-radius: 0 6px 6px 0;
}

.owner-hint,
.readonly-hint {
  margin-top: 4px;
  margin-bottom: 14px;
  color: var(--muted);
}

.notes-form h4 {
  margin: 4px 0 2px;
}

.book-header {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.book-header h3 {
  margin: 0;
}

.edit-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 14px;
  background: #e8eef7;
  color: var(--text);
  border: 1px solid #c9d2e3;
  border-radius: 8px;
  cursor: pointer;
}

.edit-trigger-btn:hover {
  background: #dae2f0;
}

.edit-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.edit-panel {
  margin-left: auto;
}

.edit-panel > summary {
  list-style: none;
}

.edit-panel > summary::-webkit-details-marker {
  display: none;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid #c9d2e3;
  background: #f0f4fb;
  color: #1d2533;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.edit-panel-body {
  margin-top: 10px;
}

.flash-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}

.flash-list li {
  background: #eaf0ff;
  color: #0c3474;
  border: 1px solid #c9d9ff;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 8px;
}

.inline-form {
  display: inline;
}

.edit-link {
  display: inline-block;
  margin-top: 8px;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
}

.edit-link:hover {
  opacity: 0.9;
}

.edit-cover-preview {
  max-width: 120px;
  border-radius: 8px;
  margin-bottom: 12px;
  display: block;
}

.cover-hint {
  color: var(--muted);
  font-size: 0.9em;
  margin-bottom: 16px;
}

.edit-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.cancel-btn {
  color: var(--muted);
  text-decoration: none;
}

/* Activity feed */
.activity-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid #e3e8f2;
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-cover {
  width: 80px;
  height: 120px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  background: #e7ecf5;
}

.activity-cover-link {
  line-height: 0;
}

.activity-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid #e3e8f2;
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-cover {
  width: 80px;
  height: 120px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  background: #e7ecf5;
}

.activity-cover-link {
  line-height: 0;
}
