/* ============================================================
   Console — dark SaaS dashboard
   Palette:  ink #0E1116  panel #161B22  raise #1C2430
             line #263040  text #E4E9F2  muted #8792A6
   Accent:   amber #F5A524 (signature)  teal #35C6B3 (secondary)
   Type:     Space Grotesk (display) · Inter (body) · JetBrains Mono (data)
   ============================================================ */

:root {
  --ink: #0e1116;
  --panel: #161b22;
  --raise: #1c2430;
  --raise-2: #222c3a;
  --line: #263040;
  --text: #e4e9f2;
  --muted: #8792a6;
  --amber: #f5a524;
  --amber-dim: #b9791a;
  --teal: #35c6b3;
  --red: #f2555a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

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

#app {
  display: grid;
  grid-template-columns: 232px 1fr;
  height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  gap: 8px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 20px;
}
.brand-mark { color: var(--amber); font-size: 18px; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.02em;
}
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 14.5px;
  font-weight: 500;
  text-align: left;
  transition: background 0.14s, color 0.14s;
}
.nav-item:hover { background: var(--raise); color: var(--text); }
.nav-item.active { background: var(--raise); color: var(--text); }
.nav-item.active .nav-icon { color: var(--amber); }
.nav-icon { font-size: 15px; width: 18px; text-align: center; color: var(--muted); }

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 12px;
  background: var(--raise);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
.user-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 3px rgba(53, 198, 179, 0.16);
  flex-shrink: 0;
}
.user-email {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Main / views ---------- */
.main { overflow-y: auto; padding: 30px 38px; }
.view { display: none; }
.view.active { display: block; animation: fade 0.22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.view-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 22px;
  gap: 20px;
}
.view-head h1 {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}
.view-sub { color: var(--muted); margin: 4px 0 0; font-size: 13.5px; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  font-size: 13.5px;
  font-weight: 600;
  transition: transform 0.08s, background 0.14s, border-color 0.14s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--amber); color: #1a1204; }
.btn-primary:hover { background: #ffb433; }
.btn-ghost { background: var(--raise); color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: var(--raise-2); }
.btn-danger-ghost { background: transparent; color: var(--red); border-color: transparent; }
.btn-danger-ghost:hover { background: rgba(242, 85, 90, 0.12); }

/* ---------- Tag filter ---------- */
.tag-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.tag-pill {
  padding: 6px 12px;
  border-radius: 100px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  transition: all 0.14s;
}
.tag-pill:hover { color: var(--text); border-color: var(--raise-2); }
.tag-pill.active { background: rgba(245, 165, 36, 0.14); border-color: var(--amber-dim); color: var(--amber); }
.tag-pill .count { opacity: 0.6; margin-left: 5px; font-family: var(--font-mono); font-size: 11px; }

/* ---------- Links grid ---------- */
.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.link-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.14s, transform 0.14s;
  position: relative;
}
.link-card:hover { border-color: var(--raise-2); transform: translateY(-2px); }
.link-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 15.5px;
  color: var(--text);
  text-decoration: none;
  line-height: 1.35;
  word-break: break-word;
}
.link-title:hover { color: var(--amber); }
.link-url {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.link-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.link-tag {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 100px;
  background: var(--raise);
  color: var(--teal);
  border: 1px solid rgba(53, 198, 179, 0.2);
}
.link-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 4px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
}
.link-by { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); }
.card-menu { display: flex; gap: 4px; }
.icon-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 13px;
  padding: 3px 6px;
  border-radius: 6px;
  transition: all 0.12s;
}
.icon-btn:hover { color: var(--text); background: var(--raise); }
.icon-btn.danger:hover { color: var(--red); background: rgba(242, 85, 90, 0.12); }

/* ---------- Empty state ---------- */
.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 48px;
  text-align: center;
  color: var(--muted);
}

/* ---------- Calendar ---------- */
.cal-controls { display: flex; align-items: center; gap: 8px; }
.cal-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  min-width: 150px;
  text-align: center;
}
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}
.cal-weekdays span {
  text-align: left;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(104px, 1fr);
  gap: 8px;
}
.cal-cell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s;
  overflow: hidden;
}
.cal-cell:hover { border-color: var(--raise-2); background: var(--raise); }
.cal-cell.other-month { opacity: 0.4; }
.cal-daynum { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); }
.cal-cell.today .cal-daynum {
  color: #1a1204;
  background: var(--amber);
  width: 22px; height: 22px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 600;
}
.cal-event {
  background: rgba(53, 198, 179, 0.14);
  border-left: 2px solid var(--teal);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 11.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-event .ev-time { font-family: var(--font-mono); font-size: 10px; color: var(--teal); margin-right: 4px; }
.cal-more { font-size: 10.5px; color: var(--muted); padding-left: 6px; }

/* ---------- Notes ---------- */
.notes-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 18px;
  height: calc(100vh - 150px);
}
.notes-list { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; padding-right: 4px; }
.note-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s;
}
.note-item:hover { border-color: var(--raise-2); }
.note-item.active { border-color: var(--amber-dim); background: var(--raise); }
.note-item-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 14.5px;
  margin: 0 0 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.note-item-preview { font-size: 12px; color: var(--muted); line-height: 1.4; max-height: 34px; overflow: hidden; }
