/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f4f5f7;
  --surface:   #ffffff;
  --border:    #e1e4e8;
  --accent:    #2563eb;
  --accent-dk: #1d4ed8;
  --text:      #1a1d23;
  --muted:     #6b7280;
  --badge-bg:  #dbeafe;
  --badge-txt: #1e40af;
  --error:     #dc2626;
  --radius:    10px;
  --shadow:    0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
}

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.hidden { display: none !important; }

/* ── Login ────────────────────────────────────────────────── */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
}

.login-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-logo {
  font-size: 3rem;
  margin-bottom: 1rem;
  line-height: 1;
}

#login-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .35rem;
}

.login-subtitle {
  color: var(--muted);
  font-size: .9rem;
  margin-bottom: 2rem;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.login-form input {
  padding: .75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  outline: none;
  transition: border-color .15s;
}

.login-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

.login-form button {
  padding: .75rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
}

.login-form button:hover  { background: var(--accent-dk); }
.login-form button:active { transform: scale(.98); }

.error {
  margin-top: .75rem;
  color: var(--error);
  font-size: .875rem;
}

/* ── App Shell ────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ───────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem 1.5rem .75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: .6rem;
}

.header-icon { font-size: 1.4rem; }

#app-title {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -.01em;
}

#logout-btn {
  padding: .4rem .9rem;
  font-size: .85rem;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

#logout-btn:hover { color: var(--text); border-color: #9ca3af; }

nav {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  gap: .25rem;
}

.tab-btn {
  padding: .5rem 1.1rem;
  font-size: .9rem;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: none;
  border-bottom: 2.5px solid transparent;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.tab-btn:hover  { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Main ─────────────────────────────────────────────────── */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  flex: 1;
  width: 100%;
}

.section-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.25rem;
}

.section-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

.badge {
  background: var(--badge-bg);
  color: var(--badge-txt);
  font-size: .75rem;
  font-weight: 600;
  padding: .2rem .55rem;
  border-radius: 999px;
}

/* ── Filter Bar ───────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin-bottom: 1.25rem;
  align-items: center;
}

.filter-bar input[type="search"] {
  flex: 1;
  min-width: 180px;
  padding: .5rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  outline: none;
  transition: border-color .15s;
  background: var(--surface);
}

.filter-bar input[type="search"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.filter-bar select {
  padding: .5rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
  cursor: pointer;
  transition: border-color .15s;
}

.filter-bar select:focus { border-color: var(--accent); }

.clear-btn {
  padding: .5rem .9rem;
  font-size: .875rem;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.clear-btn:hover { color: var(--error); border-color: var(--error); }

.no-results {
  text-align: center;
  color: var(--muted);
  padding: 2.5rem 0;
  font-size: .95rem;
}

/* ── Paper Cards ──────────────────────────────────────────── */
#papers-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.paper-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
  transition: box-shadow .15s;
}

.paper-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.1); }

.paper-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.paper-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  flex: 1;
}

.paper-tag {
  font-size: .72rem;
  font-weight: 600;
  padding: .2rem .6rem;
  border-radius: 999px;
  white-space: nowrap;
  background: #f0fdf4;
  color: #166534;
}

