/* ========================================
   学習ログ Phase 1 - Studyplus 風 UI
   ======================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  background: #F5F6F8;
  color: #1A1A1A;
  font-size: 15px;
  line-height: 1.5;
  padding-bottom: 72px; /* bottom-nav 分の余白 */
  -webkit-font-smoothing: antialiased;
}

button {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

/* ========================================
   画面切替
   ======================================== */

.screen {
  display: none;
  min-height: calc(100vh - 72px);
}
.screen.active {
  display: block;
}

/* ========================================
   目標バナー
   ======================================== */

.goal-banner {
  background: #FFF6E5;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #6B4A00;
  border-bottom: 1px solid #F0E6CC;
}
.goal-icon {
  font-size: 18px;
}
.goal-text {
  flex: 1;
}
.settings-icon {
  background: rgba(255,255,255,0.6);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

/* ========================================
   日付ナビ
   ======================================== */

.date-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 16px 8px;
  background: white;
  gap: 16px;
}
#prev-day,
#next-day {
  font-size: 24px;
  color: #6B7280;
  padding: 4px 12px;
  background: #F3F4F6;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
#current-date-display {
  font-weight: 700;
  font-size: 16px;
  min-width: 170px;
  text-align: center;
}

.action-row {
  display: flex;
  gap: 10px;
  padding: 8px 16px 16px;
  background: white;
  border-bottom: 8px solid #F5F6F8;
}
.add-btn {
  flex: 1;
  background: #2563EB;
  border: 1.5px solid #2563EB;
  color: white;
  padding: 10px 14px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 600;
}
.add-btn.secondary {
  background: white;
  color: #2563EB;
}
.add-btn.danger {
  background: white;
  border-color: #EF4444;
  color: #EF4444;
}
.modal-desc {
  text-align: center;
  color: #6B7280;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ========================================
   サマリボックス
   ======================================== */

.summary-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 8px 16px;
  padding: 14px 16px 18px;
  background: white;
  border-bottom: 8px solid #F5F6F8;
  margin-top: -8px;
}
.summary-item {
  display: flex;
  flex-direction: column;
}
.summary-item.right {
  text-align: right;
  align-items: flex-end;
}
.summary-label {
  font-size: 12px;
  color: #6B7280;
  margin-bottom: 4px;
}
.summary-value {
  font-size: 15px;
  font-weight: 600;
}
.summary-value.percent {
  color: #F59E0B;
  font-size: 22px;
  font-weight: 700;
}
#today-time-display {
  color: #1A1A1A;
  font-size: 18px;
  font-weight: 700;
}
#today-goal-display {
  color: #9CA3AF;
  font-size: 13px;
  margin-left: 4px;
}
.progress-bar {
  grid-column: 1 / 3;
  height: 6px;
  background: #E5E7EB;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #F59E0B 0%, #EAB308 100%);
  transition: width 0.3s ease;
}

/* ========================================
   セクション共通
   ======================================== */

.section {
  padding: 16px;
}
.section-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #1A1A1A;
}

/* ========================================
   教材リスト (ホーム)
   ======================================== */

.materials-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.material-card {
  background: white;
  border-radius: 10px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 1px solid #F0F1F3;
}
.material-card:active {
  transform: scale(0.98);
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.material-icon {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  flex-shrink: 0;
}
.material-text {
  flex: 1;
  min-width: 0;
}
.material-title-small {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: #1A1A1A;
}
.material-today-time {
  font-size: 12px;
  color: #6B7280;
  margin-top: 4px;
}
.material-delete-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #F3F4F6;
  color: #9CA3AF;
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.material-delete-btn:active {
  background: #FEE2E2;
  color: #EF4444;
}

/* ========================================
   記録入力画面
   ======================================== */

.record-header {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  background: white;
  border-bottom: 1px solid #E5E7EB;
  gap: 8px;
}
.record-header h1 {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  margin-right: 24px;
}
#record-back {
  font-size: 24px;
  color: #6B7280;
  padding: 4px 8px;
}

.record-material-card {
  background: white;
  padding: 16px;
  display: flex;
  gap: 14px;
  border-bottom: 1px solid #E5E7EB;
}
.material-icon-big {
  width: 80px;
  height: 100px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  background: #F3F4F6;
  flex-shrink: 0;
}
.material-info {
  flex: 1;
  min-width: 0;
}
.material-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 8px;
}
.material-category {
  margin-bottom: 10px;
}
.category-badge {
  display: inline-block;
  background: #FFB84D;
  color: white;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.manual-btn {
  background: white;
  border: 1px solid #D1D5DB;
  color: #2563EB;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.info-box {
  background: #F9FAFB;
  margin: 12px 16px;
  padding: 12px 16px;
  border-radius: 8px;
}
.info-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
}
.info-label {
  color: #6B7280;
}
.info-value {
  font-weight: 600;
  text-align: right;
}

.record-form {
  padding: 16px;
}
.form-field {
  display: flex;
  flex-direction: column;
  margin-bottom: 20px;
}
.field-label {
  font-size: 12px;
  color: #6B7280;
  margin-bottom: 6px;
  font-weight: 600;
}
.required {
  color: #EF4444;
}
.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
  padding: 10px 0;
  border: none;
  border-bottom: 1px solid #D1D5DB;
  background: transparent;
  font-size: 15px;
  outline: none;
}
.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  border-bottom-color: #2563EB;
}
.form-field textarea {
  resize: vertical;
  min-height: 60px;
}
.time-input {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #D1D5DB;
}
.time-input input {
  flex: 1;
  border: none !important;
  padding: 10px 0 !important;
  text-align: center;
}
.time-input span {
  font-size: 13px;
  color: #6B7280;
}

