:root {
  color-scheme: light;
  --ink: #252525;
  --muted: #6f6f6f;
  --line: #e8e8e8;
  --header: #f7f7f7;
  --paper: #ffffff;
  --accent: #2f80d6;
  --focus: rgba(47, 128, 214, 0.22);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Sans", "Yu Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-size: 14px;
  line-height: 1.4;
}

body.terms-open {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--paper);
}

.terms-modal {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(25, 25, 25, 0.58);
}

.terms-dialog {
  display: flex;
  width: min(100%, 40rem);
  max-height: min(92vh, 48rem);
  flex-direction: column;
  gap: 0.9rem;
  padding: 1.2rem;
  color: var(--ink);
  background: var(--paper);
  border-radius: 0.55rem;
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.22);
}

.terms-dialog h1 {
  margin: 0;
  font-size: 1.2rem;
}

.terms-scroll {
  overflow-y: auto;
  min-height: 12rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  outline: none;
}

.terms-scroll:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

.terms-scroll p {
  margin: 0.35rem 0 0.85rem;
}

.terms-scroll ol {
  margin: 0;
  padding-left: 1.4rem;
}

.terms-scroll li {
  padding-left: 0.2rem;
}

.terms-scroll li + li {
  margin-top: 0.85rem;
}

.terms-scroll li p {
  margin: 0.25rem 0 0;
}

.terms-read-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.terms-read-label input {
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  accent-color: var(--accent);
}

.terms-agree {
  align-self: flex-start;
  padding: 0.55rem 0.9rem;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 0.35rem;
  cursor: pointer;
}

.terms-agree:disabled {
  cursor: default;
  opacity: 0.45;
}

.terms-agree:focus-visible,
.terms-read-label input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.terms-error {
  margin: 0;
  color: #8a352c;
  font-size: 0.85rem;
}

.database-title {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  font-weight: 700;
}

.setup-section {
  width: min(100% - 1rem, 480px);
  margin: 5rem auto 0;
  padding: 1rem;
}

.setup-section h1 {
  margin: 0 0 1rem;
  font-size: 1.35rem;
}

.setup-form {
  display: grid;
  grid-template-columns: 6rem 1fr;
  align-items: center;
  gap: 0.7rem 0.8rem;
}

.setup-form label {
  color: var(--muted);
  font-size: 0.85rem;
}

.setup-form input {
  width: 100%;
  min-width: 0;
  padding: 0.6rem 0.7rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  outline: none;
}

.setup-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

.setup-form button {
  grid-column: 2;
  justify-self: start;
  padding: 0.5rem 1rem;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 0.35rem;
  cursor: pointer;
}

.setup-form button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.database-view {
  padding: 0.35rem 0.5rem 2rem;
}

.database-heading {
  padding: 0.2rem 0 0.65rem;
}

.record-actions {
  padding: 0 0 0.65rem;
}

.today-record {
  padding: 0.5rem 0.8rem;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 0.35rem;
  cursor: pointer;
}

.today-record:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.today-record:disabled {
  cursor: default;
  opacity: 0.55;
}

.empty-state {
  margin: 0;
  padding: 1.25rem 0.8rem;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 0.35rem;
}

.database-title {
  color: var(--ink);
  font-size: 0.92rem;
}

.database-icon {
  display: inline-grid;
  width: 1.25rem;
  height: 1.25rem;
  place-items: center;
  color: var(--muted);
  font-size: 1rem;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-bottom: 0;
}

.record-table {
  width: 100%;
  min-width: 360px;
  border-collapse: collapse;
  table-layout: fixed;
}