.paper-tag.review    { background: #fef3c7; color: #92400e; }
.paper-tag.todo      { background: #fee2e2; color: #991b1b; }
.paper-tag.reading   { background: #ede9fe; color: #4c1d95; }
.paper-tag.done      { background: #f0fdf4; color: #166534; }

.paper-authors {
  margin-top: .35rem;
  font-size: .875rem;
  color: var(--muted);
}

.paper-meta-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-top: .4rem;
  flex-wrap: wrap;
}

.paper-venue {
  font-size: .8rem;
  font-style: italic;
  color: var(--muted);
}

.paper-subject-tag {
  font-size: .72rem;
  font-weight: 600;
  padding: .18rem .55rem;
  border-radius: 999px;
  background: #f0f9ff;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.paper-links {
  margin-top: .85rem;
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
}

.paper-link {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .82rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  padding: .3rem .7rem;
  border: 1.5px solid #bfdbfe;
  border-radius: 6px;
  transition: background .12s, border-color .12s;
}

.paper-link:hover { background: #eff6ff; border-color: var(--accent); }

.paper-notes {
  margin-top: .85rem;
  font-size: .875rem;
  color: var(--muted);
  border-left: 3px solid #bfdbfe;
  padding-left: .75rem;
  line-height: 1.5;
}

/* ── Schedule ─────────────────────────────────────────────── */
#schedule-list {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.schedule-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  box-shadow: var(--shadow);
}

.schedule-date {
  min-width: 3.5rem;
  text-align: center;
  background: var(--bg);
  border-radius: 8px;
  padding: .5rem .4rem;
  line-height: 1.2;
}

.schedule-date .day   { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.schedule-date .month { font-size: .7rem;  font-weight: 600; color: var(--muted); text-transform: uppercase; }

.schedule-body { flex: 1; }

.schedule-title {
  font-size: .95rem;
  font-weight: 600;
}

.schedule-meta {
  margin-top: .25rem;
  font-size: .82rem;
  color: var(--muted);
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.schedule-desc {
  margin-top: .5rem;
  font-size: .875rem;
  color: var(--muted);
}

/* ── Section desc ────────────────────────────────────────── */
.section-desc {
  color: var(--muted);
  font-size: .875rem;
  margin-bottom: 1.25rem;
  max-width: 540px;
}

/* ── Add button ───────────────────────────────────────────── */
.add-btn {
  margin-left: auto;
  padding: .45rem 1rem;
  font-size: .875rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.add-btn:hover { background: var(--accent-dk); }

/* ── Delete button ────────────────────────────────────────── */
.delete-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: .8rem;
  cursor: pointer;
  padding: .25rem .5rem;
  border-radius: 5px;
  transition: color .12s, background .12s;
  white-space: nowrap;
}
.delete-btn:hover { color: var(--error); background: #fee2e2; }

.paper-top-right {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}

/* ── Members ──────────────────────────────────────────────── */
.add-member-form {
  display: flex;
  gap: .6rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.add-member-form input[type="email"] {
  flex: 1;
  min-width: 220px;
  padding: .55rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  outline: none;
  transition: border-color .15s;
}

.add-member-form input[type="email"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

#members-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.member-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  font-size: .9rem;
}

.member-email { color: var(--text); }

/* ── Modals ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.1rem;
  color: var(--muted);
  cursor: pointer;
  padding: .25rem .4rem;
  border-radius: 5px;
  transition: color .12s, background .12s;
}
.modal-close:hover { color: var(--text); background: var(--bg); }

/* ── Form rows ────────────────────────────────────────────── */
#upload-form, #event-form {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.form-row label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text);
}

.req { color: var(--error); }

.form-row input,
.form-row select,
.form-row textarea {
  padding: .55rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
  color: var(--text);
  background: var(--surface);
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.form-row textarea { resize: vertical; }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  flex-direction: unset;
}

.two-col > div {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.two-col label {
  font-size: .82rem;
  font-weight: 600;
}

/* ── Upload progress ──────────────────────────────────────── */
.upload-progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width .2s;
}

/* ── Modal actions ────────────────────────────────────────── */
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: .6rem;
  padding-top: .25rem;
}

.btn-primary {
  padding: .55rem 1.25rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover    { background: var(--accent-dk); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.btn-secondary {
  padding: .55rem 1.1rem;
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.btn-secondary:hover { color: var(--text); border-color: #9ca3af; }

/* ── Blog ─────────────────────────────────────────────────── */
#blog-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.post-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem .75rem;
}

.post-title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
}

.post-meta {
  margin-top: .25rem;
  font-size: .8rem;
  color: var(--muted);
}

.post-content {
  padding: 0 1.5rem 1.25rem;
  font-size: .9rem;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
}

/* ── Comments ─────────────────────────────────────────────── */
.comments-section {
  border-top: 1px solid var(--border);
  background: #fafbfc;
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: .6rem;
}

.comments-loading {
  font-size: .82rem;
  color: var(--muted);
}

.no-comments {
  font-size: .82rem;
  color: var(--muted);
}

.comment-item {
  display: flex;
  flex-direction: column;
  gap: .2rem;
}

.comment-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .6rem .85rem;
  font-size: .875rem;
  line-height: 1.55;
  color: var(--text);
}

.comment-meta {
  font-size: .75rem;
  color: var(--muted);
  padding-left: .2rem;
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding-top: .25rem;
  border-top: 1px solid var(--border);
}

.comment-author {
  padding: .45rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  outline: none;
  transition: border-color .15s;
}

.comment-content {
  padding: .45rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  font-family: inherit;
  resize: vertical;
  outline: none;
  transition: border-color .15s;
}

.comment-author:focus,
.comment-content:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.comment-form .btn-primary {
  align-self: flex-end;
  padding: .4rem 1rem;
  font-size: .85rem;
}

/* ── Footer ───────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 1.5rem;
  font-size: .8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: auto;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
  .header-inner, nav, main { padding-left: 1rem; padding-right: 1rem; }
  .paper-card { padding: 1rem; }
  .schedule-item { flex-direction: column; gap: .5rem; }
}
