/* journal-overview.css */

.journal-overview-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  background-color: #f8f9fa;
}

/* Journal Header Top */
.journal-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.journal-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.month-nav-btn {
  background: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.2s;
}

.month-nav-btn:hover {
  background: #0056b3;
}

.month-nav-btn:disabled {
  background: #6c757d;
  cursor: not-allowed;
}

.current-month {
  font-size: 1rem;
  font-weight: 500;
  color: #495057;
  min-width: 100px;
  text-align: center;
}

.journal-summary-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 16px 0;
  flex-shrink: 0;
}

.journal-summary-controls {
  display: inline-flex;
  align-self: center;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(44, 62, 80, 0.08);
  box-shadow: 0 8px 24px rgba(44, 62, 80, 0.08);
}

.journal-current-month {
  font-size: 1.05rem;
  font-weight: 700;
  color: #2c3e50;
  letter-spacing: 0.02em;
}

.journal-summary-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.journal-summary-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(247, 249, 252, 0.98) 100%);
  border: 1px solid rgba(44, 62, 80, 0.08);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 10px 24px rgba(44, 62, 80, 0.08);
}

.journal-summary-card__label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7a8a9a;
  margin-bottom: 8px;
}

.journal-summary-card__value {
  font-size: 1.55rem;
  line-height: 1;
  font-weight: 800;
  color: #243447;
}

.journal-summary-card__compare {
  display: block;
  margin-top: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #94a3b8;
}

.journal-summary-card__compare-delta--positive {
  color: #dc2626;
}

.journal-summary-card__compare-delta--negative {
  color: #16a34a;
}

.journal-summary-card__compare-delta--neutral {
  color: #94a3b8;
}

.journal-summary-card--score .journal-summary-card__value {
  color: #3757c8;
}

.journal-summary-card--recorded .journal-summary-card__value {
  color: #2c3e50;
}

.journal-summary-card--keep .journal-summary-card__value {
  color: #1f8f52;
}

.journal-summary-card--try .journal-summary-card__value {
  color: #1c73e8;
}

/* Main Content */
.journal-main-content {
  display: flex;
  flex: 1;
  gap: 1rem;
  padding: 20px 1rem 1rem;
  overflow: hidden;
  min-height: 0;
  justify-content: center;
  align-items: flex-start;
}

/* Left Column */
.journal-left-column {
  flex: 0 1 auto;
  width: 100%;
  min-width: 0; /* Allow flex item to shrink below content size */
  width: max-content;
  max-width: 100%;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.journal-entries-container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: max-content;
  max-width: 100%;
}

.journal-entries-header {
  padding: 0.5rem;
  border-bottom: 1px solid #e9ecef;
  background: #f8f9fa;
}

.journal-entries-header h2 {
  margin: 0 0 0.5rem 0;
  color: #2c3e50;
  font-size: 1.1rem;
  font-weight: 500;
}

