@font-face { font-family: "Corncorn"; src: url("fonts/corncorn.ttf") format("truetype"); }

:root {
  /* 테마 색 (JS가 바꿈) — 기본: 모노 블랙 */
  --bg: #ffffff; --g1: #f1f1f1; --g2: #f8f8f8; --acc: #1f1f1f;
  --ink: #1f1f1f; --sub: #9a9a9a; --line: #ededed; --line2: #cfcfcf;
  --fill: color-mix(in srgb, var(--acc) 18%, var(--bg));
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: transparent; }
body {
  color: var(--ink); font-size: 14px; user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, textarea { font: inherit; color: var(--ink); background: transparent; outline: none; user-select: text; }
.cap { font-size: 12.5px; color: var(--sub); letter-spacing: .3px; }

#app { position: relative; height: 100%; display: flex; flex-direction: column; background: var(--bg);
  border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }

/* 상단바 */
#bar { height: 34px; display: flex; justify-content: flex-end; align-items: center; padding: 0 12px; -webkit-app-region: drag; }
.ctrl { display: flex; gap: 2px; -webkit-app-region: no-drag; }
.ctrl button { font-size: 12px; color: var(--sub); padding: 3px 6px; border-radius: 7px; }
.ctrl button:hover { color: var(--ink); background: var(--g1); }
#btnPin.on, #btnDark.on { color: var(--ink); }

/* 메인 카드 */
#card { margin: 0 16px; padding: 18px 20px 16px; border-radius: 18px; background: linear-gradient(160deg, var(--g1), var(--g2)); }
.big { font-size: 32px; line-height: 1.1; margin: 2px 0 4px; letter-spacing: -.5px; }
.big small { font-size: 14px; color: var(--sub); margin: 0 6px 0 2px; letter-spacing: 0; }
#track { position: relative; padding-top: 64px; }
#walker { position: absolute; top: 0; width: 64px; height: 64px; margin-left: -32px; transition: left 1s linear; }
#walker svg, #walker img { width: 100%; height: 100%; }
#walker.step { animation: step 1.4s ease-in-out infinite; }
@keyframes step { 50% { transform: translateY(-2px) rotate(-3deg); } }
.line { position: relative; height: 1.2px; background: var(--line2); }
.line i { position: absolute; left: 0; top: -.5px; height: 2px; background: var(--acc); transition: width 1s linear; }
.times { display: flex; justify-content: space-between; margin-top: 6px; -webkit-app-region: no-drag; }
.times label { display: flex; align-items: center; gap: 4px; cursor: pointer; border-radius: 6px; padding: 1px 3px; }
.times label:hover { background: var(--bg); }
.times input { border: 0; font-size: 13px; color: var(--ink); width: 42px; padding: 0; cursor: text; border-bottom: 1px dashed transparent; }
.times input:focus { border-bottom-color: var(--acc); }
.times input::-webkit-calendar-picker-indicator { display: none; }
.times label:last-child input { text-align: right; }
.earn { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 16px; padding-top: 12px;
  border-top: 1px solid color-mix(in srgb, var(--line2) 50%, transparent); }
.money { font-size: 27px; letter-spacing: -.5px; margin-top: 2px; }
.gauge { position: relative; width: 62px; height: 30px; border: 1.2px solid var(--acc); border-radius: 7px; overflow: hidden; }
.gauge i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--fill); transition: width 1s linear; }
.gauge span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; }

/* 본문 */
#body { flex: 1; display: flex; flex-direction: column; padding: 12px 22px 14px; min-height: 0; }
#tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--line); }
#tabs button { padding: 0 0 8px; color: var(--sub); border-bottom: 1.5px solid transparent; margin-bottom: -1px; }
#tabs button.active { color: var(--ink); border-color: var(--acc); }
.panel { flex: 1; display: flex; flex-direction: column; min-height: 0; padding-top: 10px; }
.panel[hidden], .sheet[hidden] { display: none; }
textarea { flex: 1; min-height: 44px; resize: none; border: 0; line-height: 1.7; padding: 4px 0; }
textarea::placeholder, input::placeholder { color: var(--line2); }

.calhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.calhead button { width: 24px; color: var(--sub); font-size: 16px; }
#calGrid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 3px; text-align: center; font-size: 13px; }
#calGrid .dow { font-size: 11.5px; color: var(--sub); }
#calGrid .d { position: relative; height: 22px; line-height: 22px; cursor: pointer; }
#calGrid .d span { display: inline-block; width: 22px; height: 22px; border-radius: 50%; }
#calGrid .d.other { color: var(--line2); }
#calGrid .d.today span { box-shadow: inset 0 0 0 1px var(--acc); }
#calGrid .d.sel span { background: var(--acc); color: var(--onacc); }
#calGrid .d.has::after { content: ""; position: absolute; left: 50%; bottom: -2px; width: 3px; height: 3px; margin-left: -1.5px;
  border-radius: 50%; background: var(--sub); }
#noteDate { margin: 8px 0 0; padding-top: 6px; border-top: 1px solid var(--line); }

#todoForm input { width: 100%; border: 0; border-bottom: 1px solid var(--line); padding: 4px 0 8px; }
#todoList { list-style: none; overflow-y: auto; flex: 1; }
#todoList li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
#todoList li span { flex: 1; word-break: break-all; }
#todoList li.done span { color: var(--line2); text-decoration: line-through; }
#todoList .bx { width: 14px; height: 14px; border: 1.2px solid var(--line2); border-radius: 3px; flex: none; }
#todoList li.done .bx { background: var(--acc); border-color: var(--acc); }
#todoList .del { color: var(--line2); font-size: 11px; }
#todoCount { text-align: right; padding-top: 4px; }

/* 설정·색상 시트 */
.sheet { position: absolute; left: 10px; right: 10px; top: 34px; bottom: 10px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 16px; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; z-index: 5;
  box-shadow: 0 8px 24px #0000001a; }
.sh { font-size: 15px; }
.sheet label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--sub); }
.sheet input:not([type=color]) { border: 0; border-bottom: 1px solid var(--line2); padding: 4px 0; font-size: 14px; }
.row { display: flex; gap: 12px; } .row label { flex: 1; min-width: 0; } .sheet input { width: 100%; }
.days { display: flex; gap: 4px; }
.days button { flex: 1; padding: 5px 0; border-radius: 8px; border: 1px solid var(--line); color: var(--sub); font-size: 13px; }
.days button.on { background: var(--acc); border-color: var(--acc); color: var(--onacc); }
.preview { background: var(--g1); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; line-height: 1.7; }
.btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: auto; padding-top: 4px; }
.btns button { padding: 6px 16px; border-radius: 9px; background: var(--acc); color: var(--onacc); }
.btns .ghost { background: var(--g1); color: var(--ink); }

