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

:root {
  --purple:    #4a154b;
  --purple2:   #3c1144;
  --aubergine: #611f69;
  --bg:        #f4f4f6;
  --white:     #ffffff;
  --border:    #e2e2e6;
  --border2:   #c8c8d0;
  --text:      #1d1c1d;
  --text2:     #616061;
  --text3:     #aaaaaa;
  --c1:#1264a3; --c1l:#e8f2fb;
  --c2:#007a5a; --c2l:#e3f5ef;
  --c3:#e01e5a; --c3l:#fce8ef;
  --coff:#6c6c6c; --coffl:#efefef;
  --gold:#e8a838; --goldl:#fef6e4;
}

/* ── Base ── */
html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
body {
  max-width: 430px;
  margin: 0 auto;
  padding-bottom: 40px;
}

/* ── Header — NOT sticky, plain block ── */
.hdr {
  background: var(--purple);
  padding: 16px 16px 0;
}
.hdr-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
}
.hdr-title {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
}
.shift-pill {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 13px;
  border-radius: 20px;
  background: rgba(255,255,255,.15);
  color: rgba(255,255,255,.85);
  border: 1px solid rgba(255,255,255,.2);
  transition: all .25s;
}
.shift-pill.s1 { background:rgba(18,100,163,.55); border-color:rgba(79,158,255,.4); color:#7ec8ff; }
.shift-pill.s2 { background:rgba(0,122,90,.55);   border-color:rgba(62,207,110,.4); color:#6edba8; }
.shift-pill.s3 { background:rgba(224,30,90,.55);  border-color:rgba(255,100,140,.4); color:#ff8ab0; }
@keyframes pillPop { 0%{transform:scale(1)} 50%{transform:scale(1.13)} 100%{transform:scale(1)} }
.shift-pill.pop { animation: pillPop .28s cubic-bezier(.34,1.56,.64,1); }

/* Basedate row */
.bd-bar {
  border-top: 1px solid rgba(255,255,255,.12);
  padding: 0 0 14px;
}
.bd-toggle-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: none;
  color: rgba(255,255,255,.65);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 12px;
  padding: 12px 0;
  cursor: pointer;
  width: 100%;
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
.bd-toggle-btn svg { width: 13px; height: 13px; flex-shrink: 0; }
.bd-chev { transition: transform .22s; }
.bd-toggle-btn.open .bd-chev { transform: rotate(180deg); }

.bd-slide {
  max-height: 0;
  transition: max-height .28s ease;
  clip-path: inset(0);
}
.bd-slide.open { max-height: 70px; }
.bd-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0 4px;
}
.bd-inner label { font-size: 11px; color: rgba(255,255,255,.5); white-space: nowrap; flex-shrink: 0; }
.bd-inner input[type="date"] {
  flex: 1;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 6px;
  color: rgba(255,255,255,.9);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  padding: 7px 10px;
  outline: none;
  min-height: 38px;
  -webkit-appearance: none;
  appearance: none;
}
.bd-save {
  background: rgba(255,255,255,.2);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 6px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 13px;
  cursor: pointer;
  white-space: nowrap;
  min-height: 38px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ── Content ── */
.content { padding: 8px 14px 0; }

.sec-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text3);
  padding: 14px 2px 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.sec-label .d { width: 5px; height: 5px; border-radius: 50%; background: var(--border2); flex-shrink: 0; }
.sec-label .hint {
  font-size: 9px;
  color: var(--aubergine);
  text-transform: none;
  font-weight: 400;
  letter-spacing: 0;
}

/* Card */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
}
.cp { padding: 14px; }

/* All inputs */
input[type="date"],
input[type="time"],
input[type="text"] {
  display: block;
  width: 100%;
  background: #f7f7f9;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 16px;
  font-weight: 600;
  padding: 12px 13px;
  min-height: 48px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .15s;
}
input[type="text"] {
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 400;
}
input:focus { border-color: var(--aubergine); background: #fff; }
input::placeholder { color: var(--text3); font-weight: 400; }

/* Shift buttons */
.g3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-bottom: 8px; }
.g2 { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; }
.sbtn {
  background: #f7f7f9;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  color: var(--text2);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 15px;
  font-weight: 700;
  height: 52px;
  padding: 0;
  cursor: pointer;
  text-align: center;
  position: relative;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  transition: background .12s, border-color .12s, color .12s;
}
.ad { position: absolute; top: 5px; right: 5px; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0; transition: opacity .2s; }
.sbtn.auto-calc .ad { opacity: .5; }
.sbtn.active.s1 { border-color: var(--c1); color: var(--c1); background: var(--c1l); }
.sbtn.active.s2 { border-color: var(--c2); color: var(--c2); background: var(--c2l); }
.sbtn.active.s3 { border-color: var(--c3); color: var(--c3); background: var(--c3l); }
.sbtn.active.soff { border-color: var(--border2); color: var(--coff); background: var(--coffl); }

/* Toggle rows */
.tog-row {
  display: flex;
  align-items: center;
  padding: 0 16px;
  min-height: 58px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
.tog-row:last-child { border-bottom: none; }
.tog-icon {
  width: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--aubergine);
}
.tog-icon svg { width: 18px; height: 18px; }
.tog-body { flex: 1; min-width: 0; }
.tog-name { font-size: 14px; font-weight: 500; color: var(--text); }
.tog-sub  { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* Toggle switch */
.tog-sw {
  width: 48px;
  height: 28px;
  flex-shrink: 0;
  position: relative;
  pointer-events: none;
}
.tog-track {
  position: absolute;
  inset: 0;
  background: #d0d0d0;
  border-radius: 14px;
  transition: background .2s;
}
.tog-track::after {
  content: '';
  position: absolute;
  left: 3px; top: 3px;
  width: 22px; height: 22px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
  transition: transform .2s cubic-bezier(.34,1.56,.64,1);
}
.tog-sw.on .tog-track { background: var(--aubergine); }
.tog-sw.on .tog-track::after { transform: translateX(20px); }

/* Time */
.time-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.tf { display: flex; flex-direction: column; gap: 5px; }
.fl { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text3); }
.time-val {
  background: #f7f7f9;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  padding: 12px 13px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 16px;
  font-weight: 600;
  color: var(--text2);
  min-height: 48px;
}

/* OT bar */
.ot-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 13px;
  background: #f7f7f9;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  margin-top: 10px;
  transition: background .25s, border-color .25s;
}
.ot-bar.zanmu { background: var(--goldl); border-color: rgba(232,168,56,.4); }
.ot-bar.range  { background: var(--c2l);   border-color: rgba(0,122,90,.3); }
.ot-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border2); flex-shrink: 0; transition: background .25s, transform .2s; }
.ot-bar.zanmu .ot-dot { background: var(--gold); transform: scale(1.3); }
.ot-bar.range  .ot-dot { background: var(--c2);   transform: scale(1.3); }
.ot-txt { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--text3); transition: color .25s; }
.ot-bar.zanmu .ot-txt { color: var(--gold); font-weight: 600; }
.ot-bar.range  .ot-txt { color: var(--c2);   font-weight: 600; }

