/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0d0f14;
  --bg2:      #13161e;
  --bg3:      #1a1e2a;
  --border:   #252a38;
  --accent:   #7c6af7;
  --accent2:  #e8a46a;
  --accent3:  #5ecec8;
  --text:     #e4e6f0;
  --text2:    #8890aa;
  --text3:    #555d78;
  --danger:   #e05c6e;
  --success:  #52c98b;
  --warn:     #f0b429;
  --font-head: 'Syne', sans-serif;
  --font-mono: 'DM Mono', monospace;
  --radius:   12px;
  --radius-sm: 7px;
  --shadow:   0 8px 32px rgba(0,0,0,.45);
}

html { font-size: 15px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  min-height: 100vh;
  padding-bottom: 60px;
}

/* grain overlay */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 999;
  opacity: .03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px;
}

/* ===== HEADER ===== */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 36px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(12px);
}
.logo {
  font-family: var(--font-head);
  font-size: 1.5rem; font-weight: 800; letter-spacing: -.5px;
}
.logo span { color: var(--accent); }
.header-meta {
  display: flex; align-items: center; gap: 12px;
  font-size: .75rem; color: var(--text2);
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text3);
  transition: background .4s;
}
.status-dot.connected { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.error { background: var(--danger); }

/* ===== REVISIONS BANNER ===== */
.revisions-banner {
  margin: 24px 36px 0;
  background: linear-gradient(135deg, rgba(124,106,247,.12), rgba(232,164,106,.08));
  border: 1px solid rgba(124,106,247,.25);
  border-radius: var(--radius);
  padding: 20px 24px;
}
.banner-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
}
.banner-header h2 {
  font-family: var(--font-head); font-size: 1.05rem; font-weight: 700;
}
.badge {
  background: var(--accent); color: #fff;
  font-family: var(--font-mono); font-size: .7rem; font-weight: 500;
  padding: 2px 9px; border-radius: 20px;
}

.revision-list {
  display: flex; flex-direction: column; gap: 10px;
}
.revision-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center; gap: 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  transition: border-color .2s;
}
.revision-item:hover { border-color: var(--accent); }
.rev-topic { font-family: var(--font-head); font-size: .9rem; font-weight: 600; }
.rev-meta { font-size: .7rem; color: var(--text2); margin-top: 2px; }
.rev-interval {
  font-size: .68rem; font-family: var(--font-mono);
  background: rgba(124,106,247,.15); color: var(--accent);
  padding: 3px 8px; border-radius: 4px; white-space: nowrap;
}
.rev-overdue {
  background: rgba(224,92,110,.15); color: var(--danger);
}
.btn-icon {
  width: 30px; height: 30px; border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent; color: var(--text2);
  font-size: .85rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .18s;
}
.btn-icon:hover { background: var(--bg3); color: var(--text); }
.btn-icon.done:hover { background: rgba(82,201,139,.15); color: var(--success); border-color: var(--success); }
.btn-icon.reschedule:hover { background: rgba(240,180,41,.12); color: var(--warn); border-color: var(--warn); }
.btn-icon.del:hover { background: rgba(224,92,110,.12); color: var(--danger); border-color: var(--danger); }

/* ===== MAIN LAYOUT ===== */
main {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  padding: 24px 36px;
  max-width: 1400px;
}

/* ===== CARDS ===== */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.card:last-child { margin-bottom: 0; }
.card-title {
  font-family: var(--font-head); font-size: 1rem; font-weight: 700;
  margin-bottom: 18px; color: var(--text);
}

/* ===== FORM ===== */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; font-size: .72rem; color: var(--text2);
  text-transform: uppercase; letter-spacing: .08em;
  margin-bottom: 6px;
}
.optional { text-transform: none; letter-spacing: 0; font-size: .68rem; color: var(--text3); }
input[type="text"], input[type="number"], input[type="date"], textarea {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); font-family: var(--font-mono); font-size: .85rem;
  padding: 10px 13px; border-radius: var(--radius-sm);
  outline: none; transition: border-color .2s;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }
.form-row { display: flex; gap: 12px; }
.form-group.half { flex: 1; }

/* interval chips */
.revision-intervals { margin-bottom: 18px; }
.interval-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 7px; }
.chip {
  font-size: .72rem; font-family: var(--font-mono);
  padding: 5px 10px; border-radius: 5px;
  border: 1px solid var(--border); color: var(--text3);
  cursor: pointer; user-select: none; transition: all .15s;
}
.chip.active {
  background: rgba(124,106,247,.15); border-color: var(--accent);
  color: var(--accent);
}

