@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=Rubik:wght@400;500;600&family=Caveat:wght@400;500;600;700&family=Montserrat:wght@400;500;600;700&display=swap');

/* ========================================================================
   RESET & BASE
   ======================================================================== */

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

/* ========================================================================
   THEME VARIABLES
   ======================================================================== */

:root {
  --bg-main: #FFF5EE;
  --bg-main-over-1: rgba(222, 184, 135, 0.15);
  --bg-main-over-2: rgba(205, 107, 42, 0.1);
  --bg-main-from: #FFF5EE;
  --bg-main-to: #FFE4CA;
  --bg-container: #FFF8F0;
  --red-dark: #7A1F0D;
  --red-primary: #8B2500;
  --red-medium: #B83A1A;
  --orange-brown: #CD6B2A;
  --orange-gold: #D4873A;
  --brown-dark: #3E1F00;
  --brown-medium: #6B3410;
  --brown-light: #A0522D;
  --golden-light: #DEB887;
  --golden-pale: #F4DDB5;
  --cream: #FFF8DC;
  --cream-dark: #FFEBCD;
  --text-primary: #2C1500;
  --text-secondary: #6B3410;
  --shadow: rgba(139, 37, 0, 0.15);
  --border: rgba(139, 37, 0, 0.2);
  --cell-hover: rgba(205, 107, 42, 0.12);
  --cell-note-bg: rgba(205, 107, 42, 0.08);
  --preview-border: rgba(205, 107, 42, 0.15);
  --preview-bg: rgba(205, 107, 42, 0.04);
  --cell-shadow: rgba(205, 107, 42, 0.15);
}

[data-theme="lavender"] {
  --bg-main: #F5EEFF;
  --bg-main-over-1: rgba(176, 136, 214, 0.12);
  --bg-main-over-2: rgba(128, 80, 180, 0.08);
  --bg-main-from: #F5EEFF;
  --bg-main-to: #E8D6F5;
  --bg-container: #F8F0FF;
  --red-dark: #3A1A5C;
  --red-primary: #4A2C6B;
  --red-medium: #6B44A0;
  --orange-brown: #8B60C8;
  --orange-gold: #B088D6;
  --brown-dark: #261040;
  --brown-medium: #4A2C6B;
  --brown-light: #7A55A0;
  --golden-light: #C8A8E8;
  --golden-pale: #E0C8F4;
  --cream: #F5EEFF;
  --cream-dark: #EDE0F7;
  --text-primary: #1F0A35;
  --text-secondary: #4A2C6B;
  --shadow: rgba(74, 44, 107, 0.15);
  --border: rgba(74, 44, 107, 0.18);
  --cell-hover: rgba(139, 96, 200, 0.1);
  --cell-note-bg: rgba(139, 96, 200, 0.08);
  --preview-border: rgba(139, 96, 200, 0.15);
  --preview-bg: rgba(139, 96, 200, 0.04);
  --cell-shadow: rgba(139, 96, 200, 0.15);
}

[data-theme="mint"] {
  --bg-main: #EEFBF5;
  --bg-main-over-1: rgba(93, 196, 160, 0.12);
  --bg-main-over-2: rgba(27, 107, 90, 0.08);
  --bg-main-from: #EEFBF5;
  --bg-main-to: #D6F0E6;
  --bg-container: #F0FFF8;
  --red-dark: #0F4A3A;
  --red-primary: #1B6B5A;
  --red-medium: #2D8A75;
  --orange-brown: #3AA88C;
  --orange-gold: #5DC4A0;
  --brown-dark: #0A2E24;
  --brown-medium: #1B6B5A;
  --brown-light: #3A9A82;
  --golden-light: #88D4B8;
  --golden-pale: #C0E8D8;
  --cream: #EEFBF5;
  --cream-dark: #E0F5EC;
  --text-primary: #08281E;
  --text-secondary: #1B6B5A;
  --shadow: rgba(27, 107, 90, 0.15);
  --border: rgba(27, 107, 90, 0.18);
  --cell-hover: rgba(58, 168, 140, 0.1);
  --cell-note-bg: rgba(58, 168, 140, 0.08);
  --preview-border: rgba(58, 168, 140, 0.15);
  --preview-bg: rgba(58, 168, 140, 0.04);
  --cell-shadow: rgba(58, 168, 140, 0.15);
}

[data-theme="sky"] {
  --bg-main: #EEF5FC;
  --bg-main-over-1: rgba(107, 181, 224, 0.12);
  --bg-main-over-2: rgba(26, 75, 122, 0.08);
  --bg-main-from: #EEF5FC;
  --bg-main-to: #D6E6F5;
  --bg-container: #F0F8FF;
  --red-dark: #0F3057;
  --red-primary: #1A4B7A;
  --red-medium: #2E6A9E;
  --orange-brown: #4A8EC4;
  --orange-gold: #6BB5E0;
  --brown-dark: #0A1F38;
  --brown-medium: #1A4B7A;
  --brown-light: #3A78A8;
  --golden-light: #88BDE0;
  --golden-pale: #C0DCF0;
  --cream: #EEF5FC;
  --cream-dark: #E0ECF5;
  --text-primary: #081828;
  --text-secondary: #1A4B7A;
  --shadow: rgba(26, 75, 122, 0.15);
  --border: rgba(26, 75, 122, 0.18);
  --cell-hover: rgba(74, 142, 196, 0.1);
  --cell-note-bg: rgba(74, 142, 196, 0.08);
  --preview-border: rgba(74, 142, 196, 0.15);
  --preview-bg: rgba(74, 142, 196, 0.04);
  --cell-shadow: rgba(74, 142, 196, 0.15);
}

