/* 斷捨離小幫手 - 暖色系、手機優先 */

:root {
  --cream: #FBF4EA;
  --beige: #F0E4D3;
  --beige-dark: #E3D3BC;
  --terracotta: #C97B52;
  --terracotta-dark: #AD5F3B;
  --brown: #6B4A3A;
  --text: #4A3B32;
  --text-muted: #8C7A6B;
  --sage: #7C9473;
  --danger: #B2503E;
  --white: #FFFFFF;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-soft: 0 4px 16px rgba(107, 74, 58, 0.1);
  --nav-height: 64px;
  --header-height: 56px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
}

h1, h2, h3 {
  margin: 0;
  color: var(--brown);
}

p {
  margin: 0 0 8px;
}

button {
  font-family: inherit;
}

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 16px;
  background: var(--terracotta);
  color: var(--white);
  box-shadow: var(--shadow-soft);
}

.app-header h1 {
  color: var(--white);
  font-size: 1.1rem;
  font-weight: 700;
}

.icon-btn {
  border: none;
  background: transparent;
  font-size: 1.2rem;
  line-height: 1;
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  color: inherit;
}

.icon-btn:active {
  background: rgba(255, 255, 255, 0.2);
}

/* ---------- Main / panels ---------- */
main {
  padding: 16px;
  max-width: 600px;
  margin: 0 auto;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
  animation: fade-in 0.15s ease-out;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 16px;
  margin-bottom: 16px;
}

.muted-text {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--white);
  border-top: 1px solid var(--beige-dark);
  height: var(--nav-height);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 10;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 6px 0;
}

.nav-btn .nav-icon {
  font-size: 1.3rem;
}

.nav-btn.is-active {
  color: var(--terracotta-dark);
  font-weight: 700;
}

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 600;
}

.btn-primary {
  background: var(--terracotta);
  color: var(--white);
}

.btn-primary:active {
  background: var(--terracotta-dark);
}

.btn-primary:disabled {
  background: var(--beige-dark);
  color: var(--text-muted);
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-danger-outline {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn-block {
  width: 100%;
  display: block;
  margin-top: 10px;
}

.btn-fab {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--terracotta);
  color: var(--white);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.btn-fab:active {
  background: var(--terracotta-dark);
}

/* ---------- Items tab ---------- */
.summary-bar {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.chip-row::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  border: 1px solid var(--beige-dark);
  background: var(--white);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}

.chip.is-active {
  background: var(--terracotta);
  border-color: var(--terracotta);
  color: var(--white);
}

.item-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.item-card {
  display: flex;
  gap: 12px;
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  padding: 12px;
  cursor: pointer;
}

.item-thumb {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--beige);
  flex: 0 0 auto;
}

.item-thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: var(--text-muted);
}

.item-info {
  flex: 1;
  min-width: 0;
}

.item-info .item-name {
  font-weight: 700;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.tag {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--beige);
  color: var(--brown);
}

.tag.status-待決定 { background: #EFE3C7; color: #8A6D1E; }
.tag.status-保留 { background: #DCE7D6; color: #4F6B47; }
.tag.status-丟棄 { background: #F2D9D3; color: #8A3B2C; }
.tag.status-捐贈 { background: #D8E3EC; color: #355A77; }
.tag.status-賣出 { background: #E9DCF0; color: #6B4590; }

.item-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-date {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.empty-hint {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 16px;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(74, 59, 50, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}

.modal-card {
  background: var(--cream);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px;
}

@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
  }
  .modal-card {
    border-radius: var(--radius-lg);
  }
}

.field {
  display: block;
  margin-bottom: 14px;
  font-size: 0.85rem;
  color: var(--brown);
  font-weight: 600;
}

.field input,
.field select,
.field textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--beige-dark);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 400;
  font-family: inherit;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--terracotta);
}

.photo-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}

.photo-preview {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--beige);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.modal-actions .btn-danger-outline {
  margin-right: auto;
}

/* ---------- Challenge tab ---------- */
.challenge-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.challenge-text {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 8px 0 4px;
  line-height: 1.5;
}

.btn-checked {
  background: var(--sage) !important;
}

.streak-row {
  display: flex;
  gap: 12px;
}

.streak-box {
  flex: 1;
  text-align: center;
}

.streak-num {
  display: block;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--terracotta-dark);
}

.streak-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.calendar-month-label {
  font-weight: 700;
  color: var(--brown);
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.85rem;
  color: var(--text);
}

.cal-day.empty {
  visibility: hidden;
}

.cal-day.is-checked {
  background: var(--terracotta);
  color: var(--white);
  font-weight: 700;
}

.cal-day.is-today {
  border: 2px solid var(--terracotta-dark);
}

.cal-day.is-future {
  color: var(--beige-dark);
}

/* ---------- Judge tab ---------- */
.judge-item-picker {
  margin-bottom: 16px;
}

.judge-card {
  min-height: 160px;
}

.judge-question-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--brown);
}

.judge-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.judge-option {
  text-align: left;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--beige-dark);
  background: var(--white);
  color: var(--text);
  cursor: pointer;
  font-size: 0.95rem;
}

.judge-option.is-selected {
  border-color: var(--terracotta);
  background: #FBE9DD;
  color: var(--terracotta-dark);
  font-weight: 700;
}

.judge-nav {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  margin-bottom: 12px;
}

#judge-progress {
  text-align: center;
}

.judge-result-badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 12px;
}

.judge-reasons {
  margin: 0 0 16px;
  padding-left: 20px;
}

.judge-reasons li {
  margin-bottom: 6px;
  line-height: 1.5;
}

.judge-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.ai-answer-box {
  background: var(--beige);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-top: 12px;
  white-space: pre-wrap;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: var(--brown);
  color: var(--white);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 0.85rem;
  box-shadow: var(--shadow-soft);
  z-index: 200;
  max-width: 90%;
  text-align: center;
}

[hidden]{display:none !important;}