/* buttons */
.btn-primary {
  width: 100%; padding: 12px;
  background: var(--accent); color: #fff;
  font-family: var(--font-head); font-size: .9rem; font-weight: 700;
  border: none; border-radius: var(--radius-sm);
  cursor: pointer; transition: opacity .18s, transform .1s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary:hover { opacity: .88; }
.btn-primary:active { transform: scale(.98); }
.btn-secondary {
  padding: 10px 18px;
  background: var(--bg3); color: var(--text);
  font-family: var(--font-mono); font-size: .85rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: background .15s;
}
.btn-secondary:hover { background: var(--border); }

.hidden { display: none !important; }
.feedback {
  margin-top: 10px; font-size: .78rem; min-height: 18px;
  text-align: center;
}
.feedback.ok { color: var(--success); }
.feedback.err { color: var(--danger); }

/* ===== CALENDAR ===== */
.selected-day-header {
  padding: 12px;
  margin-bottom: 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
}


.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.cal-header h3 {
  font-family: var(--font-head); font-size: .95rem; font-weight: 700;
}
.cal-nav {
  background: transparent; border: 1px solid var(--border);
  color: var(--text2); width: 30px; height: 30px; border-radius: 6px;
  cursor: pointer; font-size: 1rem; transition: all .15s;
}
.cal-nav:hover { background: var(--bg3); color: var(--text); }
.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 3px; margin-bottom: 5px;
}
.cal-weekdays span {
  text-align: center; font-size: .65rem; color: var(--text3);
  text-transform: uppercase; letter-spacing: .05em;
}
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px;
}
.cal-day {
  aspect-ratio: 1; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-family: var(--font-mono);
  color: var(--text2); cursor: default; transition: background .15s;
  position: relative;
}
.cal-day.other-month { color: var(--text3); }
.cal-day.today { color: var(--accent); font-weight: 700; }
.cal-day.today::after {
  content: ''; position: absolute; bottom: 3px;
  width: 4px; height: 4px; border-radius: 50%; background: var(--accent);
}
.cal-day.has-study-1 { background: rgba(94,206,200,.15); color: var(--accent3); }
.cal-day.has-study-2 { background: rgba(94,206,200,.3); color: var(--accent3); }
.cal-day.has-study-3 { background: rgba(94,206,200,.55); color: #0d0f14; font-weight: 700; }
.cal-day.selected { outline: 2px solid var(--accent2); outline-offset: -2px; color: var(--accent2); font-weight: 700; }
.cal-legend {
  display: flex; align-items: center; gap: 8px; margin-top: 12px;
  font-size: .68rem; color: var(--text2);
}
.legend-dot { width: 10px; height: 10px; border-radius: 3px; }
.legend-dot.l1 { background: rgba(94,206,200,.25); }
.legend-dot.l2 { background: rgba(94,206,200,.45); }
.legend-dot.l3 { background: rgba(94,206,200,.7); }

/* ===== NOTES PANEL ===== */
.notes-card { height: fit-content; }
.notes-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; gap: 12px;
}
.notes-header .card-title { margin-bottom: 0; }
.search-wrap input {
  width: 200px; padding: 7px 12px; font-size: .8rem;
}

.notes-list { display: flex; flex-direction: column; gap: 12px; max-height: 72vh; overflow-y: auto; }
.notes-list::-webkit-scrollbar { width: 4px; }
.notes-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.note-card {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 15px;
  transition: border-color .2s;
  animation: slideIn .25s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.note-card:hover { border-color: rgba(124,106,247,.4); }
.note-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
}
.note-topic { font-family: var(--font-head); font-size: .95rem; font-weight: 700; }
.note-date { font-size: .68rem; color: var(--text3); white-space: nowrap; margin-top: 3px; }
.note-notes {
  font-size: .78rem; color: var(--text2); margin-top: 8px;
  line-height: 1.5;
}
.note-footer {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
  flex-wrap: wrap;
}
.interval-tag {
  font-size: .65rem; background: rgba(124,106,247,.1);
  border: 1px solid rgba(124,106,247,.2); color: var(--accent);
  padding: 2px 7px; border-radius: 4px;
}
.interval-tag.done-tag {
  background: rgba(82,201,139,.1); border-color: rgba(82,201,139,.2); color: var(--success);
}
.duration-tag {
  font-size: .65rem; color: var(--text3); margin-left: auto;
}
.note-delete {
  background: transparent; border: none; color: var(--text3);
  cursor: pointer; font-size: .8rem; padding: 2px 4px;
  border-radius: 4px; transition: color .15s;
}
.note-delete:hover { color: var(--danger); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; width: 360px;
  box-shadow: var(--shadow);
}
.modal h3 { font-family: var(--font-head); font-size: 1.1rem; margin-bottom: 6px; }
.modal p { font-size: .82rem; color: var(--accent2); margin-bottom: 18px; }
.modal label { font-size: .72rem; color: var(--text2); text-transform: uppercase; letter-spacing: .07em; display: block; margin-bottom: 6px; }
.modal input { margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ===== EMPTY STATE ===== */
.empty-state {
  font-size: .82rem; color: var(--text3); text-align: center;
  padding: 20px 0;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  main { grid-template-columns: 1fr; padding: 16px 18px; }
  header { padding: 14px 18px; }
  .revisions-banner { margin: 14px 18px 0; }
  .revision-item { grid-template-columns: 1fr auto; }
  .rev-interval, .rev-meta { display: none; }
}