/* Keywords */
.kw-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.kw-btn {
  background: #f7f7f9;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  color: var(--text2);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  min-height: 36px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background .12s, border-color .12s, color .12s;
}
.kw-btn.active          { border-color: var(--c1);  color: var(--c1);  background: var(--c1l); }
.kw-btn.active.kw-mtg   { border-color: var(--c2);  color: var(--c2);  background: var(--c2l); }
.kw-btn.active.kw-han   { border-color: var(--gold); color: var(--gold); background: var(--goldl); }
.kw-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  font-size: 11px;
  color: var(--text3);
  flex-shrink: 0;
  touch-action: manipulation;
}
.kw-add-row { display: flex; gap: 8px; margin-top: 10px; }
.kw-add-row input { flex: 1; }
.add-btn {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  background: var(--purple);
  border: none;
  border-radius: 7px;
  color: #fff;
  font-size: 22px;
  font-weight: 300;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Slide panels */
.slide-wrap {
  max-height: 0;
  transition: max-height .3s ease;
  clip-path: inset(0);
}
.slide-wrap.open { max-height: 250px; }

/* Output card */
.out-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
}
.out-hdr {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(135deg, var(--purple) 0%, var(--aubergine) 100%);
  border-radius: 10px 10px 0 0;
}
.out-hdr-ico {
  width: 30px; height: 30px;
  border-radius: 6px;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.out-hdr-ico svg { width: 17px; height: 17px; fill: #fff; }
.out-hdr-ttl { font-size: 13px; font-weight: 700; color: #fff; }
.out-hdr-sub { font-size: 10px; color: rgba(255,255,255,.6); margin-top: 1px; }
.out-body { padding: 13px 14px; border-bottom: 1px solid var(--border); min-height: 60px; }
.out-txt {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
}
.out-txt.empty { color: var(--text3); font-style: italic; font-family: 'Noto Sans JP', sans-serif; font-size: 12px; }

.hidden { display: none !important; }
