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

:root {
  --ink:          #1a1612;
  --ink-soft:     #4a4038;
  --paper:        #f5f0e8;
  --cream:        #ede6d6;
  --rule:         #d4c9b0;
  --accent:       #c0392b;
  --accent-light: #e8b4af;
  --white:        #fdfaf4;
  --radius:       4px;
  --ff-display:   'Playfair Display', Georgia, serif;
  --ff-body:      'DM Sans', sans-serif;
}

html, body { height: 100%; }

body {
  font-family: var(--ff-body);
  background-color: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 27px,
      rgba(180,160,120,0.12) 28px
    );
}

/* ── TOPBAR ── */
.topbar {
  background: var(--ink);
  color: var(--paper);
  padding: 0 32px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(26,22,18,0.35);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--paper);
  font-family: var(--ff-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.logo-icon {
  width: 34px;
  height: 34px;
  background: var(--accent);
  color: #fff;
  font-family: var(--ff-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.03em;
  display: grid;
  place-items: center;
  border-radius: 3px;
  flex-shrink: 0;
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-actions span {
  font-size: 13px;
  font-weight: 400;
  color: var(--rule);
  letter-spacing: 0.04em;
}

.divider { color: var(--ink-soft) !important; }

.logout-btn {
  background: none;
  border: 1px solid rgba(213,200,180,0.35);
  color: var(--rule);
  font-family: var(--ff-body);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.logout-btn:hover {
  border-color: var(--accent-light);
  color: var(--accent-light);
}

/* ── NAVBAR ── */
.navbar {
  background: var(--cream);
  border-bottom: 1px solid var(--rule);
  padding: 0 32px;
  height: 48px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.nav-back {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: color 0.2s;
}

.nav-back:hover { color: var(--accent); }

.nav-title {
  font-family: var(--ff-display);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0.01em;
  text-align: center;
  white-space: nowrap;
}

.add-btn {
  justify-self: end;
  background: var(--ink);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  padding: 0;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s;
}

.add-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform: translateX(-101%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.add-btn:hover::after { transform: translateX(0); }
.add-btn:hover { transform: translateY(-1px); }

.add-btn a {
  display: block;
  position: relative;
  z-index: 1;
  font-family: var(--ff-body);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  text-decoration: none;
  padding: 7px 16px;
}

/* ── MAIN ── */
.main {
  flex: 1;
  padding: 36px 32px 60px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

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

/* ── SEARCH BAR ── */
/* Wireframe: centered, Entry label + search input + Search button */
.search-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 28px;
}

.search-bar label {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-soft);
  white-space: nowrap;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: 999px; /* pill shape as in wireframe */
  padding: 8px 14px;
  width: 260px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input-wrap:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(26,22,18,0.07);
}

.search-input-wrap svg {
  color: var(--rule);
  flex-shrink: 0;
}

.search-input-wrap input {
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--ff-body);
  font-size: 14px;
  font-weight: 300;
  color: var(--ink);
  width: 100%;
}

.search-input-wrap input::placeholder { color: #b8a98c; }

.search-btn {
  font-family: var(--ff-body);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  background: var(--ink);
  border: none;
  border-radius: var(--radius);
  padding: 9px 22px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s;
}

.search-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform: translateX(-101%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.search-btn:hover::after { transform: translateX(0); }
.search-btn:hover { transform: translateY(-1px); }

/* ── TOPIC SECTION ── */
.topic-name {
  font-family: var(--ff-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--ink);
  position: relative;
}

.topic-name::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -5px;
  width: 44px;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
}

/* ── CARDS CONTAINER (bordered wrapper per wireframe) ── */
.cards-container {
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--cream);
  padding: 20px;
  box-shadow:
    0 1px 3px rgba(26,22,18,0.04),
    0 4px 16px rgba(26,22,18,0.05);
}

/* ── ENTRIES GRID: strict 2-column as in wireframe ── */
.entries-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

/* ── ENTRY CARD ── */
.entry-card {
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 1px 2px rgba(26,22,18,0.04),
    0 2px 10px rgba(26,22,18,0.04);
  transition: box-shadow 0.25s, transform 0.2s;
}

.entry-card:hover {
  box-shadow:
    0 2px 6px rgba(26,22,18,0.08),
    0 6px 22px rgba(26,22,18,0.09);
  transform: translateY(-2px);
}

/* Corner fold */
.entry-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 0; height: 0;
  border-style: solid;
  border-width: 0 28px 28px 0;
  border-color: transparent var(--cream) transparent transparent;
}

/* ── CARD HEADER ── */
.entry-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.entry-card-info { flex: 1; }

.entry-card-title {
  font-family: var(--ff-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
  margin-bottom: 5px;
}

.entry-card-date {
  font-size: 12px;
  font-weight: 400;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

/* Photo placeholder — large square per wireframe */
.entry-card-photo {
  flex-shrink: 0;
  width: 72px;
  height: 72px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: var(--rule);
  position: relative;
  overflow: hidden;
}

/* X cross lines like wireframe broken-image icon */
.entry-card-photo::before,
.entry-card-photo::after {
  content: '';
  position: absolute;
  width: 140%;
  height: 1px;
  background: var(--rule);
  top: 50%; left: -20%;
}

.entry-card-photo::before { transform: rotate(35deg); }
.entry-card-photo::after  { transform: rotate(-35deg); }

.entry-card-photo svg {
  width: 22px;
  height: 22px;
  position: relative;
  z-index: 1;
}

.entry-card-photo span {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  position: relative;
  z-index: 1;
}

/* ── CARD BODY ── */
.entry-card-body {
  font-size: 13px;
  font-weight: 300;
  color: var(--ink-soft);
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── CARD LINK ── */
.entry-card-link {
  font-size: 12.5px;
  font-weight: 400;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.01em;
  border-bottom: 1px solid transparent;
  align-self: flex-start;
  transition: border-color 0.2s;
}

.entry-card-link:hover { border-bottom-color: var(--accent); }

/* ── CARD ACTIONS ── */
.entry-card-actions {
  display: flex;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--rule);
  margin-top: auto;
}

.btn-edit,
.btn-delete {
  font-family: var(--ff-body);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  border-radius: var(--radius);
  padding: 6px 18px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s;
}

.btn-edit {
  background: var(--cream);
  border: 1px solid var(--rule);
  color: var(--ink-soft);
}

.btn-edit:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  transform: translateY(-1px);
}

.btn-delete {
  background: transparent;
  border: 1px solid var(--accent-light);
  color: var(--accent);
}

.btn-delete:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transform: translateY(-1px);
}

/* ── FOOTER ── */
.footer {
  background: var(--cream);
  border-top: 1px solid var(--rule);
  text-align: center;
  padding: 16px 20px;
  font-size: 12px;
  font-weight: 300;
  letter-spacing: 0.08em;
  color: #8a7d68;
}

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  .main { padding: 24px 16px 48px; }
  .topbar, .navbar { padding: 0 16px; }
  .entries-grid { grid-template-columns: 1fr; }
  .search-bar { flex-wrap: wrap; justify-content: center; }
  .search-input-wrap { width: 100%; }
}