/* リセット */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  background-color: #f5f5f5;
  color: #333;
  padding-bottom: 20px;
}

body.modal-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  user-select: none;
}

/* ヘッダー */
header {
  background-color: #fff;
  padding: 16px 20px;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-size: 20px;
  font-weight: 700;
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.insights-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #f5f5f5;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.insights-btn:hover {
  background: #e0e0e0;
}

.insights-btn:active {
  background: #d0d0d0;
}

.insights-btn .material-symbols-outlined {
  font-size: 24px;
  color: #666;
}

.filter-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #1976d2;
  color: white;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s;
}

.filter-button:hover {
  background: #1565c0;
}

.filter-button:active {
  background: #0d47a1;
}

.filter-icon {
  font-size: 18px;
}

/* タイムライン */
#timeline {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 16px;
  min-height: calc(100vh - 200px);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}

.empty-state p {
  font-size: 16px;
  line-height: 1.6;
}

/* 投稿カード */
.post {
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin: 16px 0;
  display: flex;
  gap: 12px;
  position: relative;
  transition: all 0.3s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.post.highlight {
  background: #e3f2fd;
  box-shadow: 0 2px 8px rgba(25, 118, 210, 0.3);
}

.post.completed {
  opacity: 0.6;
}

.post.completed .post-text {
  text-decoration: line-through;
  color: #999;
}

.post-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  flex-shrink: 0;
}

.post-content {
  flex: 1;
  cursor: pointer;
}

.post-mood {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  margin-right: 8px;
  margin-bottom: 4px;
  font-weight: 600;
}

.post-mood[data-mood='great'] {
  background: #e3f2fd;
  color: #1976d2;
}

.post-mood[data-mood='good'] {
  background: #e8f5e9;
  color: #388e3c;
}

.post-mood[data-mood='okay'] {
  background: #fff3e0;
  color: #f57c00;
}

.post-mood[data-mood='bad'] {
  background: #fbe9e7;
  color: #e64a19;
}

.post-mood[data-mood='worst'] {
  background: #ffebee;
  color: #c62828;
}

.post-mood .material-symbols-outlined {
  font-size: 28px;
}

.post-label {
  display: inline-block;
  background: #e0e0e0;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 13px;
  color: #666;
  margin-right: 8px;
  margin-bottom: 4px;
}

.post-text {
  font-size: 15px;
  line-height: 1.5;
  margin: 4px 0;
  word-break: break-word;
  white-space: pre-wrap;
}

.post-meta {
  font-size: 13px;
  color: #999;
  margin-top: 8px;
}

.post-due-date {
  position: absolute;
  top: 12px;
  right: 52px;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 8px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.post-due-date.overdue {
  background: #ffebee;
  color: #c62828;
}

.post-due-date.critical {
  background: #fff3e0;
  color: #e65100;
}

.post-due-date.urgent {
  background: #fff8e1;
  color: #f57c00;
}

.post-due-date.warning {
  background: #f5f5f5;
  color: #666;
}

.post-due-date.safe {
  background: #f5f5f5;
  color: #999;
}

.due-icon {
  font-size: 14px;
}

/* 3点メニュー */
.delete-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.delete-btn:hover {
  background: #f5f5f5;
}

.delete-btn:active {
  background: #e0e0e0;
}

.delete-btn .material-symbols-outlined {
  font-size: 20px;
  color: #666;
}

.post-menu {
  display: none;
  position: absolute;
  bottom: 40px;
  right: 12px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  z-index: 200;
  min-width: 160px;
}

.post-menu.show {
  display: block;
}

.post-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: none;
  background: white;
  cursor: pointer;
  font-size: 14px;
  text-align: left;
  transition: background 0.2s;
}

.post-menu-item:hover {
  background: #f5f5f5;
}

.post-menu-item:active {
  background: #e0e0e0;
}

.post-menu-item.delete {
  color: #d32f2f;
}

.post-menu-icon {
  font-size: 20px;
  color: #666;
}

.post-menu-item.delete .post-menu-icon {
  color: #d32f2f;
}

@media (max-height: 500px) {
  .post-menu {
    max-height: 120px;
    overflow-y: auto;
  }
}

/* 追加ボタン */
.add-button {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #1976d2;
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 100;
}

.add-button:hover {
  background: #1565c0;
  transform: scale(1.05);
}

.add-button:active {
  background: #0d47a1;
  transform: scale(0.95);
}

.add-button .material-symbols-outlined {
  font-size: 32px;
}

