/* Global styles */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  margin: 0;
  padding: 0;
  background: #f2f2f7;
  color: #1c1c1e;
  line-height: 1.5;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: #fff;
  border-bottom: 1px solid #e5e5ea;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.topbar h1 {
  font-size: 1.25rem;
  font-weight: 300;
  margin: 0;
  position: relative;
  display: inline-block;
}

.topbar h1 .beta-badge {
  position: absolute;
  top: 0;
  right: -0.75rem;
  color: #007aff;
  font-size: 0.6em;
  font-weight: 600;
}

.topbar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 0.5rem;
}


.topbar-actions {
  display: none;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.topbar-actions.active {
  display: flex;
}

.header-controls {
  display: flex;
  gap: 0.5rem;
}

.menu-toggle {
  border: 1px solid #9b9ba1;
  background: #eaeaea00;
  border-radius: 8px;
  color: #6a6a6a;
  padding: 0.25rem 0.75rem;
  height: 2.0em;
  font-size: 1.25rem;
  align-self: center;
  cursor: pointer;
}

.refresh-btn {
  border: 1px solid #9b9ba1;
  background: #ffffff;
  border-radius: 8px;
  color: #6a6a6a;
  width: 2.5rem;
  height: 2.5rem;
  font-size: 1.25rem;
  align-self: center;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.refresh-btn:disabled {
  opacity: 0.6;
}

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

.refresh-btn.spinning {
  animation: spin 1s linear infinite;
}

.refresh-wrapper {
  display: none;
}

.topbar-actions > * {
  flex: 1;
}

.topbar-actions .btn {
  display: block;
  width: 100%;
  text-align: center;
  box-sizing: border-box;
}

.topbar-actions form {
  margin: 0;
}

@media (min-width: 480px) {
  .menu-toggle {
    display: none;
  }

  .topbar {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .topbar-header {
    width: auto;
  }

  .topbar-actions {
    display: flex;
    flex-direction: row;
    width: auto;
  }

  .topbar-actions > * {
    flex: 0 0 7rem;
  }
}

.topbar h1 a {
  color: inherit;
  text-decoration: none;
}

main {
  max-width: 700px;
  margin: 0 auto;
  padding: 1rem;
}


.feeds-layout {
  display: flex;
  flex-direction: column;
}

.feed-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
}

.lists-wrapper {
  flex: 1;
}


.feed-setting {
  display: block;
  margin-bottom: 0.5rem;
}

.feed-tabs .tab {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem;
  border: 1px solid #e5e5ea;
  border-radius: 999px;
  background: #fff;
  font-size: 0.9rem;
  cursor: pointer;
  color: #000000;
}

.feed-tabs .tab .tg-icon {
  width: 0.8rem;
  height: 0.8rem;
}

.feed-tabs .tab.active {
  background: #007aff;
  color: #fff;
  border-color: #007aff;
}

.hidden {
    display: none;
}

.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.item-description {
  margin-top: 0.5rem;
  color: #333;
  font-size: 0.9rem;
  white-space: pre-line;
}

ul {
  padding-inline-start: 16px; /* or even 0px */
  margin-left: 0; /* optional, removes extra margin */
}

li {
  margin-bottom: 10px; /* optional, removes extra margin */
}

.item-card {
  background: #fff;
  border: 1px solid #e5e5ea;
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.item-top {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
}

.item-title {
  font-weight: 300;
  color: #1c1c1e;
  text-decoration: none;
  flex: 1;
}

.item-title:hover {
  text-decoration: underline;
}

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.left { display: flex; align-items: center; gap: 8px; }
.right { display: flex; align-items: center; gap: 8px; }

.item-date {
  display: inline-block; 
  border: 1px solid #9b9ba1; 
  border-radius: 999px; 
  padding: 2px 8px; 
  background:#fff;
  font-size: 0.8rem;
  color: #6c6c70;
  white-space: nowrap;
}

.actions {
  display: flex;
  gap: 0.5rem;
}

.btn {
  border: 1px solid #9b9ba1;
  background: #eaeaea00;
  border-radius: 8px;
  color: #6a6a6a;
  padding: 0.25rem 0.75rem;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
}

.btn-read,
.btn-summary {
  display: inline-block;
  font-family: Arial;
  font-size: 0.8125rem; /* 13px */
}

.btn-summary {
  background: #eef6ff;
  padding: 0.4rem 0.75rem;
}

.btn-form {
  margin-top: 10px;
}

.btn-sign-out {
  padding: 0.5rem 1rem;
}

.btn:hover {
  background: #f2f2f7;
}

.btn-danger {
  border-color: #ff3b30;
  color: #ff3b30;
}

.btn-danger:hover {
  background: #fff4f4;
}

.delete-account-form {
  margin-top: 1rem;
}

.summary {
  margin-top: 0.5rem;
  background: #f9f9fb;
  border: 1px solid #e5e5ea;
  padding: 0.75rem;
  border-radius: 8px;
}

/* Landing page */
.landing {
  max-width: 600px;
  margin: 4rem auto;
  text-align: center;
  padding: 0 1rem;
}

.landing h1 {
  font-size: 2rem;
  margin-bottom: 1rem;
}

.landing p {
  margin-bottom: 2rem;
  color: #3a3a3c;
}

.landing .cta {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.btn-primary {
  background: #007bff;
  color: #fff;
  border: 1px solid #007bff;
}

.btn-primary:hover {
  background: #0069d9;
}

.error {
  color: #ff3b30;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"] {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #e5e5ea;
  border-radius: 8px;
  margin-top: 0.5rem;
  font-size: 1rem;
  box-sizing: border-box;
}

button {
  background: #007aff;
  border: none;
  border-radius: 8px;
  color: #fff;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  cursor: pointer;
}

button:hover {
  background: #005bb5;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.auth-form button {
  margin-top: 0.75rem;
}

.auth-links {
  margin-bottom: 1.5rem;
}

.auth-links p {
  margin: 0.5rem 0;
}

.auth-card, .support-card, .settings-card, .no-feeds-card {
  background: #fff;
  border: 1px solid #e5e5ea;
  border-radius: 12px;
  padding: 1rem;
}

.no-feeds-card ul {
  padding-left: 1.25rem;
  margin: 0.5rem 0 0 0;
}

.no-feeds-card code {
  word-break: break-all;
}

.auth-card {
  margin-bottom: 1.5rem;
}

.support-card {
  margin-top: 2rem;
}

.feed-list {
  list-style: none;
  padding: 0;
}

.feed-list li {
  display: flex;
  align-items: center;
  background: #fff;
  border: 1px solid #e5e5ea;
  border-radius: 8px;
  padding: 0.5rem;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.feed-list .feed-title {
  flex: 1;
}

.drag-handle {
  cursor: grab;
  color: #9b9ba1;
}

.edit-feed {
  background: #ffffff;  
  color: #333;
  border: 0.5px solid #9b9ba1;
  border-radius: 4px;
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.delete-feed {
  background: #ff3b30;
  border: none;
  color: #fff;
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
}

.settings-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.settings-card h3 {
  margin-top: 0;
}

.status-badge {
  display: inline-block;
  border: 1px solid #e5e5ea;
  border-radius: 999px;
  padding: 2px 8px;
  background: #fff;
  font-size: 0.8rem;
}

.status-badge.premium {
  border-color: #007aff;
  color: #007aff;
}

.status-badge.free {
  color: #6c6c70;
}

.premium-info {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: #6c6c70;
}

.support-card p {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: #6c6c70;
}

.support-card a {
  color: #007aff;
  text-decoration: none;
}

.support-card a:hover {
  text-decoration: underline;
}

.premium-info a {
  color: #007aff;
  text-decoration: none;
}

.premium-info a:hover {
  text-decoration: underline;
}

.alert {
  border-radius: 8px;
  padding: 0.75rem;
  border: 1px solid #e5e5ea;
  margin: 1rem 0;
  text-align: center;
  font-weight: 500;
}

.alert-success {
  background: #e6ffed;
  border-color: #34c759;
  color: #1c7c2f;
}

.alert-error {
  background: #fff4f4;
  border-color: #ff3b30;
  color: #ff3b30;
}

.feed-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.feed-actions {
  display: flex;
  gap: 0.25rem;
}

.feed-actions form {
  margin: 0;
}

@media (min-width: 768px) {
  .feeds-layout {
    flex-direction: row;
    align-items: flex-start;
  }

  .refresh-wrapper {
    display: block;
    position: sticky;
    top: 5em;
    margin-left: 1rem;
  }

  .header-controls .refresh-btn {
    display: none;
  }

  .feed-tabs {
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    margin-bottom: 0;
    margin-right: 1rem;
    width: 200px;
    max-height: calc(100vh - 4rem);
    position: sticky;
    top: 5em;
    z-index: 1000;
  }

  .item-top {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (min-width: 1024px) {
  main {
    max-width: 1000px;
  }
}

.password-rules {
  font-size: 0.9rem;
  color: #6a6a6a;
  margin: 0.25rem 0 1rem;
}

/* Feed catalog */
.feed-catalog summary {
  cursor: pointer;
  font-weight: 600;
  margin: 0;
  font-size: 1.1rem;
}

.catalog-content {
  margin-top: 0.5rem;
}

.catalog-content select {
  width: 100%;
  padding: 0.5rem;
  margin-bottom: 0.75rem;
  border: 1px solid #e5e5ea;
  border-radius: 8px;
  font-size: 1rem;
}

.catalog-feeds {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 300px;
  overflow-y: auto;
}

.catalog-feed {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0;
  border-bottom: 1px solid #e5e5ea;
}

.add-catalog-feed {
  border: 1px solid #9b9ba1;
  background: #fff;
  border-radius: 8px;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: #000;
}

.add-catalog-feed:hover {
  background: #f0f0f0;
  color: #000;
}

.add-catalog-feed:disabled {
  opacity: 0.5;
  cursor: default;
  background: #fff;
  color: #000;
}

.tg-images {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.5rem;
}

.tg-images img {
  width: 80px;
  height: auto;
  border-radius: 4px;
  cursor: pointer;
}

.img-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.img-popup.hidden {
  display: none;
}

.img-popup img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 8px;
}

.img-popup .popup-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
}