[data-theme="gold"] {
  --bg-main: #FFF8EE;
  --bg-main-over-1: rgba(212, 160, 48, 0.12);
  --bg-main-over-2: rgba(122, 92, 13, 0.08);
  --bg-main-from: #FFF8EE;
  --bg-main-to: #F5E6C8;
  --bg-container: #FFFBF0;
  --red-dark: #5C4208;
  --red-primary: #7A5C0D;
  --red-medium: #A07A1A;
  --orange-brown: #C4962A;
  --orange-gold: #D4A030;
  --brown-dark: #382800;
  --brown-medium: #6B4E0A;
  --brown-light: #9A7828;
  --golden-light: #DEB84A;
  --golden-pale: #F0DA90;
  --cream: #FFF8EE;
  --cream-dark: #F8ECD6;
  --text-primary: #2C2000;
  --text-secondary: #6B4E0A;
  --shadow: rgba(122, 92, 13, 0.15);
  --border: rgba(122, 92, 13, 0.18);
  --cell-hover: rgba(196, 150, 42, 0.1);
  --cell-note-bg: rgba(196, 150, 42, 0.08);
  --preview-border: rgba(196, 150, 42, 0.15);
  --preview-bg: rgba(196, 150, 42, 0.04);
  --cell-shadow: rgba(196, 150, 42, 0.15);
}

[data-theme="cherry"] {
  --bg-main: #FFF0F2;
  --bg-main-over-1: rgba(196, 74, 106, 0.12);
  --bg-main-over-2: rgba(92, 16, 32, 0.08);
  --bg-main-from: #FFF0F2;
  --bg-main-to: #F5D6DE;
  --bg-container: #FFF8F8;
  --red-dark: #4A0A18;
  --red-primary: #5C1020;
  --red-medium: #8A2038;
  --orange-brown: #B83850;
  --orange-gold: #C44A6A;
  --brown-dark: #2C0410;
  --brown-medium: #5C1020;
  --brown-light: #8A2E48;
  --golden-light: #D4788E;
  --golden-pale: #EAB4C4;
  --cream: #FFF0F2;
  --cream-dark: #F8E0E6;
  --text-primary: #24040C;
  --text-secondary: #5C1020;
  --shadow: rgba(92, 16, 32, 0.15);
  --border: rgba(92, 16, 32, 0.18);
  --cell-hover: rgba(184, 56, 80, 0.1);
  --cell-note-bg: rgba(184, 56, 80, 0.08);
  --preview-border: rgba(184, 56, 80, 0.15);
  --preview-bg: rgba(184, 56, 80, 0.04);
  --cell-shadow: rgba(184, 56, 80, 0.15);
}

/* ========================================================================
   LAYOUT
   ======================================================================== */

html, body {
  height: 100%;
  font-family: 'Rubik', sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  overflow-x: hidden;
}

body {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: 20px;
  background:
    radial-gradient(ellipse at 10% 20%, var(--bg-main-over-1) 0%, transparent 50%),
    radial-gradient(ellipse at 90% 80%, var(--bg-main-over-2) 0%, transparent 50%),
    linear-gradient(180deg, var(--bg-main-from) 0%, var(--bg-main-to) 100%);
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    url('../images/cat-whiskers.svg') repeat-x top 20px left 0,
    url('../images/cat-whiskers.svg') repeat-x bottom 30px right 0;
  background-size: 120px auto;
  opacity: 0.08;
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  bottom: 0;
  right: 0;
  width: 300px;
  height: 300px;
  background: url('../images/cat-sleeping.svg') no-repeat bottom right;
  background-size: contain;
  opacity: 0.04;
  pointer-events: none;
  z-index: 0;
}

.cat-bg {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.cat-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: sepia(0.35) saturate(1.15) brightness(1.08);
  mask-image: radial-gradient(ellipse at center, black 45%, transparent 90%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 45%, transparent 90%);
}

.cat-bg-fade {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 30%, var(--bg-main) 100%);
  mix-blend-mode: normal;
}

.theme-full-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-attachment: fixed;
  display: none;
  pointer-events: none;
}

.cat-bg-tl {
  top: -60px;
  left: -80px;
  width: 480px;
  height: 480px;
}

.cat-bg-tr {
  top: -40px;
  right: -60px;
  width: 420px;
  height: 420px;
}

.cat-bg-bl {
  bottom: -50px;
  left: -70px;
  width: 400px;
  height: 400px;
}

.cat-bg-br {
  bottom: -30px;
  right: -80px;
  width: 460px;
  height: 460px;
}

@media (max-width: 768px) {
  .cat-bg-tl { width: 300px; height: 300px; top: -40px; left: -60px; }
  .cat-bg-tr { width: 260px; height: 260px; top: -30px; right: -50px; }
  .cat-bg-bl { width: 250px; height: 250px; bottom: -30px; left: -50px; }
  .cat-bg-br { width: 280px; height: 280px; bottom: -20px; right: -60px; }
}

@media (max-width: 480px) {
  .cat-bg { display: none; }
}

/* ========================================================================
   CALENDAR GRID
   ======================================================================== */

.calendar-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1100px;
  background: var(--bg-container);
  border-radius: 24px;
  box-shadow:
    0 8px 32px var(--shadow),
    0 2px 8px rgba(139, 37, 0, 0.08);
  overflow: hidden;
  border: 1px solid var(--border);
  backdrop-filter: blur(4px);
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  background:
    linear-gradient(135deg, var(--red-dark) 0%, var(--red-primary) 40%, var(--red-medium) 100%);
  border-bottom: 3px solid var(--orange-brown);
  position: relative;
  overflow: hidden;
}