.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.presets button { border: 1px solid var(--line); border-radius: 10px; padding: 6px; font-size: 12px; text-align: left; }
.presets button.on { border-color: var(--acc); box-shadow: inset 0 0 0 1px var(--acc); }
.presets .sw { display: flex; height: 14px; border-radius: 4px; overflow: hidden; margin-bottom: 4px; border: 1px solid #0000000f; }
.presets .sw i { flex: 1; }
.targets { display: flex; gap: 4px; }
.targets button { flex: 1; padding: 5px 0; border-radius: 8px; border: 1px solid var(--line); font-size: 12px; color: var(--sub);
  display: flex; align-items: center; justify-content: center; gap: 5px; }
.targets button i { width: 9px; height: 9px; border-radius: 50%; border: 1px solid #0002; }
.targets button.on { border-color: var(--acc); color: var(--ink); }
.chart { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.chart button { aspect-ratio: 1; border-radius: 6px; border: 1px solid #0000000f; }
.chart button.on { outline: 1.5px solid var(--ink); outline-offset: 1px; }
.custom { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--sub); }
.custom label { flex-direction: row; align-items: center; gap: 8px; }
.custom input { width: 34px; height: 22px; border: 1px solid var(--line); border-radius: 6px; padding: 0; }

/* 접힌 모드: 카드만 */
body.folded #body, body.folded .sheet { display: none !important; }
body.folded #app { border-color: transparent; background: transparent; }
body.folded #bar { height: 26px; }
body.folded #card { margin: 0 8px 8px; }
body.folded #app { border-color: var(--line); background: var(--bg); }

.toggle { display: flex; justify-content: space-between; align-items: center; }
.sw2 { width: 38px; height: 22px; border-radius: 11px; background: var(--line2); position: relative; transition: background .2s; }
.sw2 i { position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .2s; }
.sw2.on { background: var(--acc); } .sw2.on i { left: 19px; background: var(--bg); }

/* ── 글꼴 ── */
body { font-family: var(--font, "Corncorn"), "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans CJK KR", sans-serif; }
.fontrow { display: flex; gap: 6px; }
.fontrow select { flex: 1; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line2); border-radius: 8px; padding: 5px 8px; }
.upload { flex-direction: row !important; align-items: center; padding: 5px 10px; border-radius: 8px; background: var(--acc);
  color: var(--onacc) !important; font-size: 12px !important; cursor: pointer; white-space: nowrap; }
.fontprev { background: var(--g1); border-radius: 10px; padding: 10px 12px; font-size: 16px; }
#fontMsg:empty { display: none; }

/* ── 카드: 말풍선 · 야근 ── */
#card { position: relative; }
#otBtn { font-size: 12px; padding: 4px 10px; border-radius: 20px;
  border: 1px solid var(--acc); -webkit-app-region: no-drag; }
#otBtn.run { background: var(--acc); color: var(--onacc); }
#card.ot { box-shadow: inset 0 0 0 1.5px var(--acc); }
#bubble { position: absolute; top: 4px; background: var(--acc); color: var(--onacc); font-size: 12.5px; padding: 6px 10px;
  border-radius: 10px; white-space: nowrap; z-index: 3; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }

/* ── 연차 ── */
.calhead #leaveLeft { margin-left: auto; margin-right: 6px; }
.calhead #calTitle { margin-left: 4px; }
.calhead { justify-content: flex-start; gap: 4px; }
.calhead #nextM { margin-left: 0; }
#calGrid .d.leave span { background: var(--g1); box-shadow: inset 0 0 0 1px var(--line2); }
#calGrid .d.leave::before { content: attr(data-l); position: absolute; top: -3px; right: 0; font-size: 9px; color: var(--sub); }
.notehead { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line); }
#noteDate { margin: 0; padding: 0; border: 0; }
.leaveBtns { display: flex; gap: 3px; }
.leaveBtns button { font-size: 11px; padding: 2px 7px; border-radius: 12px; border: 1px solid var(--line2); color: var(--sub); }
.leaveBtns button.on { background: var(--acc); border-color: var(--acc); color: var(--onacc); }

/* ── 목표 ── */
#goalToday { padding-bottom: 8px; line-height: 1.5; }
#goalForm { display: flex; gap: 6px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
#goalForm input { border: 0; min-width: 0; padding: 4px 0; }
#goalName { flex: 1.4; } #goalPrice { flex: 1; text-align: right; }
#goalForm button { font-size: 12px; padding: 3px 10px; border-radius: 8px; background: var(--acc); color: var(--onacc); }
#goalList { list-style: none; overflow-y: auto; flex: 1; }
#goalList li { padding: 10px 0; border-bottom: 1px solid var(--line); }
#goalList .gr { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
#goalList .gn { flex: 1; word-break: break-all; }
#goalList .gbar { height: 1.2px; background: var(--line2); position: relative; margin: 8px 0 5px; }
#goalList .gbar i { position: absolute; left: 0; top: -.5px; height: 2px; background: var(--acc); }
#goalList .del { color: var(--line2); font-size: 11px; }

/* ── 설정 옵션 ── */
.opt { display: flex; justify-content: space-between; align-items: center; }
.pills { display: flex; gap: 3px; }
.pills button { font-size: 12px; padding: 3px 9px; border-radius: 12px; border: 1px solid var(--line2); color: var(--sub); }
.pills button.on { background: var(--acc); border-color: var(--acc); color: var(--onacc); }
#tabs { gap: 16px; }

