:root {
  --ink: #0b1120;
  --panel: #111827;
  --soft: #1f2937;
  --line: rgba(255, 255, 255, 0.1);
  --muted: #94a3b8;
  --muted-2: #64748b;
  --text: #f8fafc;
  --accent: #10b981;
  --accent-soft: rgba(16, 185, 129, 0.1);
  --calm: #38bdf8;
  --danger: #ef4444;
  --radius-xl: 18px;
  --radius-2xl: 24px;
  --radius-3xl: 28px;
  --shadow-glow: 0 20px 80px rgba(56, 189, 248, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  transition-duration: 180ms;
  transition-property: background-color, border-color, box-shadow, color, opacity, transform;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0) scale(0.98);
}

button:focus-visible {
  outline: 3px solid rgba(16, 185, 129, 0.22);
  outline-offset: 2px;
}

[contenteditable='true']:focus-visible {
  outline: none;
}

svg {
  display: block;
  width: 1em;
  height: 1em;
}

[contenteditable='true']:empty::before {
  color: var(--muted-2);
  content: attr(data-placeholder);
}

@keyframes drift {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(18px, 24px, 0) scale(1.08); }
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes modal-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(10px) scale(0.98); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes content-refresh {
  from { opacity: 0.35; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes login-breathe {
  0%, 100% { box-shadow: var(--shadow-glow); }
  50% { box-shadow: 0 22px 90px rgba(16, 185, 129, 0.1); }
}

@keyframes calendar-month-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.hidden {
  display: none !important;
}

.flex {
  display: flex !important;
}

.background-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}

.glow {
  position: absolute;
  border-radius: 999px;
  filter: blur(64px);
  animation: drift 14s ease-in-out infinite;
}

.glow-primary {
  left: 50%;
  top: -160px;
  width: 420px;
  height: 420px;
  background: rgba(16, 185, 129, 0.15);
}

.glow-secondary {
  right: -120px;
  bottom: -180px;
  width: 360px;
  height: 360px;
  background: rgba(56, 189, 248, 0.1);
  animation-delay: 2s;
}

.page-shell {
  max-width: 1024px;
  margin: 0 auto;
  padding: 20px 16px;
}

.surface {
  border: 1px solid var(--line);
  border-radius: var(--radius-3xl);
  background: rgba(17, 24, 39, 0.85);
  box-shadow: var(--shadow-glow);
  backdrop-filter: blur(16px);
}

.animate-rise {
  animation: rise-in 520ms ease-out both;
}

.delay-1 {
  animation-delay: 80ms;
}

.delay-2 {
  animation-delay: 160ms;
}

.calendar-panel {
  width: min(100%, 330px);
  margin: 0 auto;
  padding: 16px;
  align-self: flex-start;
}

.calendar-header,
.date-row,
.modal-header,
.entry-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.calendar-header {
  margin-bottom: 20px;
}

.section-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.month-title {
  margin: 0;
  color: #fff;
  font-size: 18px;
  font-weight: 650;
  white-space: nowrap;
}

.month-controls {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
}

.close-button {
  display: grid;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  font-size: 20px;
}

.close-button:hover {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.icon-button:hover,
.ghost-button:hover,
.format-button:hover,
.calendar-today:hover {
  background: rgba(255, 255, 255, 0.1);
}

.weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.weekdays {
  color: var(--muted-2);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.calendar-grid {
  margin-top: 12px;
}

.calendar-grid.is-switching-month {
  animation: calendar-month-in 240ms ease-out both;
}

.calendar-spacer,
.calendar-day {
  aspect-ratio: 1;
}

.calendar-day {
  position: relative;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  font-size: 14px;
  font-weight: 650;
}

.calendar-day:hover {
  background: rgba(255, 255, 255, 0.1);
}

.calendar-day.is-selected {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 30px rgba(16, 185, 129, 0.2);
}

.calendar-day.is-today {
  border-color: rgba(16, 185, 129, 0.7);
  background: transparent;
  color: #a7f3d0;
}

.calendar-day.has-entries {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.calendar-today {
  width: 100%;
  margin-top: 20px;
}

.content-column {
  width: min(100%, 896px);
  margin: 24px auto 0;
}

.content-column.is-refreshing .date-panel,
.content-column.is-refreshing .feed-panel {
  animation: content-refresh 260ms ease-out both;
}

.content-column.is-refreshing .feed-panel {
  animation-delay: 45ms;
}

.content-column > * + * {
  margin-top: 24px;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding-block: 32px;
}

.login-card {
  width: min(100%, 390px);
  padding: 24px;
  animation: rise-in 520ms ease-out both, login-breathe 6s ease-in-out infinite;
}

.login-header {
  margin-bottom: 24px;
}

.login-title {
  margin: 6px 0 0;
  color: #fff;
  font-size: clamp(26px, 7vw, 34px);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.login-subtitle {
  margin: 10px 0 0;
  color: var(--muted-2);
  font-size: 15px;
  line-height: 1.55;
}

.login-form {
  margin: 0;
}

.login-field + .login-field {
  margin-top: 16px;
}

.login-field {
  position: relative;
}

.login-field-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  color: var(--muted-2);
  font-size: 19px;
  pointer-events: none;
  transform: translateY(-50%);
  transition: color 180ms ease, transform 180ms ease;
}

.login-field:focus-within .login-field-icon {
  color: #a7f3d0;
  transform: translateY(-50%) scale(1.04);
}

.login-label {
  display: block;
  margin-bottom: 8px;
  color: #cbd5e1;
  font-size: 14px;
  font-weight: 700;
}

.login-input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  outline: none;
  padding: 0 16px 0 48px;
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.login-input::placeholder {
  color: var(--muted-2);
}

.login-input:focus {
  border-color: rgba(16, 185, 129, 0.45);
  background: rgba(31, 41, 55, 0.72);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.08);
}

.login-error {
  display: none;
  margin: 18px 0 0;
  border: 1px solid rgba(248, 113, 113, 0.24);
  border-radius: 16px;
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  padding: 12px 14px;
  font-size: 14px;
}

.login-error.visible {
  display: block;
}

.login-submit {
  width: 100%;
  margin-top: 22px;
  padding-block: 14px;
}

.date-panel,
.feed-panel {
  padding: 20px;
}

.selected-date {
  margin: 0;
  color: #fff;
  font-size: clamp(24px, 4vw, 30px);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.add-entry-button {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 16px;
  background: var(--accent-soft);
  color: #a7f3d0;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
}

.add-entry-button:hover {
  border-color: rgba(16, 185, 129, 0.5);
  background: rgba(16, 185, 129, 0.15);
}

.add-entry-plus {
  color: var(--accent);
  font-size: 20px;
  line-height: 1;
}

.feed-header {
  margin-bottom: 16px;
}

.feed-header h3,
.modal-header h3,
.confirm-content h3 {
  margin: 0;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
}

.feed-header p,
.modal-footer p,
.confirm-content p,
.empty-text {
  margin: 6px 0 0;
  color: var(--muted-2);
  font-size: 14px;
}

.entries-list > * + * {
  margin-top: 12px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  padding: 32px 16px;
  text-align: center;
}

.empty-title {
  margin: 0;
  color: #cbd5e1;
  font-size: 16px;
  font-weight: 650;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: rgba(11, 17, 32, 0.8);
  backdrop-filter: blur(10px);
}

#confirmDeleteModal {
  z-index: 60;
}

.modal-layer {
  animation: fade-in 180ms ease-out both;
}

.modal-layer.is-closing {
  animation: fade-out 180ms ease-out both;
}

.modal-panel {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-3xl);
  background: var(--panel);
  box-shadow: var(--shadow-glow);
  animation: modal-in 220ms ease-out both;
}

.modal-layer.is-closing .modal-panel {
  animation: modal-out 180ms ease-out both;
}

.modal-header {
  margin-bottom: 28px;
}

.editor-modal {
  display: flex;
  max-height: calc(100vh - 48px);
  max-width: 896px;
  flex-direction: column;
  padding: 24px;
}

.confirm-modal {
  max-width: 448px;
  padding: 24px;
}

.toolbar {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(31, 41, 55, 0.7);
  padding: 8px;
}

.format-button,
.ghost-button {
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: #e2e8f0;
  padding: 8px 12px;
  font-size: 14px;
}

.format-bold {
  font-weight: 800;
}

.format-italic {
  font-style: italic;
}

.format-underline {
  text-decoration: underline;
}

.format-button.is-active {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.15);
  color: #d1fae5;
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.3);
}