.calendar-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    url('../images/cat-silhouette.svg') no-repeat right 30px center;
  background-size: auto 100%;
  opacity: 0.08;
  pointer-events: none;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 1;
}

.header-cat-icon {
  width: 36px;
  height: 36px;
  filter: brightness(0) invert(1) opacity(0.7);
}

.header-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: #FFE4CA;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 1;
  background: rgba(255,255,255,0.1);
  padding: 6px 12px;
  border-radius: 40px;
  backdrop-filter: blur(4px);
}

.header-clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 8px;
  line-height: 1.1;
}

.clock-time {
  font-family: 'Rubik', sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: #FFEEDD;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}

.clock-sep {
  animation: clockBlink 1s step-end infinite;
}

@keyframes clockBlink {
  50% { opacity: 0; }
}

.clock-tz {
  font-size: 0.6rem;
  color: var(--golden-light);
  font-weight: 500;
  letter-spacing: 0.3px;
}

.nav-btn {
  background: transparent;
  border: none;
  color: #FFE4CA;
  font-size: 1.1rem;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
  font-weight: 600;
  line-height: 1;
}

.nav-btn:hover {
  background: rgba(255,255,255,0.2);
  transform: scale(1.1);
}

.nav-btn:active {
  transform: scale(0.95);
}

.nav-selector {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 12px;
  min-width: 100px;
}

.nav-month {
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: #FFEEDD;
  line-height: 1.2;
}

.nav-year {
  font-size: 0.85rem;
  color: var(--golden-light);
  font-weight: 500;
  letter-spacing: 0.5px;
}

.header-right {
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cat-msg-btn {
  background: rgba(255,255,255,0.12);
  border: none;
  color: #FFE4CA;
  font-size: 1.3rem;
  padding: 8px 10px;
  cursor: pointer;
  border-radius: 12px;
  transition: all 0.2s;
  line-height: 1;
}

.cat-msg-btn:hover {
  background: rgba(255,255,255,0.25);
  transform: scale(1.15);
}

.settings-btn {
  background: rgba(255,255,255,0.12);
  border: none;
  color: #FFE4CA;
  font-size: 1.4rem;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 12px;
  transition: all 0.2s;
  line-height: 1;
}

.settings-btn:hover {
  background: rgba(255,255,255,0.25);
  transform: rotate(30deg);
}

.search-btn {
  background: rgba(255,255,255,0.12);
  border: none;
  color: #FFE4CA;
  font-size: 1.2rem;
  padding: 8px 10px;
  cursor: pointer;
  border-radius: 12px;
  transition: all 0.2s;
  line-height: 1;
}

.search-btn:hover {
  background: rgba(255,255,255,0.25);
  transform: scale(1.15);
}

.calendar-body {
  padding: 12px 24px 12px;
}

.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}

.weekday {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 8px 0;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.day-cell {
  position: relative;
  height: 110px;
  background: var(--cream);
  border: 1px solid rgba(139, 37, 0, 0.08);
  border-radius: 10px;
  padding: 6px 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.day-cell:hover {
  background: var(--cell-hover);
  border-color: var(--orange-brown);
  box-shadow: 0 2px 12px var(--cell-shadow);
  transform: translateY(-1px);
}

.day-cell.other-month {
  opacity: 0.35;
}

.day-cell.today {
  background: linear-gradient(135deg, var(--golden-pale), var(--cream-dark));
  border-color: var(--orange-gold);
  box-shadow: inset 0 0 0 2px var(--orange-gold);
}

.day-cell.today::after {
  content: '';
  position: absolute;
  top: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  background: var(--orange-brown);
  border-radius: 0 10px 0 10px;
}

.day-number {
  font-family: 'Playfair Display', serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--brown-dark);
  margin-bottom: 4px;
  line-height: 1.2;
}

.day-cell.today .day-number {
  color: var(--red-primary);
}

.day-note-preview {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.78rem;
  color: var(--brown-medium);
  line-height: 1.3;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  word-break: break-word;
  padding: 4px 2px;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: var(--golden-light) transparent;
}

.day-note-preview::-webkit-scrollbar {
  width: 4px;
}

.day-note-preview::-webkit-scrollbar-thumb {
  background: var(--golden-light);
  border-radius: 4px;
}

.note-preview-line {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.78rem;
  color: var(--brown-medium);
  line-height: 1.25;
  padding: 4px 0 4px 6px;
  border-bottom: 1px solid var(--preview-border);
  border-left: 3px solid var(--orange-brown);
  margin-bottom: 4px;
  background: var(--preview-bg);
  border-radius: 0 3px 3px 0;
}

.note-preview-line p {
  margin: 0;
}

.note-preview-line:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.note-preview-line.done {
  opacity: 0.55;
  color: var(--text-secondary);
}

.note-preview-line.memory {
  background: linear-gradient(135deg, rgba(212, 160, 48, 0.12), rgba(255, 200, 100, 0.06));
  border-left-color: #D4A030;
  font-family: 'Caveat', cursive;
  font-size: 1rem;
  line-height: 1.5;
}

.note-preview-line.shared {
  background: linear-gradient(135deg, rgba(128, 80, 200, 0.08), rgba(160, 100, 220, 0.04));
  border-left-color: #8B60C8;
}

.note-preview-line.shared.memory {
  border-left-color: #B8860B;
}

.note-preview-line.shared .shared-icon {
  font-size: 0.7rem;
  margin-right: 2px;
}

.day-cell.has-note {
  border-left: 3px solid var(--orange-brown);
}

.day-cell.has-note .day-number::after {
  content: ' 🐾';
  font-size: 0.65rem;
}

.day-note-count {
  display: none;
}

.calendar-footer {
  padding: 12px 28px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  border-top: 1px solid rgba(139, 37, 0, 0.06);
}

.footer-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: var(--cell-note-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-family: 'Rubik', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
}

.footer-btn:hover {
  background: var(--cell-hover);
  border-color: var(--orange-brown);
  box-shadow: 0 2px 8px rgba(205, 107, 42, 0.15);
  transform: translateY(-1px);
}

.footer-btn:active {
  transform: translateY(0);
}

.weather-widget {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 12px 0 6px;
  border-right: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
}

@media (max-width: 600px) {
  .weather-widget {
    display: none;
  }
}

.bottom-nav {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px 14px;
  border-top: 1px solid rgba(139, 37, 0, 0.06);
}

.bottom-nav .nav-btn {
  background: var(--cell-note-bg);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 1rem;
  padding: 8px 14px;
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.2s;
  font-weight: 600;
  line-height: 1;
}

.bottom-nav .nav-btn:hover {
  background: var(--cell-hover);
  border-color: var(--orange-brown);
  transform: scale(1.05);
}

.bottom-nav .nav-selector {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 8px;
  min-width: 80px;
}

.bottom-nav .nav-month {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.bottom-nav .nav-year {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}


.cat-decoration {
  display: flex;
  align-items: center;
  gap: 14px;
}

.footer-cat {
  height: 28px;
  opacity: 0.4;
}

.footer-text {
  font-family: 'Playfair Display', serif;
  font-size: 0.8rem;
  color: var(--brown-light);
  font-style: italic;
}

/* ========================================================================
   MODAL
   ======================================================================== */

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(44, 21, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--bg-container);
  border-radius: 20px;
  width: 90%;
  max-width: 736px;
  box-shadow: 0 20px 60px rgba(44, 21, 0, 0.3);
  border: 1px solid var(--border);
  animation: slideUp 0.25s ease;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  background: linear-gradient(135deg, var(--red-dark), var(--red-primary));
  color: #FFE4CA;
}

.modal-header .modal-date {
  color: #FFE4CA;
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.modal-header h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  font-weight: 600;
}

.modal-close {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #FFE4CA;
  font-size: 1.1rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: rgba(255,255,255,0.3);
  transform: scale(1.1);
}

.modal-body {
  padding: 24px;
  position: relative;
}

.modal-paw {
  position: absolute;
  top: 12px;
  right: 24px;
  width: 40px;
  opacity: 0.08;
  pointer-events: none;
}

.modal-date {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  color: var(--brown-dark);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px dotted var(--golden-light);
}

.note-textarea {
  width: 100%;
  min-height: 140px;
  padding: 14px 16px;
  border: 2px solid var(--golden-light);
  border-radius: 12px;
  font-family: 'Montserrat', sans-serif;
  font-size: 1rem;
  color: var(--text-primary);
  background: var(--cream);
  resize: vertical;
  outline: none;
  transition: all 0.2s;
  line-height: 1.5;
}

.note-textarea:focus {
  border-color: var(--orange-brown);
  box-shadow: 0 0 0 3px rgba(205, 107, 42, 0.15);
  background: white;
}

.note-textarea::placeholder {
  color: var(--brown-light);
  opacity: 0.6;
}

.notes-list {
  margin-bottom: 12px;
  max-height: 240px;
  overflow-y: auto;
}

.notes-list:empty {
  display: none;
}

.notes-empty {
  font-size: 0.85rem;
  color: var(--brown-light);
  font-style: italic;
  text-align: center;
  padding: 16px 0;
}

.note-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 8px;
  border-left: 4px solid var(--orange-brown);
  box-shadow: 0 1px 3px rgba(139, 37, 0, 0.06);
  transition: all 0.15s;
}

.note-item:hover {
  border-color: var(--orange-brown);
  box-shadow: 0 2px 10px rgba(205, 107, 42, 0.12);
}

.note-item-idx {
  font-family: 'Playfair Display', serif;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--orange-brown);
  min-width: 18px;
  text-align: center;
  flex-shrink: 0;
  padding-top: 1px;
}