#calGrid .d.leave.sel span { background: var(--acc); color: var(--onacc); box-shadow: none; }

/* ── 버튼 글씨 위아래 가운데 정렬 (손글씨 글꼴 기준선 보정) ── */
.leaveBtns button, .pills button, .days button, .targets button, #otBtn, #goalForm button,
.btns button, .ctrl button, .upload, #todoList .del, #goalList .del, #tabs button {
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}
.leaveBtns button { height: 22px; padding: 1px 8px 0; }
.pills button     { height: 24px; padding: 1px 10px 0; }
.days button      { height: 28px; padding: 1px 0 0; }
.targets button   { height: 28px; padding: 1px 0 0; }
#otBtn            { height: 26px; padding: 1px 11px 0; }
#goalForm button  { height: 26px; padding: 1px 11px 0; }
.btns button      { height: 32px; padding: 1px 16px 0; }
.ctrl button      { height: 24px; padding: 1px 6px 0; }
.upload           { height: 30px; padding: 1px 10px 0 !important; }
.gauge span       { line-height: 1; padding-top: 1px; }
.opt .cap { line-height: 1; padding-top: 1px; }
[hidden] { display: none !important; }

/* ── 캐릭터 선택 ── */
.chars { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.chars button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px 5px;
  border: 1px solid var(--line); border-radius: 10px; font-size: 11px; color: var(--sub); line-height: 1.2; }
.chars button .pic { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; }
.chars button .pic svg, .chars button .pic img { width: 100%; height: 100%; object-fit: contain; }
.chars button span.nm { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chars button.on { border-color: var(--acc); box-shadow: inset 0 0 0 1px var(--acc); color: var(--ink); }
.chars button .x { position: absolute; top: 2px; right: 4px; font-size: 10px; color: var(--line2); }
.charrow { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.charrow .cap { font-size: 11.5px; line-height: 1.4; }
#charMsg:empty { display: none; }
#walker img { object-fit: contain; }

/* ── 사용법 ── */
.guide { overflow-y: auto; flex: 1; padding-right: 4px; font-size: 13px; line-height: 1.65; }
.guide h4 { font-size: 14px; font-weight: normal; margin: 14px 0 3px; padding-top: 10px; border-top: 1px solid var(--line); }
.guide h4:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.guide p { margin-bottom: 4px; color: var(--ink); }
.guide b { font-weight: normal; border-bottom: 1px solid var(--acc); }
.guide i { font-style: normal; background: var(--g1); padding: 0 4px; border-radius: 4px; }
#btnHelp.on { color: var(--ink); background: var(--g1); }

/* ── 카드 오른쪽 위 목표 ── */
#cardGoal { position: absolute; right: 18px; top: 18px; width: 112px; text-align: right; cursor: pointer; -webkit-app-region: no-drag; }
#cgName { color: var(--ink); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cgBar { height: 1.2px; background: var(--line2); position: relative; margin: 6px 0 4px; }
.cgBar i { position: absolute; right: auto; left: 0; top: -.5px; height: 2px; background: var(--acc); }
#cgInfo { font-size: 11px; white-space: nowrap; }
.earnR { display: flex; align-items: center; gap: 6px; }

#otBtn { white-space: nowrap; height: 30px !important; padding: 1px 14px 0 !important; }
.earn > div:first-child { min-width: 0; }
#earnCap { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.upbtns { display: flex; gap: 5px; flex: none; }
.upload.ghost { background: var(--g1); color: var(--ink) !important; }

/* 화면 끝 탭 (넣었을 때) */
#edgeTab { display: none; }
body.tab #app, body.tab .sheet { display: none !important; }
body.tab #edgeTab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  position: fixed; inset: 0; width: 100%; height: 100%; background: var(--acc); color: var(--onacc);
  border-radius: 14px; -webkit-app-region: no-drag; }
#edgeTab .et-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bg); }
#etTime { display: flex; flex-direction: column; align-items: center; gap: 4px; line-height: 1; }
#etTime b { font-weight: normal; font-size: 10px; opacity: .75; white-space: nowrap; }
#etTime span { font-size: 13px; white-space: nowrap; }
