* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f0f0f;
  color: #e0e0e0;
  min-height: 100vh;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
}

h1 {
  text-align: center;
  font-size: 1.8rem;
  margin-bottom: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Tabs */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 24px;
  background: #1a1a1a;
  border-radius: 12px;
  padding: 4px;
}

.tab {
  flex: 1 1 auto;
  min-width: 88px;
  white-space: nowrap;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: #888;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
}

.tab.active {
  background: #2a2a2a;
  color: #fff;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Form */
.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 6px;
}

input,
select {
  width: 100%;
  padding: 12px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #1a1a1a;
  color: #e0e0e0;
  font-size: 1rem;
  font-family: inherit;
}

input:focus,
select:focus {
  outline: none;
  border-color: #4a9eff;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.form-row-2 {
  grid-template-columns: 1fr 1fr;
}

/* Today's sets */
.today-sets-header {
  font-size: 0.85rem;
  color: #888;
  margin: 20px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #222;
}

/* 今日のメニュー（記録タブ上部） */
.today-menu {
  background: #16261c;
  border: 1px solid #2e6b45;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
}

.today-menu-header {
  font-weight: 700;
  font-size: 0.95rem;
  color: #66dd99;
  cursor: pointer;
  list-style: none;
}

.today-menu-header::-webkit-details-marker {
  display: none;
}

.today-menu-list {
  list-style: none;
  margin-top: 10px;
}

.today-menu-item {
  display: flex;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid #1e3a28;
  font-size: 0.9rem;
}

.today-menu-item:last-child {
  border-bottom: none;
}

.today-menu-check {
  min-width: 20px;
  color: #66dd99;
  font-weight: 700;
}

.today-menu-name {
  flex: 1;
}

.today-menu-spec {
  color: #7a9a85;
  font-size: 0.82rem;
  white-space: nowrap;
  margin-left: 10px;
}

.today-menu-item.menu-done .today-menu-name {
  color: #6f8a78;
  text-decoration: line-through;
}

.today-menu-rest {
  background: #1a1a1a;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.88rem;
  color: #888;
}

/* 前回実績（種目入力の下） */
.last-session {
  margin-top: 6px;
  font-size: 0.82rem;
  color: #aaa;
  min-height: 0;
}

.last-session:empty {
  margin-top: 0;
}

.last-session-label {
  color: #4a9eff;
  font-weight: 600;
  margin-right: 4px;
}

.today-ex-group {
  margin-bottom: 14px;
}

.today-ex-prev {
  font-size: 0.78rem;
  color: #777;
  margin: 0 0 6px 2px;
}

.set-arrow {
  font-size: 0.8rem;
  margin: 0 8px;
  white-space: nowrap;
}

.today-set-item.set-up {
  border-left: 3px solid #4aefb0;
}

.today-set-item.set-up .set-arrow {
  color: #4aefb0;
}

.today-set-item.set-down {
  border-left: 3px solid #6a6a4a;
}

.today-set-item.set-down .set-arrow {
  color: #c9a94a;
}

.today-ex-name {
  font-weight: 600;
  font-size: 0.92rem;
  color: #fff;
  margin: 0 0 6px 2px;
}

.today-set-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: #1a1a1a;
  border-radius: 8px;
  margin-bottom: 6px;
}

.today-set-num {
  color: #4a9eff;
  font-weight: 600;
  margin-right: 12px;
  min-width: 32px;
}

.today-set-detail {
  flex: 1;
  font-size: 0.9rem;
  color: #ccc;
}

.today-set-delete {
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  padding: 2px 6px;
  font-size: 1rem;
  border-radius: 4px;
  transition: color 0.2s;
}

.today-set-delete:hover {
  color: #ff4a4a;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 8px;
  background: #4a9eff;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: #3a8eef;
}

.btn-primary:active {
  background: #2a7edf;
}

a.btn-primary {
  display: inline-block;
  width: auto;
  text-decoration: none;
  text-align: center;
}