.note-item-text {
  flex: 1;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.88rem;
  color: var(--text-primary);
  line-height: 1.4;
  word-break: break-word;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.note-item-text p {
  margin: 0 0 0.5em 0;
}

.note-item-text p:last-child {
  margin-bottom: 0;
}

.note-item-text.expanded {
  overflow: visible;
  white-space: pre-wrap;
}

.note-item.done {
  opacity: 0.6;
}

.note-item.done .note-item-text {
  color: var(--text-secondary);
}

.note-item.memory {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.10), rgba(255, 200, 100, 0.05));
  border-left-color: #D4A030;
  border-color: rgba(212, 160, 48, 0.4);
  box-shadow: 0 2px 12px rgba(212, 160, 48, 0.10);
}

.note-item.memory::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url('../images/cat-paw.svg');
  background-size: 28px 28px;
  background-repeat: repeat;
  opacity: 0.10;
  pointer-events: none;
}

.note-item.memory .note-item-text {
  position: relative;
  z-index: 1;
  font-family: 'Caveat', cursive;
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.5;
}

.note-item.memory .note-item-idx {
  position: relative;
  z-index: 1;
  color: #B8860B;
}

.note-item.memory .note-item-idx::before {
  content: '✨ ';
  font-size: 0.75rem;
}

.note-item.shared {
  border-left-color: #8B60C8;
  background: linear-gradient(135deg, rgba(128, 80, 200, 0.06), rgba(160, 100, 220, 0.03));
}

.note-item.shared.memory {
  border-left-color: #B8860B;
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.08), rgba(255, 200, 100, 0.04));
}

