:root {
  --stat-card-gradient: linear-gradient(135deg, rgba(30, 75, 43, 0.12), rgba(37, 96, 58, 0.08));
  --stat-card-border: rgba(30, 75, 43, 0.18);
  --chip-bg: rgba(30, 75, 43, 0.12);
  --chip-border: rgba(30, 75, 43, 0.26);
}

html.dark {
  --stat-card-gradient: linear-gradient(135deg, rgba(110, 231, 183, 0.14), rgba(15, 23, 42, 0.6));
  --stat-card-border: rgba(110, 231, 183, 0.28);
  --chip-bg: rgba(148, 163, 184, 0.16);
  --chip-border: rgba(148, 163, 184, 0.28);
}

.app-page main,
.app-page .page-header {
  width: min(1180px, 94%);
}

.app-shell {
  display: grid;
  gap: 2rem;
}

.app-shell--split {
  grid-template-columns: 320px 1fr;
  align-items: flex-start;
}

@media (max-width: 960px) {
  .app-shell--split {
    grid-template-columns: 1fr;
  }
}

.dashboard-hero {
  display: grid;
  gap: 1rem;
}

.dashboard-hero__heading {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.dashboard-hero__heading h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.8rem);
  color: var(--color-primary);
}

.dashboard-hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  color: var(--color-primary);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
}

.stat-card {
  position: relative;
  overflow: hidden;
  background: var(--stat-card-gradient);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  border: 1px solid var(--stat-card-border);
  display: grid;
  gap: 0.65rem;
}

.stat-card h3 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.stat-value {
  font-size: clamp(2.2rem, 4vw, 2.8rem);
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

.stat-trend {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.95rem;
  color: var(--color-text-muted);
}

.quick-actions {
  display: grid;
  gap: 1.5rem;
}

.quick-actions__list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}

.action-card {
  padding: 1.4rem;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(255, 255, 255, 0.6);
  display: grid;
  gap: 0.65rem;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.action-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 24px rgba(15, 23, 42, 0.12);
}

html.dark .action-card {
  background: rgba(15, 23, 42, 0.7);
  border-color: rgba(148, 163, 184, 0.24);
}

.action-card h4 {
  margin: 0;
  font-size: 1.1rem;
}

.recent-list {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}

.recent-empty {
  text-align: center;
  color: var(--color-text-muted);
  padding: 2rem 1rem;
}

.recent-item {
  padding: 1.2rem 1.4rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(255, 255, 255, 0.7);
  display: grid;
  gap: 0.4rem;
  transition: border-color 160ms ease, transform 160ms ease;
}

.recent-item:hover {
  border-color: rgba(30, 75, 43, 0.35);
  transform: translateY(-2px);
}

html.dark .recent-item {
  background: rgba(15, 23, 42, 0.7);
  border-color: rgba(148, 163, 184, 0.24);
}

.recent-item h4 {
  margin: 0;
  font-size: 1.05rem;
}

.recent-item__meta {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.45rem;
}

.section-heading .btn {
  white-space: nowrap;
}

.page-loader {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(4px);
  z-index: 120;
}

.page-loader[hidden] {
  display: none;
}

.loader-spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 4px solid rgba(148, 163, 184, 0.4);
  border-top-color: var(--color-primary);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Journal workspace */

.journal-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.75rem;
  align-items: flex-start;
}

@media (max-width: 1080px) {
  .journal-layout {
    grid-template-columns: 280px 1fr;
  }
}

@media (max-width: 900px) {
  .journal-layout {
    grid-template-columns: 1fr;
  }
}

.sidebar-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-height: min(680px, 85vh);
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 0.5rem 0 1rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
}

.sidebar-header .btn {
  width: 100%;
}

.search-field {
  position: relative;
}

.search-field input {
  padding-left: 2.75rem;
  width: 100%;
}

.search-field svg {
  position: absolute;
  top: 50%;
  left: 1rem;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  opacity: 0.55;
}

.entry-filter {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.6rem;
}

.entry-filter select {
  width: 100%;
}

.entry-list {
  display: grid;
  gap: 0.75rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.4rem;
}

.entry-item {
  appearance: none;
  -webkit-appearance: none;
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.75);
  padding: 0.9rem 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.entry-item:hover {
  transform: translateY(-3px);
  border-color: rgba(30, 75, 43, 0.32);
  box-shadow: 0 14px 20px rgba(15, 23, 42, 0.08);
}

.entry-item:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

.entry-item.is-active {
  border-color: var(--color-primary);
  box-shadow: 0 14px 24px rgba(30, 75, 43, 0.16);
}

.entry-item__main {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  min-width: 0;
}

.entry-item__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-item__date {
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

html.dark .entry-item {
  background: rgba(15, 23, 42, 0.7);
  border-color: rgba(148, 163, 184, 0.24);
}

.editor-panel {
  display: grid;
  gap: 1.5rem;
}

.editor-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
}

.editor-header h1 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2rem);
  color: var(--color-primary);
}

.editor-meta {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.editor-form {
  display: grid;
  gap: 1rem;
}

.editor-form textarea {
  min-height: 260px;
  resize: vertical;
  line-height: 1.7;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-end;
}

.editor-hint {
  margin-top: -0.25rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  text-align: right;
}

.editor-hint[data-variant="error"] {
  color: #b91c1c;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(30, 75, 43, 0.14);
  color: var(--color-primary);
}

html.dark .badge {
  background: rgba(110, 231, 183, 0.14);
  color: rgba(110, 231, 183, 0.95);
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1.5rem;
  color: var(--color-text-muted);
  display: grid;
  gap: 0.75rem;
}

.hidden {
  display: none !important;
}

@media (max-width: 600px) {
  .section-heading {
    flex-direction: column;
    align-items: flex-start;
  }

  .editor-actions {
    justify-content: stretch;
  }

  .editor-actions .btn {
    flex: 1;
  }
}

/* Profile layout */

.profile-overview {
  display: grid;
  gap: 1rem;
}

.profile-overview h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.6rem);
  color: var(--color-primary);
}

.profile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.profile-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.75rem;
}

.form-section {
  display: grid;
  gap: 1.25rem;
}

.form-section header {
  display: grid;
  gap: 0.35rem;
}

.form-section header h2 {
  margin: 0;
  font-size: 1.4rem;
}

.form-section header p {
  margin: 0;
  color: var(--color-text-muted);
}

.form-grid--two {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.25rem;
}

.form-footer-note {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.danger-zone {
  border: 1px solid rgba(220, 38, 38, 0.2);
  background: rgba(220, 38, 38, 0.06);
  color: #991b1b;
  display: grid;
  gap: 1.1rem;
}

.danger-zone header h2 {
  color: inherit;
}

.danger-zone .btn-primary {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  box-shadow: 0 12px 22px rgba(185, 28, 28, 0.22);
}

.danger-zone .btn-primary:hover {
  box-shadow: 0 16px 28px rgba(185, 28, 28, 0.28);
}

.danger-zone input {
  background: rgba(255, 255, 255, 0.95);
}

html.dark .danger-zone {
  background: rgba(185, 28, 28, 0.12);
  border-color: rgba(248, 113, 113, 0.25);
  color: rgba(248, 113, 113, 0.95);
}

html.dark .danger-zone input {
  background: rgba(15, 23, 42, 0.7);
  border-color: rgba(248, 113, 113, 0.35);
  color: inherit;
}
