:root {
  color-scheme: light;
  --bg: #f6f7f1;
  --surface: #ffffff;
  --surface-soft: #f0f5f2;
  --ink: #20312d;
  --muted: #66736d;
  --line: #dce4de;
  --primary: #21745b;
  --primary-dark: #175640;
  --accent: #d98b2b;
  --warn: #b34032;
  --shadow: 0 18px 50px rgba(36, 54, 47, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(135deg, rgba(33, 116, 91, 0.12), transparent 34rem),
    linear-gradient(225deg, rgba(217, 139, 43, 0.1), transparent 30rem),
    var(--bg);
  color: var(--ink);
  font-family:
    "Hiragino Sans",
    "Yu Gothic",
    "Meiryo",
    system-ui,
    sans-serif;
  line-height: 1.7;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 56px;
}

.page-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--primary-dark);
  font-weight: 700;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.page-nav a::before {
  content: "←";
  margin-right: 0.45em;
}

.page-nav a:hover,
.page-nav a:focus-visible {
  color: var(--primary);
}

.page-footer {
  padding-top: 24px;
  text-align: center;
}

.page-footer a {
  color: var(--muted);
  font-size: 0.78rem;
  text-underline-offset: 3px;
}

.page-footer a:hover,
.page-footer a:focus-visible {
  color: var(--primary);
}

.hero {
  padding: 28px 0 20px;
}

.hero h1 {
  margin: 8px 0 12px;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1.12;
  letter-spacing: 0;
}

.lead {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.eyebrow,
.label {
  margin: 0;
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0;
}

section {
  margin-top: 22px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

h2 {
  margin: 4px 0 0;
  font-size: 1.45rem;
  line-height: 1.35;
  letter-spacing: 0;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.date-picker {
  display: grid;
  gap: 6px;
  min-width: min(220px, 100%);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.date-picker input,
.field input,
.field textarea,
.json-output {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.date-picker input,
.field input {
  min-height: 44px;
  padding: 10px 12px;
}

.field textarea,
.json-output {
  padding: 12px;
  resize: vertical;
}

.date-picker input:focus,
.field input:focus,
.field textarea:focus,
.json-output:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(33, 116, 91, 0.15);
}

.entry-form {
  display: grid;
  gap: 18px;
  margin-top: 20px;
}

.entry-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.entry-card,
.stat-card,
.history-day {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.entry-card {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.entry-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.entry-index {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--primary-dark);
  font-weight: 800;
}

.entry-note {
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  font-size: 0.92rem;
  font-weight: 700;
}

.counter {
  justify-self: end;
  color: var(--muted);
  font-size: 0.78rem;
}

.counter.is-over {
  color: var(--warn);
  font-weight: 700;
}

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

.hint-chip {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid #cbdad1;
  border-radius: 999px;
  background: #f7faf8;
  color: var(--primary-dark);
  font-size: 0.85rem;
  font-weight: 700;
}

.hint-chip:hover,
.hint-chip:focus-visible {
  border-color: var(--primary);
}

.form-actions,
.data-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.status {
  min-height: 1.7em;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.status.is-error {
  color: var(--warn);
  font-weight: 700;
}

.primary-button,
.secondary-button,
.ghost-button,
.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
  text-decoration: none;
}

.primary-button {
  background: var(--primary);
  color: #fff;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--primary-dark);
}

.secondary-button,
.file-button {
  border-color: var(--primary);
  background: #fff;
  color: var(--primary-dark);
}

.ghost-button {
  border-color: var(--line);
  background: #fff;
  color: var(--muted);
}

.ghost-button:hover,
.ghost-button:focus-visible,
.secondary-button:hover,
.secondary-button:focus-visible,
.file-button:hover,
.file-button:focus-within {
  background: var(--surface-soft);
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.stats-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.9fr);
  gap: 20px;
  align-items: center;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  padding: 18px;
}

.stat-number {
  display: block;
  color: var(--primary-dark);
  font-size: 2.2rem;
  font-weight: 900;
  line-height: 1;
}

.stat-label {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-weight: 700;
}

.history-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.empty-state {
  margin: 0;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-soft);
}

.history-day {
  padding: 18px;
}

.history-day h3 {
  margin: 0 0 12px;
  font-size: 1.05rem;
  letter-spacing: 0;
}

.history-items {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-item {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.history-item:first-child {
  padding-top: 0;
  border-top: 0;
}

.history-item strong {
  display: block;
}

.history-item p {
  margin: 4px 0 0;
  color: var(--muted);
}

.tiny-note {
  margin: 6px 0 0;
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 700;
}

.data-panel {
  display: grid;
  gap: 14px;
}

.json-output {
  min-height: 180px;
  font-family:
    "SFMono-Regular",
    Consolas,
    "Liberation Mono",
    monospace;
  font-size: 0.85rem;
  line-height: 1.55;
}

@media (max-width: 900px) {
  .entry-list,
  .stats-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1120px);
    padding: 20px 0 36px;
  }

  section {
    padding: 18px;
  }

  .section-head,
  .form-actions,
  .data-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button,
  .secondary-button,
  .ghost-button,
  .file-button {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}