.note-item.shared .note-item-idx {
  font-size: 0.72rem;
  color: #8B60C8;
  min-width: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}

.shared-author-label {
  font-weight: 600;
  font-size: 0.72rem;
}

.shared-update-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #4CAF50;
  border-radius: 50%;
  margin-left: 4px;
  vertical-align: middle;
  animation: shared-update-blink 1.2s ease-in-out infinite;
}

@keyframes shared-update-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

.shared-user-picker {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.shared-picker-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.shared-user-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 4px 4px;
  margin: 2px 4px 2px 0;
  font-size: 0.82rem;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
}

.shared-user-label:hover {
  background: var(--cell-hover);
}

.shared-user-label input[type="checkbox"] {
  accent-color: #8B60C8;
}

.note-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.note-item-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 2px 4px;
  border-radius: 4px;
  transition: all 0.15s;
  opacity: 0.5;
  line-height: 1;
}

.note-item:hover .note-item-btn {
  opacity: 0.8;
}

.note-item-btn:hover {
  opacity: 1 !important;
  background: rgba(205, 107, 42, 0.1);
}

.note-editor-sep {
  text-align: center;
  font-size: 0.75rem;
  color: var(--brown-light);
  margin: 4px 0 10px;
  position: relative;
}

.note-editor-sep::before {
  content: '— новый —';
  background: var(--bg-container);
  padding: 0 10px;
  position: relative;
  z-index: 1;
}

.note-counter {
  text-align: right;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 8px;
  font-weight: 500;
}

.note-counter.warning {
  color: var(--red-primary);
}

.memory-option {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 10px;
  padding: 0 2px;
}

.memory-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-family: 'Rubik', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.memory-toggle-btn:hover {
  border-color: #D4A030;
  color: var(--text-primary);
}

.memory-toggle-btn.active {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.15), rgba(255, 200, 100, 0.08));
  border-color: #D4A030;
  color: #B8860B;
  box-shadow: 0 2px 8px rgba(212, 160, 48, 0.15);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  background: var(--cream);
  border-top: 1px solid rgba(139, 37, 0, 0.08);
}

.btn {
  padding: 10px 22px;
  border: none;
  border-radius: 10px;
  font-family: 'Rubik', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn:active {
  transform: scale(0.97);
}

.btn-save {
  background: linear-gradient(135deg, var(--orange-brown), var(--brown-medium));
  color: white;
  box-shadow: 0 2px 8px rgba(205, 107, 42, 0.3);
}

.btn-save:hover {
  box-shadow: 0 4px 16px rgba(205, 107, 42, 0.4);
  transform: translateY(-1px);
}

.btn-delete {
  background: transparent;
  color: var(--red-medium);
  border: 1px solid rgba(184, 58, 26, 0.2);
}

.btn-delete:hover {
  background: rgba(184, 58, 26, 0.08);
  border-color: var(--red-medium);
}

.btn-logout {
  background: transparent;
  color: var(--red-medium);
  border: 1px solid rgba(184, 58, 26, 0.2);
  width: 100%;
  justify-content: center;
  margin-top: 4px;
}

.btn-logout:hover {
  background: rgba(184, 58, 26, 0.08);
  border-color: var(--red-medium);
}

.import-export-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.btn-import,
.btn-export {
  flex: 1;
  justify-content: center;
  background: transparent;
  color: var(--brown-medium);
  border: 1px solid var(--border);
  padding: 10px 12px;
}

.btn-import:hover,
.btn-export:hover {
  background: var(--cell-hover);
  border-color: var(--orange-brown);
  box-shadow: 0 2px 8px rgba(205, 107, 42, 0.12);
  transform: translateY(-1px);
}

.modal-settings {
  max-width: 500px;
}

.settings-section {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(139, 37, 0, 0.06);
}

.settings-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.settings-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--brown-dark);
  margin-bottom: 4px;
}

.settings-hint {
  font-size: 0.82rem;
  color: var(--brown-light);
  margin-bottom: 12px;
}

.settings-status {
  font-size: 0.82rem;
  color: var(--brown-medium);
  margin-top: 8px;
  font-weight: 500;
}

.settings-status.success {
  color: #2E7D32;
}

.settings-status.error {
  color: var(--red-medium);
}

.theme-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 4px;
}

.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 6px;
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--cream);
}

.theme-option:hover {
  border-color: var(--orange-brown);
  background: var(--cell-hover);
}

.theme-option.active {
  border-color: var(--orange-brown);
  background: var(--golden-pale);
  box-shadow: 0 0 0 2px var(--orange-gold);
}

.theme-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: block;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.theme-name {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 500;
  line-height: 1.1;
  text-align: center;
}

.settings-about {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-style: italic;
}

.note-indicator {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: var(--red-primary);
  color: #FFEEDD;
  padding: 18px 36px;
  border-radius: 20px;
  font-size: 1.3rem;
  font-weight: 600;
  box-shadow: 0 8px 40px rgba(139, 37, 0, 0.4);
  z-index: 2000;
  white-space: nowrap;
  max-width: 90vw;
  opacity: 0;
  transition: none;
  pointer-events: none;
}

.note-indicator.show {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  animation: indicatorPop 0.35s ease forwards;
}

.note-indicator.undo-mode {
  top: auto;
  left: auto;
  bottom: 32px;
  right: 32px;
  transform: translateX(120%);
  animation: undoSlideIn 0.4s ease forwards;
  pointer-events: auto;
}

.note-indicator.undo-mode.slide-out {
  animation: undoSlideOut 0.35s ease forwards;
}