.journal-entries-labels {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0;
  border-bottom: 1px solid #e9ecef;
  font-size: 0.75rem;
  font-weight: 600;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.journal-label-date {
  width: 45px;
  text-align: center;
}

.journal-label-routines {
  flex: 1;
  color: #44546a;
}

.journal-label-highlights {
  width: 36%;
  color: #8a6d1d;
}

.journal-label-rate {
  width: 56px;
  text-align: center;
  color: #49627a;
}

.journal-label-keep {
  flex: 1;
  color: #28a745;
}

.journal-label-problem {
  flex: 1;
  color: #dc3545;
}

.journal-label-try {
  flex: 1;
  color: #007bff;
}

.journal-entries-list {
  flex: 1;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow-y: hidden;
  overflow-x: hidden;
  min-height: 0; /* Allow flex item to shrink */
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.journal-entries-list::-webkit-scrollbar,
.journal-activity-grid::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.journal-entries-list::-webkit-scrollbar-thumb,
.journal-activity-grid::-webkit-scrollbar-thumb {
  background: rgba(44, 62, 80, 0.18);
  border-radius: 999px;
}

.journal-entries-list::-webkit-scrollbar-track,
.journal-activity-grid::-webkit-scrollbar-track {
  background: transparent;
}

.journal-review-matrix-shell {
  --journal-review-header-height: 96px;
  --journal-review-row-height: 24px;
  width: max-content;
  max-width: 100%;
  min-width: 0;
  padding: 0;
}

.journal-review-routine-empty {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #e7edf3;
  background: #f8fafc;
  color: #6b7c8f;
  font-size: 0.78rem;
  font-weight: 600;
}

.journal-review-matrix {
  width: max-content;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  background: #ffffff;
}

.journal-review-day-col {
  width: 34px;
}

.journal-review-routine-col {
  width: 30px;
}

.journal-review-add-col {
  width: 36px;
}

.journal-review-rate-col {
  width: 42px;
}

.journal-review-highlight-col {
  width: 420px;
}

.journal-review-matrix th,
.journal-review-matrix td {
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
}

.journal-review-day-header,
.journal-review-day-cell {
  width: 34px;
  min-width: 34px;
  text-align: center;
  background: #f8fafc;
  color: #3f4b5b;
  font-weight: 700;
}

.journal-review-day-header {
  height: var(--journal-review-header-height);
  font-size: 0.66rem;
  text-transform: uppercase;
}

.journal-review-routine-group-header,
.journal-review-highlight-group-header {
  height: 32px;
  background: #eef3f8;
  color: #344054;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.journal-review-highlight-group-header {
  background: #fff7dd;
  color: #775b13;
}

.journal-review-routine-header {
  position: relative;
  width: 30px;
  min-width: 30px;
  height: var(--journal-review-header-height);
  padding: 7px 2px 19px;
  vertical-align: bottom;
  cursor: grab;
  user-select: none;
  transition: opacity 0.14s ease, transform 0.14s ease, box-shadow 0.14s ease;
}

.journal-review-routine-header:active {
  cursor: grabbing;
}

.journal-review-routine-header.is-dragging {
  opacity: 0.54;
  transform: scale(0.98);
}

.journal-review-routine-header.is-drop-before::before,
.journal-review-routine-header.is-drop-after::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  z-index: 4;
  width: 3px;
  border-radius: 999px;
  background: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
}

.journal-review-routine-header.is-drop-before::before {
  left: -2px;
}

.journal-review-routine-header.is-drop-after::before {
  right: -2px;
}

.journal-review-routine-label {
  display: inline-block;
  max-height: 72px;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.72rem;
  line-height: 1;
  font-weight: 800;
}

.journal-review-routine-remove {
  position: absolute;
  top: 5px;
  left: 50%;
  width: 17px;
  height: 17px;
  padding: 0;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  box-shadow:
    0 3px 8px rgba(15, 23, 42, 0.12),
    inset 0 0 0 1px rgba(255, 255, 255, 0.62);
  color: #334155;
  cursor: pointer;
  font-size: 0;
  line-height: 1;
  opacity: 0;
  transform: translate(-50%, -3px) scale(0.9);
  transition:
    opacity 0.14s ease,
    transform 0.14s ease,
    background-color 0.14s ease,
    border-color 0.14s ease,
    color 0.14s ease;
}

.journal-review-routine-remove::before,
.journal-review-routine-remove::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 1.5px;
  border-radius: 999px;
  background: currentColor;
  transform-origin: center;
}

.journal-review-routine-remove::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.journal-review-routine-remove::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.journal-review-routine-header:hover .journal-review-routine-remove,
.journal-review-routine-remove:focus-visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.journal-review-routine-remove:hover {
  border-color: rgba(220, 38, 38, 0.28);
  background: #fff5f5;
  color: #dc2626;
}

.journal-review-add-routine-header,
.journal-review-add-routine-cell {
  width: 36px;
  min-width: 36px;
  background: #f8fafc;
  text-align: center;
}

.journal-review-add-routine-header {
  height: var(--journal-review-header-height);
}

.journal-review-add-routine-cell {
  height: var(--journal-review-row-height);
  cursor: pointer;
}

.journal-review-rate-header,
.journal-review-rate-cell {
  width: 42px;
  min-width: 42px;
  text-align: center;
  background: #f5fbfa;
}

.journal-review-rate-header {
  height: var(--journal-review-header-height);
  color: #246b70;
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
  box-shadow: inset 1px 0 0 rgba(36, 107, 112, 0.06);
}

