:root {
  --bg: #f4f6f5;
  --card-bg: #ffffff;
  --primary: #2f5d50;
  --primary-dark: #234439;
  --accent: #c9803a;
  --text: #22302c;
  --muted: #6b7a75;
  --border: #e1e6e3;
  --danger: #b3462c;
}

* {
  box-sizing: border-box;
}

button {
  touch-action: manipulation;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
}

.demo-banner {
  background: var(--accent);
  color: white;
  font-size: 0.8rem;
  text-align: center;
  padding: 6px 10px;
  padding-top: calc(6px + env(safe-area-inset-top));
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
  background: var(--primary);
  color: white;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  font-size: 1.1rem;
  margin: 0;
}

.today-badge {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 0.85rem;
}

.badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
}

.tabbar {
  display: flex;
  background: white;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 56px;
  z-index: 9;
}

.tab-btn {
  flex: 1;
  padding: 12px;
  border: none;
  background: transparent;
  font-size: 0.95rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: bold;
}

.tab-panel {
  padding: 16px;
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
}

.hidden {
  display: none !important;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.card h2 {
  font-size: 1rem;
  margin: 0 0 10px;
  color: var(--primary-dark);
}

.highlight-card {
  border-color: var(--accent);
  background: #fff8f0;
}

.theme-text {
  font-size: 1.05rem;
  font-weight: bold;
  margin: 0;
}

.muted-text {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 8px;
}

.hint-text {
  color: var(--primary);
  font-size: 0.85rem;
  margin-top: 8px;
}

.field-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 10px 0 4px;
}

.text-input,
textarea,
.inline-form input {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
}

textarea {
  resize: vertical;
}

.primary-btn {
  width: 100%;
  padding: 12px;
  margin-top: 12px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-size: 0.95rem;
  font-weight: bold;
  cursor: pointer;
}

.primary-btn:active {
  background: var(--primary-dark);
}

.secondary-btn {
  padding: 10px 14px;
  border: 1px solid var(--primary);
  border-radius: 8px;
  background: white;
  color: var(--primary);
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

.inline-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.inline-form input {
  flex: 1;
}

.pending-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pending-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #f8f5ef;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.pending-item .pending-text {
  flex: 1;
  font-size: 0.9rem;
}

.pending-item .pending-days {
  font-size: 0.75rem;
  color: var(--accent);
  white-space: nowrap;
}

.pending-item .btn-resolve {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
}

.streak-text {
  font-size: 1.4rem;
  font-weight: bold;
  color: var(--primary);
  margin: 0 0 10px;
}

.streak-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.streak-day {
  aspect-ratio: 1;
  border-radius: 4px;
  background: var(--border);
}

.streak-day.done {
  background: var(--primary);
}

.session-list,
.news-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.session-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
}

.session-item .session-date {
  font-size: 0.75rem;
  color: var(--muted);
}

.session-item .session-theme {
  font-weight: bold;
  font-size: 0.9rem;
}

.session-item .session-body {
  white-space: pre-wrap;
  font-size: 0.85rem;
  margin-top: 8px;
  color: var(--text);
}

.news-item {
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.news-item .news-title {
  color: var(--primary-dark);
  font-size: 0.9rem;
  display: block;
}

.news-item .news-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}

.fetched-at {
  font-size: 0.75rem;
  color: var(--muted);
  margin: -4px 0 10px;
}

.error-text {
  color: var(--danger);
  font-size: 0.85rem;
}

/* ===== パソコン(横幅の広い画面)向けレイアウト ===== */
@media (min-width: 700px) {
  #app {
    max-width: 1000px;
  }

  .topbar {
    padding: 20px 32px;
  }

  .topbar h1 {
    font-size: 1.3rem;
  }

  .tabbar {
    top: 65px;
  }

  .tab-panel {
    padding: 24px 32px;
  }

  #tab-study.tab-panel {
    max-width: 640px;
    margin: 0 auto;
  }

  #tab-news.tab-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    align-items: start;
  }

  #tab-news.tab-panel .card {
    margin-bottom: 0;
  }
}