@keyframes undoSlideIn {
  0% {
    opacity: 0;
    transform: translateX(120%);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes undoSlideOut {
  0% {
    opacity: 1;
    transform: translateX(0);
  }
  100% {
    opacity: 0;
    transform: translateX(120%);
  }
}

.undo-btn {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.3);
  color: #FFEEDD;
  padding: 6px 16px;
  border-radius: 20px;
  font-family: 'Rubik', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.undo-btn:hover {
  background: rgba(255,255,255,0.35);
  border-color: rgba(255,255,255,0.5);
  transform: scale(1.05);
}

.undo-btn:active {
  transform: scale(0.95);
}

@keyframes indicatorPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.6);
  }
  60% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.05);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .calendar-header {
    padding: 14px 16px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .header-title {
    font-size: 1.2rem;
  }

  .header-nav {
    display: none;
  }

  .header-clock {
    flex-direction: row;
    gap: 6px;
    align-items: baseline;
  }

  .header-clock .clock-time {
    color: #FFEEDD;
    font-size: 1rem;
    font-weight: 600;
  }

  .header-clock .clock-tz {
    color: #FFEEDD;
    font-size: 0.55rem;
    line-height: 1;
  }

  .bottom-nav {
    display: flex;
  }

  .calendar-body {
    padding: 12px 10px;
  }

  .day-cell {
    height: 80px;
    padding: 4px 5px;
  }

  .day-number {
    font-size: 0.9rem;
  }

  .day-note-preview {
    font-size: 0.65rem;
  }

  .note-preview-line {
    font-size: 0.65rem;
  }

  .weekday {
    font-size: 0.7rem;
  }

  .modal-overlay.active {
    align-items: flex-start;
    padding: 20px 0;
    overflow-y: auto;
  }

  .modal-content {
    width: 95%;
    margin: auto;
  }

  .modal-body {
    padding: 16px;
  }

  .notes-list {
    max-height: 240px;
  }
}

@media (max-width: 480px) {
  .day-cell {
    height: 56px;
    border-radius: 6px;
  }

  .day-number {
    font-size: 0.8rem;
  }

  .day-note-preview {
    display: none;
  }

  .day-cell.has-note .day-number::after {
    content: none;
  }

  .day-note-count {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--orange-brown);
    line-height: 1;
    margin-top: auto;
    padding: 2px 0;
  }

  .calendar-header {
    padding: 10px 12px;
  }

  .header-title {
    font-size: 1rem;
  }

  .header-cat-icon {
    width: 28px;
    height: 28px;
  }
}

@media (min-width: 1200px) {
  .day-cell {
    height: 120px;
  }
}

/* ========================================================================
   MOVE PICKER
   ======================================================================== */

.move-picker {
  background: var(--bg-container);
  border: 2px solid var(--orange-brown);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 8px 32px var(--shadow);
  position: relative;
  z-index: 10;
}

.move-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.move-picker-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.move-picker-close {
  background: transparent;
  border: none;
  font-size: 1rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s;
}

.move-picker-close:hover {
  background: var(--cell-hover);
  color: var(--text-primary);
}

.move-picker-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.move-picker-nav-btn {
  background: var(--cream);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 1rem;
  padding: 4px 10px;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
}

.move-picker-nav-btn:hover {
  background: var(--cell-hover);
  border-color: var(--orange-brown);
}

.move-picker-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.move-picker-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 6px;
}

.move-picker-weekdays span {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 4px 0;
}

.move-picker-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.move-picker-day {
  text-align: center;
  padding: 6px 2px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.move-picker-day:hover {
  background: var(--cell-hover);
  color: var(--red-primary);
}

.move-picker-day.empty {
  cursor: default;
}

.move-picker-day.current {
  background: var(--golden-pale);
  color: var(--red-primary);
  font-weight: 700;
}

/* ========================================================================
   MESSAGES
   ======================================================================== */

.msg-btn {
  position: relative;
  background: rgba(255,255,255,0.12);
  border: none;
  color: #FFE4CA;
  font-size: 1.3rem;
  padding: 8px 10px;
  cursor: pointer;
  border-radius: 12px;
  transition: all 0.2s;
  line-height: 1;
}

.msg-btn:hover {
  background: rgba(255,255,255,0.25);
  transform: scale(1.15);
}

.msg-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #E53935;
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  font-family: 'Rubik', sans-serif;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.msg-modal {
  max-width: 700px;
  height: 500px;
  display: flex;
  flex-direction: column;
}

.msg-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.msg-sidebar {
  width: 220px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  background: var(--cream);
}

.msg-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.msg-chat-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brown-light);
  font-style: italic;
  font-size: 0.9rem;
}

.msg-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.msg-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-conv-list {
  padding: 8px;
}

.msg-conv-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 4px;
}

.msg-conv-item:hover {
  background: var(--cell-hover);
}

.msg-conv-item.active {
  background: var(--cell-note-bg);
  border: 1px solid var(--border);
}

.msg-conv-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--orange-brown), var(--brown-medium));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 600;
  flex-shrink: 0;
}

.msg-conv-info {
  flex: 1;
  min-width: 0;
}