.journal-review-add-routine-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid #c8d4e2;
  border-radius: 50%;
  background: #ffffff;
  color: #31516f;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1;
}

.journal-review-add-routine-btn.compact {
  width: 26px;
  height: 26px;
  font-size: 1rem;
}

.journal-review-add-routine-btn:hover {
  background: #eaf2fb;
  border-color: #7ea7d8;
}

.journal-review-highlight-header {
  position: relative;
  height: var(--journal-review-header-height);
  padding: 0 12px;
  background: #fffaf0;
  color: #7b5f1d;
  text-align: center;
  font-size: 0.75rem;
}

.journal-review-highlight-title {
  display: inline-block;
  font-weight: 700;
}

.journal-review-month-nav {
  position: absolute;
  right: 10px;
  top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #25313d;
}

.journal-review-month-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(44, 62, 80, 0.14);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: #25384c;
  cursor: pointer;
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(36, 52, 71, 0.12);
  transition: box-shadow 0.16s ease, opacity 0.16s ease, background-color 0.16s ease;
}

.journal-review-month-btn:hover:not(:disabled),
.journal-review-month-btn:focus-visible:not(:disabled) {
  box-shadow: 0 12px 24px rgba(36, 52, 71, 0.16);
  outline: none;
}

.journal-review-month-btn:disabled {
  opacity: 0.36;
  cursor: not-allowed;
}

.journal-review-month-label {
  min-width: 112px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 800;
  color: #10243b;
  white-space: nowrap;
}

.journal-review-row {
  transition: background-color 0.16s;
}

.journal-review-row:hover {
  background: #f8fbff;
}

.journal-review-row.is-today {
  background: linear-gradient(90deg, rgba(64, 131, 191, 0.12), rgba(64, 131, 191, 0.045) 44%, rgba(255, 255, 255, 0.98));
  box-shadow: inset 3px 0 0 rgba(64, 131, 191, 0.38);
}

.journal-review-row.is-today:hover {
  background: linear-gradient(90deg, rgba(64, 131, 191, 0.16), rgba(64, 131, 191, 0.06) 44%, rgba(248, 251, 255, 0.98));
}

.journal-review-row.is-today .journal-review-day-cell {
  background: #eaf4ff;
  color: #1f5f99;
  font-weight: 900;
}

.journal-review-day-cell {
  height: var(--journal-review-row-height);
  font-size: 0.82rem;
}

.journal-review-routine-cell {
  position: relative;
  width: 30px;
  min-width: 30px;
  height: var(--journal-review-row-height);
  text-align: center;
  color: #273443;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 800;
  overflow: visible;
  cursor: pointer;
}

.journal-review-routine-fill {
  position: absolute;
  top: 3px;
  right: 6px;
  bottom: 3px;
  left: 6px;
  z-index: 1;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.04)),
    var(--routine-color, #94a3b8);
  box-shadow:
    inset 1px 0 0 rgba(255, 255, 255, 0.32),
    inset -1px 0 0 rgba(15, 23, 42, 0.16),
    0 0 0 1px rgba(15, 23, 42, 0.06);
  pointer-events: none;
}

.journal-review-routine-cell.is-streak .journal-review-routine-fill {
  top: -1px;
  bottom: -1px;
  border-radius: 0;
  box-shadow:
    inset 1px 0 0 rgba(255, 255, 255, 0.32),
    inset -1px 0 0 rgba(15, 23, 42, 0.16);
}

.journal-review-routine-cell.is-streak-start .journal-review-routine-fill {
  top: 3px;
  border-top-left-radius: 999px;
  border-top-right-radius: 999px;
}

.journal-review-routine-cell.is-streak-end .journal-review-routine-fill {
  bottom: 3px;
  border-bottom-left-radius: 999px;
  border-bottom-right-radius: 999px;
}

.journal-review-routine-cell.is-streak-start.is-streak-end .journal-review-routine-fill {
  top: 3px;
  bottom: 3px;
  border-radius: 999px;
}

