/* ECU Notebook — Zoho-style notebook UI */
:root {
  --green: #1a9e5c;
  --green-dark: #147a46;
  --ink: #202124;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f4f6f5;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px;
}
#app { min-height: 100%; }

/* ---------- Auth screens ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(135deg, #e8f7ee, #f4f6f5); }
.auth-card { background: #fff; border-radius: 16px; box-shadow: 0 8px 30px rgba(0,0,0,.08); padding: 32px 28px; width: 100%; max-width: 380px; }
.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.auth-card p.sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.auth-card label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.auth-card input { width: 100%; padding: 12px; font-size: 16px; border: 1px solid var(--line); border-radius: 10px; outline: none; }
.auth-card input:focus { border-color: var(--green); }
.btn { display: block; width: 100%; margin-top: 20px; padding: 13px; border: 0; border-radius: 10px; background: var(--green); color: #fff; font-size: 16px; font-weight: 600; cursor: pointer; }
.btn:active { background: var(--green-dark); }
.btn.ghost { background: #eef2f0; color: var(--ink); }
.auth-err { color: #c0392b; font-size: 14px; margin-top: 12px; min-height: 20px; }
.auth-logo { width: 52px; height: 52px; border-radius: 14px; background: var(--green); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 700; margin-bottom: 14px; }

/* ---------- Header ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; padding: 10px 12px; }
.icon-btn { border: 0; background: none; font-size: 22px; width: 42px; height: 42px; border-radius: 50%; cursor: pointer; color: var(--ink); display: flex; align-items: center; justify-content: center; }
.icon-btn:active { background: #eef2f0; }
.topbar .title { font-size: 19px; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.searchbar { display: flex; align-items: center; gap: 8px; background: #eef2f0; border-radius: 24px; padding: 9px 14px; margin: 12px 12px 4px; }
.searchbar input { border: 0; background: none; outline: none; font-size: 15px; flex: 1; }

/* ---------- Drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; left: 0; bottom: 0; width: 290px; background: #fff; z-index: 41; transform: translateX(-105%); transition: transform .22s ease; display: flex; flex-direction: column; box-shadow: 4px 0 24px rgba(0,0,0,.12); }
.drawer.open { transform: none; }
.drawer .dhead { padding: 20px 18px 12px; border-bottom: 1px solid var(--line); }
.drawer .dhead .who { font-weight: 700; font-size: 16px; }
.drawer .dhead .role { color: var(--muted); font-size: 13px; }
.ditem { display: flex; align-items: center; gap: 14px; padding: 13px 18px; font-size: 15px; cursor: pointer; border: 0; background: none; width: 100%; text-align: left; color: var(--ink); }
.ditem:active, .ditem.active { background: #e8f7ee; }
.ditem .di { font-size: 20px; width: 26px; text-align: center; }
.drawer .dfoot { margin-top: auto; border-top: 1px solid var(--line); }

/* ---------- Notes grid ---------- */
.notes-grid { column-count: 2; column-gap: 10px; padding: 10px 12px 90px; }
@media (min-width: 700px) { .notes-grid { column-count: 3; max-width: 1000px; margin: 0 auto; } }
@media (min-width: 1100px) { .notes-grid { column-count: 4; max-width: 1300px; } }
.ncard { break-inside: avoid; border-radius: 12px; padding: 14px; margin: 0 0 10px; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.08); border: 1px solid rgba(0,0,0,.04); }
.ncard img.thumb { width: 100%; border-radius: 8px; margin-bottom: 8px; display: block; }
.ncard .nt { font-weight: 700; font-size: 15px; margin-bottom: 4px; word-break: break-word; }
.ncard .nb { color: #4b5563; font-size: 13.5px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; white-space: pre-wrap; }
.ncard .nd { color: var(--muted); font-size: 12px; margin-top: 8px; }
.ncard .pcount { display: inline-block; background: rgba(0,0,0,.08); border-radius: 10px; font-size: 11px; padding: 2px 8px; margin-top: 6px; color: #374151; }
.c0 { background: #ffffff; } .c1 { background: #fef9c3; } .c2 { background: #fce7f3; }
.c3 { background: #d1fae5; } .c4 { background: #dbeafe; } .c5 { background: #ffedd5; } .c6 { background: #ede9fe; }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; font-size: 15px; }

/* ---------- Notebook covers ---------- */
.nb-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 14px 12px 90px; }
@media (min-width: 700px) { .nb-grid { grid-template-columns: repeat(3, 1fr); max-width: 1000px; margin: 0 auto; } }
.nb-card { border-radius: 14px; overflow: hidden; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.1); background: #fff; }
.nb-cover { height: 110px; display: flex; align-items: flex-end; padding: 10px; color: #fff; font-weight: 700; font-size: 16px; text-shadow: 0 1px 4px rgba(0,0,0,.35); }
.g0 { background: linear-gradient(135deg, #34d399, #059669); } .g1 { background: linear-gradient(135deg, #60a5fa, #2563eb); }
.g2 { background: linear-gradient(135deg, #fbbf24, #d97706); } .g3 { background: linear-gradient(135deg, #f472b6, #db2777); }
.g4 { background: linear-gradient(135deg, #a78bfa, #7c3aed); } .g5 { background: linear-gradient(135deg, #64748b, #334155); }
.nb-meta { padding: 10px 12px; font-size: 13px; color: var(--muted); }

/* ---------- FAB ---------- */
.fab { position: fixed; right: 20px; bottom: 24px; width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--green); color: #fff; font-size: 34px; line-height: 1; cursor: pointer; box-shadow: 0 6px 18px rgba(26,158,92,.4); z-index: 30; }
.fab:active { background: var(--green-dark); }

/* ---------- Editor ---------- */
.editor-wrap { position: fixed; inset: 0; z-index: 50; background: #fff; display: flex; flex-direction: column; }
.ed-bar { display: flex; align-items: center; gap: 4px; padding: 8px 8px; border-bottom: 1px solid var(--line); background: #fff; }
.ed-bar .sp { flex: 1; }
.ed-title { border: 0; outline: none; font-size: 21px; font-weight: 700; padding: 16px 18px 6px; width: 100%; font-family: inherit; }
.ed-body { border: 0; outline: none; font-size: 16px; line-height: 1.6; padding: 6px 18px 20px; width: 100%; flex: 1; resize: none; font-family: inherit; }
.ed-photos { display: flex; gap: 8px; padding: 8px 18px; overflow-x: auto; }
.ed-photos .ph { position: relative; flex: 0 0 auto; }
.ed-photos img { width: 92px; height: 92px; object-fit: cover; border-radius: 10px; }
.ed-photos .rm { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: #111827; color: #fff; font-size: 14px; cursor: pointer; }
.ph-add { width: 92px; height: 92px; flex: 0 0 auto; border-radius: 10px; border: 2px dashed #cbd5e1; background: #f8fafc; color: var(--muted); font-size: 30px; cursor: pointer; }
.ed-colors { display: flex; gap: 10px; padding: 10px 18px; }
.dot { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.dot.sel { border-color: var(--ink); }
.ed-meta { padding: 4px 18px 18px; color: var(--muted); font-size: 12px; }

/* ---------- Users ---------- */
.urow { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 12px; padding: 14px; margin: 10px 12px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.urow .un { font-weight: 600; flex: 1; }
.urow .rl { font-size: 12px; color: var(--muted); background: #eef2f0; padding: 3px 10px; border-radius: 12px; }
.urow .del { border: 0; background: #fee2e2; color: #b91c1c; border-radius: 8px; padding: 8px 12px; cursor: pointer; font-size: 13px; }
.form-card { background: #fff; border-radius: 12px; padding: 16px; margin: 10px 12px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.form-card h3 { margin: 0 0 10px; font-size: 16px; }
.form-card input { width: 100%; padding: 11px; font-size: 15px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; outline: none; }
.form-card .btn { margin-top: 6px; }
.sect { padding: 18px 12px 4px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); background: #111827; color: #fff; padding: 12px 20px; border-radius: 24px; font-size: 14px; z-index: 99; opacity: 0; transition: opacity .25s; pointer-events: none; }
.toast.show { opacity: 1; }
.rcode { font-family: ui-monospace, monospace; font-size: 22px; font-weight: 700; letter-spacing: 2px; text-align: center; background: #f0fdf4; border: 2px dashed var(--green); border-radius: 12px; padding: 16px 8px; margin: 14px 0; color: var(--ink); }
.flink { text-align: center; margin-top: 14px; font-size: 14px; }
.flink a { color: var(--green-dark); }
.urow .pwreset { border: 0; background: #e0f2fe; color: #0369a1; border-radius: 8px; padding: 8px 12px; cursor: pointer; font-size: 13px; }
.uemail { font-size: 12px; color: var(--muted); margin-top: 2px; }
