:root {
  --bg: #08111f;
  --bg2: #0d1726;
  --card: rgba(15, 23, 42, .82);
  --card2: rgba(30, 41, 59, .68);
  --line: rgba(148, 163, 184, .18);
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #7c3aed;
  --accent2: #4f46e5;
  --danger: #ef4444;
  --success: #10b981;
  --shadow: 0 24px 70px rgba(0,0,0,.35);
}

body.light {
  --bg: #f5f7fb;
  --bg2: #ffffff;
  --card: rgba(255,255,255,.88);
  --card2: rgba(241,245,249,.9);
  --line: rgba(15,23,42,.13);
  --text: #0f172a;
  --muted: #64748b;
  --shadow: 0 24px 70px rgba(15,23,42,.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 0%, rgba(124,58,237,.22), transparent 28%),
    radial-gradient(circle at 90% 0%, rgba(59,130,246,.15), transparent 30%),
    var(--bg);
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.auth-card {
  width: min(480px, 100%);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 30px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -1px;
}

.auth-brand { margin-bottom: 22px; }

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 14px 34px rgba(124,58,237,.45);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 22px;
  background: rgba(2,6,23,.22);
}

.auth-tabs button {
  border: 0;
  border-radius: 10px;
  padding: 12px;
  color: var(--muted);
  background: transparent;
  font-weight: 850;
}

.auth-tabs button.active {
  color: var(--text);
  background: var(--card2);
}

.auth-card h1 { margin: 0 0 8px; }
.auth-card p, .hint { color: var(--muted); line-height: 1.5; }

form { display: grid; gap: 14px; }

label {
  display: grid;
  gap: 8px;
  font-weight: 750;
}

input, textarea, select {
  width: 100%;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 13px 14px;
  outline: none;
  background: var(--card2);
}

textarea { min-height: 110px; resize: vertical; }

.auth-message {
  min-height: 24px;
  margin-top: 16px;
  color: #fca5a5;
  font-weight: 700;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 282px 1fr;
}

.sidebar {
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: rgba(8,17,31,.78);
  backdrop-filter: blur(24px);
}

body.light .sidebar { background: rgba(255,255,255,.8); }

.menu {
  margin-top: 28px;
  display: grid;
  gap: 7px;
}

.menu-item, .planner-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  border: 0;
  color: var(--text);
  background: transparent;
  border-radius: 13px;
  padding: 13px 14px;
  font-weight: 750;
}

.menu-item:hover, .menu-item.active, .planner-btn:hover, .planner-btn.active {
  background: linear-gradient(90deg, rgba(124,58,237,.34), rgba(79,70,229,.16));
}

.sidebar-section {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 4px 12px;
  font-weight: 850;
}

.section-title button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  background: var(--card);
}

.planner-list { display: grid; gap: 6px; }

.planner-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 18px var(--c);
}

.main { min-width: 0; }

.topbar {
  height: 72px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  background: rgba(8,17,31,.38);
  backdrop-filter: blur(24px);
}

body.light .topbar { background: rgba(255,255,255,.72); }

.search {
  width: min(520px, 44vw);
  height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 16px;
  background: var(--card);
}

.search input {
  border: 0;
  padding: 0;
  background: transparent;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn, .logout-btn, .ghost-btn, .square-btn, .primary-btn, .danger-btn {
  min-height: 44px;
  border-radius: 13px;
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--card);
  padding: 0 16px;
  font-weight: 850;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn { width: 44px; padding: 0; font-size: 19px; }
.import-label, .upload-btn { cursor: pointer; }

.primary-btn {
  border: 0;
  color: white;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  box-shadow: 0 15px 40px rgba(79,70,229,.35);
}

.danger-btn {
  color: #fca5a5;
  background: rgba(239,68,68,.13);
  border-color: rgba(239,68,68,.28);
}

.full { width: 100%; }

.logout-btn {
  color: #fca5a5;
  background: rgba(239,68,68,.12);
  border-color: rgba(239,68,68,.24);
}

.profile {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 160px;
}

.profile small {
  display: block;
  color: var(--muted);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 900;
  background: linear-gradient(135deg, #fb7185, #f97316);
}

.workspace { padding: 16px; }

.view { display: none; }
.view.active { display: block; }

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.view-header h1 {
  margin: 0;
  font-size: 31px;
  letter-spacing: -1px;
}

.view-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.header-actions h2 {
  margin: 0 8px;
  min-width: 170px;
}

.square-btn { width: 44px; padding: 0; font-size: 24px; }

.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(110px, 1fr));
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: rgba(15,23,42,.42);
  box-shadow: var(--shadow);
}

body.light .calendar { background: rgba(255,255,255,.76); }

