/* 2ASY-Calendar 원본의 크림 종이 톤. 데스크톱 앱과 같은 색을 쓴다. */
:root {
  --bg: #f6f2e9;
  --panel: #ffffff;
  --panel-soft: #faf7f0;
  --line: #e3dac6;
  --text: #5d5344;
  --sub: #a2957f;
  --accent: #a79574;
  --accent-soft: #efe4cd;
  --today: #fdf3dc;
  --sat: #6884b2;
  --sun: #c46058;
  --font: 14px;
}

* { box-sizing: border-box; }

/* .page 나 .sheet 의 display 선언이 브라우저 기본 [hidden] 규칙을 이겨서
 * 숨긴 요소가 그대로 보인다. 여기서 확실히 눌러 둔다. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Pretendard, "Pretendard Variable", "Malgun Gothic", -apple-system,
               BlinkMacSystemFont, system-ui, sans-serif;
  font-size: var(--font);
  /* 한글 가로획이 힌팅에 눌려 사라지지 않게 한다 */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { margin: 0; font-size: 1.25em; }
h1 { font-size: 1.15em; }
code { background: var(--accent-soft); padding: 1px 5px; border-radius: 5px; }

/* ---------- 뼈대 ---------- */
#topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
  padding-top: max(10px, env(safe-area-inset-top));
}
#tabs {
  display: flex; gap: 6px; padding: 8px 14px 0;
  overflow-x: auto; scrollbar-width: none;
}
#tabs::-webkit-scrollbar { display: none; }
#tabs button {
  border: 1px solid var(--line); border-bottom: none;
  background: var(--panel-soft); color: var(--sub);
  padding: 8px 16px; border-radius: 10px 10px 0 0;
  font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap;
}
#tabs button[aria-selected="true"] { background: var(--panel); color: var(--text); }

#main { padding: 12px 14px 90px; max-width: 1100px; }
.page { display: flex; flex-direction: column; gap: 8px; }

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.head { margin-top: 6px; }
.grow { flex: 1; }
.muted { color: var(--sub); margin: 0; }
.two { display: grid; grid-template-columns: 1fr 2fr; gap: 16px; align-items: start; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
label { display: flex; flex-direction: column; gap: 4px; color: var(--sub); }

.pill {
  background: var(--accent-soft); color: var(--text);
  border-radius: 8px; padding: 4px 10px; font-weight: 700;
}

/* ---------- 입력 ---------- */
input, textarea, select, button {
  font: inherit; color: var(--text);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px;
}
input, textarea, select { width: 100%; }
input.short { max-width: 120px; }
textarea { resize: vertical; }
button { cursor: pointer; width: auto; white-space: nowrap; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
button.ghost:hover, button.primary:hover { filter: brightness(0.96); }
.filebtn { display: inline-flex; flex-direction: row; align-items: center;
  border: 1px solid var(--line); background: var(--panel);
  border-radius: 8px; padding: 8px 10px; cursor: pointer; color: var(--text); }

/* ---------- 목록 ---------- */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.list li {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px;
  display: flex; align-items: center; gap: 8px;
}
.list li.done span.txt { text-decoration: line-through; color: var(--sub); }
.list li .txt { flex: 1; word-break: break-word; }
.list li .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.list li .del { border: none; background: none; color: var(--sub); padding: 2px 6px; }

/* ---------- 캘린더 ---------- */
.calgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calgrid .wd {
  text-align: center; font-weight: 700; color: var(--sub);
  background: var(--accent-soft); border-radius: 8px; padding: 3px 0;
}
.calgrid .wd.sat { color: var(--sat); }
.calgrid .wd.sun { color: var(--sun); }
.cell {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  min-height: 78px; padding: 4px 5px; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px; overflow: hidden;
}
.cell.sat { background: #f5f8fc; }
.cell.sun { background: #fdf6f5; }
.cell.today { background: var(--today); border-color: var(--accent); }
.cell.sel { border: 2px solid var(--accent); }
.cell.out { opacity: .45; }
.cell .num { font-weight: 700; font-size: .95em; }
.cell.sat .num { color: var(--sat); }
.cell.sun .num { color: var(--sun); }
.chip {
  font-size: .8em; color: #fff; border-radius: 4px; padding: 1px 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.calgrid.small .cell { min-height: 44px; align-items: center; justify-content: center; text-align: center; }

/* ---------- 해빗 ---------- */
.habits { display: grid; grid-template-columns: minmax(90px, 2fr) repeat(7, 1fr); gap: 4px; align-items: center; }
.habits .hd { text-align: center; font-weight: 700; color: var(--sub); }
.habits .hd.sat { color: var(--sat); }
.habits .hd.sun { color: var(--sun); }
.habits input[type="checkbox"] { width: 18px; height: 18px; margin: 0 auto; accent-color: var(--accent); }

/* ---------- 타임테이블 ---------- */
.timetable { display: flex; flex-direction: column; gap: 2px; max-height: 60vh; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 10px; padding: 6px; background: var(--panel); }
.slot { display: flex; align-items: center; gap: 8px; }
.slot .time {
  width: 62px; flex: none; color: var(--sub); cursor: pointer;
  border-radius: 6px; padding: 4px 6px; text-align: center; user-select: none;
}
.slot.done .time { color: var(--sat); font-weight: 700; }
.slot.done input { text-decoration: line-through; color: var(--sub); }
.slot input { border: none; background: transparent; border-bottom: 1px solid var(--line); border-radius: 0; }
.slot:nth-child(even) { background: var(--panel-soft); border-radius: 6px; }

/* ---------- 피드 ---------- */
#feed {
  position: fixed; right: 0; top: 0; bottom: 0; width: 360px; max-width: 92vw;
  background: var(--panel); border-left: 1px solid var(--line);
  padding: 12px 14px; overflow-y: auto; z-index: 30;
  box-shadow: -8px 0 24px rgba(93, 83, 68, .12);
  padding-top: max(12px, env(safe-area-inset-top));
}
.legend { display: flex; flex-wrap: wrap; gap: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 4px; color: var(--sub); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- 시트(일정 편집) ---------- */
.sheet {
  position: fixed; inset: 0; background: rgba(93, 83, 68, .35);
  display: flex; align-items: center; justify-content: center; z-index: 40; padding: 16px;
}
.sheetbody {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; width: min(440px, 100%); display: flex; flex-direction: column; gap: 10px;
  max-height: 90vh; overflow-y: auto;
}

/* ---------- 폰 ---------- */
@media (max-width: 760px) {
  .two, .grid2, .grid3 { grid-template-columns: 1fr; }
  #main { padding: 10px 10px 96px; }
  .cell { min-height: 62px; }
  .chip { font-size: .72em; }
  .habits { grid-template-columns: minmax(70px, 1.4fr) repeat(7, 1fr); gap: 2px; }
  /* 탭을 아래로 내려 엄지로 누르게 한다 */
  #tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    background: var(--panel); border-top: 1px solid var(--line);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  #tabs button { border: none; border-radius: 10px; padding: 8px 10px; font-size: .92em; }
  #tabs button[aria-selected="true"] { background: var(--accent-soft); }
  #feed { width: 100%; max-width: 100%; }
  .sheet { align-items: flex-end; padding: 0; }
  .sheetbody { border-radius: 14px 14px 0 0; width: 100%; }
}