.msg-conv-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.msg-conv-preview {
  font-size: 0.75rem;
  color: var(--brown-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.msg-conv-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}

.msg-conv-time {
  font-size: 0.6rem;
  color: var(--brown-light);
  white-space: nowrap;
}

.msg-conv-badge {
  background: var(--red-medium);
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.msg-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.85rem;
  line-height: 1.4;
  word-break: break-word;
  position: relative;
}

.msg-bubble p {
  margin: 0 0 0.5em 0;
}

.msg-bubble p:last-child {
  margin-bottom: 0;
}

.msg-bubble-delete {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: var(--red-medium);
  color: white;
  font-size: 0.7rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s, background 0.15s;
  transform: scale(0.8);
  z-index: 2;
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

.msg-bubble:hover .msg-bubble-delete {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.msg-bubble-delete:hover {
  background: var(--red-dark);
  transform: scale(1.15) !important;
}

.msg-bubble-delete:active {
  transform: scale(0.95) !important;
}

.msg-bubble-outgoing .msg-bubble-delete {
  background: rgba(255,255,255,0.35);
  color: white;
}

.msg-bubble-outgoing .msg-bubble-delete:hover {
  background: var(--red-medium);
}

@keyframes msgFadeOut {
  0% { opacity: 1; transform: scale(1); max-height: 200px; margin-bottom: 8px; }
  50% { opacity: 0; transform: scale(0.95) translateX(20px); max-height: 200px; margin-bottom: 8px; }
  100% { opacity: 0; transform: scale(0.95) translateX(20px); max-height: 0; margin-bottom: 0; padding: 0; overflow: hidden; }
}

.msg-bubble.deleting {
  animation: msgFadeOut 0.35s ease forwards;
  pointer-events: none;
}

.msg-bubble-incoming {
  align-self: flex-start;
  background: var(--cream);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.msg-bubble-outgoing {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--orange-brown), var(--brown-medium));
  color: white;
  border-bottom-right-radius: 4px;
}

.msg-bubble-info {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.msg-bubble-from {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--brown-light);
}

.msg-bubble-incoming .msg-bubble-from {
  color: var(--brown-light);
}

.msg-bubble-outgoing .msg-bubble-from {
  color: rgba(255,255,255,0.7);
}

.msg-bubble-time {
  font-size: 0.6rem;
  color: var(--brown-light);
}

.msg-bubble-outgoing .msg-bubble-time {
  color: rgba(255,255,255,0.6);
}

.msg-bubble-read {
  font-size: 0.65rem;
  margin-left: 4px;
  letter-spacing: 1px;
}

.msg-bubble-outgoing .msg-bubble-read {
  color: rgba(255,255,255,0.7);
}

.msg-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-container);
}

.msg-input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid var(--golden-light);
  border-radius: 20px;
  font-family: 'Rubik', sans-serif;
  font-size: 0.85rem;
  color: var(--text-primary);
  background: var(--cream);
  outline: none;
  transition: all 0.2s;
}

.msg-input:focus {
  border-color: var(--orange-brown);
  box-shadow: 0 0 0 3px rgba(205, 107, 42, 0.15);
}

.msg-input::placeholder {
  color: var(--brown-light);
  opacity: 0.6;
}

.btn-send {
  background: linear-gradient(135deg, var(--orange-brown), var(--brown-medium));
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(205, 107, 42, 0.3);
  flex-shrink: 0;
}

.btn-send:hover {
  box-shadow: 0 4px 14px rgba(205, 107, 42, 0.4);
  transform: scale(1.05);
}

.msg-date-separator {
  text-align: center;
  font-size: 0.7rem;
  color: var(--brown-light);
  padding: 8px 0;
  font-weight: 500;
}

.msg-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--cream);
  flex-shrink: 0;
}

.msg-chat-user {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.msg-chat-delete-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s;
  opacity: 0.4;
}

.msg-chat-delete-btn:hover {
  opacity: 1;
  background: rgba(184, 58, 26, 0.1);
}

.msg-search-input {
  flex: 1;
  max-width: 200px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.8rem;
  font-family: inherit;
  outline: none;
  background: var(--cream);
  color: var(--text-primary);
}

.msg-search-input:focus {
  border-color: var(--orange-brown);
  box-shadow: 0 0 0 2px rgba(205, 107, 42, 0.15);
}

.msg-search-results-header {
  text-align: center;
  font-size: 0.78rem;
  color: var(--brown-light);
  padding: 6px 0 10px;
  font-style: italic;
}

.msg-highlight {
  animation: msgHighlightFade 2s ease;
}

@keyframes msgHighlightFade {
  0%, 30% { background: rgba(205, 107, 42, 0.2); }
  100% { background: transparent; }
}

@media (max-width: 768px) {
  .msg-modal {
    height: 80vh;
  }

  .msg-sidebar {
    width: 160px;
  }

  .msg-conv-item {
    padding: 8px 10px;
  }

  .msg-conv-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
  }

  .msg-conv-name {
    font-size: 0.78rem;
  }

  .msg-conv-preview {
    display: none;
  }

  .msg-search-input {
    max-width: 140px;
    font-size: 0.75rem;
  }

  .msg-bubble-delete {
    opacity: 0.6;
    transform: scale(1);
    pointer-events: auto;
  }
}

@media (max-width: 480px) {
  .msg-modal .modal-header h2 {
    font-size: 1rem;
  }

  .msg-sidebar {
    width: 100px;
  }

  .msg-conv-preview,
  .msg-conv-time {
    display: none;
  }

  .msg-new-conv-btn {
    font-size: 0.78rem;
    padding: 8px 10px;
  }

  .msg-search-input {
    max-width: 110px;
    font-size: 0.72rem;
    padding: 3px 8px;
  }
}

.msg-new-conv-btn {
  display: block;
  width: calc(100% - 16px);
  margin: 8px auto 4px;
  padding: 10px 12px;
  background: var(--cell-note-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: 'Rubik', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--brown-medium);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.msg-new-conv-btn:hover {
  background: var(--cell-hover);
  border-color: var(--orange-brown);
  color: var(--text-primary);
}

.msg-user-pick-header {
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 12px 0 16px;
}

.msg-user-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  margin: 0 8px 4px;
}

