/* 入力画面（iPhone のホーム画面に追加して使う） */

:root {
  --ink: #1f2433;
  --muted: #555b69;
  --line: #d5d8de;
  --field: #8a8f99;
  --bg: #f7f7f5;
  --card: #fff;
  --primary: #1f2433;
  --danger: #b3261e;
  --ok: #1e6b3a;
  --focus: #1f5fbf;
  --alert: #c62828;
  --past: #eceef1;
  /* 札の色。ボード（board.css）とそろえる */
  --tag-parts: #f2c230;
  --tag-wash: #7cc882;
  --tag-call: #f29a9a;
  --tag-keep: #9cc2f2;
  --tag-ins: #d0b0f2;
  --tag-other: #d5d8de;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

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

.bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 4px) calc(env(safe-area-inset-right) + 8px) 8px
    calc(env(safe-area-inset-left) + 16px);
  background: var(--primary);
  color: #fff;
}

.bar h1 {
  font-size: 18px;
}

.bar-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 8px;
  color: #fff;
}

.tabs {
  display: flex;
  gap: 6px;
  width: 100%;
  padding-right: 8px;
}

.tabs button {
  flex: 1 1 0;
  min-height: 44px;
  border: 1px solid rgb(255 255 255 / 0.5);
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font: inherit;
  font-weight: 700;
}

.tabs button[aria-pressed="true"] {
  border-color: #fff;
  background: #fff;
  color: var(--ink);
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px calc(env(safe-area-inset-right) + 16px) calc(env(safe-area-inset-bottom) + 32px)
    calc(env(safe-area-inset-left) + 16px);
}

.add-label,
.name-field label {
  display: block;
  margin-bottom: 4px;
  font-weight: 700;
}

/* iOS は 16px 未満の入力欄で拡大するので、文字は 16px 以上にする */
textarea,
input[type="text"],
input[type="date"] {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--field);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 17px;
}

textarea {
  resize: vertical;
}

input[type="text"],
input[type="date"] {
  min-height: 44px;
}

/* iOS の日付欄は中身が空だと高さが潰れるので、見た目を自前にする */
input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
}

.who {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.name-field {
  margin-top: 12px;
}

.btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.6;
}

.btn-primary {
  width: 100%;
  margin-top: 12px;
  background: var(--primary);
  color: #fff;
}

.btn-danger {
  border-color: var(--danger);
  color: var(--danger);
}

.msg {
  min-height: 1.6em;
  margin-top: 8px;
  color: var(--ok);
}

.msg.is-error {
  color: var(--danger);
}

.list {
  margin-top: 16px;
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.list-head h2 {
  font-size: 18px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
}

.toggle input {
  width: 22px;
  height: 22px;
}

.memos {
  list-style: none;
}

.memo {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}

.memo + .memo {
  margin-top: 8px;
}

.memo-body {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.memo-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.memo-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.memo.is-done .memo-body {
  color: var(--muted);
  text-decoration: line-through;
}

.empty {
  padding: 16px 0;
  color: var(--muted);
  text-align: center;
}

/* 予定：一覧 */
#ev-list-view > .btn-primary {
  margin-top: 0;
}

.ev-group + .ev-group {
  margin-top: 16px;
}

.ev-group h3 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 16px;
}

.count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.ev-group .empty {
  padding: 8px 0;
  text-align: left;
}

.ev-list {
  list-style: none;
}

.ev-list li + li {
  margin-top: 8px;
}

.ev-card {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  text-align: left;
}

.ev-card:active {
  border-color: var(--ink);
}

.ev-card.is-past {
  border-style: dashed;
  background: var(--past);
}

.ev-title {
  display: block;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.ev-sub {
  display: block;
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.ev-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.badge,
.tag {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.4;
}

.badge {
  border: 1px solid var(--field);
}

.badge[data-contact="要"] {
  border-color: var(--alert);
  background: var(--alert);
  color: #fff;
}

.tag {
  background: var(--tag-other);
}

[data-tag="部品待ち"] { --tag: var(--tag-parts); }
[data-tag="洗車済"] { --tag: var(--tag-wash); }
[data-tag="要連絡"] { --tag: var(--tag-call); }
[data-tag="預かり"] { --tag: var(--tag-keep); }
[data-tag="保険"] { --tag: var(--tag-ins); }

.tag[data-tag] {
  background: var(--tag, var(--tag-other));
}

/* 予定：フォーム */
.ev-form h2 {
  font-size: 18px;
}

.field {
  min-width: 0;
  margin-top: 14px;
  padding: 0;
  border: 0;
}

.field legend,
.field > label {
  display: block;
  margin-bottom: 4px;
  padding: 0;
  font-weight: 700;
}

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

.seg,
.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.choice {
  position: relative;
  flex: 1 1 0;
  min-width: 64px;
}

.checks .choice {
  flex: 0 0 auto;
}

/* 本物の入力は見えないまま上に重ね、押せる範囲を札全体にする */
.choice input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
}

.choice span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--field);
  border-radius: 8px;
  background: #fff;
  font-weight: 700;
}

.choice input:checked + span {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.choice input:checked + span[data-tag] {
  border: 2px solid var(--ink);
  background: var(--tag);
  color: var(--ink);
}

.choice input[type="checkbox"]:checked + span::before {
  content: "✓";
  margin-right: 4px;
}

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

.sub-label {
  display: block;
  margin: 12px 0 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.custom-tag-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.custom-tag-row + .msg {
  min-height: 0;
  margin-top: 4px;
}

.custom-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
}

.tag-remove {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--tag-other);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin-top: 10px;
  font-weight: 700;
}

.check input {
  width: 22px;
  height: 22px;
}

.form-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: 8px;
}

.form-actions .btn-primary {
  margin-top: 0;
}

.btn-block {
  width: 100%;
  margin-top: 24px;
}
