/* tokens */
:root {
  --bg:          #110508;
  --bg-surface:  #1c0b10;
  --bg-raised:   #271018;
  --bg-card:     #311420;
  --border:      #4a1828;
  --border-soft: #3a1220;
  --accent:      #8b1a30;
  --accent-hi:   #b5223e;
  --accent-glow: #d4294a;
  --text:        #e8d5da;
  --text-muted:  #8a6570;
  --text-dim:    #5a3540;
  --weekend:     #b5223e;
  --today-ring:  #d4294a;
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body:    'Inter', system-ui, sans-serif;
  --radius:       8px;
  --radius-sm:    5px;
  --safe-top:     env(safe-area-inset-top, 0px);
  --safe-bot:     env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.hidden { display: none !important; }
.screen { position: fixed; inset: 0; }

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #2a0d16 0%, #110508 70%);
}

.login-wrap {
  width: 100%;
  max-width: 340px;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.login-logo {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  box-shadow: 0 0 40px rgba(139, 26, 48, 0.35);
}
.login-logo img { width: 100%; height: 100%; object-fit: cover; }

.login-title {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 300;
  letter-spacing: 0.06em;
  color: var(--text);
  margin-bottom: 32px;
}

.login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.field input {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.2s;
}
.field input:focus { border-color: var(--accent-hi); }
.field input::placeholder { color: var(--text-dim); }

.error-msg {
  font-size: 13px;
  color: #e05070;
  text-align: center;
  padding: 8px 12px;
  background: rgba(139, 26, 48, 0.2);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(139, 26, 48, 0.4);
}

.btn-primary {
  background: var(--accent);
  color: #f0d0d8;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.05em;
  padding: 13px 20px;
  cursor: pointer;
  transition: background 0.18s, box-shadow 0.18s;
  width: 100%;
}
.btn-primary:hover { background: var(--accent-hi); box-shadow: 0 0 16px rgba(181, 34, 62, 0.4); }
.btn-primary:active { background: var(--accent-glow); }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 12px) 16px 10px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-soft);
  position: relative;
  z-index: 10;
}

.header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.month-label {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--text);
  text-transform: capitalize;
}

.user-badge {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.nav-arrow {
  background: none;
  border: none;
  color: var(--accent-hi);
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 10px;
  transition: color 0.15s;
  font-weight: 300;
}
.nav-arrow:hover { color: var(--accent-glow); }

.weekdays-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-soft);
  padding: 6px 4px 5px;
}
.weekdays-row span {
  text-align: center;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.weekdays-row span.weekend { color: var(--weekend); opacity: 0.7; }

#app-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg);
}

.calendar-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 1fr;
  gap: 1px;
  background: var(--border-soft);
  overflow: hidden;
  min-height: 0;
}

.day-cell {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 5px 5px 4px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
  overflow: hidden;
  min-height: 0;
}
.day-cell:hover { background: var(--bg-raised); }
.day-cell.other-month { opacity: 0.3; }
.day-cell.today .day-num {
  background: var(--today-ring);
  color: #fff;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
}
.day-cell.has-notes::after {
  content: '';
  position: absolute;
  bottom: 3px;
  right: 4px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-hi);
}

.day-num {
  font-size: 12px;
  font-weight: 400;
  color: var(--text);
  line-height: 24px;
  min-width: 24px;
  text-align: center;
  flex-shrink: 0;
}
.day-cell.weekend .day-num { color: var(--weekend); }

.day-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: 3px;
  width: 100%;
}
.day-dot {
  height: 3px;
  border-radius: 2px;
  flex: 1;
  min-width: 4px;
  max-width: 20px;
}

.logout-btn {
  position: fixed;
  bottom: calc(var(--safe-bot) + 14px);
  left: 50%;
  transform: translateX(-50%);
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 7px 18px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.18s;
  z-index: 5;
}
.logout-btn:hover {
  border-color: var(--accent);
  color: var(--text-muted);
}

.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
}

.notes-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 101;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  display: flex;
  flex-direction: column;
  max-height: 82vh;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  padding-bottom: var(--safe-bot);
}
.notes-panel.visible {
  transform: translateY(0);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.panel-date {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: 0.02em;
}

.panel-close {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}
.panel-close:hover { background: var(--bg-card); color: var(--text); }

.notes-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 60px;
}
.notes-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 20px 0;
  font-style: italic;
  font-family: var(--font-display);
}

.note-item {
  background: var(--bg-raised);
  border-radius: var(--radius);
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
  display: flex;
  flex-direction: column;
  gap: 5px;
  position: relative;
}

.note-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.note-author {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.note-tag {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.note-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.note-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.note-del-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all 0.15s;
}
.note-del-btn:hover {
  border-color: #8b1a30;
  color: #e05070;
  background: rgba(139,26,48,0.15);
}

.add-note-area {
  padding: 12px 16px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

#note-text {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 12px;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
  line-height: 1.5;
}
#note-text:focus { border-color: var(--accent-hi); }
#note-text::placeholder { color: var(--text-dim); }

.note-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#note-label {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 7px 12px;
  outline: none;
  transition: border-color 0.2s;
}
#note-label:focus { border-color: var(--accent-hi); }
#note-label::placeholder { color: var(--text-dim); }

.color-picker {
  display: flex;
  align-items: center;
  gap: 10px;
}
.color-label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  flex-shrink: 0;
}
.color-swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s, border-color 0.15s;
}
.swatch:hover { transform: scale(1.2); }
.swatch.selected {
  border-color: #fff;
  transform: scale(1.15);
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

@media (min-width: 600px) {
  .notes-panel {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
  }
  .notes-panel.visible {
    transform: translateX(-50%) translateY(0);
  }
}