.journal-review-rate-cell {
  height: var(--journal-review-row-height);
  color: #246b70;
  font-size: 0.74rem;
  font-weight: 800;
  box-shadow: inset 1px 0 0 rgba(36, 107, 112, 0.06);
  cursor: pointer;
}

.journal-review-rate-cell.has-rate {
  background: #eef8f6;
  color: #164f55;
  font-weight: 800;
}

.journal-review-highlight-cell {
  height: var(--journal-review-row-height);
  padding: 0 12px;
  color: #52616f;
  font-size: 0.78rem;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.journal-review-highlight-cell.has-highlight {
  color: #2f3d4a;
}

.journal-routine-picker {
  position: fixed;
  z-index: 1200;
  width: 220px;
  max-height: 260px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid #d7e0ea;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 16px 40px rgba(30, 41, 59, 0.18);
}

.journal-routine-picker-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #334155;
  cursor: pointer;
  text-align: left;
  font-size: 0.82rem;
  font-weight: 700;
}

.journal-routine-picker-option:hover {
  background: #f1f5f9;
}

.journal-routine-picker-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(15, 23, 42, 0.14);
  flex-shrink: 0;
}

.journal-routine-picker-empty {
  padding: 10px;
  color: #718096;
  font-size: 0.8rem;
}

/* Journal Entry Item */
.journal-entry-item {
  display: flex;
  border-bottom: 1px solid #e9ecef;
  transition: background-color 0.2s, box-shadow 0.2s, transform 0.2s;
  cursor: pointer;
  min-height: 1.8rem;
  align-items: center;
}

.journal-entry-item:hover {
  background-color: #f8f9fa;
}

.journal-entry-item.is-today {
  background: linear-gradient(90deg, rgba(64, 131, 191, 0.12), rgba(64, 131, 191, 0.04) 28%, rgba(255, 255, 255, 0.98) 72%);
  box-shadow: inset 3px 0 0 rgba(64, 131, 191, 0.38);
}

.journal-entry-item.is-today:hover {
  background: linear-gradient(90deg, rgba(64, 131, 191, 0.16), rgba(64, 131, 191, 0.06) 28%, rgba(248, 250, 252, 0.98) 72%);
}

.journal-entry-item.has-entry {
  background:
    linear-gradient(90deg, rgba(91, 141, 239, 0.04) 0%, rgba(91, 141, 239, 0.015) 24%, rgba(255, 255, 255, 0.98) 70%);
}

.journal-entry-item.has-entry:hover {
  background:
    linear-gradient(90deg, rgba(91, 141, 239, 0.08) 0%, rgba(91, 141, 239, 0.03) 28%, rgba(248, 250, 252, 0.98) 70%);
  box-shadow: inset 0 0 0 1px rgba(91, 141, 239, 0.08);
}

.journal-entry-item.is-high-score {
  background:
    linear-gradient(90deg, rgba(31, 111, 98, 0.08) 0%, rgba(31, 111, 98, 0.03) 28%, rgba(255, 255, 255, 0.98) 70%);
}

.journal-entry-item.is-high-score:hover {
  background:
    linear-gradient(90deg, rgba(31, 111, 98, 0.12) 0%, rgba(31, 111, 98, 0.05) 28%, rgba(248, 250, 252, 0.98) 70%);
}

.journal-entry-item.is-low-score {
  background:
    linear-gradient(90deg, rgba(220, 53, 69, 0.08) 0%, rgba(220, 53, 69, 0.03) 28%, rgba(255, 255, 255, 0.98) 70%);
}

.journal-entry-item.is-low-score:hover {
  background:
    linear-gradient(90deg, rgba(220, 53, 69, 0.12) 0%, rgba(220, 53, 69, 0.05) 28%, rgba(248, 250, 252, 0.98) 70%);
}

.journal-entry-item:last-child {
  border-bottom: none;
}

.journal-entry-date {
  width: 45px;
  padding: 0.3rem 0.2rem;
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #495057;
  border-right: 1px solid #e9ecef;
  font-size: 0.9rem;
  min-height: 1.22rem;
  flex-shrink: 0; /* Prevent date column from shrinking */
}

.journal-entry-item.is-today .journal-entry-date {
  background: #eaf4ff;
  color: #1f5f99;
  font-weight: 900;
}

