/* ===== Journal View — Tinder-style ===== */
.view-journal {
  flex-direction: column;
  height: 100%;
}

.journal-scroll {
  flex: 1;
  overflow: hidden;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

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

.journal-view-title {
  font-size: 20px;
  font-weight: 700;
}

.journal-save-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.save-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--status-online);
}

.save-dot.unsaved {
  background: #F59E0B;
}

/* ===== 2-Column Layout (CSS Grid) ===== */
.journal-columns {
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: auto 1fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
}

.journal-col-left {
  grid-column: 1;
  grid-row: 1;
}

.journal-col-right {
  grid-column: 2;
  grid-row: 1 / -1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.journal-list-section {
  grid-column: 1;
  grid-row: 2;
  margin-top: 0;
  min-height: 0;
}

/* ===== Calendar Card ===== */
.journal-calendar-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

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

.journal-cal-month {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.journal-cal-nav {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--radius);
  transition: all 150ms;
}

.journal-cal-nav:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.journal-cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

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

.journal-cal-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-secondary);
  border-radius: var(--radius);
  cursor: default;
  position: relative;
  min-height: 36px;
}

.journal-cal-day.other-month {
  color: var(--text-muted);
  opacity: 0.4;
}

.journal-cal-day.today {
  background: var(--accent);
  color: white;
  font-weight: 700;
  border-radius: var(--radius-full);
  cursor: pointer;
}

.journal-cal-day.has-journal {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-primary);
}

.journal-cal-day.has-journal:hover {
  background: var(--bg-hover);
}

.journal-cal-day.today.has-journal:hover {
  background: var(--accent);
  opacity: 0.9;
}

.journal-cal-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 2px;
}

.journal-cal-day.today .journal-cal-dot {
  background: white;
}

/* ===== Routine Toggle Card ===== */
.journal-routine-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  transition: all 200ms ease;
}

.journal-routine-card:hover {
  box-shadow: var(--shadow-card);
}

.journal-routine-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.journal-routine-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.journal-routine-icon {
  font-size: 20px;
}

.journal-routine-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.journal-routine-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}

.journal-routine-agent {
  font-weight: 600;
  color: var(--agent-sori-name, var(--accent));
}

.journal-routine-sep {
  color: var(--text-muted);
}

.journal-routine-time {
  color: var(--text-secondary);
}

/* Schedule picker */
.journal-routine-schedule {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light, var(--border));
}

.journal-routine-schedule-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.journal-routine-range-label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.journal-routine-schedule-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.journal-routine-time-picker {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 드롭다운: routine-form-select 클래스 재사용 (routine.css)
   journal-routine-select로 width/padding 오버라이드 */
.journal-routine-select {
  width: auto;
  min-width: 56px;
  padding: 8px 12px;
}

.journal-routine-time-sep {
  font-weight: 600;
  color: var(--text-muted);
}

/* ===== Editor Card ===== */
.journal-editor-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.journal-date-row {
  padding: 14px 16px 0;
}

.journal-date {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.journal-editor-wrap {
  padding: 12px 16px;
  padding-bottom: calc(12px + env(keyboard-inset-height, 0px));
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  transition: padding-bottom 200ms ease;
}

.journal-rendered {
  min-height: 200px;
  cursor: text;
}

.journal-rendered:empty::before {
  content: "오늘 하루를 기록해보세요...";
  color: var(--text-muted);
}

.journal-editor {
  width: 100%;
  min-height: 300px;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font-family);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-primary);
  background: transparent;
}

.journal-editor::placeholder {
  color: var(--text-muted);
}

.journal-edit-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-hover);
  border-radius: var(--radius);
}

.journal-card-actions {
  padding: 12px 16px;
  border-top: 1px solid var(--border-light, var(--border));
}

.journal-delegate-btn {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: var(--radius-full);
  background: var(--accent-pink-light, #FFF1F2);
  color: var(--accent-pink, #EC4899);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: all 150ms ease;
}

.journal-delegate-btn:hover {
  background: var(--accent-pink, #EC4899);
  color: white;
}

/* ===== Journal List ===== */
.journal-list-scroll {
  max-height: 400px;
  overflow-y: auto;
  border-radius: var(--radius-xl);
}

.journal-list-sentinel {
  text-align: center;
  padding: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.journal-list-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.journal-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 200ms ease;
  box-shadow: var(--shadow-sm);
}

.journal-list-item:hover {
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
}

.journal-list-item-info {
  flex: 1;
  min-width: 0;
}

.journal-list-item-date {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.journal-list-item-preview {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.journal-list-item-arrow {
  font-size: 12px;
  color: var(--text-muted);
}

.journal-list-empty {
  text-align: center;
  padding: 24px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ===== Journal Viewer Modal ===== */
.journal-viewer-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 200ms ease;
}

.journal-viewer-panel {
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  background: var(--bg-primary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -4px 30px rgba(0,0,0,0.15);
  animation: slideUp 250ms ease;
}

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

.journal-viewer-date {
  font-size: 16px;
  font-weight: 700;
}

.journal-viewer-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: all 150ms;
}

.journal-viewer-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.journal-viewer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  line-height: 1.7;
}

@media (min-width: 768px) {
  .journal-viewer-modal {
    align-items: center;
  }
  .journal-viewer-panel {
    border-radius: var(--radius-xl);
    max-height: 70vh;
  }
}

/* ===== Journal Mobile ===== */
@media (max-width: 767px) {
  .journal-scroll {
    padding: 14px;
    overflow-y: auto;
    display: block;
  }

  .journal-columns {
    display: flex;
    flex-direction: column;
  }

  .journal-col-left {
    width: 100%;
    order: 0;
  }

  .journal-col-right {
    order: 1;
  }

  /* 지난 일지를 모바일에서 최하단 배치 */
  .journal-list-section {
    order: 2;
  }

  .journal-editor-wrap {
    padding: 10px 14px;
  }

  .journal-editor {
    font-size: 16px; /* iOS 줌 방지 */
  }

  .journal-card-actions {
    padding: 10px 14px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
}