.submit-btn {
  width: 100%;
  background: #2563EB;
  color: white;
  padding: 14px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  margin-top: 20px;
  transition: opacity 0.15s;
}
.submit-btn:active {
  opacity: 0.8;
}

.outline-btn {
  width: 100%;
  background: white;
  color: #2563EB;
  border: 1.5px solid #2563EB;
  padding: 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 10px;
}

.danger-btn {
  width: 100%;
  background: white;
  color: #EF4444;
  border: 1.5px solid #EF4444;
  padding: 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 10px;
}

/* ========================================
   マイページ (設定)
   ======================================== */

.page-header {
  padding: 16px;
  background: white;
  border-bottom: 1px solid #E5E7EB;
  text-align: center;
}
.page-header h1 {
  font-size: 18px;
  font-weight: 700;
}

.settings-section {
  background: white;
  padding: 16px;
  margin-bottom: 8px;
}
.setting-field {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
}
.setting-field input {
  width: 100%;
  padding: 10px 0;
  border: none;
  border-bottom: 1px solid #D1D5DB;
  background: transparent;
  font-size: 15px;
  outline: none;
}
.setting-field input:focus {
  border-bottom-color: #2563EB;
}

.materials-manage-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.manage-material-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: #F9FAFB;
  border-radius: 8px;
}
.manage-material-item .material-icon {
  width: 36px;
  height: 36px;
  font-size: 18px;
}
.manage-material-info {
  flex: 1;
  min-width: 0;
}
.manage-material-title {
  font-size: 13px;
  font-weight: 600;
}
.manage-material-category {
  font-size: 11px;
  color: #6B7280;
}
.delete-material-btn {
  color: #EF4444;
  font-size: 18px;
  padding: 4px 8px;
}

.about-text {
  font-size: 13px;
  color: #6B7280;
  line-height: 1.8;
}

.placeholder-text {
  text-align: center;
  padding: 60px 20px;
  color: #9CA3AF;
  font-size: 14px;
}

/* ========================================
   分析画面
   ======================================== */

.analysis-summary {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1px;
  background: #E5E7EB;
  border-bottom: 8px solid #F5F6F8;
}
.analysis-summary-item {
  background: white;
  padding: 14px 10px;
  text-align: center;
}
.analysis-summary-item .summary-label {
  font-size: 11px;
  color: #6B7280;
  margin-bottom: 6px;
}
.analysis-summary-item .summary-value {
  font-size: 15px;
  font-weight: 700;
  color: #1A1A1A;
}

.period-switcher {
  display: flex;
  background: #F3F4F6;
  margin: 16px;
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.period-btn {
  flex: 1;
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #6B7280;
  border-radius: 8px;
  transition: all 0.15s;
}
.period-btn.active {
  background: white;
  color: #2563EB;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.date-range-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px 12px;
  gap: 16px;
}
#analysis-prev,
#analysis-next {
  font-size: 22px;
  color: #6B7280;
  padding: 4px 12px;
  background: #F3F4F6;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
#analysis-range-display {
  font-weight: 700;
  font-size: 14px;
  color: #1A1A1A;
  min-width: 160px;
  text-align: center;
}

.chart-container {
  background: white;
  margin: 0 0 8px;
  padding: 16px;
  position: relative;
  height: 280px;
  border-bottom: 8px solid #F5F6F8;
}

.analysis-materials-section {
  padding: 16px;
}
.analysis-material-item {
  background: white;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid #F0F1F3;
}
.analysis-mat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.analysis-mat-header .material-icon {
  width: 32px;
  height: 32px;
  font-size: 16px;
}
.analysis-mat-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.analysis-mat-total {
  font-size: 15px;
  font-weight: 700;
  color: #1A1A1A;
}
.analysis-mat-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
  gap: 4px;
  padding-top: 8px;
  border-top: 1px dashed #E5E7EB;
}
.breakdown-cell {
  text-align: center;
  padding: 2px;
}
.breakdown-label {
  font-size: 10px;
  color: #9CA3AF;
}
.breakdown-value {
  font-size: 11px;
  font-weight: 600;
  color: #1A1A1A;
}

/* ========================================
   モーダル
   ======================================== */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: flex-end;
  justify-content: center;
}
.modal.active {
  display: flex;
}
.modal-content {
  background: white;
  width: 100%;
  max-width: 480px;
  border-radius: 16px 16px 0 0;
  padding: 24px 20px 32px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-content h2 {
  font-size: 17px;
  margin-bottom: 20px;
  text-align: center;
}
.modal-subhead {
  font-size: 14px;
  font-weight: 700;
  color: #1A1A1A;
  margin: 24px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #E5E7EB;
}
.modal-subhead:first-of-type {
  margin-top: 0;
}
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.modal-actions button {
  flex: 1;
  margin-top: 0 !important;
}

/* ========================================
   ボトムナビ
   ======================================== */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: white;
  border-top: 1px solid #E5E7EB;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 100;
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  color: #9CA3AF;
  font-size: 10px;
  font-weight: 600;
}
.nav-btn.active {
  color: #2563EB;
}
.nav-icon {
  font-size: 20px;
  line-height: 1;
}
.nav-label {
  font-size: 10px;
}

/* ========================================
   iPad / デスクトップ最適化
   ======================================== */

@media (min-width: 640px) {
  body {
    max-width: 480px;
    margin: 0 auto;
    box-shadow: 0 0 20px rgba(0,0,0,0.05);
  }
  .bottom-nav {
    max-width: 480px;
    margin: 0 auto;
  }
}
