@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,400;8..60,600;8..60,700&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --paper: #EFEBDF;
  --card: #FBF9F2;
  --ink: #21261F;
  --ink-soft: #5B5A4E;
  --line: #D9D3BE;
  --teal: #2B6A63;
  --teal-dark: #1F4F49;
  --ochre: #A9762E;
  --brick: #A23B2E;
  --idea: #A9762E;
  --progress: #2B6A63;
  --done: #4C7A3F;
  --shadow: 0 2px 10px rgba(33, 38, 31, 0.08);
  --radius: 3px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px);
  background-size: 100% 40px;
  background-attachment: fixed;
}

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* ---------- LOGIN ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
}
.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 48px 40px;
  width: 320px;
  text-align: center;
}
.login-mark {
  font-family: 'Source Serif 4', serif;
  font-size: 42px;
  font-weight: 700;
  color: var(--teal-dark);
}
.login-sub {
  color: var(--ink-soft);
  font-size: 13px;
  letter-spacing: 0.03em;
  margin-top: -4px;
  margin-bottom: 28px;
}
.login-card input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius);
  font-size: 14px;
}
.login-card button {
  width: 100%;
  padding: 10px;
  background: var(--teal-dark);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  margin-top: 6px;
}
.login-card button:hover { background: var(--teal); }
.login-error { color: var(--brick); font-size: 13px; min-height: 16px; margin-top: 10px; }
.link-btn {
  background: none;
  border: none;
  color: var(--teal-dark);
  font-size: 12.5px;
  text-decoration: underline;
  margin-top: 16px;
  cursor: pointer;
}

/* ---------- TOPBAR ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  font-family: 'Source Serif 4', serif;
  font-weight: 700;
  font-size: 22px;
  color: var(--teal-dark);
  flex-shrink: 0;
}
.brand-dot { color: var(--ochre); }
.search-wrap { flex: 1; max-width: 480px; }
.search-wrap input {
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  font-size: 14px;
}
.topbar-actions { display: flex; gap: 8px; margin-left: auto; }

.btn {
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 500;
}
.btn-primary { background: var(--teal-dark); color: #fff; }
.btn-primary:hover { background: var(--teal); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-soft); }
.btn-ghost:hover { background: var(--paper); }
.btn-text { background: none; border: none; color: var(--ink-soft); text-decoration: underline; padding: 4px; font-size: 13px; }
.btn-danger { background: none; border: 1px solid var(--brick); color: var(--brick); }
.btn-danger:hover { background: var(--brick); color: #fff; }
.btn-icon { background: none; border: none; font-size: 16px; color: var(--ink-soft); padding: 4px 8px; }

/* ---------- LAYOUT ---------- */
.layout { display: flex; max-width: 1200px; margin: 0 auto; }
.sidebar {
  width: 220px;
  flex-shrink: 0;
  padding: 24px 16px;
  border-right: 1px solid var(--line);
  min-height: calc(100vh - 61px);
}
.filter-group { margin-bottom: 24px; }
.filter-group h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin: 0 0 10px;
  font-weight: 600;
}
.filter-list { display: flex; flex-direction: column; gap: 6px; }
.filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  cursor: pointer;
  color: var(--ink);
}
.filter-item input { accent-color: var(--teal-dark); }
.tag-filter-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  background: #fff;
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-idea { background: var(--idea); }
.dot-progress { background: var(--progress); }
.dot-done { background: var(--done); }

.content { flex: 1; padding: 24px; min-width: 0; }
.entry-count { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 14px; font-family: 'IBM Plex Mono', monospace; }

/* ---------- ENTRY CARDS ---------- */
.entry-list { display: flex; flex-direction: column; gap: 12px; }
.entry-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--teal-dark);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.08s ease;
}
.entry-card:hover { transform: translateX(2px); }
.entry-card[data-status="idea"] { border-left-color: var(--idea); }
.entry-card[data-status="in_progress"] { border-left-color: var(--progress); }
.entry-card[data-status="done"] { border-left-color: var(--done); }

.entry-card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.entry-title {
  font-family: 'Source Serif 4', serif;
  font-weight: 600;
  font-size: 17px;
  margin: 0;
}
.entry-date {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--ink-soft);
  white-space: nowrap;
}
.entry-snippet {
  color: var(--ink-soft);
  font-size: 13.5px;
  margin: 6px 0 10px;
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.entry-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-family: 'IBM Plex Mono', monospace;
  background: var(--paper);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.tag-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(169, 118, 46, 0.12);
  color: var(--ochre);
  font-family: 'IBM Plex Mono', monospace;
}

.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-soft); }
.empty-mark { font-family: 'Source Serif 4', serif; font-size: 40px; color: var(--line); margin-bottom: 4px; }

/* ---------- MODAL ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(33, 38, 31, 0.5); }
.modal-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 560px;
  padding: 24px 28px 28px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.catalog-no { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--ink-soft); }

.title-input {
  width: 100%;
  font-family: 'Source Serif 4', serif;
  font-size: 20px;
  font-weight: 600;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 6px 0 10px;
  margin-bottom: 14px;
  background: transparent;
}
.title-input:focus { outline: none; border-bottom-color: var(--teal-dark); }

.field-row { display: flex; gap: 10px; margin-bottom: 12px; }
.field-row select {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  font-size: 13.5px;
}

#entryContent {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  margin-bottom: 12px;
}
#entryTags, #entrySource {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  font-size: 13.5px;
  margin-bottom: 10px;
}

.attachments-section { margin-top: 6px; padding-top: 12px; border-top: 1px dashed var(--line); }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 12px;
  cursor: pointer;
}
.checkbox-row input { accent-color: var(--teal-dark); }

.badge-owner {
  background: rgba(43, 106, 99, 0.12);
  color: var(--teal-dark);
  border-color: transparent;
}
.attachments-section h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); margin: 0 0 8px; }
.attachment-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.attachment-item { display: flex; align-items: center; justify-content: space-between; font-size: 13px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px; }
.attachment-item a { color: var(--teal-dark); text-decoration: none; }
.attachment-item a:hover { text-decoration: underline; }
.attachment-remove { background: none; border: none; color: var(--brick); font-size: 12px; }
.attachment-upload { display: flex; align-items: center; gap: 10px; }
.attachment-upload .hint { font-size: 11.5px; color: var(--ink-soft); }

.modal-footer { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.spacer { flex: 1; }

/* ---------- VIEW MODAL (lasāmais skats) ---------- */
.view-card { max-width: 620px; }
.view-title {
  font-family: 'Source Serif 4', serif;
  font-size: 24px;
  font-weight: 700;
  margin: 4px 0 12px;
  line-height: 1.3;
}
.view-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.view-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.view-content {
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink);
  white-space: pre-wrap;
  word-wrap: break-word;
  padding: 16px 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  max-height: 55vh;
  overflow-y: auto;
}
.view-source {
  font-size: 12.5px;
  color: var(--ink-soft);
  font-style: italic;
  margin-bottom: 14px;
}
.view-source::before { content: "Avots: "; font-style: normal; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--line); min-height: auto; display: flex; flex-wrap: wrap; gap: 20px; }
  .filter-group { margin-bottom: 0; flex: 1; min-width: 140px; }
  .topbar { flex-wrap: wrap; padding: 12px 16px; }
  .search-wrap { order: 3; max-width: none; width: 100%; }
  .content { padding: 16px; }
}
