/* ===== コンポーネントスタイル ===== */

/* ── Toggle / Accordion ── */
.toggle-section {
  background: var(--surface);
  border: 1px solid var(--border-lt);
  border-radius: var(--r);
  margin-bottom: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.toggle-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition);
  gap: 10px;
}
.toggle-header:hover { background: var(--surface2); }
.toggle-header:active { background: var(--border-lt); }
.toggle-title {
  font-weight: 700;
  font-size: .95rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toggle-icon {
  font-size: .75rem;
  color: var(--text-lt);
  transition: transform .2s ease;
  flex-shrink: 0;
}
.toggle-section.open .toggle-icon { transform: rotate(180deg); }
.toggle-body {
  display: none;
  padding: 0 16px 14px;
  border-top: 1px solid var(--border-lt);
}
.toggle-section.open .toggle-body { display: block; }
.toggle-body-inner { padding-top: 12px; }

/* ── Week Calendar ── */
.week-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-day {
  aspect-ratio: 1;
  border-radius: var(--r-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1.5px solid var(--border-lt);
  background: var(--surface2);
  transition: all var(--transition);
  text-decoration: none;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  padding: 4px 2px;
  min-height: 52px;
}
.cal-day:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(47,104,68,.15); }
.cal-day:active { transform: scale(.95); }
.cal-day .day-label {
  font-size: .62rem;
  color: var(--text-lt);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.cal-day .day-num {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
}
.cal-day .day-icons {
  font-size: .65rem;
  line-height: 1;
  min-height: 12px;
}
/* カレンダー背景色 */
.cal-day.bg-yellow  { background: #fffde7; border-color: var(--yellow); }
.cal-day.bg-red     { background: #ffebee; border-color: var(--red); }
.cal-day.bg-green   { background: #e8f5e9; border-color: var(--green); }
.cal-day.today      { border-color: var(--primary); border-width: 2px; }
.cal-day.today .day-num { color: var(--primary); }
.cal-day.sun .day-label,.cal-day.sun .day-num { color: #e53935; }
.cal-day.sat .day-label,.cal-day.sat .day-num { color: #1e88e5; }

/* ── Item Buttons（デイリーページ） ── */
.items-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
@media (min-width: 500px) { .items-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 700px) { .items-grid { grid-template-columns: repeat(4, 1fr); } }

.item-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--transition);
  gap: 4px;
  text-align: center;
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  min-height: 72px;
}
.item-btn:hover { border-color: var(--primary); background: #f0f7f3; }
.item-btn:active { transform: scale(.96); }
.item-btn.done {
  background: #e8f5e9;
  border-color: #81c784;
}
.item-btn.done .item-name { color: #2e7d32; }
.item-btn.neg { border-color: #ef9a9a; }
.item-btn.neg:hover { background: #ffebee; border-color: var(--neg); }
.item-btn.neg.done { background: #ffebee; border-color: #ef5350; }

.item-name { font-size: .8rem; font-weight: 600; color: var(--text); line-height: 1.3; }
.item-meta { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.item-pts  { font-size: .7rem; font-weight: 700; color: var(--pts); background: var(--pts-bg); padding: 1px 6px; border-radius: 10px; }
.item-time { font-size: .7rem; font-weight: 700; color: var(--time); background: var(--time-bg); padding: 1px 6px; border-radius: 10px; }
.item-neg-badge { font-size: .7rem; font-weight: 700; color: var(--neg); background: var(--neg-bg); padding: 1px 6px; border-radius: 10px; }
.item-done-mark {
  position: absolute;
  top: 4px; right: 5px;
  font-size: .7rem;
  color: #43a047;
}
.item-count-badge {
  position: absolute;
  top: 4px; left: 5px;
  font-size: .65rem;
  font-weight: 700;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  padding: 0 5px;
  min-width: 18px;
  text-align: center;
}

/* ── Log Area ── */
.log-area { position: relative; }
.log-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.log-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--surface2);
  border: 1px solid var(--border-lt);
  border-radius: var(--r-sm);
  font-size: .8rem;
  gap: 8px;
  line-height: 1.4;
}
.log-item:hover .log-del { opacity: 1; }
.log-text { flex: 1; word-break: break-all; }
.log-pts  { color: var(--pts);  font-weight: 700; }
.log-time { color: var(--time); font-weight: 700; }
.log-neg  { color: var(--neg);  font-weight: 700; }
.log-del {
  flex-shrink: 0;
  background: none; border: none;
  color: var(--text-lt);
  font-size: .85rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: .3;
  transition: opacity var(--transition), color var(--transition);
}
.log-del:hover { opacity: 1; color: var(--neg); }

.log-textarea {
  width: 100%;
  min-height: 120px;
  padding: 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: .78rem;
  color: var(--text-md);
  background: var(--surface2);
  resize: vertical;
  line-height: 1.8;
}

/* ── Today Summary strip ── */
.today-strip {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.today-chip {
  flex: 1;
  min-width: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
  border-radius: var(--r-sm);
  font-size: .75rem;
  font-weight: 600;
  border: 1px solid;
}
.today-chip.pts  { background: var(--pts-bg);  border-color: #f0c0a0; color: var(--pts);  }
.today-chip.time { background: var(--time-bg); border-color: #a0ccee; color: var(--time); }
.today-chip .big { font-size: 1.4rem; font-weight: 700; line-height: 1.2; }

/* ── Rate memo table ── */
.rate-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.rate-table td { padding: 6px 8px; border-bottom: 1px solid var(--border-lt); }
.rate-table td:first-child { color: var(--text-lt); white-space: nowrap; }
.rate-table td:last-child { font-weight: 600; }
.rate-table tr:last-child td { border-bottom: none; }

/* ── Exchange history ── */
.exchange-list { display: flex; flex-direction: column; gap: 6px; }
.exchange-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border-lt);
  border-radius: var(--r-sm);
  font-size: .82rem;
  gap: 8px;
}
.exchange-item .ex-pts { font-weight: 700; color: var(--neg); }
.exchange-item .ex-meta { font-size: .72rem; color: var(--text-lt); }
.exchange-type-badge {
  font-size: .68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--pts-bg);
  color: var(--pts);
  flex-shrink: 0;
}

/* ── Chart container ── */
.chart-wrap {
  width: 100%; 
  background: var(--surface);
  border-radius: var(--r);
  border: 1px solid var(--border-lt);
  padding: 14px;
  margin-bottom: 12px;
}
.chart-wrap h4 { font-size: .82rem; color: var(--text-lt); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 12px; }
canvas { max-width: 100%; }

/* ── Settings item list ── */
.settings-list { display: flex; flex-direction: column; gap: 8px; }
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface2);
  border: 1px solid var(--border-lt);
  border-radius: var(--r-sm);
  gap: 10px;
}
.settings-row .row-main { flex: 1; }
.settings-row .row-name { font-weight: 600; font-size: .9rem; }
.settings-row .row-sub  { font-size: .75rem; color: var(--text-lt); margin-top: 2px; }
.settings-row .row-actions { display: flex; gap: 6px; }
.edit-btn {
  padding: 5px 10px;
  font-size: .75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
}
.edit-btn:hover { border-color: var(--primary); color: var(--primary); }
.del-btn {
  padding: 5px 10px;
  font-size: .75rem;
  border: 1px solid #ffcdd2;
  border-radius: 6px;
  background: #fff5f5;
  color: var(--neg);
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
}
.del-btn:hover { background: var(--neg); color: #fff; border-color: var(--neg); }

/* ── Clothes counter bar ── */
.clothes-bar-wrap {
  background: var(--surface2);
  border: 1px solid var(--border-lt);
  border-radius: var(--r-sm);
  padding: 12px 14px;
}
.clothes-count-dots {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.clothes-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem;
  font-weight: 700;
  color: var(--text-lt);
  transition: all var(--transition);
}
.clothes-dot.filled {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ── Monthly table ── */
.monthly-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .83rem;
}
.monthly-table th {
  background: var(--surface2);
  padding: 7px 10px;
  text-align: left;
  font-size: .72rem;
  color: var(--text-lt);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
.monthly-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-lt);
}
.monthly-table tr:last-child td { border-bottom: none; }
.monthly-table .td-pts  { color: var(--pts);  font-weight: 700; }
.monthly-table .td-time { color: var(--time); font-weight: 700; }

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--border-lt); margin: 12px 0; }

/* ── Badge ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: .72rem;
  font-weight: 700;
}
.badge-green  { background: #e8f5e9; color: #2e7d32; }
.badge-red    { background: #ffebee; color: #c62828; }
.badge-yellow { background: #fffde7; color: #f57f17; }
.badge-blue   { background: #e3f2fd; color: #1565c0; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 30px 16px;
  color: var(--text-lt);
  font-size: .88rem;
}
.empty-state .empty-icon { font-size: 2rem; margin-bottom: 8px; }

/* ── Animations ── */
@keyframes fadeIn  { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pop     { 0%,100% { transform: scale(1); } 50% { transform: scale(1.18); } }
.anim-in   { animation: fadeIn .2s ease forwards; }
.anim-pop  { animation: pop .25s ease; }

/* ── PWA safe area ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .modal-box { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}

/* ── Dark mode (軽微対応) ── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:       #141814;
    --surface:  #1e241e;
    --surface2: #262e26;
    --text:     #e8ece8;
    --text-md:  #b0b8b0;
    --text-lt:  #778877;
    --border:   #334433;
    --border-lt:#2a342a;
  }
}
