:root {
  --navy: #21395f;
  --orange: #e86b38;
  --red: #d33f3f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif;
  background: #f4f5f7;
  color: #222;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

#topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  background: var(--navy); color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
}
#topbar h1 { font-size: 17px; margin: 0; flex: 1; font-weight: 600; }
#syncStatus { font-size: 12px; opacity: 0.85; }
.iconbtn {
  background: none; border: none; color: #fff;
  font-size: 20px; padding: 2px 8px;
}

.view { padding: 14px; max-width: 720px; margin: 0 auto; }

.cardlist { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: #fff; border-radius: 12px; padding: 12px 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  display: flex; align-items: center; gap: 12px;
}
.card .main { flex: 1; min-width: 0; }
.card .title { font-weight: 600; font-size: 15px; }
.card .sub { font-size: 12.5px; color: #666; margin-top: 2px; }

.duebadge {
  min-width: 74px; text-align: center;
  border-radius: 8px; padding: 6px 8px;
  font-size: 13px; font-weight: 700; color: #fff;
}
.due-green { background: #3d9a55; }
.due-yellow { background: #d99a00; }
.due-red { background: var(--red); }

.stepbadge {
  font-size: 11.5px; font-weight: 700; color: var(--navy);
  border: 1.5px solid var(--navy); border-radius: 6px; padding: 3px 7px;
  white-space: nowrap;
}
.stepbadge.done { color: #3d9a55; border-color: #3d9a55; }

.empty { color: #888; text-align: center; margin-top: 40px; }

.titleinput {
  width: 100%; font-size: 18px; font-weight: 600;
  border: none; border-bottom: 2px solid #ccc; background: none;
  padding: 8px 2px; margin-bottom: 12px;
}
.titleinput:focus { outline: none; border-color: var(--navy); }

.row { display: flex; gap: 10px; margin-bottom: 10px; }
.row > * { flex: 1; min-width: 0; }

select, input, textarea {
  font: inherit; font-size: 15px;
  border: 1px solid #ccc; border-radius: 8px;
  padding: 9px 10px; background: #fff; width: 100%;
}
textarea { resize: vertical; }

.fieldlabel {
  font-size: 12.5px; font-weight: 700; color: #667;
  margin: 18px 0 6px;
}

#stepBar { display: flex; gap: 5px; margin-bottom: 10px; }
#stepBar button {
  flex: 1; padding: 8px 0; font-size: 12.5px; font-weight: 700;
  border: 1.5px solid var(--navy); background: #fff; color: var(--navy);
  border-radius: 8px;
}
#stepBar button.current { background: var(--navy); color: #fff; }
#stepBar button.past { background: #dbe3ef; }

.stepname { font-size: 13px; font-weight: 700; margin: 8px 0 4px; color: var(--navy); }

.check {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border-radius: 10px; padding: 10px 12px;
  margin-bottom: 6px; font-size: 14.5px;
}
.check input[type="checkbox"] { width: 20px; height: 20px; flex: none; }
.check.done label { text-decoration: line-through; color: #999; }
.check label { flex: 1; }

.datefield, .setfield {
  display: block; font-size: 12.5px; color: #667; font-weight: 600;
}
.datefield input, .setfield input { margin-top: 4px; font-weight: 400; }

.hint { font-size: 12.5px; color: #667; margin: 4px 0 0; }

.deadline-item {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border-radius: 10px; padding: 8px 10px; margin-bottom: 6px;
}
.deadline-item input[type="checkbox"] { width: 20px; height: 20px; flex: none; }
.deadline-item input[type="text"] { flex: 2; }
.deadline-item input[type="date"] { flex: 1.4; }
.deadline-item .removebtn {
  background: none; border: none; color: #b33; font-size: 18px; padding: 0 4px; flex: none;
}

.mainbtn {
  background: var(--navy); color: #fff; border: none;
  border-radius: 10px; padding: 12px; font-size: 15px; font-weight: 700; width: 100%;
}
.ghostbtn {
  background: #fff; color: var(--navy); border: 1.5px solid var(--navy);
  border-radius: 10px; padding: 10px; font-size: 14px; font-weight: 600; width: 100%;
}
.dangerbtn {
  background: #fff; color: var(--red); border: 1.5px solid var(--red);
  border-radius: 10px; padding: 10px; font-size: 14px; font-weight: 600; width: 100%;
}
.bottombtns { margin-top: 24px; }

#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; background: #fff; border-top: 1px solid #ddd;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; border: none; background: none;
  padding: 12px 0 10px; font-size: 13px; font-weight: 600; color: #889;
}
.tab.active { color: var(--navy); }

#fab {
  position: fixed; right: 18px; bottom: calc(76px + env(safe-area-inset-bottom));
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--orange); color: #fff; border: none;
  font-size: 28px; line-height: 1;
  box-shadow: 0 3px 8px rgba(0,0,0,0.25); z-index: 10;
}

#toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #333; color: #fff; font-size: 13.5px;
  padding: 9px 16px; border-radius: 20px; z-index: 20;
  max-width: 86%;
}