.btn-secondary {
  padding: 8px 16px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #222;
  color: #ddd;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-secondary:hover {
  background: #2a2a2a;
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Health (CSV取り込み) */
.health-import {
  background: #1a1a1a;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.health-import-header {
  font-weight: 700;
  font-size: 0.95rem;
  color: #4a9eff;
  cursor: pointer;
  list-style: none;
}

.health-import-header::-webkit-details-marker {
  display: none;
}

.health-import-note {
  font-size: 0.8rem;
  color: #999;
  line-height: 1.6;
  margin: 10px 0;
}

.health-import-note code {
  background: #2a2a2a;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}

.health-csv {
  width: 100%;
  box-sizing: border-box;
  background: #111;
  border: 1px solid #333;
  border-radius: 8px;
  color: #ddd;
  font-family: monospace;
  font-size: 0.82rem;
  padding: 10px;
  margin-bottom: 10px;
  resize: vertical;
}

.health-connect {
  background: #1a1a1a;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
}

.health-connect-title {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 8px;
}

.health-connect-note {
  font-size: 0.88rem;
  color: #999;
  line-height: 1.6;
  margin-bottom: 16px;
}

.health-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.health-synced {
  font-size: 0.78rem;
  color: #888;
}

.health-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.health-table th {
  text-align: right;
  color: #888;
  font-weight: 600;
  font-size: 0.78rem;
  padding: 6px 8px;
  border-bottom: 1px solid #2a2a2a;
}

.health-table th:first-child {
  text-align: left;
}

.health-table td {
  text-align: right;
  padding: 8px;
  border-bottom: 1px solid #1a1a1a;
  color: #ddd;
}

.health-table td:first-child {
  text-align: left;
  color: #aaa;
}

/* History */
.history-date {
  font-size: 0.85rem;
  color: #888;
  margin: 20px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #222;
}

.history-date:first-child {
  margin-top: 0;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: #1a1a1a;
  border-radius: 8px;
  margin-bottom: 8px;
}

.history-item-info {
  flex: 1;
}

.history-item-exercise {
  font-weight: 600;
  margin-bottom: 2px;
}

.history-item-details {
  font-size: 0.85rem;
  color: #888;
}

.history-item-delete {
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 1.1rem;
  border-radius: 4px;
  transition: color 0.2s;
}

.history-item-delete:hover {
  color: #ff4a4a;
}

/* Progress */
.chart-container {
  margin-top: 16px;
  background: #1a1a1a;
  border-radius: 12px;
  padding: 16px;
}

.empty-state {
  text-align: center;
  color: #555;
  padding: 40px 0;
}

/* Menu */
.menu-day,
.menu-summary {
  background: #1a1a1a;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}

.menu-comeback {
  background: #16261c;
  border: 1px solid #2e6b45;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.menu-comeback-header {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 10px;
  color: #66dd99;
}

.menu-comeback-note {
  font-size: 0.85rem;
  line-height: 1.6;
  color: #b8c9bd;
  margin-bottom: 12px;
}

.menu-comeback-note strong {
  color: #66dd99;
}

.menu-comeback-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #66dd99;
  letter-spacing: 0.03em;
  margin: 6px 0 2px;
}

.menu-comeback-foot {
  font-size: 0.8rem;
  color: #7a9a85;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #234;
}

.menu-day-header {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 12px;
  color: #4a9eff;
}

.menu-exercises {
  list-style: none;
  counter-reset: ex;
}

.menu-exercises li {
  counter-increment: ex;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #222;
}

.menu-exercises li:last-child {
  border-bottom: none;
}

.menu-exercises li::before {
  content: counter(ex);
  color: #4a9eff;
  font-weight: 600;
  min-width: 20px;
  margin-right: 10px;
}

.menu-name {
  flex: 1;
}

.menu-spec {
  color: #888;
  font-size: 0.85rem;
  white-space: nowrap;
  margin-left: 12px;
}

.menu-freq-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
}

.menu-freq-part {
  font-weight: 600;
}

.menu-freq-val {
  color: #888;
}

.menu-zone {
  display: inline-block;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 8px;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: middle;
}

.menu-zone-rack {
  background: #3a2a1a;
  color: #ffa866;
}

.menu-zone-free {
  background: #1a2a3a;
  color: #66aaff;
}

.menu-zone-cable {
  background: #2a1a3a;
  color: #c266ff;
}

.menu-zone-machine {
  background: #1a3a2a;
  color: #66dd99;
}

/* Coach (Advice) */
.advice-block {
  background: #1a1a1a;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}

.advice-block-header {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 12px;
  color: #4a9eff;
}

.advice-block-body p {
  font-size: 0.92rem;
  line-height: 1.6;
  color: #ccc;
  margin-bottom: 8px;
}

.advice-block-body p:last-child {
  margin-bottom: 0;
}

.advice-conclusion {
  color: #e0e0e0 !important;
  padding-top: 6px;
  border-top: 1px solid #222;
}

.advice-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.advice-list li {
  padding: 12px 0;
  border-bottom: 1px solid #222;
}

.advice-list li:first-child {
  padding-top: 0;
}

.advice-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.advice-item-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: #e0e0e0;
  margin-bottom: 4px;
}

.advice-item-detail {
  font-size: 0.88rem;
  color: #ccc;
  margin-bottom: 4px;
  line-height: 1.5;
}

.advice-item-detail strong {
  color: #4a9eff;
  font-weight: 600;
}

.advice-item-reason {
  font-size: 0.8rem;
  color: #777;
  line-height: 1.5;
}

.advice-rule-intro {
  font-size: 0.9rem;
  color: #e0e0e0;
  margin-bottom: 12px;
  line-height: 1.5;
}

.advice-rule-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 16px;
  margin-bottom: 10px;
}

