:root {
  --green: #2f6b3a;
  --text: #1d2420;
  --muted: #5d6862;
  --line: #d5dbd7;
  --bg: #ffffff;
  --notice-bg: #e8f3ea;
  --error: #b3261e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --green: #7cc28a;
    --text: #e6ebe7;
    --muted: #a3ada7;
    --line: #3a423d;
    --bg: #161a17;
    --notice-bg: #213027;
    --error: #ff8a80;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 17px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--green);
  color: #fff;
}
.app-name { font-weight: 700; }
.tabs { display: flex; gap: 4px; }
.tabs a {
  color: #fff;
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 600;
}
.tabs a[aria-current="page"] { background: rgba(255, 255, 255, 0.22); }
.account { max-width: 640px; margin: 24px auto 32px; padding: 0 16px; color: var(--muted); font-size: 14px; }
.account form { margin: 0; }
.link { background: none; border: none; color: inherit; text-decoration: underline; font: inherit; padding: 0; margin-left: 8px; }
main { max-width: 640px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 8px 0 16px; }
h2 { font-size: 18px; margin-top: 32px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.stack label.check { flex-direction: row; align-items: center; font-weight: 400; }
input[type="text"], input[type="password"], input[type="date"], textarea {
  width: 100%;
  font: inherit;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
textarea { resize: vertical; }
button.primary {
  font: inherit;
  font-weight: 700;
  padding: 14px;
  border: none;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
}
.notice, .status { background: var(--notice-bg); padding: 10px 12px; border-radius: 8px; }
.error { color: var(--error); margin: 0; }
.hint { color: var(--muted); font-size: 14px; margin: 0; }
.recent { list-style: none; padding: 0; margin: 0; }
.recent li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.recent .date { color: var(--muted); margin-right: 8px; }

/* 一覧・検索 */
.search { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.search .row { display: flex; gap: 8px; }
.search .row > * { flex: 1; min-width: 0; }
.search input, .search select {
  width: 100%;
  font: inherit;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
.search label { font-size: 14px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.search details summary { color: var(--muted); font-size: 14px; cursor: pointer; }
.search details[open] { display: flex; flex-direction: column; gap: 10px; }
button.secondary {
  font: inherit;
  padding: 10px;
  border: 1px solid var(--green);
  border-radius: 8px;
  background: var(--bg);
  color: var(--green);
  font-weight: 700;
}
.count { color: var(--muted); font-size: 14px; margin: 0 0 8px; }
.cards { list-style: none; padding: 0; margin: 0; }
.cards li { border-bottom: 1px solid var(--line); }
.cards a { display: block; padding: 12px 0; color: inherit; text-decoration: none; }
.meta { color: var(--muted); font-size: 14px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--muted); }
.excerpt { margin: 4px 0 0; }
mark { background: #ffe58a; color: #1d2420; padding: 0 1px; }
.pager { display: flex; justify-content: space-between; margin: 16px 0; }
.pager a { color: var(--green); font-weight: 600; }
.body-full { white-space: pre-wrap; font-size: 18px; margin: 16px 0; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; color: var(--muted); font-size: 14px; }
dl.facts dt { font-weight: 600; }
dl.facts dd { margin: 0; }
.back { color: var(--green); font-weight: 600; }

/* 詳細・訂正・履歴・ゴミ箱 */
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 20px 0; }
.button-link {
  display: inline-block;
  padding: 10px 16px;
  border: 1px solid var(--green);
  border-radius: 8px;
  color: var(--green);
  font-weight: 700;
  text-decoration: none;
}
.danger-zone { margin-top: 32px; }
.link.danger { color: var(--error); margin-left: 0; }
.versions { list-style: none; padding: 0; margin: 0; }
.versions li { border-bottom: 1px solid var(--line); padding: 12px 0; }
.versions .body-full { font-size: 16px; margin: 8px 0 0; }
button.small { padding: 4px 12px; font-size: 14px; }
.trash-item { padding: 12px 0; }
.trash-item form { margin: 0 0 0 auto; }
.date-hint { background: var(--notice-bg); padding: 12px; border-radius: 8px; display: flex; flex-direction: column; gap: 8px; }
.date-hint[hidden] { display: none; }
.date-hint .row { display: flex; gap: 8px; flex-wrap: wrap; }

/* 写真 */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; margin: 12px 0; }
.photo-grid:empty { display: none; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; display: block; }
.photo-grid .thumb { position: relative; }
.photo-grid .remove {
  position: absolute; top: 4px; right: 4px; width: 28px; height: 28px;
  border-radius: 50%; border: none; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 16px; line-height: 1;
}
.photo-add { margin-top: 16px; }
input[type="file"] { font: inherit; font-weight: 400; }
.photo-grid .thumb form { margin: 0; }
.removed-photos { margin-top: 16px; color: var(--muted); }
.removed-photos img { opacity: 0.6; }
.put-back { position: absolute; bottom: 4px; left: 4px; right: 4px; background: var(--bg); }

/* 二段階認証 */
.steps { padding-left: 20px; }
.steps li { margin-bottom: 6px; }
.qr { background: #fff; padding: 12px; border-radius: 8px; width: fit-content; margin: 12px 0; }
.qr svg { display: block; }
.secret, .codes code { font-family: ui-monospace, Menlo, monospace; font-size: 16px; letter-spacing: 1px; word-break: break-all; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 0; list-style: none; }

/* 畑 */
.field-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.field-row strong { font-size: 18px; }
.stack select, .stack input[type="number"] {
  font: inherit; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text);
}

/* 収穫・出荷 */
.yield-box { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.yield-box summary { font-weight: 600; cursor: pointer; }
.yield-box .stack { margin-top: 12px; }
.row2 { display: flex; gap: 8px; }
.row2 > * { flex: 1; min-width: 0; }
.stack select, .stack input[type="number"] { width: 100%; }

/* 作付けカルテ */
.subnav { display: flex; gap: 16px; margin: -4px 0 12px; }
.subnav a { color: var(--green); font-weight: 600; }
.summary { background: var(--notice-bg); padding: 12px; border-radius: 8px; color: var(--text); }
.timeline { list-style: none; padding: 0; margin: 0; border-left: 3px solid var(--line); }
.timeline li { padding: 8px 0 8px 14px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 16px; width: 11px; height: 11px; border-radius: 50%; background: var(--line); }
.timeline li.is-planting::before { background: var(--green); }
.timeline a { color: inherit; text-decoration: none; display: block; }
.badge.planting { border-color: var(--green); color: var(--green); }
.badge.muted { opacity: 0.7; }
.crop-row { padding: 10px 0; }
.crop-row a { color: var(--green); font-size: 14px; }

/* ご意見・要望 */
.feedback-link { max-width: 640px; margin: 24px auto 0; padding: 0 16px; font-size: 14px; color: var(--muted); }
.feedback-link a { color: var(--green); font-weight: 600; }
.kinds { border: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.kinds legend { font-weight: 600; margin-bottom: 6px; }
.feedback-item { padding: 12px 0; }
.status-done { opacity: 0.6; }
.small-link { color: var(--green); font-size: 14px; }