.note-item-meta { font-family: var(--font-mono); font-size: 10px; color: var(--muted); margin-top: 7px; }

.notes-editor {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
}
.note-title {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  margin-bottom: 12px;
}
.note-title::placeholder { color: var(--muted); }
.rte-toolbar {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.rte-toolbar button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 13px;
  min-width: 30px;
  transition: all 0.12s;
}
.rte-toolbar button:hover { background: var(--raise); color: var(--text); }
.rte-sep { width: 1px; height: 18px; background: var(--line); margin: 0 5px; }
.rte-surface {
  flex: 1;
  overflow-y: auto;
  outline: none;
  line-height: 1.6;
  font-size: 15px;
}
.rte-surface:empty::before { content: "Start writing…"; color: var(--muted); }
.rte-surface h2 { font-family: var(--font-display); font-size: 18px; margin: 14px 0 8px; }
.rte-surface blockquote {
  border-left: 3px solid var(--amber-dim);
  margin: 10px 0;
  padding: 4px 0 4px 14px;
  color: var(--muted);
}
.rte-surface a { color: var(--teal); }
.rte-surface ul, .rte-surface ol { padding-left: 22px; }

.note-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.note-meta { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.note-actions { display: flex; align-items: center; gap: 12px; }
.save-state { font-size: 12px; color: var(--teal); min-width: 60px; text-align: right; }

.notes-empty { grid-column: 2; align-self: start; margin-top: 0; }

/* ---------- Modals ---------- */
/* hidden must win over the display rule below, or modals show without JS */
[hidden] { display: none !important; }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(6, 9, 13, 0.72);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  z-index: 50;
  animation: fade 0.15s ease;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: min(460px, 92vw);
  padding: 24px;
}
.modal h2 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  margin: 0 0 18px;
}
.modal label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 14px;
}
.modal input, .modal textarea {
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  font-weight: 400;
  outline: none;
  transition: border-color 0.14s;
}
.modal input:focus, .modal textarea:focus { border-color: var(--amber-dim); }
.modal textarea { resize: vertical; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}
.modal-actions .spacer { flex: 1; }

/* Date/time input calendar icon → visible on dark */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator { filter: invert(0.7); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--raise-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  box-shadow: var(--shadow);
  z-index: 60;
  animation: fade 0.2s ease;
}
.toast.error { border-color: var(--red); color: #ffd4d5; }

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--raise-2); border-radius: 6px; border: 2px solid var(--ink); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Focus visibility ---------- */
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  #app { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row;
    align-items: center;
    padding: 12px 14px;
    overflow-x: auto;
  }
  .brand { padding: 0 12px 0 4px; }
  .nav { flex-direction: row; flex: 1; }
  .nav-item { width: auto; }
  .user-chip { display: none; }
  .main { padding: 20px 16px; }
  .notes-layout { grid-template-columns: 1fr; height: auto; }
  .notes-editor { min-height: 60vh; }
  .cal-grid { grid-auto-rows: minmax(70px, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ============================================================
   Login screen (Firebase auth gate)
   ============================================================ */
.login-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(245, 165, 36, 0.10), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(53, 198, 179, 0.10), transparent 55%),
    var(--ink);
}
.login-card {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 40px 34px;
  text-align: center;
}
.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  margin-bottom: 14px;
}
.login-brand .brand-mark { font-size: 26px; }
.login-brand .brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 27px;
  letter-spacing: -0.02em;
}
.login-tagline {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 30px;
  line-height: 1.5;
}
.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--raise);
  color: var(--text);
  font-size: 14.5px;
  font-weight: 600;
  transition: background 0.14s, border-color 0.14s, transform 0.08s;
}
.google-btn:hover { background: var(--raise-2); border-color: var(--raise-2); }
.google-btn:active { transform: translateY(1px); }
.login-note {
  margin: 16px 0 0;
  font-size: 13px;
  color: var(--red);
  line-height: 1.45;
}
.login-fineprint {
  margin: 22px 0 0;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
  opacity: 0.7;
}

/* Sign-out button in the user chip */
.user-chip { position: relative; }
.signout-btn {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 5px;
  transition: color 0.12s, background 0.12s;
}
.signout-btn:hover { color: var(--red); background: rgba(242, 85, 90, 0.12); }