.advice-rule-cat {
  color: #ccc;
  font-size: 0.88rem;
}

.advice-rule-val {
  color: #4a9eff;
  font-weight: 600;
  font-size: 0.88rem;
}

.advice-rule-note {
  font-size: 0.8rem;
  color: #777;
  padding-top: 8px;
  border-top: 1px solid #222;
  line-height: 1.5;
}

.advice-target-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.advice-target-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #222;
}

.advice-target-list li:last-child {
  border-bottom: none;
}

.advice-target-name {
  color: #ccc;
  font-size: 0.9rem;
}

.advice-target-val {
  color: #4a9eff;
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  margin-left: 12px;
}

.advice-block-tip {
  background: linear-gradient(135deg, #1a2a3a 0%, #1a1a2a 100%);
  border: 1px solid #2a3a5a;
}

.advice-tip {
  font-size: 0.92rem;
  line-height: 1.7;
  color: #d0d8e0;
}

.advice-tip strong {
  color: #6ab0ff;
}

/* Notes */
.note-card {
  background: #1a1a1a;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}

.note-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  cursor: pointer;
  list-style: none;
}

.note-header::-webkit-details-marker {
  display: none;
}

.note-header::before {
  content: '▸';
  color: #4a9eff;
  font-size: 0.8rem;
  align-self: center;
}

.note-card[open] > .note-header::before {
  content: '▾';
}

.note-card[open] > .note-header {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #222;
}

.note-date {
  font-size: 0.8rem;
  color: #888;
  white-space: nowrap;
}

.note-title {
  font-weight: 700;
  font-size: 1.02rem;
  color: #4a9eff;
}

.note-summary {
  font-size: 0.92rem;
  line-height: 1.7;
  color: #d0d8e0;
}

.note-summary h1,
.note-summary h2,
.note-summary h3 {
  font-size: 0.95rem;
  color: #fff;
  margin: 14px 0 6px;
}

.note-summary ul,
.note-summary ol {
  padding-left: 1.3em;
  margin: 6px 0;
}

.note-summary li {
  margin: 3px 0;
}

.note-summary p {
  margin: 6px 0;
}

.note-summary strong {
  color: #6ab0ff;
}

.note-summary code {
  background: #2a2a2a;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.85em;
}

.note-summary table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 0.85rem;
}

.note-summary th,
.note-summary td {
  border: 1px solid #2a2a2a;
  padding: 4px 8px;
  text-align: left;
}

.note-conversation {
  margin-top: 12px;
  border-top: 1px solid #222;
  padding-top: 10px;
}

.note-conversation > summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: #66aaff;
  list-style: none;
}

.note-conversation > summary::before {
  content: '▸ ';
}

.note-conversation[open] > summary::before {
  content: '▾ ';
}

.note-conversation-body {
  margin-top: 10px;
  padding: 12px;
  background: #111;
  border-radius: 8px;
  font-size: 0.8rem;
  line-height: 1.6;
  color: #b0b8c0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  max-height: 420px;
  overflow-y: auto;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #2a2a2a;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s;
}

.toast.show {
  opacity: 1;
}