.msg-user-item:hover {
  background: var(--cell-hover);
}

.note-item.reminder {
  border-left-color: #E53935;
  background: linear-gradient(135deg, rgba(229, 57, 53, 0.06), rgba(255, 100, 100, 0.03));
}

.note-item.reminder .note-item-idx {
  color: #C62828;
  font-size: 1rem;
  font-weight: 700;
  font-family: 'Rubik', sans-serif;
  min-width: auto;
  font-variant-numeric: tabular-nums;
}

.note-item.reminder.done {
  opacity: 0.55;
}

.note-item.selected {
  outline: 2px solid var(--orange-brown);
  outline-offset: -2px;
  box-shadow: 0 0 0 4px rgba(205, 107, 42, 0.15), 0 2px 12px rgba(205, 107, 42, 0.2);
  background: var(--cell-hover);
}

.note-preview-line.reminder {
  border-left-color: #E53935;
  background: linear-gradient(135deg, rgba(229, 57, 53, 0.08), rgba(255, 100, 100, 0.03));
  font-size: 0.78rem;
}

.note-item-text a,
.note-preview-line a,
.msg-bubble a {
  color: var(--orange-brown);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  word-break: break-all;
}

.note-item-text a:hover,
.note-preview-line a:hover,
.msg-bubble a:hover {
  color: var(--red-primary);
}

.reminder-toggle-btn.active {
  background: linear-gradient(135deg, rgba(229, 57, 53, 0.15), rgba(255, 100, 100, 0.08));
  border-color: #E53935;
  color: #C62828;
  box-shadow: 0 2px 8px rgba(229, 57, 53, 0.15);
}

.reminder-time-select {
  flex: 1;
  padding: 10px 8px;
  border: 2px solid var(--golden-light);
  border-radius: 10px;
  font-family: 'Rubik', sans-serif;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--cream);
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236B3410' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px;
  padding-right: 28px;
}

.reminder-time-select:hover {
  border-color: var(--orange-brown);
}

.reminder-time-select:focus {
  border-color: var(--orange-brown);
  box-shadow: 0 0 0 3px rgba(205, 107, 42, 0.15);
}

/* ========================================================================
   SEARCH
   ======================================================================== */

.search-modal-content {
  max-width: 620px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.search-modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  padding: 16px 20px;
}

.search-input-area {
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-family: 'Rubik', sans-serif;
  font-size: 0.95rem;
  color: var(--text-primary);
  background: var(--cream);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  border-color: var(--orange-brown);
  box-shadow: 0 0 0 3px rgba(205, 107, 42, 0.15);
}

.search-input::placeholder {
  color: var(--brown-light);
  opacity: 0.6;
}

.search-results {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 80px;
}

.search-results-placeholder {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 0;
  font-style: italic;
  font-size: 0.9rem;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.search-result-item:hover {
  background: var(--cell-hover);
}

.search-result-date {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 90px;
  font-weight: 500;
}

.search-result-text {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}

.search-result-type {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 500;
  line-height: 1.4;
}

.search-result-type.note {
  background: rgba(205, 107, 42, 0.12);
  color: var(--brown-medium);
}

.search-result-type.memory {
  background: rgba(212, 160, 48, 0.15);
  color: #8B6E0A;
}

.search-result-type.shared {
  background: rgba(139, 96, 200, 0.12);
  color: #5A2D82;
}

.search-result-type.reminder {
  background: rgba(229, 57, 53, 0.1);
  color: #B71C1C;
}

/* ── Tag badges in notes list ── */
.note-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 2px;
}

.note-tag-badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 500;
  background: var(--orange-brown);
  color: #fff;
  padding: 2px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.note-tag-badge:hover { background: var(--brown-medium); }

/* ── Search controls ── */
.search-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 8px 0 4px;
  flex-wrap: wrap;
}

.search-memories-btn {
  font-size: 0.78rem;
  padding: 4px 12px;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s;
}

.search-memories-btn.active {
  background: var(--orange-brown);
  color: #fff;
  border-color: var(--orange-brown);
}

.search-memories-btn:hover { opacity: 0.85; }

.search-tag-filter {
  position: relative;
  flex: 1;
  min-width: 120px;
}

.search-tag-input {
  width: 100%;
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-family: 'Rubik', sans-serif;
  font-size: 0.88rem;
  color: var(--text-primary);
  background: var(--cream);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-tag-input:focus {
  border-color: var(--orange-brown);
  box-shadow: 0 0 0 3px rgba(205, 107, 42, 0.15);
}

.search-tag-input::placeholder {
  color: var(--brown-light);
  opacity: 0.6;
}

.search-tag-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-container);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 160px;
  overflow-y: auto;
  z-index: 30;
  margin-top: 2px;
  box-shadow: 0 4px 12px var(--shadow);
}

.search-tag-dropdown-item {
  padding: 5px 12px;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--text-primary);
}

.search-tag-dropdown-item:hover { background: var(--cell-hover); }

/* ── Inline hashtag links ── */
.note-hashtag {
  color: var(--orange-brown);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}

.note-hashtag:hover {
  text-decoration: underline;
}

@media (max-width: 768px) {
  .search-modal-content {
    max-height: 90vh;
  }

  .search-modal-body {
    padding: 12px 14px;
  }

  .search-result-item {
    flex-wrap: wrap;
    gap: 4px 8px;
    padding: 8px 10px;
  }

  .search-result-date {
    min-width: 70px;
    font-size: 0.72rem;
  }

  .search-result-text {
    font-size: 0.82rem;
    min-width: 0;
    flex-basis: 100%;
    order: 1;
  }

  .search-result-type {
    font-size: 0.65rem;
  }
}