:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --border: #dcdce0;
  --text: #1c1c1e;
  --text-muted: #6b6b70;
  --accent: #2d6cdf;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0 0 32px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.app-header {
  padding: 20px 16px 12px;
}

.nav-links {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.nav-link {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--surface);
}

.nav-link.is-active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.app-header h1 {
  margin: 0;
  font-size: 1.3rem;
}

.update-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}

.updated-at {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.refresh-btn {
  flex-shrink: 0;
  padding: 6px 14px;
  font-size: 0.8rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
}

.refresh-btn:active {
  background: rgba(45, 108, 223, 0.12);
}

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

.refresh-message {
  margin: 6px 0 0;
  font-size: 0.78rem;
  color: var(--accent);
}

.filter-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: 0 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-row {
  display: flex;
}

#filterText {
  width: 100%;
  padding: 10px 12px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.filter-row-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.filter-field:first-child {
  grid-column: 1 / -1;
}

.filter-field select,
.filter-field input[type="date"] {
  padding: 8px 10px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.clear-btn {
  align-self: flex-start;
  padding: 6px 12px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
}

.clear-btn:active {
  background: var(--bg);
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 16px 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.card-summary {
  font-weight: 600;
  font-size: 1rem;
}

.card-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.card-body {
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  margin: 0 0 8px;
}

.card-body-wrap {
  margin-bottom: 8px;
}

.card-body.is-collapsible {
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-body.is-collapsible.is-expanded {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
}

.card-toggle {
  display: none;
  position: sticky;
  bottom: 10px;
  margin: 0;
  padding: 3px 12px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
}

.card-toggle.is-visible {
  display: inline-flex;
}

.card-toggle:active {
  background: rgba(45, 108, 223, 0.12);
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.team-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(45, 108, 223, 0.12);
  color: var(--accent);
  font-size: 0.75rem;
}

.team-badge--blue {
  background: rgba(45, 108, 223, 0.12);
  color: #2d6cdf;
}

.team-badge--gray {
  background: rgba(107, 107, 112, 0.14);
  color: #6b6b70;
}

.team-badge--green {
  background: rgba(47, 158, 68, 0.14);
  color: #2f9e44;
}

.team-badge--yellow {
  background: rgba(184, 134, 11, 0.14);
  color: #b8860b;
}

.search-highlight {
  background: rgba(45, 108, 223, 0.22);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
  font-weight: 600;
}

.card-note {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.card-uploader {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.drive-link {
  font-size: 0.78rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.drive-link:active {
  opacity: 0.7;
}

.empty-state,
.loading-state {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 16px;
  font-size: 0.9rem;
}

@media (min-width: 640px) {
  .filter-row-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .filter-field:first-child {
    grid-column: auto;
  }

  .card-list {
    max-width: 720px;
    margin: 0 auto;
  }

  .filter-bar {
    max-width: 720px;
    margin: 0 auto;
  }

  .app-header {
    max-width: 720px;
    margin: 0 auto;
  }
}
