:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f3f3f3);
  --text: var(--tg-theme-text-color, #111);
  --hint: var(--tg-theme-hint-color, #777);
  --link: var(--tg-theme-link-color, #2481cc);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-text: var(--tg-theme-button-text-color, #fff);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: contain;
}

header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid color-mix(in srgb, var(--hint) 15%, transparent);
}

h1 { font-size: 20px; margin: 0; font-weight: 600; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border: 0; border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  font: inherit; cursor: pointer;
}
.pill:active { opacity: 0.7; }

main { padding: 16px; max-width: 720px; margin: 0 auto; }

.card {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
}
.card:active { opacity: 0.7; }

.card .image {
  margin: -16px -16px 12px;
  aspect-ratio: 16/9;
  background-size: cover;
  background-position: center;
  background-color: color-mix(in srgb, var(--hint) 15%, transparent);
  border-radius: var(--radius) var(--radius) 0 0;
}

.card .meta { color: var(--hint); font-size: 15px; }
.card h2 { font-size: 17px; margin: 4px 0; font-weight: 600; }
.chip {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  background: color-mix(in srgb, var(--hint) 15%, transparent);
  font-size: 13px; color: var(--hint);
}

.article-card { padding: 16px; }
.article-card .head { display: flex; gap: 10px; align-items: flex-start; }
.article-card .emoji { font-size: 20px; line-height: 1; }
.article-card .title { font-weight: 600; }
.article-card .summary { color: var(--hint); margin-top: 4px; }
.article-card .body { margin-top: 12px; }
.article-card .actions { margin-top: 12px; display: flex; gap: 12px; }

.btn-link {
  background: none; border: 0; color: var(--link); font: inherit; padding: 0; cursor: pointer;
}
.btn-link:active { opacity: 0.7; }

.expand {
  overflow: hidden;
  max-height: 0;
  transition: max-height 200ms cubic-bezier(0.32, 0.72, 0, 1);
}
.expand.open { max-height: 4000px; }

.skeleton {
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--hint) 10%, transparent),
    color-mix(in srgb, var(--hint) 18%, transparent),
    color-mix(in srgb, var(--hint) 10%, transparent));
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 8px;
  height: 14px; margin: 8px 0;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.empty { text-align: center; color: var(--hint); padding: 48px 16px; }
.empty .emoji { font-size: 48px; }

.error-row { color: #c53030; margin-top: 8px; font-size: 15px; }

.lang-sheet { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.lang-sheet__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); animation: lang-fade 180ms ease-out; }
.lang-sheet__card {
  position: relative;
  width: 100%;
  max-width: 720px;
  max-height: 80vh;
  background: var(--bg);
  border-radius: 18px 18px 0 0;
  padding: 8px 0 max(16px, env(safe-area-inset-bottom)) 0;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.25);
  animation: lang-slide 220ms cubic-bezier(0.32, 0.72, 0, 1);
  display: flex;
  flex-direction: column;
}
.lang-sheet__title {
  text-align: center; font-size: 13px; color: var(--hint);
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 12px 16px 8px;
}
.lang-sheet__list { overflow-y: auto; padding: 0 8px; }
.lang-sheet__item {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 14px 16px;
  border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 17px; text-align: left;
  border-radius: 10px; cursor: pointer;
  min-height: 48px;
}
.lang-sheet__item:active { background: var(--bg2); }
.lang-sheet__item.is-active { color: var(--accent); font-weight: 500; }
.lang-sheet__check { color: var(--accent); font-weight: 600; }

@keyframes lang-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes lang-slide { from { transform: translateY(100%); } to { transform: translateY(0); } }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
