/* ===== Reset & Base ===== */
*{margin:0;padding:0;box-sizing:border-box}
html{font-size:16px;-webkit-text-size-adjust:100%}
body{
  font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
  background:#f5f5f7;
  color:#1d1d1f;
  min-height:100vh;
  padding-bottom:80px;
}

/* ===== Header ===== */
.header{
  background:#fff;
  padding:16px 20px 12px;
  border-bottom:1px solid #e5e5ea;
  position:sticky;top:0;z-index:100;
}
.header h1{font-size:20px;font-weight:700;letter-spacing:-0.3px}
.header .sub{font-size:12px;color:#8e8e93;margin-top:2px}

/* ===== Tab Bar ===== */
.tab-bar{
  display:flex;
  position:fixed;bottom:0;left:0;right:0;
  background:#fff;
  border-top:1px solid #e5e5ea;
  z-index:100;
  padding-bottom:env(safe-area-inset-bottom, 0);
}
.tab-bar button{
  flex:1;
  border:none;background:transparent;
  padding:8px 0 6px;
  font-size:10px;color:#8e8e93;
  display:flex;flex-direction:column;align-items:center;gap:2px;
  cursor:pointer;
  -webkit-tap-highlight-color:transparent;
}
.tab-bar button.active{color:#007aff}
.tab-bar button .icon{font-size:22px;line-height:1}

/* ===== Content ===== */
.content{padding:16px;display:none}
.content.active{display:block}

/* ===== Cards ===== */
.card{
  background:#fff;
  border-radius:14px;
  padding:16px;
  margin-bottom:12px;
  box-shadow:0 1px 3px rgba(0,0,0,0.06);
}
.card-title{
  font-size:15px;font-weight:700;
  display:flex;align-items:center;gap:6px;
  margin-bottom:10px;
}
.card-title .badge{
  font-size:11px;font-weight:600;
  padding:2px 8px;border-radius:10px;
  color:#fff;
}
.badge-today{background:#ff9500}
.badge-past{background:#ff3b30}

/* ===== Data Row ===== */
.data-row{
  display:flex;justify-content:space-between;
  padding:6px 0;
  border-bottom:1px solid #f2f2f7;
  font-size:14px;
}
.data-row:last-child{border-bottom:none}
.data-row .label{color:#8e8e93}
.data-row .value{font-weight:600;text-align:right}

/* ===== Form ===== */
.form-group{margin-bottom:14px}
.form-group label{
  display:block;font-size:13px;font-weight:600;
  color:#6e6e73;margin-bottom:4px;
}
.form-group input,.form-group select{
  width:100%;padding:12px;
  border:1px solid #d1d1d6;border-radius:10px;
  font-size:16px;background:#fff;
  -webkit-appearance:none;
  appearance:none;
}
.form-group select{
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238e8e93' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:right 12px center;
  padding-right:32px;
}
.form-group input:focus,.form-group select:focus{
  outline:none;border-color:#007aff;
  box-shadow:0 0 0 3px rgba(0,122,255,0.15);
}

/* ===== Buttons ===== */
.btn{
  width:100%;padding:14px;border:none;border-radius:12px;
  font-size:16px;font-weight:600;
  cursor:pointer;position:relative;
  -webkit-tap-highlight-color:transparent;
  transition:opacity 0.15s;
}
.btn:active{opacity:0.7}
.btn-primary{background:#007aff;color:#fff}
.btn-green{background:#34c759;color:#fff}
.btn-outline{
  background:transparent;color:#007aff;
  border:1.5px solid #007aff;
}
.btn-danger{background:transparent;color:#ff3b30;border:1.5px solid #ff3b30}
.btn-sm{padding:10px 16px;font-size:14px;border-radius:10px;width:auto}
.btn+.btn{margin-top:10px}

/* ===== Action Buttons ===== */
.action-card{
  background:#fff;border-radius:14px;
  overflow:hidden;margin-bottom:12px;
  box-shadow:0 1px 3px rgba(0,0,0,0.06);
}
.action-btn{
  display:flex;align-items:center;gap:12px;
  padding:14px 16px;
  border:none;background:transparent;
  font-size:15px;font-weight:500;
  width:100%;text-align:left;
  cursor:pointer;
  -webkit-tap-highlight-color:transparent;
  border-bottom:1px solid #f2f2f7;
}
.action-btn:last-child{border-bottom:none}
.action-btn:active{background:#f2f2f7}
.action-btn .action-icon{font-size:22px;width:28px;text-align:center}
.action-btn .action-text{flex:1}
.action-btn .action-arrow{color:#c7c7cc;font-size:16px}

/* ===== Toast ===== */
.toast{
  position:fixed;top:60px;left:50%;transform:translateX(-50%);
  background:#1d1d1f;color:#fff;
  padding:10px 20px;border-radius:10px;
  font-size:14px;font-weight:500;
  z-index:200;opacity:0;
  transition:opacity 0.3s;
  pointer-events:none;
  max-width:90%;text-align:center;
}
.toast.show{opacity:1}

/* ===== Loading ===== */
.loading{
  display:flex;flex-direction:column;
  align-items:center;justify-content:center;
  padding:60px 20px;color:#8e8e93;
}
.spinner{
  width:32px;height:32px;
  border:3px solid #e5e5ea;
  border-top-color:#007aff;
  border-radius:50%;
  animation:spin 0.8s linear infinite;
  margin-bottom:12px;
}
@keyframes spin{to{transform:rotate(360deg)}}

/* ===== Pull to Refresh (visual) ===== */
.refresh-btn{
  display:flex;align-items:center;justify-content:center;
  gap:6px;padding:8px;
  color:#007aff;font-size:14px;font-weight:500;
  background:transparent;border:none;
  width:100%;margin-bottom:8px;
  cursor:pointer;
}
.refresh-btn:active{opacity:0.5}

/* ===== Empty State ===== */
.empty{
  text-align:center;padding:40px 20px;
  color:#8e8e93;font-size:15px;
}

/* ===== Settings section title ===== */
.section-title{
  font-size:13px;font-weight:600;
  color:#8e8e93;text-transform:uppercase;
  letter-spacing:0.5px;
  padding:0 4px;margin-bottom:8px;
}
.section-title+.action-card{margin-top:4px}

/* ===== 入力欄の下に出す注意書き ===== */
.field-note{
  margin-top:6px;
  font-size:12px;line-height:1.5;
  color:#e65100;
}
.field-note[hidden]{display:none}

/* ===== 診断の出力 ===== */
.diagnose-out{
  margin-top:8px;
  padding:12px;
  background:#fff;
  border:1px solid #d1d1d6;border-radius:10px;
  font-family:ui-monospace,SFMono-Regular,Menlo,monospace;
  font-size:12px;line-height:1.6;
  color:#1d1d1f;
  white-space:pre-wrap;word-break:break-all;
}
.diagnose-out[hidden]{display:none}

/* ===== Modal Overlay ===== */
.modal-overlay{
  position:fixed;top:0;left:0;right:0;bottom:0;
  background:rgba(0,0,0,0.4);
  z-index:300;display:none;
  align-items:flex-end;justify-content:center;
}
.modal-overlay.show{display:flex}
.modal-sheet{
  background:#fff;
  border-radius:16px 16px 0 0;
  width:100%;max-width:500px;
  padding:20px 20px calc(20px + env(safe-area-inset-bottom, 0));
  max-height:85vh;overflow-y:auto;
  animation:slideUp 0.25s ease;
}
@keyframes slideUp{from{transform:translateY(100%)}to{transform:translateY(0)}}
.modal-header{
  display:flex;justify-content:space-between;align-items:center;
  margin-bottom:16px;
}
.modal-header h2{font-size:17px;font-weight:700}
.modal-close{
  border:none;background:#f2f2f7;
  width:30px;height:30px;border-radius:50%;
  font-size:16px;cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  color:#8e8e93;
}
.modal-close:active{background:#e5e5ea}

/* ===== LINE / 警告の帯 ===== */
.status-box{
  padding:12px 16px;
  border-radius:10px;
  font-size:13px;line-height:1.6;
  margin-bottom:12px;
}
.status-ok{background:#e8f5e9;color:#2e7d32}
.status-ng{background:#fff3e0;color:#e65100}
.status-warn{background:#fff3cd;color:#856404}

/* ===== 予定のカード =====
   通知が来ていない予定と、来たのに完了していない予定を見分けたいので、
   左端の色帯で状態を出す。文字だけだと一覧で流し読みできない。 */
.occ{
  background:#fff;border-radius:14px;
  padding:14px 16px;margin-bottom:10px;
  box-shadow:0 1px 3px rgba(0,0,0,0.06);
  border-left:4px solid #c7c7cc;
}
.occ.is-due{border-left-color:#ff9500}
.occ.is-sent{border-left-color:#ff3b30}
.occ-head{display:flex;justify-content:space-between;align-items:baseline;gap:8px}
.occ-name{font-size:15px;font-weight:700;flex:1}
.occ-when{font-size:12px;color:#8e8e93;white-space:nowrap}
.occ-meta{font-size:12px;color:#8e8e93;margin-top:2px}
.occ-actions{display:flex;gap:8px;margin-top:10px}
.occ-actions button{
  flex:1;border:none;border-radius:10px;
  padding:9px 0;font-size:13px;font-weight:600;
  font-family:inherit;
  -webkit-tap-highlight-color:transparent;
}
.act-done{background:#34c759;color:#fff}
.act-snooze{background:#f2f2f7;color:#1d1d1f}
.act-skip{background:#f2f2f7;color:#8e8e93}
.occ-actions button:active{opacity:.7}

/* ===== リマインダーの一覧 ===== */
.rem{
  background:#fff;border-radius:14px;
  padding:14px 16px;margin-bottom:10px;
  box-shadow:0 1px 3px rgba(0,0,0,0.06);
  display:flex;align-items:center;gap:12px;
}
.rem.off{opacity:.55}
.rem-main{flex:1;min-width:0;text-align:left;border:none;background:transparent;font-family:inherit;padding:0}
.rem-name{font-size:15px;font-weight:700;color:#1d1d1f}
.rem-rule{font-size:12px;color:#8e8e93;margin-top:3px;line-height:1.5}
.rem-next{font-size:12px;color:#007aff;margin-top:3px}

/* 有効・無効のつまみ。iOS の見た目に寄せる */
.switch{position:relative;width:48px;height:28px;flex:none}
.switch input{position:absolute;opacity:0;width:100%;height:100%;margin:0}
.switch span{
  position:absolute;inset:0;border-radius:14px;background:#e5e5ea;
  transition:background .2s;
}
.switch span::after{
  content:'';position:absolute;top:2px;left:2px;
  width:24px;height:24px;border-radius:50%;background:#fff;
  box-shadow:0 1px 3px rgba(0,0,0,.2);
  transition:transform .2s;
}
.switch input:checked+span{background:#34c759}
.switch input:checked+span::after{transform:translateX(20px)}

/* ===== 例のボタン ===== */
.preset-row{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:16px}
.chip{
  border:1px solid #d1d1d6;background:#fff;
  border-radius:999px;padding:7px 12px;
  font-size:12px;font-weight:600;color:#007aff;
  font-family:inherit;
  -webkit-tap-highlight-color:transparent;
}
.chip:active{background:#f2f2f7}

/* ===== 曜日えらび ===== */
.weekday-row{display:flex;gap:6px}
.weekday-row label{flex:1}
.weekday-row input{position:absolute;opacity:0;pointer-events:none}
.weekday-row span{
  display:block;text-align:center;
  padding:10px 0;border-radius:10px;
  border:1px solid #d1d1d6;background:#fff;
  font-size:14px;font-weight:600;color:#8e8e93;
}
.weekday-row input:checked+span{
  background:#007aff;border-color:#007aff;color:#fff;
}

/* ===== 記録 ===== */
.done-row{
  display:flex;justify-content:space-between;gap:8px;
  padding:8px 0;border-bottom:1px solid #f2f2f7;
  font-size:13px;
}
.done-row:last-child{border-bottom:none}
.done-row .when{color:#8e8e93;font-size:12px}
.pill{
  font-size:11px;font-weight:700;
  padding:2px 8px;border-radius:10px;white-space:nowrap;
}
.pill-done{background:#e8f5e9;color:#2e7d32}
.pill-miss{background:#ffeaea;color:#c62828}
.pill-skip{background:#f2f2f7;color:#8e8e93}
