:root {
  --mint: #7fe0c4;
  --mint-dark: #4fae92;
  --mint-bg: #eafff7;
  --pink: #ff9fc2;
  --blue: #5aabe8;
  --yellow: #ffd34d;
  --ink: #33403d;
  --ink-soft: #6b7a76;
  --bg: #fbfdfc;
  --card: #ffffff;
  --line-chat: #06c755;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 10px rgba(79, 174, 146, 0.12);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

#app {
  max-width: 430px;
  margin: 0 auto;
  padding: 0 16px 32px;
  min-height: 100vh;
}

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* ---------- header ---------- */
.header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0 10px;
}

.header__avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  flex: none;
  background: var(--mint-bg);
  box-shadow: var(--shadow);
}

.header__avatar svg {
  width: 100%;
  height: 100%;
  display: block;
}

.header__titles {
  flex: 1;
  min-width: 0;
}

.header__logo {
  font-size: 20px;
  font-weight: 800;
  margin: 0;
  letter-spacing: 0.02em;
}

.header__freshness {
  font-size: 12px;
  color: var(--ink-soft);
  margin: 2px 0 0;
}

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

.card__title {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.card__title .icon {
  color: var(--mint-dark);
}

.empty-note {
  font-size: 13px;
  color: var(--ink-soft);
  background: var(--mint-bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

/* ---------- conditions ---------- */
.field {
  margin-bottom: 12px;
}

.field:last-child {
  margin-bottom: 0;
}

.field__label {
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.hint-small {
  font-size: 10px;
  color: var(--ink-soft);
  background: #f1f1ea;
  border-radius: 6px;
  padding: 1px 5px;
}

select, input[type="number"], input[type="text"] {
  width: 100%;
  font-size: 16px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid #e1ece8;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
}

select:focus, input:focus {
  outline: none;
  border-color: var(--mint);
}

.segmented {
  display: flex;
  gap: 6px;
}

.segmented button {
  flex: 1;
  border: 1.5px solid #e1ece8;
  background: #fff;
  color: var(--ink-soft);
  border-radius: var(--radius-sm);
  padding: 9px 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.segmented button.is-active {
  background: var(--mint);
  border-color: var(--mint-dark);
  color: #fff;
}

/* ---------- history ---------- */
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.history-table th {
  text-align: left;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 4px 4px;
  border-bottom: 1px solid #eef3f1;
}

.history-table td {
  padding: 6px 4px;
  border-bottom: 1px solid #f3f7f5;
}

.history-table tr.is-outlier td {
  color: #b8a37a;
  opacity: 0.75;
}

.history-table .val {
  text-align: right;
  font-weight: 700;
}

.outlier-flag {
  display: inline-flex;
  vertical-align: -3px;
  margin-right: 3px;
  color: #c79a3f;
}

.chart-wrap {
  margin-top: 12px;
  height: 160px;
}

/* ---------- prediction ---------- */
.predict-main {
  text-align: center;
  padding: 8px 0 4px;
}

.predict-main__label {
  font-size: 12px;
  color: var(--ink-soft);
}

.predict-main__value {
  font-size: 32px;
  font-weight: 800;
  color: var(--mint-dark);
}

.predict-sub {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.predict-sub__item {
  flex: 1;
  background: var(--mint-bg);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  text-align: center;
}

.predict-sub__item .lbl {
  font-size: 11px;
  color: var(--ink-soft);
}

.predict-sub__item .val {
  font-size: 16px;
  font-weight: 700;
}

.predict-count {
  text-align: center;
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 8px;
}

/* ---------- target / remaining ---------- */
.target-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.btn--mint {
  background: var(--mint);
  color: #fff;
}

.btn--outline {
  background: #fff;
  border: 1.5px solid var(--mint);
  color: var(--mint-dark);
}

.result-grid {
  margin-top: 14px;
}

.result-pt {
  text-align: center;
  padding: 10px 0;
}

.result-pt__value {
  font-size: 30px;
  font-weight: 800;
}

.result-pt__label {
  font-size: 12px;
  color: var(--ink-soft);
}

.result-pt.is-reached .result-pt__value {
  color: var(--pink);
}

.result-items {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.result-items__item {
  background: var(--mint-bg);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  text-align: center;
}

.result-items__item .lbl {
  font-size: 11px;
  color: var(--ink-soft);
  margin-bottom: 2px;
}

.result-items__item .val {
  font-size: 18px;
  font-weight: 800;
  color: var(--mint-dark);
}

.result-note {
  font-size: 10.5px;
  color: var(--ink-soft);
  margin-top: 10px;
}

.settings {
  margin-top: 14px;
  border-top: 1px dashed #e1ece8;
  padding-top: 10px;
}

.settings__toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.settings__toggle .icon {
  transition: transform 0.15s ease;
}

.settings__toggle.is-open .icon {
  transform: rotate(180deg);
}

.settings__body {
  margin-top: 10px;
}

.settings__body[hidden] {
  display: none;
}

.rate-row {
  display: flex;
  gap: 8px;
}

.rate-row select {
  flex: 1;
}

.rate-row input {
  flex: 1;
}

/* ---------- chat ---------- */
.chat-card {
  padding: 0;
  overflow: hidden;
}

.chat-card__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid #f0f4f2;
}

.chat-card__head img, .chat-card__head .mini-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--mint-bg);
  flex: none;
}

.chat-card__head .mini-avatar svg {
  width: 100%;
  height: 100%;
}

.chat-card__head .name {
  font-size: 13px;
  font-weight: 700;
}

.chat-log {
  height: 300px;
  overflow-y: auto;
  padding: 12px;
  background: #f7faf8;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  max-width: 86%;
}

.msg--bot {
  align-self: flex-start;
}

.msg--me {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg__avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  overflow: hidden;
  flex: none;
  background: var(--mint-bg);
}

.msg__avatar svg {
  width: 100%;
  height: 100%;
}

.msg__bubble {
  font-size: 14px;
  line-height: 1.4;
  padding: 8px 12px;
  border-radius: 16px;
  word-break: break-word;
  white-space: pre-wrap;
}

.msg--bot .msg__bubble {
  background: #fff;
  border: 1px solid #e9f1ee;
  border-bottom-left-radius: 4px;
}

.msg--me .msg__bubble {
  background: var(--line-chat);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg--typing .msg__bubble {
  color: var(--ink-soft);
  font-weight: 700;
  letter-spacing: 2px;
}

.chat-input {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #f0f4f2;
  background: #fff;
}

.chat-input input {
  flex: 1;
  border-radius: 999px;
  padding: 10px 14px;
}

.chat-input button {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--line-chat);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.chat-input button .icon {
  width: 18px;
  height: 18px;
}

footer.page-footer {
  text-align: center;
  font-size: 11px;
  color: var(--ink-soft);
  padding: 10px 0 24px;
}

/* ---------- icons ---------- */
.icon {
  width: 16px;
  height: 16px;
  display: inline-block;
  vertical-align: -3px;
}

@media (min-width: 431px) {
  #app {
    padding: 0 20px 32px;
  }
}

/* 生成素材のアイテムアイコン（Codex 生成・透過 webp） */
.result-items__item .item-icon {
  display: block;
  width: 40px;
  height: 40px;
  margin: 0 auto 4px;
  object-fit: contain;
}

/* 期間の切り替え（7日／30日／90日／全部）と、表を決まった高さでスクロールさせる枠 */
.segmented--range {
  margin-bottom: 12px;
}

.history-scroll {
  max-height: 330px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 12px;
  border-top: 1px solid #e1ece8;
}

.history-scroll thead th {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
