/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f2f2f7;
  --card-bg: #ffffff;
  --text: #1c1c1e;
  --text2: #8e8e93;
  --accent: #007aff;
  --border: #e5e5ea;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Kaku Gothic ProN',
    'Hiragino Sans', Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* === Header === */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #1a1a2e;
  color: #fff;
  padding: 10px 14px 8px;
}

.header-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.updated-at {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  margin-left: auto;
}

.refresh-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  padding: 6px;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 8px;
}

.refresh-btn:active {
  background: rgba(255,255,255,0.12);
}

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

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

/* === Source Menu === */
.source-menu {
  position: relative;
  margin-top: 8px;
}

.menu-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 7px 12px;
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-height: 36px;
}

.menu-toggle:active {
  background: rgba(255,255,255,0.18);
}

.menu-current {
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-chevron {
  flex-shrink: 0;
  margin-left: 6px;
  transition: transform 0.2s;
  opacity: 0.6;
}

.menu-chevron.open {
  transform: rotate(180deg);
}

.menu-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: rgba(26,26,46,0.97);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-radius: 12px;
  max-height: 68vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 110;
  padding: 4px 0;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}

.menu-cat-header {
  padding: 10px 14px 3px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.5px;
}

.menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 8px 14px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  font-size: 14px;
  cursor: pointer;
  min-height: 38px;
  text-align: left;
}

.menu-item:active {
  background: rgba(255,255,255,0.08);
}

.menu-item.active {
  color: #fff;
  background: rgba(0,122,255,0.25);
}

.menu-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-item-count {
  flex-shrink: 0;
  font-size: 12px;
  color: rgba(255,255,255,0.3);
  margin-left: 8px;
}

.menu-item.active .menu-item-count {
  color: rgba(255,255,255,0.6);
}

.menu-item.empty {
  color: rgba(255,255,255,0.3);
}

.menu-item.empty .menu-item-count {
  color: rgba(255,255,255,0.15);
}

/* === Articles === */
.articles {
  padding: 8px 0 calc(24px + var(--safe-bottom));
}

.article-list {
  background: var(--card-bg);
  margin: 0 10px;
  border-radius: 12px;
  overflow: hidden;
}

/* === Article Card === */
.card {
  padding: 10px 14px;
  border-bottom: 0.5px solid var(--border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.card:last-child {
  border-bottom: none;
}

.card:active {
  background: #f2f2f7;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
  font-size: 12px;
  color: var(--text2);
  line-height: 1.3;
}

.card-source {
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}

.card-dot {
  flex-shrink: 0;
}

.card-time {
  flex-shrink: 0;
}

.lang-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 0px 4px;
  border-radius: 3px;
  background: #dbeafe;
  color: #2563eb;
  margin-left: 2px;
  flex-shrink: 0;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 2px;
}

.card-summary {
  font-size: 13px;
  line-height: 1.4;
  color: var(--text2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}

.card-foot {
  display: flex;
  gap: 16px;
  padding-top: 2px;
}

.foot-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  padding: 2px 0;
  cursor: pointer;
  min-height: 28px;
  display: flex;
  align-items: center;
}

.foot-link:active {
  opacity: 0.5;
}

/* === Full Content (expandable) === */
.card-fullcontent {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.card-fullcontent.open {
  max-height: 3000px;
}

.card-fullcontent-inner {
  padding: 8px 0;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
  border-top: 0.5px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
}

/* === Loading === */
.loading {
  text-align: center;
  padding: 48px 20px;
  color: var(--text2);
  font-size: 14px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

/* === Toast === */
.toast {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: rgba(0,0,0,0.8);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 200;
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  pointer-events: none;
  max-width: calc(100vw - 40px);
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text2);
}

.empty-state p {
  font-size: 14px;
}
