:root {
  --text: #37352f;
  --muted: #787774;
  --faint: #a5a29d;
  --line: #e9e9e7;
  --bg: #ffffff;
  --col: #f7f7f5;
  --hover: #efefed;
  --accent: #2383e2;
  --danger: #d44c47;
  --todo: #9b9a97;
  --doing: #2383e2;
  --done: #4dab9a;
  --hold: #d9730d;
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.brand { font-weight: 700; letter-spacing: -0.01em; font-size: 15px; white-space: nowrap; }
.brand span { font-weight: 500; color: var(--muted); }

.btn {
  white-space: nowrap;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--text); border-color: var(--text); color: #fff; }
.btn.primary:hover { opacity: 0.9; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.danger { color: var(--danger); border-color: transparent; }
.btn.danger:hover { background: #fbe4e4; }

input.field, select.field, textarea.field {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  background: var(--bg);
  outline: none;
  width: 100%;
}
input.field:focus, select.field:focus, textarea.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(35, 131, 226, 0.12); }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; background: var(--col); padding: 16px; }
.login { width: 100%; max-width: 300px; display: grid; gap: 10px; text-align: center; }
.login .brand { font-size: 20px; margin-bottom: 8px; }
.login input {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; text-align: center; outline: none; background: #fff;
}
.login input:focus { border-color: var(--accent); }
.login .btn { padding: 10px; }
.error { color: var(--danger); font-size: 13px; min-height: 20px; margin: 0; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 20px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 2px; }
.tab { border: 0; background: none; padding: 5px 10px; border-radius: 6px; color: var(--muted); font-weight: 500; }
.tab:hover { background: var(--hover); }
.tab.active { color: var(--text); background: var(--hover); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.filter { display: flex; gap: 2px; background: var(--col); border-radius: 7px; padding: 2px; }
.filter button { border: 0; background: none; padding: 3px 10px; border-radius: 5px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.filter button.active { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }

.menu { position: relative; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 4px);
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 24px rgba(15, 15, 15, 0.1);
  padding: 4px; min-width: 150px; display: grid;
}
.menu-pop a, .menu-pop button {
  display: block; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 5px;
  color: var(--text); text-decoration: none; font-size: 13px;
}
.menu-pop a:hover, .menu-pop button:hover { background: var(--hover); }
.menu-btn { border: 0; background: none; padding: 2px; border-radius: 50%; display: grid; place-items: center; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-size: 13px; font-weight: 600; background: var(--hover); color: var(--text);
}
.avatar.kim { background: #e7f3f8; color: #1f6c9f; }
.avatar.park { background: #f6f3f9; color: #6940a5; }
.whoami { font-size: 12px; color: var(--muted); padding: 6px 10px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; white-space: nowrap; }
.status-tabs { display: none; }

main { padding: 20px 24px 40px; }

/* ---------- board ---------- */
.board { display: grid; grid-template-columns: repeat(4, minmax(210px, 1fr)); gap: 14px; align-items: start; overflow-x: auto; }
.column { background: var(--col); border-radius: 10px; padding: 10px; min-height: 120px; }
.column-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 10px; font-weight: 600; font-size: 13px; }
.column-head .count { color: var(--faint); font-weight: 500; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.todo { background: var(--todo); }
.dot.doing { background: var(--doing); }
.dot.done { background: var(--done); }
.dot.hold { background: var(--hold); }

.cards { display: grid; gap: 8px; min-height: 8px; }
.card {
  background: #fff; border-radius: var(--radius); padding: 10px 12px;
  box-shadow: 0 0 0 1px rgba(15, 15, 15, 0.06), 0 1px 2px rgba(15, 15, 15, 0.06);
  cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.card:hover { background: #fbfbfa; }
.card.dragging { opacity: 0.35; }
.card.ghost {
  position: fixed; left: 0; top: 0; z-index: 30; pointer-events: none; margin: 0;
  box-shadow: 0 0 0 1px rgba(15, 15, 15, 0.06), 0 10px 24px rgba(15, 15, 15, 0.16);
}
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; }
.card-title { font-weight: 500; word-break: break-word; }
.card-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.card-meta .date { margin-left: auto; color: var(--faint); }
.who { display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 4px; font-size: 12px; white-space: nowrap; }
.who.kim { background: #e7f3f8; color: #1f6c9f; }
.who.park { background: #f6f3f9; color: #6940a5; }
.placeholder { height: 4px; border-radius: 2px; background: var(--accent); margin: -2px 0; }

.add-card { margin-top: 8px; width: 100%; border: 0; background: none; text-align: left; padding: 6px 6px; border-radius: 6px; color: var(--faint); }
.add-card:hover { background: var(--hover); color: var(--muted); }
.new-card { margin-top: 8px; }
.new-card input { box-shadow: 0 0 0 1px rgba(15, 15, 15, 0.06); border: 0; }

/* ---------- modal ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 20; background: rgba(15, 15, 15, 0.35);
  display: flex; justify-content: center; align-items: flex-start; padding: 6vh 16px; overflow-y: auto;
}
.modal { background: #fff; width: 100%; max-width: 680px; border-radius: 12px; box-shadow: 0 16px 48px rgba(15, 15, 15, 0.2); padding: 28px 32px 24px; }
.modal-title { width: 100%; border: 0; outline: none; font-size: 24px; font-weight: 700; padding: 0; margin-bottom: 16px; }
.props { display: grid; grid-template-columns: 90px 1fr; gap: 6px 12px; align-items: center; font-size: 13px; margin-bottom: 18px; }
.props .label { color: var(--muted); }
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button {
  border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 3px 10px; font-size: 13px; color: var(--muted);
}
.seg button:hover { background: var(--hover); }
.seg button.on { color: var(--text); border-color: var(--text); font-weight: 600; }
.seg button.st-todo.on { color: #6b6a67; border-color: var(--todo); background: #f1f1ef; }
.seg button.st-doing.on { color: #1b6ab8; border-color: var(--doing); background: #e7f3f8; }
.seg button.st-done.on { color: #2f7f71; border-color: var(--done); background: #e9f5f1; }
.seg button.st-hold.on { color: #b35d0b; border-color: var(--hold); background: #fbecdd; }
.modal { position: relative; }
.modal-close {
  position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border: 0; border-radius: 6px;
  background: none; color: var(--faint); font-size: 16px;
}
.modal-close:hover { background: var(--hover); color: var(--text); }
.modal-title { padding-right: 36px !important; }
.props .value { color: var(--text); }
.content {
  width: 100%; min-height: 140px; border: 0; outline: none; resize: none; padding: 12px 0; line-height: 1.7;
  border-top: 1px solid var(--line);
}
.modal-section { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 8px; }
.modal-section h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 0 10px; }
.comment { padding: 8px 0; }
.comment + .comment { border-top: 1px solid #f1f1ef; }
.comment-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--faint); }
.comment-head .del { margin-left: auto; border: 0; background: none; color: var(--faint); font-size: 12px; visibility: hidden; }
.comment:hover .del { visibility: visible; }
.comment-head .del:hover { color: var(--danger); }
.comment-text { margin-top: 3px; white-space: pre-wrap; word-break: break-word; }
.comment-form { display: flex; gap: 8px; margin-top: 10px; align-items: flex-start; }
.comment-form > .who { flex: none; margin-top: 8px; }
.comment-form textarea { resize: none; min-height: 36px; height: 36px; overflow: hidden; }
.comment-form .btn { white-space: nowrap; height: 36px; }
.empty { color: var(--faint); font-size: 13px; padding: 4px 0; }
.modal-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; }
.saved { font-size: 12px; color: var(--faint); }

.form { display: grid; gap: 12px; }
.form h2 { margin: 0 0 4px; font-size: 18px; }
.form label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form label.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); margin-top: -4px; cursor: pointer; }
.form label.check input { margin: 0; accent-color: var(--text); }
input.field:disabled { background: var(--col); color: var(--faint); }
.variable { font-size: 13px; color: var(--muted); }

/* ---------- subscriptions ---------- */
.subs { max-width: 880px; }
.subs-head { display: flex; align-items: flex-end; gap: 24px; margin-bottom: 16px; flex-wrap: wrap; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.subs-head .btn { margin-left: auto; }
.sub-list { border-top: 1px solid var(--line); }
.sub-row {
  display: grid; grid-template-columns: 1.6fr 1fr 1.1fr 0.7fr 1.4fr; gap: 12px; align-items: center;
  padding: 11px 6px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.sub-row:hover { background: #fbfbfa; }
.sub-row.head { cursor: default; font-size: 12px; color: var(--muted); padding: 8px 6px; }
.sub-row.head:hover { background: none; }
.sub-name { font-weight: 500; }
.sub-price { font-variant-numeric: tabular-nums; }
.sub-sub { display: none; }
.sub-memo { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dday { font-size: 12px; padding: 1px 7px; border-radius: 4px; background: var(--col); color: var(--muted); justify-self: start; white-space: nowrap; }
.dday.soon { background: #fbecdd; color: #b35d0b; }

@media (max-width: 760px) {
  /* iOS는 16px 미만 입력창에 포커스하면 화면을 확대한다 */
  input, select, textarea, .field { font-size: 16px !important; }
  body.modal-open { overflow: hidden; }

  .top { padding: 8px 12px 0; padding-top: max(8px, env(safe-area-inset-top)); gap: 8px; flex-wrap: wrap; }
  .top .brand { display: none; }
  .tab { padding: 6px 12px; font-size: 15px; }
  .top-right { margin-left: auto; gap: 6px; }
  .filter button { padding: 5px 9px; }
  .menu-btn { padding: 4px; }
  .avatar { width: 30px; height: 30px; }
  .top > :not(.status-tabs) { margin-bottom: 8px; }

  .status-tabs {
    display: flex; width: calc(100% + 24px); margin: 0 -12px; padding: 0 8px;
    border-top: 1px solid var(--line); overflow-x: auto; scrollbar-width: none;
  }
  .status-tabs::-webkit-scrollbar { display: none; }
  .stab {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px;
    border: 0; background: none; padding: 11px 4px 10px; font-size: 14px; color: var(--muted); white-space: nowrap;
    border-bottom: 2px solid transparent; transition: background 0.15s;
  }
  .stab .count { color: var(--faint); font-size: 12px; }
  .stab.active { color: var(--text); font-weight: 600; border-bottom-color: var(--text); }
  .stab.drop { background: #e7f3f8; border-radius: 8px 8px 0 0; }

  main { padding: 12px 12px calc(40px + env(safe-area-inset-bottom)); }
  .board { display: block; overflow: visible; min-height: 60vh; }
  .column { display: none; background: none; padding: 0; min-height: 0; }
  .column.m-active { display: block; }
  .column-head { display: none; }
  .cards { gap: 10px; }
  .card { padding: 14px 14px; }
  .card-title { font-size: 15px; }
  .card:hover { background: #fff; }
  .card:active { background: #fbfbfa; }
  .add-card { margin-top: 10px; padding: 12px; font-size: 15px; text-align: center; border: 1px dashed var(--line); border-radius: 8px; }
  .new-card input { padding: 12px; }

  .overlay { padding: 0; align-items: stretch; overscroll-behavior: contain; }
  .modal {
    max-width: none; min-height: 100%; border-radius: 0; box-shadow: none;
    padding: max(16px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  }
  .modal-close { top: max(10px, env(safe-area-inset-top)); right: 8px; width: 40px; height: 40px; font-size: 18px; }
  .modal-title { font-size: 21px; margin-top: 4px; }
  .props { grid-template-columns: 64px 1fr; gap: 10px 10px; }
  .seg button { padding: 7px 12px; font-size: 14px; }
  .content { min-height: 120px; }
  .comment-head .del { visibility: visible; }
  .comment-form { flex-wrap: wrap; }
  .comment-form > .who { display: none; }
  .comment-form textarea { flex: 1; min-height: 44px; height: 44px; padding: 10px 12px; }
  .comment-form .btn { height: 44px; padding: 0 16px; }
  .modal-foot .btn { padding: 9px 16px; }

  .subs-head { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .subs-head .btn { grid-column: 1 / -1; margin: 0; padding: 12px; font-size: 15px; }
  .stat .v { font-size: 20px; }
  .sub-row { grid-template-columns: 1fr auto auto; padding: 13px 4px; gap: 10px; }
  .sub-row > :nth-child(3), .sub-row > :nth-child(5) { display: none; }
  .sub-row.head { display: none; }
  .sub-name { display: grid; gap: 2px; min-width: 0; }
  .sub-sub { display: block; font-size: 12px; color: var(--faint); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .row { grid-template-columns: 1fr; }
  .form .field { padding: 10px 12px; }
  .form .modal-foot .btn { padding: 10px 18px; }
}
