main {
  padding: 0;
}

.view-mode-bar {
  display: flex;
  justify-content: flex-end;
  padding: 0.5em 1em;
  flex-shrink: 0;
}

.view-mode-select {
  font-size: 0.85em;
  padding: 0.25em 0.5em;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg-primary);
  color: var(--color-fg-primary);
  cursor: pointer;
}

.view-mode-select:hover {
  border-color: var(--color-shadow-accent);
}

.view-mode-select option {
  display: inline-flex;
  align-items: center;
}

.index {
  width: 100%;
  height: 100%;
  font-family: -apple-system, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Open Sans", "Droid Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: auto;
  background: var(--color-bg-tertiary);
}

.folder {
  width: 100%;
  display: flex;
  flex-direction: column;
  background: var(--color-bg-primary);
}

.folder .folder-title {
  width: calc(100% - 0.66em);
  display: flex;
  background: var(--color-folder-bg);
  box-shadow: 1px 1px 1px 1px var(--color-shadow-tertiary);
  font-size: 0.8em;
  padding: 0.33em;
}

.view-full .folder {
  background: var(--color-bg-tertiary);
}

.folder .folder-title a {
  width: 100%;
}

.articles {
  width: 100%;
  height: 100%;
  display: flex;
  flex-wrap: wrap;
  padding: 0;
}

.article {
  display: block;
  width: 100%;
  box-shadow: 0 1px 3px 1px var(--color-shadow);
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-fg-primary) !important;
}

.article:hover {
   box-shadow: 0 1px 4px 3px var(--color-shadow-accent);
   opacity: 1;
   border-radius: .5em;
}

@media screen and (min-width: 480px) and (max-width: 800px) {
  .view-cards .article {
    width: 450px;
    margin: 0 auto;
  }
}

@media screen and (min-width: 640px) and (max-width: 767px) {
  .article {
    padding: 0 calc(1em + 7vw);
  }
}

@media screen and (min-width: 640px) {
  .view-cards .article {
    max-height: 50vh;
  }
}

@media screen and (min-width: 768px) and (max-width: 979px) {
  .article {
    width: 50%;
  }
}

@media screen and (min-width: 980px) and (max-width: 1279px) {
  .article {
    width: 33.33%;
  }
}

@media screen and (min-width: 1280px) and (max-width: 1599px) {
  .article {
    width: 25%;
  }
}

@media screen and (min-width: 1600px) {
  .article {
    width: 20%;
  }
}

.article .container {
  height: 100%;
  padding: 2em;
  position: relative;
  display: flex;
  flex-direction: column;
}

.image {
  height: 35%;
  z-index: 1;
}

.image img {
  width: 100%;
  height: 100%;
  border-radius: 0.75em;
}

.article .title {
  color: var(--color-title-fg);
  font-size: 1.2em;
  font-weight: bold;
  margin-top: .4em;
  text-align: center;
}

a {
  border-bottom: 0;
}


a:hover {
  opacity: 0.8;
}

.description {
  color: var(--color-fg-tertiary);
  font-size: .75em;
  max-height: 4em;
  overflow: hidden;
  text-overflow: ellipsis;
  /* Blur the bottom */
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 1) 75%, rgba(0, 0, 0, 0) 100%);
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 1) 75%, rgba(0, 0, 0, 0) 100%);
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
}

.published-date {
  font-size: .8em;
  color: var(--color-fg-tertiary);
  margin: .5em 0 2em 0;
  text-align: center;
}

.source {
  font-size: .75em;
  color: var(--color-fg-tertiary);
  display: flex;
  align-items: center;
  gap: .5em;
}

.source .source-logo {
  width: 1.5em;
  height: 1.5em;
  border-radius: 100%;
}

.view-cards .source {
  margin: 1em 0 2em 0;
  /* Anchor to the bottom of the container */
  position: absolute;
  bottom: 5em;
}

.view-list .source {
  margin: 0.5em 0 1em 0;
}

h3 {
  margin: 40px 0 0;
}

/* ── List view ── */

.view-list .folder {
  max-width: 1024px;
  margin-top: 1em;
  border-radius: 0.5em;
  box-shadow: 0 0 3px 3px var(--color-shadow);
}

.view-list .articles {
  flex-direction: column;
  border-radius: 0.5em;
}

