/* ===== GLOBAL ===== */
 :root {
  --accent-1: #0d6f3a;
  --accent-2: #16a34a;
  --muted: #e8f8ef;
  --card: #ffffff;
  --glass: rgba(255,255,255,0.6);
  --text: #0b2b18;
  --muted-text: #3f5746;
  --radius: 12px;
}

@media (prefers-reduced-motion: no-preference) {
  :root {
    --accent-1: #0d6f3a; /* deep green */
    --accent-2: #16a34a; /* vibrant green */
    --muted: #e8f8ef;    /* pale green */
    --card: #ffffff;
    --glass: rgba(255,255,255,0.6);
    --text: #0b2b18;
    --muted-text: #3f5746;
    --radius: 12px;
  }
}

body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  background: linear-gradient(180deg, #eef9f0 0%, #f6fbf7 60%);
  color: var(--text);
  padding: 24px;
  margin: 0;
  -webkit-font-smoothing:antialiased;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.left-rail {
  position: sticky;
  top: 16px;
  align-self: start;
  background: linear-gradient(180deg, var(--card), var(--glass));
  border: 1px solid rgba(10,60,35,0.04);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(6,78,44,0.06);
  padding: 18px;
}

.main-content {
  min-width: 0;
}

/* centered site container */
#header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

#logo {
  width: 100%;
  max-width: 248px;
  height: auto;
  display: block;
  object-fit: contain;
}

#logo img {
  max-width: 58px;
  max-height: 58px;
}

#header h1 {
  font-size: 1.55rem;
  margin: 0;
  color: var(--accent-1);
  letter-spacing: -0.02em;
}

.how-block {
  margin: 10px 0 14px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f7fff7;
  border: 1px solid rgba(16,97,51,0.08);
}

.how-block h3 {
  margin: 0 0 6px 0;
  font-size: 0.95rem;
}

.how-block p {
  margin: 0;
  color: var(--muted-text);
  font-size: 0.9rem;
  line-height: 1.4;
}

.main-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.main-nav a {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--accent-1);
  font-weight: 600;
  background: rgba(255,255,255,0.8);
  border: 1px solid rgba(16,97,51,0.08);
}

.main-nav button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--accent-1);
  font-weight: 600;
  background: rgba(255,255,255,0.8);
  border: 1px solid rgba(16,97,51,0.08);
  box-shadow: none;
}

.main-nav a:hover {
  background: #f2fbf3;
}

.main-nav button:hover {
  background: #f2fbf3;
}

.menu-search {
  margin-top: 8px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(16,97,51,0.08);
  background: rgba(255,255,255,0.8);
}

.menu-search label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted-text);
}

.menu-search-row {
  display: flex;
  gap: 8px;
}

.menu-search-row input {
  width: 100%;
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid rgba(10,60,35,0.08);
}

.menu-search-row button {
  min-width: 44px;
  padding: 10px 12px;
}

#intro {
  text-align: center;
  color: var(--muted-text);
  margin: 18px auto 30px auto;
  font-size: 1rem;
  max-width: 900px;
}

/* ===== TOP BAR ===== */
#topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: none;
  background: transparent;
  padding: 8px 0;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  font-size: 0.95em;
  transition: opacity 180ms ease, transform 180ms ease;
}

#topbar.topbar-hidden {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}

#topbar #session {
  margin: 0;
  color: var(--muted-text);
  background: transparent;
  padding: 0;
  border-radius: 999px;
  box-shadow: none;
}

#topbar #session:empty {
  display: none;
}

.hidden { display: none; }

/* ===== MAIN PANELS ===== */
#login, #projects, #editor {
  background: linear-gradient(180deg, var(--card), var(--glass));
  padding: 28px;
  max-width: 980px;
  margin: 20px auto;
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(6,78,44,0.06);
  border: 1px solid rgba(10,60,35,0.04);
}

h1 { text-align:center; font-weight:700; color:var(--accent-1); }
h2, h3 { color: var(--accent-1); }

/* session */
#session { text-align:center; margin-bottom: 12px; font-weight:600; color:var(--muted-text); }

/* ===== PROJECT LIST ===== */
#projectsLayout { display: flex; align-items: flex-start; gap: 16px; }
#projectsMain { flex: 1; min-width: 0; }

#userMenuColumn {
  width: 240px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(16,97,51,0.06);
  background: linear-gradient(180deg,#ffffff,#f7fff7);
}

