:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f3f4f6;
  color: #111827;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f3f4f6;
}

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  align-items: start;
  min-height: 100vh;
  min-height: 100dvh;
}

.menu-toggle {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

.sidebar {
  padding: 24px;
  background: #111827;
  color: #f9fafb;
  border-right: 1px solid #1f2937;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
}

.brand h1 {
  margin: 0;
  font-size: 24px;
}

.brand p {
  margin: 8px 0 0;
  color: #9ca3af;
}

.brand .run-schedule {
  margin-top: 6px;
  color: #bfdbfe;
  font-size: 13px;
}

.sidebar-tools {
  margin-top: 20px;
}

.search-input,
.date-filter {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #374151;
  border-radius: 12px;
  background: #1f2937;
  color: #f9fafb;
}

.date-filter {
  margin-top: 10px;
}

.search-input::placeholder {
  color: #9ca3af;
}

.article-count {
  margin: 10px 0 0;
  font-size: 13px;
  color: #9ca3af;
}

.article-list {
  margin-top: 24px;
  display: grid;
  gap: 12px;
}

.article-item {
  padding: 16px;
  border: 1px solid #374151;
  border-radius: 12px;
  background: #1f2937;
  cursor: pointer;
}

.article-item.active {
  border-color: #60a5fa;
  background: #1d4ed8;
}

.article-item h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.article-item p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: #d1d5db;
}

.article-item .item-meta {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.item-pill,
.meta-pill {
  display: inline-block;
  margin: 0;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e5e7eb;
  color: #374151;
  font-size: 12px;
}

.content {
  padding: 32px;
}

.empty-state,
.article-view {
  max-width: 960px;
  margin: 0 auto;
}

.hidden {
  display: none;
}

.article-header {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.article-header h2 {
  margin: 8px 0 12px;
  font-size: 32px;
}

.meta-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  margin: 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 12px;
}

.summary {
  margin: 0;
  color: #4b5563;
  line-height: 1.7;
}

.topics {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.article-cover {
  margin: 0;
  overflow: hidden;
  border-radius: 20px;
  background: #e5e7eb;
  box-shadow: 0 10px 30px rgba(17, 24, 39, 0.08);
}

.article-cover img {
  display: block;
  width: 100%;
  height: auto;
}

.topic-chip {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4338ca;
  font-size: 12px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 40;
  max-width: calc(100vw - 360px);
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.06);
  border: 1px solid rgba(17, 24, 39, 0.06);
}

.actions button {
  font-size: 13px;
  padding: 8px 12px;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: #111827;
  color: white;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

button:active {
  transform: scale(0.97);
}

button.is-success {
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: #f0fdf4;
  box-shadow: 0 6px 18px rgba(22, 163, 74, 0.35);
}

button.is-error {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: #fef2f2;
  box-shadow: 0 6px 18px rgba(220, 38, 38, 0.35);
}

button:disabled {
  cursor: default;
  opacity: 0.92;
}

#toast-host {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.25);
  transform: translateY(-16px);
  opacity: 0;
  transition: transform 240ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 240ms ease;
  max-width: min(92vw, 420px);
  text-align: center;
}

.toast-visible {
  transform: translateY(0);
  opacity: 1;
}

.toast-success {
  background: linear-gradient(135deg, #10b981, #059669);
}

.toast-error {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

.article-body {
  padding: 32px;
  border-radius: 20px;
  background: white;
  box-shadow: 0 10px 30px rgba(17, 24, 39, 0.08);
}

.article-body h1 {
  font-size: 32px;
  line-height: 1.5;
}

.article-body p {
  font-size: 18px;
  line-height: 1.9;
  color: #1f2937;
}

.article-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 24px auto;
  border-radius: 16px;
}

@media (max-width: 960px) {
  body {
    overscroll-behavior-y: contain;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .menu-toggle {
    display: inline-flex;
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 14px);
    left: 14px;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 14px;
    background: rgba(17, 24, 39, 0.92);
    color: #fff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.22);
    z-index: 60;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .menu-toggle-bar {
    display: block;
    width: 18px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform 220ms ease, opacity 220ms ease;
  }

  body.sidebar-open .menu-toggle-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }

  body.sidebar-open .menu-toggle-bar:nth-child(2) {
    opacity: 0;
  }

  body.sidebar-open .menu-toggle-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(84vw, 340px);
    padding: calc(env(safe-area-inset-top, 0px) + 24px) 20px calc(env(safe-area-inset-bottom, 0px) + 20px);
    border-right: 0;
    transform: translateX(-102%);
    transition: transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 70;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 24px 0 64px rgba(15, 23, 42, 0.35);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.48);
    opacity: 0;
    pointer-events: none;
    transition: opacity 240ms ease;
    z-index: 65;
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .brand h1 {
    font-size: 22px;
  }

  .content {
    padding: calc(env(safe-area-inset-top, 0px) + 72px) 16px calc(env(safe-area-inset-bottom, 0px) + 96px);
  }

  .article-view {
    max-width: 100%;
  }

  .article-header {
    margin-bottom: 18px;
    gap: 12px;
  }

  .article-header h2 {
    font-size: 22px;
    margin: 6px 0 10px;
    line-height: 1.4;
  }

  .summary {
    font-size: 14px;
    line-height: 1.7;
  }

  .article-cover {
    border-radius: 16px;
  }

  .article-header > div:first-child {
    width: 100%;
  }

  .actions {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    max-width: none;
    padding: 10px 12px calc(env(safe-area-inset-bottom, 0px) + 10px);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-top: 1px solid rgba(17, 24, 39, 0.08);
    border-radius: 0;
    gap: 8px;
    justify-content: stretch;
    flex-wrap: nowrap;
    z-index: 50;
    box-shadow: 0 -6px 24px rgba(15, 23, 42, 0.08);
  }

  .actions button {
    flex: 1 1 0;
    min-width: 0;
    padding: 10px 6px;
    font-size: 13px;
    min-height: 44px;
    line-height: 1.25;
    word-break: break-word;
  }

  .article-body {
    padding: 18px 16px 22px;
    border-radius: 18px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
  }

  .article-body h1 {
    font-size: 24px;
    line-height: 1.4;
  }

  .article-body h2 {
    font-size: 19px;
    line-height: 1.45;
    margin-top: 28px;
  }

  .article-body p {
    font-size: 17px;
    line-height: 1.9;
  }

  .article-body img {
    margin: 18px auto;
    border-radius: 14px;
  }

  .empty-state {
    padding: 60px 20px;
    text-align: center;
    font-size: 14px;
    color: #6b7280;
  }

  #toast-host {
    top: calc(env(safe-area-inset-top, 0px) + 70px);
    width: 92vw;
  }

  .toast {
    font-size: 13px;
    padding: 10px 16px;
  }
}