.record-table th,
.record-table td {
  height: 2.45rem;
  padding: 0.35rem 0.65rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.record-table th:last-child,
.record-table td:last-child {
  border-right: 0;
}

.record-table th {
  overflow: hidden;
  color: var(--muted);
  background: var(--header);
  font-size: 0.8rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-table th:first-child,
.record-table td:first-child {
  width: 44%;
}

.record-table th:last-child,
.record-table td:last-child {
  width: 56%;
}

.record-table td:first-child {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.record-table tr.is-today td {
  background: #fffdf8;
}

.check-cell {
  text-align: left !important;
}

.check-cell input {
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  vertical-align: middle;
}

.check-cell input:disabled {
  cursor: default;
  opacity: 1;
}

.check-cell input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.app-error {
  width: min(100% - 1rem, 680px);
  margin: 1rem auto;
  padding: 0.7rem 0.8rem;
  color: #8a352c;
  background: #fcebea;
  border-radius: 0.35rem;
  font-size: 0.85rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

.app-footer {
  padding: 0.5rem 0.5rem 2rem;
}

.link-button {
  min-height: 44px;
  padding: 0.5rem 0.25rem;
  color: var(--muted);
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 0.85rem;
  text-decoration: underline;
}

.link-button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

body.survey-open {
  overflow: hidden;
}

.survey-prompt {
  position: fixed;
  z-index: 900;
  right: 0;
  bottom: 0.75rem;
  left: 0;
  width: min(100% - 1.5rem, 560px);
  margin: 0 auto;
  padding: 0.9rem 1rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.16);
  animation: survey-slide-up 0.25s ease-out;
}

.survey-prompt-title {
  margin: 0 0 0.2rem;
  font-weight: 600;
}

.survey-prompt-text {
  margin: 0 0 0.7rem;
  color: var(--muted);
}

.survey-prompt-actions,
.survey-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.survey-primary,
.survey-secondary {
  min-height: 44px;
  padding: 0.5rem 1rem;
  border-radius: 0.35rem;
  cursor: pointer;
}

.survey-primary {
  color: #fff;
  background: var(--accent);
  border: 0;
}

.survey-secondary {
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
}

.survey-primary:disabled {
  cursor: default;
  opacity: 0.45;
}

.survey-primary:focus-visible,
.survey-secondary:focus-visible,
.survey-close:focus-visible,
.survey-comment textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.survey-modal {
  position: fixed;
  z-index: 1100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(25, 25, 25, 0.58);
}

.survey-dialog {
  width: min(100%, 32rem);
  max-height: min(92vh, 42rem);
  padding: 1.2rem;
  overflow-y: auto;
  color: var(--ink);
  background: var(--paper);
  border-radius: 0.5rem;
}

.survey-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.survey-head h1 {
  margin: 0;
  font-size: 1.1rem;
}

.survey-close {
  width: 44px;
  height: 44px;
  color: var(--muted);
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
}

.survey-form {
  display: grid;
  gap: 0.8rem;
  margin-top: 0.6rem;
}

.survey-notice {
  margin: 0;
  padding: 0.6rem 0.7rem;
  color: var(--muted);
  background: var(--header);
  border-radius: 0.35rem;
  font-size: 0.82rem;
}

.survey-progress {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.survey-question {
  margin: 0;
  padding: 0;
  border: 0;
}

.survey-question legend {
  padding: 0;
  margin-bottom: 0.7rem;
  font-weight: 600;
  line-height: 1.5;
}

.survey-scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.4rem;
}

.survey-scale label {
  position: relative;
  display: block;
}

.survey-scale input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  opacity: 0;
}

.survey-scale span {
  display: grid;
  min-height: 48px;
  place-items: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  font-size: 1.05rem;
}

.survey-scale input:checked + span {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.survey-scale input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.survey-scale-ends {
  display: flex;
  justify-content: space-between;
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.survey-comment {
  display: grid;
  gap: 0.4rem;
}

.survey-comment textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  resize: vertical;
}

.survey-comment-count {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: right;
}

.survey-website {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.survey-error {
  margin: 0;
  color: #8a352c;
  font-size: 0.85rem;
}

.survey-done {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.survey-done p {
  margin: 0;
  line-height: 1.6;
}

@keyframes survey-slide-up {
  from {
    opacity: 0;
    transform: translateY(1rem);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .survey-prompt {
    animation: none;
  }
}

/* 見た目の調整（落ち着いたミニマル）。構造・文言・動作は変えず、色・余白・形だけを上書きする。 */
:root {
  --ink: #2a2c2b;
  --muted: #666b67;
  --line: #e7e3dc;
  --header: #f3f0ea;
  --paper: #ffffff;
  --accent: #3f7d73;
  --focus: rgba(63, 125, 115, 0.28);
}

body {
  background: #f4f1ec;
  font-size: 16px;
  line-height: 1.55;
}

.app-shell {
  padding: 0.9rem 0.75rem 2rem;
  background: transparent;
}

.database-view {
  padding: 1.1rem 1rem 1.2rem;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 2px 14px rgba(60, 52, 40, 0.08);
}

.database-heading {
  padding: 0.1rem 0 0.9rem;
}

.database-title {
  gap: 0.6rem;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.database-icon {
  width: 1.9rem;
  height: 1.9rem;
  font-size: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M4 21c0-7 5-13 13-13 7 0 11 5 11 11 0 5-5 8-12 8-7 0-12-2-12-6z' fill='%233f7d73'/%3E%3Cpath d='M10 16c2-3 5-4 8-3' stroke='%23ffffff' stroke-opacity='.55' stroke-width='1.6' stroke-linecap='round' fill='none'/%3E%3C/svg%3E") center / contain no-repeat;
}

.record-actions {
  padding: 0 0 1rem;
}

.today-record {
  width: 100%;
  min-height: 48px;
  padding: 0.85rem 1rem;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 600;
}

.empty-state {
  padding: 1.5rem 0.8rem;
  border-radius: 12px;
}

.table-scroll {
  border: 0;
}

.record-table {
  min-width: 0;
  border-collapse: separate;
  border-spacing: 0;
}

.record-table th,
.record-table td {
  height: 3.1rem;
  padding: 0.4rem 0.5rem;
  border-right: 0;
  border-bottom: 1px solid var(--line);
}

.record-table th {
  color: var(--muted);
  background: transparent;
  font-size: 0.82rem;
  font-weight: 600;
}

.record-table tr.is-today td {
  background: #eef5f3;
}

.record-table tr.is-today td:first-child {
  border-radius: 10px 0 0 10px;
}

.record-table tr.is-today td:last-child {
  border-radius: 0 10px 10px 0;
}

.check-cell input,
.terms-read-label input {
  appearance: none;
  -webkit-appearance: none;
  width: 1.65rem;
  height: 1.65rem;
  border: 2px solid #cdc7bd;
  border-radius: 8px;
  background: #fff;
}

.check-cell input:checked,
.terms-read-label input:checked {
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E") center / 80% no-repeat;
  border-color: var(--accent);
}

.check-cell input:disabled:checked {
  background-color: #a9c9c3;
  border-color: #a9c9c3;
}

.check-cell input:disabled:not(:checked) {
  background: #faf8f5;
  border-color: #e2ddd4;
}

.terms-read-label input:disabled {
  background: #faf8f5;
  border-color: #e2ddd4;
  cursor: default;
}

.setup-section {
  margin-top: 2.5rem;
  padding: 1.4rem 1.2rem;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 2px 14px rgba(60, 52, 40, 0.08);
}

.setup-section h1 {
  font-size: 1.4rem;
}

.setup-form input {
  padding: 0.75rem 0.8rem;
  background: #fbfaf7;
  border-radius: 10px;
}

.setup-form button {
  min-height: 48px;
  padding: 0.8rem 1.6rem;
  border-radius: 999px;
  font-weight: 600;
}

.terms-modal {
  background: rgba(46, 42, 36, 0.55);
}

.terms-dialog {
  padding: 1.5rem;
  border-radius: 18px;
}

.terms-dialog h1 {
  font-size: 1.3rem;
}

.terms-scroll {
  padding: 1rem 1.1rem;
  background: #fcfbf9;
  border-radius: 12px;
  line-height: 1.7;
}

.terms-agree {
  width: 100%;
  min-height: 48px;
  padding: 0.85rem 1rem;
  border-radius: 999px;
  font-weight: 600;
}

.survey-dialog {
  padding: 1.4rem;
  border-radius: 18px;
}

.survey-scale span {
  border-radius: 12px;
}

.survey-comment textarea {
  font: inherit;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
}

.survey-primary,
.survey-secondary {
  border-radius: 999px;
}

.survey-prompt {
  border-radius: 16px;
}

.app-footer {
  text-align: center;
}

@media (max-width: 520px) {
  .setup-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .setup-section {
    margin-top: 3rem;
  }

  .setup-form {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .setup-form label:not(:first-child) {
    margin-top: 0.35rem;
  }

  .setup-form button {
    grid-column: 1;
    margin-top: 0.35rem;
  }
}