.format-group {
  position: relative;
}

.format-menu {
  position: absolute;
  left: 0;
  top: 100%;
  z-index: 10;
  width: 144px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow-glow);
  opacity: 0;
  padding: 8px;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.format-group:hover .format-menu,
.format-group:focus-within .format-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.format-menu-button {
  display: block;
  width: 100%;
  text-align: left;
}

.format-menu-button.is-active {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.15);
  color: #d1fae5;
}

.color-format-group {
  margin-left: auto;
}

.color-menu {
  right: 0;
  left: auto;
  width: 170px;
}

.color-option {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: #e2e8f0;
  padding: 8px 10px;
  text-align: left;
}

.color-option:hover {
  background: rgba(255, 255, 255, 0.1);
}

.color-option span {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: var(--preset-color);
}

.entry-editor {
  scrollbar-color: rgba(16, 185, 129, 0.45) rgba(255, 255, 255, 0.04);
  scrollbar-width: thin;
  overflow-y: auto;
  min-height: 192px;
  max-height: min(52vh, 520px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(31, 41, 55, 0.8);
  color: var(--text);
  font-size: 16px;
  line-height: 1.75;
  outline: none;
  padding: 12px 16px;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.entry-editor::-webkit-scrollbar {
  width: 10px;
}

.entry-editor::-webkit-scrollbar-track {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}

.entry-editor::-webkit-scrollbar-thumb {
  border: 2px solid rgba(31, 41, 55, 0.85);
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.45);
}

.entry-editor::-webkit-scrollbar-thumb:hover {
  background: rgba(16, 185, 129, 0.7);
}

.entry-editor:focus {
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: none;
}

.entry-editor ul,
.entry-text ul {
  margin: 0 0 0 18px;
  padding-left: 16px;
  list-style: disc;
}

.entry-editor li.list-level-2,
.entry-text li.list-level-2 {
  margin-left: 24px;
  list-style-type: circle;
}

.entry-editor ol,
.entry-text ol {
  margin: 0 0 0 18px;
  padding-left: 16px;
  list-style: decimal;
}

.entry-editor li,
.entry-text li {
  margin: 0;
  padding-left: 2px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.primary-button,
.danger-button {
  border: 0;
  border-radius: 16px;
  color: #fff;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 700;
}

.primary-button {
  background: var(--accent);
}

.primary-button:hover {
  background: #10b981;
  box-shadow: 0 10px 26px rgba(16, 185, 129, 0.18);
}

.danger-button {
  background: rgba(239, 68, 68, 0.9);
}

.danger-button:hover {
  background: var(--danger);
}

.ghost-button {
  border-color: var(--line);
  color: #cbd5e1;
}

.confirm-content {
  display: flex;
  gap: 16px;
}

.danger-icon {
  display: grid;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(248, 113, 113, 0.2);
  border-radius: 16px;
  background: rgba(248, 113, 113, 0.1);
  color: #fca5a5;
  font-size: 20px;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.entry-card {
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(31, 41, 55, 0.7);
  padding: 16px;
  animation: rise-in 360ms ease-out both;
  transition: background-color 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.entry-card.no-animation {
  animation: none;
}

.entry-card:hover {
  border-color: rgba(16, 185, 129, 0.25);
  background: var(--soft);
  transform: translateY(-2px);
}

.entry-time {
  color: var(--muted);
  font-size: 14px;
}

.delete-entry {
  display: grid;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
}

.delete-entry:hover {
  border-color: rgba(248, 113, 113, 0.3);
  background: rgba(248, 113, 113, 0.1);
  color: #fca5a5;
}

.entry-text {
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 16px;
  line-height: 1.75;
}

@media (min-width: 1280px) {
  .calendar-panel {
    position: fixed;
    left: 20px;
    top: 20px;
    width: 310px;
    margin: 0;
  }

  .content-column {
    margin-top: 0;
  }
}

@media (min-width: 640px) {
  .page-shell {
    padding-inline: 24px;
  }

  .date-panel,
  .feed-panel {
    padding: 24px;
  }
}

@media (max-width: 640px) {
  .date-row,
  .modal-footer,
  .confirm-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .add-entry-button,
  .primary-button,
  .danger-button,
  .ghost-button {
    justify-content: center;
    width: 100%;
  }

  .color-format-group {
    margin-left: 0;
  }

  .color-menu {
    right: auto;
    left: 0;
  }

  .confirm-actions {
    flex-direction: column-reverse;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