.article-list {
  width: 100% !important;
  box-shadow: none !important;
  border-bottom: 1px solid var(--color-border) !important;
  padding: 0;
}

.article-list:hover {
  box-shadow: none !important;
  background: var(--color-folder-bg, rgba(0,0,0,0.02));
}

.article-list .container {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 1em;
  padding: 0.75em 1em;
}

.article-list .title {
  font-size: 1em;
  text-align: left;
  margin: 0;
}

.article-list .published-date {
  margin: 0.5em 0 0.25em 0;
  font-size: 0.68em;
  white-space: nowrap;
}

.article-list .description {
  width: 100%;
  margin-top: 0.25em;
  font-size: 0.85em;
}

/* ── Full (WordPress-like) view ── */

.view-full .articles {
  flex-direction: column;
  align-items: center;
  max-width: fit-content;
  margin: 0 auto;
}

.article-full {
  width: 100%;
  margin: 1em 0;
}

@media screen and (max-width: 1023px) {
  .article-full {
    width: calc(100% - 1em);
    padding: 0 0.5em;
  }
}

@media screen and (min-width: 1024px) {
  .article-full {
    padding: 0 1.25em;
    width: calc(100% - 2em);
  }
}

.article-full-header {
  display: block;
  border-bottom: 0;
}

.article-full .title {
  font-size: 1.8em;
  text-align: left;
  margin: 0.5em 0 0.2em;
}

.article-full .published-date {
  text-align: left;
}

.article-full .image {
  height: auto;
  max-width: 30em;
  max-height: 20em;
  overflow: hidden;
  display: block;
  margin: 0 auto;
}

.article-full .image img {
  max-width: 100%;
  height: auto;
  max-height: 20em;
  object-fit: contain;
}

@media screen and (max-width: 768px) {
  .article-full-header,
  .article-content {
    padding: 0 0.25em;
  }
}

@media screen and (max-width: 1024px) {
  .article-full {
    margin: 0;
  }

  .article.article-list {
    padding-bottom: 0.5em;
  }
}

.article-content img {
  max-width: 100%;
  height: auto;
}

/* Tags page */
.tags-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5em;
  padding-bottom: 1em;
  border-bottom: 1px solid var(--color-border);
}

.tags-header h1 {
  margin: 0;
  font-size: 2em;
  color: var(--color-title-fg);
}

.tags-stats {
  display: flex;
  gap: 1em;
  font-size: 0.9em;
  color: var(--color-fg-secondary);
}

.tags-stats span {
  background: var(--color-bg-secondary);
  padding: 0.5em 1em;
  border-radius: 20px;
  border: 1px solid var(--color-border);
}

.tags-controls {
  display: flex;
  gap: 0.5em;
  margin-bottom: 1.5em;
}

.sort-btn {
  padding: 0.5em 1em;
  border: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  color: var(--color-fg-secondary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9em;
  transition: all 0.2s ease;
}

.sort-btn:hover {
  background: var(--color-bg-tertiary);
  border-color: var(--color-shadow-accent);
}

.sort-btn.active {
  background: var(--color-shadow-accent);
  color: white;
  border-color: var(--color-shadow-accent);
}

.tags {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75em;
  margin: 0;
  padding: 0;
}

.no-tags {
  text-align: center;
  color: var(--color-fg-tertiary);
  font-style: italic;
  margin: 2em 0;
}

.tag-count {
  font-size: 0.9em;
  color: var(--color-fg-tertiary);
  background: var(--color-bg-primary);
  padding: 0.25em 0.5em;
  border-radius: 12px;
  font-weight: 500;
}

/* Mobile responsive design */
@media screen and (max-width: 767px) {
  .tags-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1em;
  }
  
  .tags-stats {
    flex-direction: column;
    gap: 0.5em;
    width: 100%;
  }
  
  .tags-stats span {
    text-align: center;
  }
  
  .tags-controls {
    width: 100%;
  }
  
  .sort-btn {
    flex: 1;
    text-align: center;
  }
  
  .tags {
    grid-template-columns: 1fr;
    gap: 0.5em;
  }
}

@media screen and (min-width: 768px) and (max-width: 1023px) {
  .tags {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

@media screen and (min-width: 1024px) {
  .container {
    max-width: 64em;
    margin: 0 auto;
    padding: 0 2em;
  }
  
  .tags {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}