/* モーダル共通 */
#inputModal,
#filterModal,
#insightsModal,
#menuModal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1500;
  align-items: flex-end;
}

#inputModal.show,
#filterModal.show,
#insightsModal.show,
#menuModal.show {
  display: flex;
}

#inputSheet,
#filterSheet,
#insightsSheet,
#menuSheet {
  background: white;
  width: 100%;
  max-height: 85vh;
  border-radius: 20px 20px 0 0;
  padding: 24px;
  animation: slideUp 0.3s ease-out;
  overflow-y: auto;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

#inputSheet h2,
#filterSheet h2,
#insightsSheet h2,
#menuSheet h2 {
  font-size: 20px;
  margin-bottom: 20px;
  color: #333;
}

/* 投稿モーダル */
#inputText {
  width: 100%;
  padding: 12px;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  font-size: 16px;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 16px;
}

#inputText:focus {
  outline: none;
  border-color: #1976d2;
}

.modal-icon-menu {
  display: flex;
  justify-content: space-around;
  gap: 8px;
  margin-bottom: 16px;
}

.modal-icon-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  background: #f5f5f5;
  border: 2px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.modal-icon-btn:hover {
  background: #e8e8e8;
}

.modal-icon-btn:active,
.modal-icon-btn.active {
  background: #e3f2fd;
  border-color: #1976d2;
}

.modal-icon-btn.has-value {
  border-color: #1976d2;
}

.modal-icon-btn.has-value .material-symbols-outlined {
  font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 24;
  color: #1976d2;
}

.modal-icon-btn.has-value .modal-icon-label {
  color: #1976d2;
  font-weight: 600;
}

.modal-icon-btn .material-symbols-outlined {
  font-size: 24px;
  color: #666;
}

.modal-icon-label {
  font-size: 12px;
  color: #666;
}

.modal-icon-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  background: #1976d2;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.expandable-section {
  display: none;
  margin-bottom: 16px;
  padding: 16px;
  background: #f5f5f5;
  border-radius: 12px;
}

.expandable-section.show {
  display: block;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: #666;
  margin-bottom: 12px;
}

/* ラベル選択 */
.label-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.label-item {
  padding: 8px 16px;
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 20px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.label-item:hover {
  background: #f5f5f5;
}

.label-item:active,
.label-item.selected {
  background: #1976d2;
  color: white;
  border-color: #1976d2;
}

.label-management-toggle {
  text-align: center;
  color: #1976d2;
  font-size: 14px;
  cursor: pointer;
  padding: 8px;
  margin-top: 8px;
}

.label-management-toggle:hover {
  text-decoration: underline;
}

.label-edit-mode {
  display: none;
  margin-top: 12px;
}

.label-edit-mode.show {
  display: block;
}

.label-edit-list {
  margin-bottom: 12px;
}

.label-edit-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: white;
  border-radius: 8px;
  margin-bottom: 8px;
}

.label-edit-name {
  flex: 1;
  font-size: 14px;
}

.label-rename-btn,
.label-delete-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: #f5f5f5;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.label-rename-btn:hover,
.label-delete-btn:hover {
  background: #e0e0e0;
}

.label-rename-btn:active,
.label-delete-btn:active {
  background: #d0d0d0;
}

.label-delete-btn .material-symbols-outlined {
  color: #d32f2f;
}

.label-add-form {
  display: flex;
  gap: 8px;
}

.label-add-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
}

.label-add-input:focus {
  outline: none;
  border-color: #1976d2;
}

.label-add-btn {
  padding: 8px 16px;
  background: #1976d2;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.label-add-btn:hover {
  background: #1565c0;
}

.label-add-btn:active {
  background: #0d47a1;
}

/* 気分選択 */
.mood-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mood-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.mood-item:hover {
  background: #f5f5f5;
}

.mood-item.selected {
  border-width: 2px;
  transform: scale(1.02);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.mood-item[data-mood='great'].selected {
  background: #e3f2fd;
  border-color: #1976d2;
}

.mood-item[data-mood='good'].selected {
  background: #e8f5e9;
  border-color: #388e3c;
}

.mood-item[data-mood='okay'].selected {
  background: #fff3e0;
  border-color: #f57c00;
}

.mood-item[data-mood='bad'].selected {
  background: #fbe9e7;
  border-color: #e64a19;
}

.mood-item[data-mood='worst'].selected {
  background: #ffebee;
  border-color: #c62828;
}

.mood-item .material-symbols-outlined {
  font-size: 28px;
}

.mood-item[data-mood='great'] .material-symbols-outlined {
  color: #1976d2;
}

.mood-item[data-mood='good'] .material-symbols-outlined {
  color: #388e3c;
}

.mood-item[data-mood='okay'] .material-symbols-outlined {
  color: #f57c00;
}

.mood-item[data-mood='bad'] .material-symbols-outlined {
  color: #e64a19;
}

.mood-item[data-mood='worst'] .material-symbols-outlined {
  color: #c62828;
}

.mood-label {
  font-size: 16px;
  font-weight: 500;
}

/* 期日入力 */
.due-date-input-wrapper {
  display: flex;
  gap: 8px;
  align-items: center;
}

.due-date-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
}

