:root{
  --bg: #fff8fb;
  --bg-soft: #fffdfd;
  --card: #ffffff;
  --card-soft: #fff4f8;
  --text: #2f2431;
  --sub: #7f6b78;
  --line: #f1dbe6;
  --accent: #ff7eb6;
  --accent-strong: #ff5ea1;
  --accent-soft: #ffd8ea;
  --mint: #c7f1e3;
  --shadow: 0 10px 30px rgba(89, 53, 74, 0.08);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
}

*{
  box-sizing: border-box;
}

html, body{
  margin: 0;
  padding: 0;
  background:
    radial-gradient(circle at top, #fff2f7 0%, #fff8fb 38%, #fffdfd 100%);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

body{
  min-height: 100vh;
}

button, input{
  font: inherit;
}

button{
  border: 0;
  cursor: pointer;
}

.app-shell{
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}

.topbar{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 2px 22px;
}

.eyebrow{
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--sub);
}

.topbar h1{
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.subtitle{
  margin: 6px 0 0;
  color: var(--sub);
  font-size: 14px;
}

.date-card{
  flex-shrink: 0;
  padding: 10px 12px;
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--sub);
}

.content{
  display: grid;
  gap: 14px;
}

.summary-grid{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.summary-card{
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 12px;
  box-shadow: var(--shadow);
}

.summary-label{
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--sub);
}

.summary-value{
  font-size: 19px;
  letter-spacing: -0.03em;
}

.panel{
  background: rgba(255,255,255,0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 18px 16px;
}

.panel-head{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h2{
  margin: 0 0 6px;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.panel-head p{
  margin: 0;
  color: var(--sub);
  font-size: 13px;
  line-height: 1.45;
}

.template-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.template-card{
  background: linear-gradient(180deg, #fff8fb 0%, #fff3f8 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 12px;
  text-align: left;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.template-card:active{
  transform: scale(0.98);
}

.template-card.selected{
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(255, 94, 161, 0.16);
}

.template-name{
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
  font-size: 15px;
}

.template-preview{
  margin: 0;
  color: var(--sub);
  font-size: 12px;
  line-height: 1.5;
}

.progress-bar-wrap{
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.progress-bar{
  flex: 1;
  height: 12px;
  background: #f5e8ef;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill{
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-soft), var(--accent-strong));
  transition: width 0.22s ease;
}

.progress-text{
  flex-shrink: 0;
  font-size: 12px;
  color: var(--sub);
}

.routine-list{
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.routine-item{
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-soft);
  border: 1px solid #f6e6ee;
  border-radius: 16px;
  padding: 12px;
}

.routine-check{
  width: 22px;
  height: 22px;
  accent-color: var(--accent-strong);
  flex-shrink: 0;
}

.routine-text{
  flex: 1;
  font-size: 14px;
  line-height: 1.45;
  word-break: keep-all;
}

.routine-text.done{
  color: #a08b97;
  text-decoration: line-through;
}

.routine-actions{
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: #fff1f7;
  color: #7a5164;
}

.primary-btn,
.secondary-btn{
  min-height: 42px;
  padding: 0 14px;
  border-radius: 14px;
  font-weight: 700;
}

.primary-btn{
  background: var(--accent);
  color: white;
  box-shadow: 0 8px 18px rgba(255, 94, 161, 0.22);
}

.secondary-btn{
  background: #f8eef3;
  color: #684f5d;
}

.message-box{
  margin-top: 14px;
  padding: 14px;
  border-radius: 16px;
  background: linear-gradient(180deg, #fff5fa 0%, #fff0f7 100%);
  color: #85546c;
  font-size: 14px;
  line-height: 1.5;
}

.ad-panel{
  padding: 14px;
}

.ad-placeholder{
  min-height: 72px;
  border: 1px dashed #e5bfd2;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sub);
  background: #fff8fb;
  font-size: 14px;
}

.bottom-note{
  margin-top: 14px;
  padding: 4px 2px 0;
  text-align: center;
  color: var(--sub);
  font-size: 12px;
}

.modal-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(45, 24, 36, 0.24);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
}

.modal-backdrop.hidden{
  display: none;
}

.modal{
  width: 100%;
  max-width: 480px;
  background: white;
  border-radius: 24px;
  box-shadow: 0 18px 50px rgba(63, 28, 45, 0.18);
  overflow: hidden;
}

.modal-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
}

.modal-head h3{
  margin: 0;
  font-size: 18px;
}

.modal-body{
  padding: 0 16px 16px;
}

.field-label{
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--sub);
}

.text-input{
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  background: #fffdfd;
}

.modal-actions{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 16px 16px;
}

.empty-state{
  margin: 0;
  padding: 18px 14px;
  border-radius: 16px;
  text-align: center;
  background: #fff8fb;
  color: var(--sub);
  border: 1px dashed #edd0dd;
  font-size: 14px;
}

@media (max-width: 360px){
  .summary-grid{
    grid-template-columns: 1fr;
  }

  .template-grid{
    grid-template-columns: 1fr;
  }

  .panel-head{
    flex-direction: column;
  }

  .progress-bar-wrap{
    flex-direction: column;
    align-items: stretch;
  }
}