.journal-entry-date.has-entry {
  background: linear-gradient(180deg, #ffffff 0%, #f3f7fb 100%);
}

.journal-entry-date.is-high-score {
  background: linear-gradient(180deg, #f2fbf8 0%, #e0f4ee 100%);
  color: #1f6f62;
}

.journal-entry-date.is-low-score {
  background: linear-gradient(180deg, #fff5f5 0%, #fde8e8 100%);
  color: #b54747;
}

.journal-entry-content {
  /* width: 600px; */
  width: 100%;
  padding: 0.3rem 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0; /* Prevent content area from shrinking */
}

.journal-entry-rate-cell {
  width: 56px;
  min-width: 56px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
}

.journal-entry-rate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef2f6;
  color: #5a6a7a;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.journal-entry-rate.compact {
  min-width: 34px;
  min-height: 22px;
  padding: 0 6px;
}

.journal-entry-rate.empty {
  background: #f3f5f7;
  color: #9aa7b4;
}

.journal-entry-rate.is-low {
  background: #fdecec;
  color: #b54747;
}

.journal-entry-rate.is-midlow {
  background: #fff1e2;
  color: #b26a2d;
}

.journal-entry-rate.is-mid {
  background: #eef2f6;
  color: #556270;
}

.journal-entry-rate.is-midhigh {
  background: #e8f7f3;
  color: #2f6f62;
}

.journal-entry-rate.is-high {
  background: #e9f2ff;
  color: #1f5e99;
}

.journal-entry-summary {
  display: flex;
  gap: 0.2rem;
  flex: 1;
  overflow: hidden; /* Prevent content from overflowing */
}

.journal-entry-summary-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  width: 100%;
  overflow: hidden; /* Prevent content from overflowing to other columns */
}

.journal-entry-summary-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0; /* Prevent dot from shrinking */
}

.journal-entry-summary-dot.keep {
  background-color: #28a745;
}

.journal-entry-summary-dot.problem {
  background-color: #dc3545;
}

.journal-entry-summary-dot.try {
  background-color: #007bff;
}

.journal-entry-summary-dot.empty {
  background-color: #e9ecef;
}

.journal-entry-summary-text {
  font-size: 0.75rem;
  color: #6c757d;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1; /* Take remaining space after dot */
  min-width: 0; /* Allow text to shrink */
}

.journal-entry-summary-text.empty {
  color: #adb5bd;
  font-style: italic;
}

/* Empty state */
.journal-empty-message {
  padding: 2rem;
  text-align: center;
  color: #6c757d;
  font-style: italic;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Right Column */
.journal-right-column {
  flex: 1;
  min-width: 0; /* Allow flex item to shrink below content size */
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.journal-placeholder {
  text-align: center;
  color: #6c757d;
}

.journal-placeholder h3 {
  margin-bottom: 0.5rem;
  color: #495057;
}

.journal-placeholder p {
  margin: 0;
  font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
  .journal-summary-row {
    padding: 12px 8px 0;
  }

  .journal-summary-controls {
    width: 100%;
    justify-content: center;
  }

  .journal-summary-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .journal-main-content {
    flex-direction: column;
  }

  .journal-header {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  .journal-entry-item {
    flex-direction: column;
  }

  .journal-entry-date {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #e9ecef;
  }
}

/* Modal Styles */
.journal-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.2s ease-out;
}

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

.journal-modal-content {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border-radius: 16px;
  padding: 0;
  max-width: 880px;
  width: 90%;
  height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.25);
  animation: slideUp 0.3s ease-out;
}

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

.journal-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(135deg, #2C3E50 0%, #34495e 100%);
  border-radius: 16px 16px 0 0;
}

.journal-modal-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
}

.journal-modal-close {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 28px;
  cursor: pointer;
  color: #ffffff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
}

.journal-modal-close:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: rotate(90deg);
}

.journal-modal-sections {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(260px, 1fr);
  gap: 14px;
  align-items: stretch;
  padding: 20px;
  flex: 1;
  overflow-y: auto;
}