.user-menu-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-decoration: none;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--accent-1);
  font-weight: 600;
  background: #ffffff;
  border: 1px solid rgba(16,97,51,0.08);
  box-shadow: none;
  width: 100%;
  margin-right: 0;
  min-width: 0;
  min-height: 38px;
  padding: 8px 10px;
}

.count-chip {
  display: inline-block;
  min-width: 42px;
  text-align: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #0d6f3a;
  background: rgba(13, 111, 58, 0.14);
}

.project {
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 14px;
  cursor: pointer;
  background: linear-gradient(180deg,#ffffff,#f7fff7);
  border: 1px solid rgba(16,97,51,0.06);
  display: block;
}

.project:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(10,80,40,0.06);
}

.project-title { font-weight:700; font-size:1.05rem; color:var(--accent-1); margin-bottom:6px; }
.project-title-row { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:6px; }
.project-title-row .project-title { margin-bottom:0; }
.project-top-right { display:flex; align-items:center; gap:8px; }
.project-created { font-size:0.8rem; color:#6a7f6e; white-space:nowrap; }
.project-pending-count {
  display:inline-block;
  padding:2px 8px;
  border-radius:999px;
  font-size:0.75rem;
  font-weight:700;
  color:#0d6f3a;
  background:rgba(13, 111, 58, 0.14);
  white-space:nowrap;
}
.project-preview { color: var(--muted-text); margin:8px 0; }
.project-preview.empty { color:#8aa88f; font-style:italic; }
.project-meta { font-size:0.9rem; color: #556a58; }
.project-body {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 12px;
  align-items: start;
}
.project-cover {
  width: 100%;
  min-height: 120px;
  border-radius: 10px;
  border: 1px solid rgba(10,60,35,0.08);
  background: #f4faf4;
  overflow: hidden;
}
.project-cover-image {
  width: 100%;
  height: 100%;
  max-height: 170px;
  object-fit: cover;
  display: block;
}
.project-cover-empty {
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #7e9784;
  font-size: 0.86rem;
}
.project-content {
  min-width: 0;
}
.project-content .project-preview {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
}
.project-like-row { margin-top: 8px; display: flex; align-items: center; }
.project-like-btn { min-width: 64px; margin-right: 0; padding: 8px 12px; }

.project-actions { position: relative; }
.project-menu-trigger {
  min-width: 36px;
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 0;
}

.project-action-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 190px;
  z-index: 30;
  background: #fff;
  border: 1px solid rgba(10,60,35,0.1);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(6,78,44,0.16);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.project-action-menu.hidden {
  display: none;
}

.project-action-menu button {
  width: 100%;
  text-align: left;
  margin-right: 0;
  min-width: 0;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(10,60,35,0.06);
  background: #fff;
  color: #264632;
  box-shadow: none;
}

.project-action-menu button.danger {
  color: #9d1c1c;
  border-color: rgba(157, 28, 28, 0.22);
}

/* owner controls inside project */
.owner-controls { margin-top:10px; display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.owner-controls input { padding:6px 8px; border-radius:8px; border:1px solid rgba(0,0,0,0.06); }

#invitationsPanel {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(16,97,51,0.06);
  background: linear-gradient(180deg,#ffffff,#f7fff7);
}

#followPanel {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(16,97,51,0.06);
  background: linear-gradient(180deg,#ffffff,#f7fff7);
}

.invitation-item {
  border: 1px solid rgba(16,97,51,0.06);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
}

.invitation-title { font-weight: 700; color: var(--accent-1); margin-bottom: 4px; }
.invitation-meta { font-size: 0.9rem; color: #556a58; margin-bottom: 4px; }
.invitation-actions { display: flex; gap: 8px; margin-top: 6px; }
.invitation-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.invitation-badge.admin {
  background: rgba(13, 111, 58, 0.14);
  color: #0d6f3a;
}
.invitation-badge.user {
  background: rgba(63, 87, 70, 0.14);
  color: #3f5746;
}

/* ===== EDITOR ===== */
#projectTitle { font-size:1.4rem; margin-bottom:8px; color:var(--accent-1); }
.editor-meta {
  margin-top: 8px;
  font-size: 0.82rem;
  color: #6a7f6e;
}

#projectFilters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

#projectFilters label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

#projectFilters input[type="radio"] {
  margin: 0;
}

.projects-separator {
  border: 0;
  border-top: 1px solid rgba(10,60,35,0.1);
  margin: 6px 0 10px;
}

/* ===== TEXT AREAS ===== */
textarea { width:100%; height:220px; box-sizing:border-box; font-size:1rem; line-height:1.6; padding:12px; border-radius:10px; border:1px solid rgba(10,60,35,0.08); background:#fcfff9; }
textarea[readonly] { background:#f3f8f3; color:var(--muted-text); }

/* ===== BUTTONS ===== */
.buttons { margin-top:14px; }
button { margin-right:8px; padding:10px 16px; min-width:86px; cursor:pointer; border-radius:10px; border:none; background:var(--accent-2); color:white; font-weight:600; box-shadow:0 8px 18px rgba(15,120,65,0.12); }
button:hover { filter:brightness(0.98); transform:translateY(-1px); }

input, select, button, textarea, .user-menu-link, .main-nav a, .main-nav button {
  min-height: 44px;
  box-sizing: border-box;
}

/* subtle secondary buttons */
button.secondary { background: #ffffff; color: var(--accent-1); border:1px solid rgba(10,60,35,0.08); box-shadow:none; }

/* admin panel */
#adminPanel { margin-top:22px; padding-top:16px; border-top:1px dashed rgba(10,60,35,0.06); }

/* footer */
footer { text-align:center; margin-top:36px; font-size:0.9em; color:var(--muted-text); }
footer a { color:var(--muted-text); text-decoration:none; }
footer a:hover { text-decoration:underline; }

/* Responsive tweaks */
@media (max-width:768px) {
  body { padding:12px; }
  .app-shell { grid-template-columns: 1fr; gap: 12px; }
  .left-rail {
    position: static;
    padding: 12px;
  }
  .main-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .main-nav a,
  .main-nav button {
    flex: 1 1 calc(50% - 8px);
    text-align: center;
  }
  .menu-search {
    width: 100%;
  }
  #logo { width:56px; height:56px; }
  #login,#projects,#editor { padding:16px; margin:10px 0; }
  #topbar {
    position: sticky;
    top: 0;
    margin-bottom: 6px;
  }
  #topbar.topbar-hidden {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
  #projectsLayout { flex-direction: column; }
  #userMenuColumn,
  #invitationsPanel { width: 100%; }
  .project-body {
    grid-template-columns: 1fr;
  }
  .project-cover-image {
    max-height: 220px;
  }
  .project-content .project-preview {
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
  }
}

/* ===== NOTIFICATIONS ===== */
#calobo-notification { display: flex; flex-direction: column; gap: 10px; }
.calobo-notice {
  min-width: 260px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 10px;
  color: white;
  box-shadow: 0 10px 24px rgba(6,78,44,0.12);
  transform: translateY(12px);
  opacity: 0;
  transition: transform 220ms ease, opacity 220ms ease;
  font-weight: 600;
  font-size: 0.95rem;
}
.calobo-notice.show { transform: translateY(0); opacity: 1; }
.calobo-notice.info { background: linear-gradient(90deg, #16a34a, #0d6f3a); }
.calobo-notice.success { background: linear-gradient(90deg, #2ecc71, #16a34a); }
.calobo-notice.warning { background: linear-gradient(90deg, #f59e0b, #d97706); }
.calobo-notice.error { background: linear-gradient(90deg, #ef4444, #c0262a); }
.calobo-notice small { display:block; font-weight:400; opacity:0.9; font-size:0.85rem; }

/* Dialogs (confirm / prompt) */
.calobo-dialog {
  width: min(520px, calc(100vw - 32px));
  min-width: 0;
  padding: 14px;
  border-radius: 10px;
  background: white;
  color: var(--text);
  box-shadow: 0 14px 40px rgba(6,78,44,0.14);
  font-weight: 600;
}
.calobo-dialog .cd-body { margin-bottom: 12px; font-weight:600; }
.calobo-dialog .cd-input { width:100%; padding:8px 10px; border-radius:8px; border:1px solid rgba(10,60,35,0.08); margin-bottom:10px; }
.calobo-dialog .cd-actions { display:flex; gap:8px; justify-content:flex-end; }
.calobo-dialog .cd-actions button { padding:8px 12px; min-width:72px; font-weight:600; border-radius:8px; }
.calobo-dialog .cd-actions .secondary { background:#f3f5f3; color:var(--text); border:1px solid rgba(10,60,35,0.06); }
.calobo-overlay {
  position: fixed;
  right: 16px;
  left: 16px;
  bottom: 16px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

/* Pagination */
#pagination { margin-top: 12px; }
#pagination button { padding: 6px 10px; border-radius: 8px; border: 1px solid rgba(10,60,35,0.06); background: white; color: var(--accent-1); font-weight:700; cursor:pointer; }
#pagination button:disabled { opacity: 0.45; cursor: default; }
