﻿:root {
  --bg: #f3f1e8;
  --card: #fffef8;
  --ink: #2d2a26;
  --line: #d7d2c3;
  --accent: #1e6f4f;
  --accent-2: #b8602c;
}

* { box-sizing: border-box; }
html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}
body {
  margin: 0;
  font-family: "Yu Gothic", "YuGothic", "Meiryo", "Hiragino Kaku Gothic ProN", "MS PGothic", sans-serif;
  background: linear-gradient(160deg, #f8f6ef, #e9e3d1);
  color: var(--ink);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg, #fff);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.topbar nav {
  display: flex;
  gap: 12px;
}

.layout {
  max-width: 1080px;
  margin: 20px auto;
  padding: 0 14px;
  display: grid;
  gap: 16px;
}

.layout.single {
  grid-template-columns: 1fr;
  max-width: 880px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.04);
}

.card.narrow {
  max-width: 420px;
  margin: 10vh auto;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.smart-summary {
  padding: 12px;
  gap: 10px;
}

.summary-item {
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.summary-label {
  margin: 0 0 8px;
  font-size: 0.82rem;
  color: #3b4d63;
  font-weight: 700;
}

.summary-value {
  margin: 0;
  letter-spacing: 0.01em;
}

.summary-value .yen {
  margin-left: 4px;
  font-size: 0.85rem;
  font-weight: 600;
}

.money {
  font-size: 1.4rem;
  font-weight: 700;
}

.income { color: var(--accent) !important; }
.expense { color: #c62828 !important; }

.month-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.calendar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mushroom-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  line-height: 1;
  color: #9ca3af;
  filter: grayscale(100%);
  user-select: none;
}

.calendar {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.calendar-wrap {
  width: 100%;
  overflow-x: auto;
}

.calendar th,
.calendar td {
  border: 1px solid var(--line);
  vertical-align: top;
  height: 90px;
  width: calc(100% / 7);
}

.calendar td a {
  display: block;
  height: 100%;
  padding: 6px;
}

.date-number {
  font-weight: 700;
}

.date-head {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cell-mushroom {
  color: #9ca3af;
  font-size: 0.9em;
  line-height: 1;
  filter: grayscale(100%);
  cursor: pointer;
  user-select: none;
}

.cell-mushroom.is-red {
  color: #d32f2f;
  filter: grayscale(0%);
}

.mini-money {
  display: block;
  margin-top: 6px;
  color: var(--accent-2);
  font-size: 0.85rem;
}

.mini-money.income {
  color: var(--accent) !important;
}

.mini-money.expense {
  color: #c62828 !important;
}

.today {
  background: #d9ecff !important;
  box-shadow: inset 0 0 0 2px #2f73b8;
}

.today .date-number {
  display: inline-block;
  min-width: 1.8em;
  padding: 1px 6px;
  border-radius: 999px;
  background: #2f73b8;
  color: #fff;
  line-height: 1.35;
}

.empty { background: #f6f6f4; }

.stack {
  display: grid;
  gap: 8px;
}

.entry-rows {
  display: grid;
  gap: 8px;
}

.income-panel {
  display: grid;
  gap: 6px;
}

.income-fields {
  display: flex;
  align-items: center;
  gap: 8px;
}

.entry-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
}

.entry-row.no-icon-row {
  grid-template-columns: minmax(0, 1fr) minmax(90px, auto) minmax(6.5em, auto);
}

.entry-note-input {
  width: 100%;
}

.yen-input {
  text-align: right;
  width: 11ch;
  min-width: 11ch;
  justify-self: start;
}

.yen-input.amount-filled-red {
  color: #a73d1d;
  font-weight: 700;
}

.category-select {
  width: 6.5em;
  min-width: 6.5em;
  justify-self: start;
}

.icon-select-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-select {
  width: 44px;
  min-width: 44px;
  text-align: center;
}

.icon-preview {
  width: 68px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.hidden {
  display: none !important;
}

.entry-icon-picker {
  display: flex;
  gap: 6px;
}

.icon-option {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 4px;
  cursor: pointer;
}

.icon-option img {
  width: 100%;
  height: 52px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}

.icon-option.active {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
}

.note-lines {
  display: grid;
  gap: 8px;
}

.note-line-input {
  width: 100%;
}

.add-line-button {
  width: fit-content;
  background: var(--accent-2);
}

label { font-weight: 700; }
input, textarea, select, button {
  font: inherit;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #bfb8a4;
}

button {
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
}

button:hover { filter: brightness(1.05); }

.back-button {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

.back-button:hover {
  text-decoration: none;
  filter: brightness(1.05);
}

.bottom-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.inline-form {
  margin: 0;
}

.reset-button {
  background: #5f6f8a;
  color: #fff;
  border: none;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
}

.error {
  background: #fee;
  border: 1px solid #e3a0a0;
  color: #8f1b1b;
  padding: 8px;
  border-radius: 8px;
}

.success {
  background: #ebf9ed;
  border: 1px solid #9dd0a6;
  color: #125d22;
  padding: 8px;
  border-radius: 8px;
}

.photo-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}

.camera-panel {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.camera-preview {
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0c1f33;
}

.camera-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.camera-actions button {
  width: auto;
}

.camera-message {
  margin: 0;
  font-size: 0.9rem;
  color: #355272;
}

.error-text {
  color: #b3261e !important;
}

.photo-grid img {
  width: 100%;
  height: 170px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.photo-grid figcaption {
  font-size: 0.82rem;
  margin-top: 4px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

@media (max-width: 760px) {
  .topbar {
    padding: 10px 12px;
    flex-wrap: wrap;
    align-items: center;
  }
  .topbar h1 {
    width: 100%;
    margin: 0;
    font-size: 1.35rem;
  }
  .topbar nav {
    width: 100%;
    justify-content: flex-end;
    gap: 10px;
    font-size: 0.92rem;
  }
  .layout {
    margin: 12px auto;
    padding: 0 10px;
    gap: 12px;
  }
  .card {
    padding: 12px;
  }
  .summary-grid { grid-template-columns: 1fr; }
  .summary-item {
    padding: 10px;
  }
  .summary-label {
    margin-bottom: 6px;
    font-size: 0.78rem;
  }
  .summary-value {
    font-size: 1.15rem;
  }
  .month-nav h2 {
    font-size: 1.35rem;
    margin: 0;
  }
  .calendar {
    min-width: 640px;
  }
  .calendar th, .calendar td {
    height: 64px;
    font-size: 0.9rem;
  }
  .calendar td a {
    padding: 4px;
  }
  .money {
    font-size: 1.25rem;
  }
  .income-fields {
    flex-direction: column;
    align-items: stretch;
  }
  .yen-input,
  .category-select {
    width: 100%;
    min-width: 0;
    justify-self: stretch;
  }
  .entry-row { grid-template-columns: 1fr; }
  .entry-row.no-icon-row { grid-template-columns: 1fr; }
  .add-line-button,
  .back-button,
  .reset-button {
    width: 100%;
    text-align: center;
  }
  .bottom-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .inline-form {
    width: 100%;
  }
  .photo-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
  }
  .photo-grid img {
    height: 120px;
  }
  .camera-actions button {
    width: 100%;
  }
}