.journal-modal-section {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.journal-modal-section:last-child {
  margin-bottom: 0;
}

.journal-rate-section {
  grid-column: 1 / -1;
  min-height: 140px;
  gap: 12px;
}

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

.journal-rate-current {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(44, 62, 80, 0.08);
  color: #2c3e50;
}

.journal-rate-current-value {
  font-size: 20px;
  line-height: 1;
}

.journal-rate-current-max {
  font-size: 12px;
  color: #6b7b8c;
}

.journal-rate-scale {
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  gap: 8px;
}

.journal-rate-btn {
  min-height: 38px;
  border: 1px solid #ccd6e0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  color: #425466;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.journal-rate-btn:hover {
  transform: translateY(-1px);
  border-color: #8ca0b6;
  background: #ffffff;
  box-shadow: 0 6px 14px rgba(44, 62, 80, 0.1);
}

.journal-rate-btn.is-active {
  border-color: #2c3e50;
  background: linear-gradient(135deg, #334a62 0%, #45617e 100%);
  color: #ffffff;
  box-shadow: 0 10px 18px rgba(44, 62, 80, 0.18);
}

.journal-rate-hint {
  min-height: 20px;
  color: #5f7183;
  font-size: 13px;
  font-weight: 600;
}

.journal-rate-hint.is-empty {
  color: #7a8896;
}

.journal-rate-hint.is-low {
  color: #b54747;
}

.journal-rate-hint.is-midlow {
  color: #b26a2d;
}

.journal-rate-hint.is-mid {
  color: #556270;
}

.journal-rate-hint.is-midhigh {
  color: #2f6f62;
}

.journal-rate-hint.is-high {
  color: #1f5e99;
}

.journal-modal-section-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 12px;
  color: #495057;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

.journal-modal-section-text {
  color: #495057;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.journal-modal-section-text.empty {
  color: #adb5bd;
  font-style: italic;
}

.journal-modal-section.try {
  grid-column: 2;
  grid-row: 3;
  min-height: 140px;
  border: 1px solid #e1e7ee;
  border-radius: 14px;
  background: #ffffff;
  padding: 14px;
  gap: 12px;
}

.journal-modal-section.keep {
  grid-column: 1 / -1;
  grid-row: 2;
}

.journal-modal-section.problem {
  grid-column: 2;
  grid-row: 2;
}

.journal-modal-section-textarea {
  width: 100%;
  flex: 1;
  min-height: 100px;
  padding: 14px 16px;
  border: 1px solid #dee2e6;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  color: #495057;
  background: #f8f9fa;
  resize: none;
  box-sizing: border-box;
  transition: all 0.2s ease;
}

.journal-modal-section.keep .journal-modal-section-textarea {
  min-height: 320px;
}

.journal-modal-section-textarea:focus {
  outline: none;
  border-color: #2C3E50;
  box-shadow: 0 0 0 4px rgba(44, 62, 80, 0.15), 0 4px 12px rgba(44, 62, 80, 0.1);
  background: #ffffff;
}

.journal-modal-footer {
  padding: 20px 28px;
  border-top: 1px solid #e9ecef;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: linear-gradient(to bottom, #ffffff 0%, #f8f9fa 100%);
  border-radius: 0 0 16px 16px;
}

.journal-modal-save {
  background: linear-gradient(135deg, #2C3E50 0%, #34495e 100%);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 12px 32px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(44, 62, 80, 0.3);
}

.journal-modal-save:hover {
  background: linear-gradient(135deg, #34495e 0%, #2C3E50 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(44, 62, 80, 0.4);
}

.journal-modal-save:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(44, 62, 80, 0.2);
}

/* Responsive Design */
@media (max-width: 768px) {
  .journal-main-content {
    flex-direction: column;
    padding: 0.5rem;
  }

  .journal-header-top {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  .journal-entry-item {
    flex-direction: column;
    align-items: stretch;
  }

  .journal-entry-date {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #e9ecef;
  }

  .journal-entry-content {
    flex-wrap: wrap;
  }

  .journal-entry-rate-cell {
    width: auto;
    min-width: 0;
    justify-content: flex-start;
  }

  .journal-rate-header {
    flex-direction: column;
    align-items: stretch;
  }

  .journal-rate-scale {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .journal-modal-content {
    width: 95%;
    max-width: 600px;
    height: 90vh;
    padding: 0;
  }

  .journal-modal-sections {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
  }

  .journal-rate-section,
  .journal-modal-section.keep,
  .journal-modal-section.problem,
  .journal-modal-section.try {
    grid-column: auto;
    grid-row: auto;
    flex: 0 0 auto;
  }

  .journal-modal-section.keep .journal-modal-section-textarea,
  .journal-modal-section-textarea {
    flex: none;
    height: 120px;
    min-height: 120px;
  }

  .journal-modal-section.keep .journal-modal-section-textarea {
    height: 140px;
  }
}

/* Activity Grid Styles */
.journal-activity-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
  overflow: hidden;
}

.journal-activity-grid {
  flex: 1;
  overflow: auto;
  padding: 0 1rem 1rem;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  background: #ffffff;
}

.activity-grid-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.activity-grid-table th,
.activity-grid-table td {
  padding: 0.305rem 0.2rem;
  text-align: center;
  border: 1px solid #e9ecef;
  min-height: 1.22rem;
}

.activity-grid-table th {
  background-color: #f8f9fa;
  font-weight: 600;
  color: #495057;
  position: sticky;
  top: 0;
  z-index: 10;
}

.activity-grid-date {
  background-color: #f8f9fa;
  font-weight: 600;
  color: #495057;
  width: 45px;
  min-width: 45px;
}

.activity-grid-cell {
  background-color: #fff;
  transition: background-color 0.2s;
  min-height: 1.22rem;
}

.activity-grid-cell.has-activity {
  background-color: #e3f2fd;
  color: #1976d2;
  font-weight: 600;
}

.activity-grid-cell.has-activity::after {
  content: "✕";
  font-size: 0.8rem;
}

.activity-grid-label {
  background-color: #f8f9fa;
  font-weight: 600;
  color: #495057;
  min-width: 60px;
  max-width: 60px;
  min-height: 1.22rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 1024px) and (max-width: 1279px) {
  .journal-summary-row {
    flex-shrink: 0;
    gap: 10px;
    padding: 14px 12px 0;
  }

  .journal-summary-controls {
    padding: 0.5rem 0.85rem;
  }

  .journal-current-month {
    font-size: 0.95rem;
  }

  .journal-summary-metrics {
    gap: 10px;
  }

  .journal-summary-card {
    padding: 12px 14px;
  }

  .journal-summary-card__value {
    font-size: 1.35rem;
  }

  .month-nav-btn {
    padding: 0.32rem 0.7rem;
    font-size: 0.85rem;
  }

  .journal-main-content {
    gap: 0.75rem;
    padding: 0.75rem;
    min-height: 0;
  }

  .journal-left-column,
  .journal-right-column {
    min-height: 0;
  }

  .journal-entries-header {
    padding: 0.4rem 0.5rem;
  }

  .journal-entries-labels {
    font-size: 0.68rem;
    gap: 0.35rem;
  }

  .journal-label-date,
  .journal-label-rate,
  .journal-entry-date,
  .activity-grid-date {
    width: 40px;
    min-width: 40px;
  }

  .journal-entry-rate-cell {
    width: 46px;
    min-width: 46px;
  }

  .journal-entry-rate {
    min-width: 30px;
    min-height: 20px;
    font-size: 0.64rem;
    padding: 0 5px;
  }

  .journal-entry-item {
    min-height: 1.58rem;
  }

  .journal-entry-date {
    padding: 0.2rem 0.15rem;
    font-size: 0.82rem;
  }

  .journal-entry-content {
    padding: 0.2rem 0.35rem;
    gap: 0.35rem;
  }

  .journal-entry-summary-text {
    font-size: 0.68rem;
  }

  .journal-activity-grid {
    padding: 0 0.75rem 0.75rem;
  }

  .activity-grid-table {
    font-size: 0.82rem;
  }

  .activity-grid-table th,
  .activity-grid-table td {
    padding: 0.24rem 0.16rem;
    min-height: 1.08rem;
  }

  .activity-grid-cell,
  .activity-grid-label {
    min-height: 1.08rem;
  }

  .activity-grid-label {
    min-width: 54px;
    max-width: 54px;
  }
}