.due-date-input:focus {
  outline: none;
  border-color: #1976d2;
}

.due-date-clear {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: #f5f5f5;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
  color: #666;
}

.due-date-clear:hover {
  background: #e0e0e0;
}

.due-date-clear:active {
  background: #d0d0d0;
}

.due-date-preview {
  margin-top: 8px;
  padding: 8px;
  background: white;
  border-radius: 8px;
  font-size: 14px;
  color: #666;
}

/* ボタングループ */
.button-group {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.button-group button {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

#cancelButton {
  background: #f5f5f5;
  color: #666;
}

#cancelButton:hover {
  background: #e0e0e0;
}

#cancelButton:active {
  background: #d0d0d0;
}

#postButton {
  background: #1976d2;
  color: white;
}

#postButton:hover {
  background: #1565c0;
}

#postButton:active {
  background: #0d47a1;
}

/* フィルターモーダル */
.filter-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-option {
  padding: 16px;
  background: #f5f5f5;
  border: 2px solid transparent;
  border-radius: 12px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-option:hover {
  background: #e8e8e8;
}

.filter-option:active,
.filter-option.selected {
  background: #e3f2fd;
  border-color: #1976d2;
  color: #1976d2;
  font-weight: 600;
}

/* グラフモーダル */
.insights-period-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.insights-period-tab {
  flex: 1;
  padding: 8px;
  background: #f5f5f5;
  border: 2px solid transparent;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.insights-period-tab:hover {
  background: #e8e8e8;
}

.insights-period-tab.active {
  background: #e3f2fd;
  border-color: #1976d2;
  color: #1976d2;
  font-weight: 600;
}

.insights-graph {
  background: white;
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 20px;
}

.mood-graph-svg {
  width: 100%;
  height: auto;
}

.insights-stats-title {
  text-align: center;
  color: #999;
  font-size: 12px;
  margin: 20px 0 12px 0;
}

.mood-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.mood-stat-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #f5f5f5;
  border-radius: 12px;
}

.mood-stat-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 80px;
  font-size: 14px;
  font-weight: 500;
}

.mood-stat-progress {
  flex: 1;
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
}

.mood-stat-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}

.mood-stat-fill.great {
  background: #1976d2;
}

.mood-stat-fill.good {
  background: #388e3c;
}

.mood-stat-fill.okay {
  background: #f57c00;
}

.mood-stat-fill.bad {
  background: #e64a19;
}

.mood-stat-fill.worst {
  background: #c62828;
}

.mood-stat-count {
  min-width: 80px;
  text-align: right;
  font-size: 13px;
  color: #666;
}

.insights-summary {
  text-align: center;
  padding: 16px;
  background: #f5f5f5;
  border-radius: 12px;
}

.insights-summary p {
  margin: 8px 0;
  font-size: 14px;
  color: #666;
}

.insights-empty {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}

.insights-empty .material-symbols-outlined {
  font-size: 64px;
  color: #ccc;
  margin-bottom: 16px;
}

.insights-empty p {
  font-size: 15px;
  line-height: 1.6;
}

/* メニューモーダル */
.menu-section {
  margin-bottom: 24px;
}

.menu-section h3 {
  font-size: 14px;
  color: #666;
  margin-bottom: 12px;
  font-weight: 600;
}

.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: #f5f5f5;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  cursor: pointer;
  margin-bottom: 8px;
  transition: background 0.2s;
}

.menu-item:hover {
  background: #e0e0e0;
}

.menu-item:active {
  background: #d0d0d0;
}

.menu-item .material-symbols-outlined {
  font-size: 24px;
  color: #1976d2;
}

.menu-info {
  background: #f5f5f5;
  padding: 16px;
  border-radius: 12px;
}

.menu-info p {
  margin: 8px 0;
  font-size: 14px;
  color: #666;
}

.menu-info strong {
  color: #333;
  font-weight: 600;
}