.weekday {
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-weight: 850;
}

.day {
  min-height: 102px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 7px;
}

.day:hover { background: rgba(124,58,237,.08); }
.day:nth-child(7n) { border-right: 0; }

.day-number {
  font-weight: 900;
  margin-bottom: 5px;
  font-size: 14px;
}

.day.other .day-number {
  color: var(--muted);
  opacity: .55;
}

.day.today .day-number {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 10px 28px rgba(124,58,237,.45);
}

.event-pill {
  width: 100%;
  border: 0;
  color: white;
  text-align: left;
  border-radius: 8px;
  padding: 5px 6px;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  background: var(--event-color, #7c3aed);
}

.details-card, .settings-card, .item-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.details-card {
  position: sticky;
  top: 106px;
  height: calc(100vh - 132px);
  overflow: auto;
}

.details-card h2 { margin-top: 0; }

.empty-state {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 18px;
}

.detail-row {
  color: var(--muted);
  margin: 12px 0;
}

.detail-row strong { color: var(--text); }

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.board-list {
  display: grid;
  gap: 12px;
}

.task-row, .member-row {
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 14px;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.task-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.task-left input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.done { text-decoration: line-through; color: var(--muted); }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 16px;
}

.item-card h3 { margin: 0 0 10px; }
.item-card p { color: var(--muted); line-height: 1.5; }

.progress {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(148,163,184,.18);
  margin: 14px 0;
}

.progress span {
  display: block;
  height: 100%;
  width: var(--p);
  background: linear-gradient(90deg, var(--accent2), var(--accent));
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(190px, 1fr));
  gap: 16px;
}

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

.photo-card img {
  width: 100%;
  height: 180px;
  display: block;
  object-fit: cover;
}

.photo-card div {
  padding: 12px;
  color: var(--muted);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 18px;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr 160px auto;
  gap: 10px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(2,6,23,.72);
  backdrop-filter: blur(10px);
  z-index: 50;
}

.modal-backdrop.show { display: grid; }

.modal {
  width: min(560px, 100%);
  max-height: 92vh;
  overflow: auto;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 24px;
  background: var(--bg2);
  box-shadow: var(--shadow);
}

.modal h2 { margin-top: 0; }

.modal-close {
  position: absolute;
  right: 16px;
  top: 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 30px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.small-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.small-actions button {
  min-height: 36px;
  padding: 0 11px;
  border-radius: 10px;
}

@media (max-width: 1180px) {
  .app { grid-template-columns: 86px 1fr; }
  .brand span, .menu-item, .sidebar-section { font-size: 0; }
  .menu-item { justify-content: center; }
  .menu-item span { font-size: 20px; }
  .calendar-layout { grid-template-columns: 1fr; }
  .details-card { position: static; height: auto; }
}

@media (max-width: 820px) {
  .app { display: block; }
  .sidebar { display: none; }
  .topbar {
    height: auto;
    padding: 14px;
    flex-direction: column;
    align-items: stretch;
  }
  .search { width: 100%; }
  .top-actions { flex-wrap: wrap; }
  .workspace { padding: 14px; }
  .view-header { flex-direction: column; align-items: stretch; }
  .calendar { grid-template-columns: repeat(7, minmax(82px, 1fr)); overflow-x: auto; }
  .day { min-height: 110px; }
  .cards-grid, .photo-grid, .settings-grid { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: 1fr; }
}

.event-photos{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top:20px;
}

.event-photo{
  width:110px;
  height:110px;
  object-fit:cover;
  border-radius:14px;
  cursor:pointer;
  border:1px solid rgba(255,255,255,.08);
  transition:.2s;
}

.event-photo:hover{
  transform:scale(1.03);
}

.photo-overlay{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.85);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:9999;
  padding:20px;
}

.photo-modal img{
  max-width:90vw;
  max-height:90vh;
  border-radius:18px;
}

/* === Compact aligned calendar layout === */

.calendar-layout {
  align-items: start;
}

.view-header {
  margin-bottom: 14px;
}

.calendar {
  height: calc(100vh - 180px);
  grid-template-rows: 34px repeat(6, minmax(0, 1fr));
}

.weekday {
  height: 34px;
}

.day {
  min-height: 0;
  padding: 6px;
}

.day-number {
  margin-bottom: 4px;
  font-size: 14px;
}

.event-pill {
  padding: 4px 6px;
  margin-top: 4px;
  font-size: 12px;
}

.details-card {
  margin-top: 78px;
  height: calc(100vh - 180px);
  top: 88px;
}

@media (max-width: 1180px) {
  .calendar {
    height: auto;
  }

  .details-card {
    margin-top: 0;
    height: auto;
  }
}
