/* 퍼피 드라이브.
   색은 맨 위 한 곳에서만 정한다. 아래 규칙에는 색 값을 직접 쓰지 않는다.
   밝은 화면: 레몬 바탕에 종이색 카드. 어두운 화면: 먹색 바탕에 레몬이 강조색. */
:root {
  color-scheme: light;
  --lemon: #F0E35A; --ink: #15160F; --cheese: #F2A640;   /* 두 화면에서 같은 세 가지 */
  --ground: var(--lemon);      /* 로그인·공유 화면의 바깥 */
  --surface: #FCFBF2;          /* 일하는 화면, 카드 */
  --side: #F1EFDF;             /* 왼쪽 메뉴 */
  --raised: #FFFEF8;           /* 입력칸 */
  --hover: #F1EFDF; --hover-side: #E4E1CC;
  --text: var(--ink); --soft: #6A6A52;
  --border: var(--ink);        /* 굵은 테두리 */
  --line: #E4E1CC;             /* 가는 구분선 */
  --solid: var(--ink); --on-solid: var(--lemon);          /* 가장 센 단추, 고른 메뉴 */
  --solid-hover: var(--ink); --on-solid-hover: var(--cheese);
  --btn: var(--lemon); --on-btn: var(--ink); --btn-line: var(--ink); --btn-hover: var(--cheese);
  --ghost: #FCFBF2;
  --accent-line: var(--ink);
  --head: var(--ink); --on-head: #FCFBF2;                 /* 창 머리띠 */
  --toast: var(--ink); --on-toast: #FCFBF2;
  --ok: #1F6B4F; --warn: #B03A1E;
  --fresh: #F7EFA0;
  --bar: var(--ink);
  --glyph-line: var(--ink); --glyph-doc: #FFFEF8; --glyph-img: #7FB89A; --glyph-vid: var(--ink);
  --focus: #B5650A; --ring: rgba(242, 166, 64, .45);
  --shadow: rgba(21, 22, 15, .22); --veil: rgba(21, 22, 15, .45);
  --drop: rgba(240, 227, 90, .93);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #101108; --surface: #1B1C13; --side: #15160F; --raised: #25261B;
  --hover: #2B2C20; --hover-side: #25261B;
  --text: #F4F2E1; --soft: #A9A78F;
  --border: #7A774A; --line: #34352A;
  --solid: var(--lemon); --on-solid: var(--ink);
  --solid-hover: var(--cheese); --on-solid-hover: var(--ink);
  --btn: transparent; --on-btn: var(--lemon); --btn-line: #A39A3C; --btn-hover: rgba(240, 227, 90, .14);
  --ghost: #25261B;
  --accent-line: var(--lemon);
  --head: #2B2C20; --on-head: #F4F2E1;
  --toast: #F4F2E1; --on-toast: var(--ink);
  --ok: #7FD1A8; --warn: #FF9B7A;
  --fresh: rgba(240, 227, 90, .16);
  --bar: var(--lemon);
  --glyph-line: #A9A78F; --glyph-doc: #25261B; --glyph-vid: #F4F2E1;
  --focus: var(--lemon); --ring: rgba(240, 227, 90, .3);
  --shadow: rgba(0, 0, 0, .55); --veil: rgba(0, 0, 0, .6);
}
/* 테마가 바뀌는 순간에는 색이 스르륵 변하지 않는다 (theme.js가 잠깐 붙였다 뗀다) */
.theme-switch *, .theme-switch *::before, .theme-switch *::after { transition: none !important; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--ground); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  font-variant-numeric: tabular-nums;  /* 숫자 폭을 맞춰서 값이 바뀌어도 글자가 흔들리지 않는다 */
  -webkit-text-size-adjust: 100%;
  word-break: keep-all; overflow-wrap: break-word;  /* 한글 낱말 중간에서 줄을 바꾸지 않는다 */
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
[data-busy] { pointer-events: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
p { margin: 0; }
.soft { color: var(--soft); }
.warn { color: var(--warn); font-weight: 600; }
.ok { color: var(--ok); font-weight: 600; }
.b { font-weight: 700; }
.grow { flex: 1; min-width: 0; }
.cut { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 단추와 입력칸. 상태가 바뀔 때만 0.2초 동안 색이 변한다 */
.field, .btn, .chip, .nav, .theme button, .link {
  /* 마우스를 올리는 일은 잦아서 150ms로 짧게 한다 */
  transition: background-color .15s ease-out, border-color .15s ease-out, color .15s ease-out, box-shadow .15s ease-out, opacity .15s ease-out, scale .15s ease-out;
}
.field { border: 2px solid var(--border); border-radius: 12px; padding: 8px 14px; background: var(--raised); min-width: 0; width: 100%; }
.field::placeholder { color: var(--soft); }
.btn {
  --bg: var(--btn); --fg: var(--on-btn); --edge: var(--btn-line);
  position: relative; border: 2px solid var(--edge); border-radius: 12px; padding: 8px 18px; font-weight: 600;
  background: var(--bg); color: var(--fg); white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--btn-hover); }
.btn:active:not(:disabled) { scale: 0.96; }  /* 눌리는 느낌 */
.btn-accent { --bg: var(--lemon); --fg: var(--ink); --edge: var(--accent-line); }
.btn-accent:hover:not(:disabled) { background: var(--cheese); }
.btn-ink { --bg: var(--solid); --fg: var(--on-solid); --edge: var(--solid); }
.btn-ink:hover:not(:disabled) { background: var(--solid-hover); color: var(--on-solid-hover); border-color: var(--solid-hover); }
.btn-ghost { --bg: var(--ghost); --fg: var(--text); --edge: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--hover); }
.btn-small { padding: 2px 10px; font-size: 14px; border-radius: 9px; }
.btn-copy { min-width: 86px; }           /* "복사됨"으로 바뀌어도 폭이 그대로다 */
.btn-small.btn-copy { min-width: 68px; }
.field:focus-visible, .btn:focus-visible, .chip:focus-visible { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--ring); }
/* 누른 단추만 돌아가는 표시를 띄운다. 글자는 자리를 지키고 숨기만 해서 폭이 변하지 않는다 */
.btn.busy { color: transparent; }
.btn.busy::after {
  content: ''; position: absolute; inset: 0; margin: auto; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--fg); border-right-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.link { border: 0; background: none; padding: 0; text-align: left; text-decoration: underline; text-underline-offset: 3px; }
.link:disabled { text-decoration: none; }
.chip { border: 2px solid var(--border); border-radius: 20px; padding: 3px 14px; background: var(--ghost); white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--solid); border-color: var(--solid); color: var(--on-solid); font-weight: 600; }

/* 로그인, 받는 사람 화면, 앱 연결 화면 */
.center { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.card {
  width: min(380px, 100%); min-height: 236px; background: var(--surface); border: 2px solid var(--border); border-radius: 28px;
  padding: 30px 26px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 50px var(--shadow);
}
.card form { display: flex; flex-direction: column; gap: 12px; }
.brand { display: block; height: 48px; width: auto; align-self: flex-start; }
.card h1 { font-size: 20px; margin: 0; line-height: 1.35; }
.code { font-size: 26px; letter-spacing: .3em; text-align: center; }
.mini { border: 2px solid var(--border); border-radius: 16px; padding: 16px; background: var(--raised); display: flex; flex-direction: column; gap: 6px; overflow-wrap: anywhere; }
.fact { display: flex; gap: 12px; }
.fact-label { width: 44px; color: var(--soft); flex-shrink: 0; }
.icon svg { width: 34px; height: 34px; display: block; }

/* 일하는 화면 */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); height: 100dvh; background: var(--surface); }
.side { background: var(--side); border-right: 2px solid var(--border); padding: 20px 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.side .brand { height: 44px; margin: 0 4px 14px; }
.nav { border: 0; background: none; text-align: left; padding: 8px 12px; border-radius: 10px; white-space: nowrap; }
.nav:hover { background: var(--hover-side); }
.nav[aria-current="page"] { background: var(--solid); color: var(--on-solid); font-weight: 600; }
.theme { display: flex; border: 2px solid var(--border); border-radius: 10px; overflow: hidden; margin: 0 4px 14px; flex-shrink: 0; }
.theme button { flex: 1; border: 0; background: none; padding: 3px 6px; font-size: 13px; white-space: nowrap; color: var(--soft); }
.theme button:hover { background: var(--hover-side); }
.theme button[aria-pressed="true"] { background: var(--solid); color: var(--on-solid); font-weight: 600; }
.who { display: flex; align-items: center; gap: 10px; padding: 0 6px; min-width: 0; }
.av { width: 36px; height: 36px; border-radius: 50%; background: var(--solid); color: var(--on-solid); font-weight: 700; display: grid; place-items: center; flex-shrink: 0; }
.main { overflow: auto; overscroll-behavior: contain; padding: 18px 22px 140px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.tools { display: flex; gap: 10px; align-items: center; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; color: var(--soft); align-items: center; min-height: 24px; }
.crumbs .link:last-child { color: var(--text); font-weight: 600; text-decoration: none; }
h2 { font-size: 20px; margin: 0; }

/* 줄 높이를 고정해서, 단추가 있는 줄과 없는 줄이 같은 높이다 */
.frow { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 6px; border-bottom: 2px solid var(--line); min-width: 0; transition: background-color 1s ease-out; }
.fhead { color: var(--soft); font-size: 14px; min-height: 0; padding: 2px 6px 6px; }
.fresh { background: var(--fresh); transition: none; }
.c-name { flex: 1; min-width: 0; }
.fhead .c-name { padding-left: 38px; }
.c-size { width: 84px; text-align: right; flex-shrink: 0; }
.c-date { width: 100px; flex-shrink: 0; }
.c-state { width: 72px; font-weight: 600; flex-shrink: 0; }
.c-act { width: 204px; display: flex; gap: 6px; justify-content: flex-end; align-items: center; flex-shrink: 0; }
.c-term { width: 116px; flex-shrink: 0; }
.c-ended { width: 372px; flex-shrink: 0; }   /* 조건 칸 3개와 그 사이 간격을 합친 폭 */
.c-wide { width: 240px; flex-shrink: 0; }
.empty { padding: 40px 6px; color: var(--soft); display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }

/* 불러오는 동안 보이는 자리 표시. 실제 줄과 같은 모양이다 */
.skel { display: block; height: 14px; border-radius: 6px; background: var(--line); animation: pulse 1s ease-in-out infinite alternate; }
.skel-a { width: 46%; } .skel-b { width: 30%; } .skel-c { width: 62%; }
.skel-box { width: 26px; height: 22px; flex-shrink: 0; }
@keyframes pulse { to { opacity: .45; } }

.g { width: 26px; height: 22px; border: 2px solid var(--glyph-line); border-radius: 6px; flex-shrink: 0; }
.g-folder { background: var(--cheese); }
.g-doc { background: var(--glyph-doc); width: 20px; height: 26px; margin: 0 3px; }
.g-img { background: var(--glyph-img); }
.g-vid { background: var(--glyph-vid); }

/* 업로드 창 */
.dock {
  position: fixed; right: 18px; bottom: 18px; width: min(440px, calc(100vw - 36px)); background: var(--surface);
  border: 2px solid var(--border); border-radius: 18px; box-shadow: 0 14px 40px var(--shadow); overflow: hidden;
}
.dock-head { background: var(--head); color: var(--on-head); padding: 8px 14px; font-weight: 600; }
.dock-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; max-height: 50dvh; overflow: auto; overscroll-behavior: contain; }
.dock-more { padding: 0 14px 10px; font-size: 14px; }
.dock-foot { display: flex; gap: 8px; align-items: center; min-height: 50px; padding: 10px 14px; border-top: 2px solid var(--line); font-size: 14px; }
.dock-foot .btn { min-width: 78px; }
.up { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.up-top { display: flex; gap: 10px; align-items: center; min-height: 28px; }
.up-text { min-height: 21px; }
.bar { height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 5px; background: var(--bar); transition: width .25s linear, background-color .2s ease-out; }
.bar.done i { background: var(--cheese); }
.parts { display: flex; flex-wrap: wrap; gap: 4px; }
.part { width: 14px; height: 14px; border: 2px solid var(--glyph-line); border-radius: 4px; background: var(--surface); transition: background-color .2s ease-out; }
.part.done { background: var(--cheese); }
.part.live { background: var(--lemon); animation: blink .7s ease-in-out infinite alternate; }
@keyframes blink { to { opacity: .35; } }

.drop { position: fixed; inset: 0; background: var(--drop); color: var(--ink); border: 6px dashed var(--ink); display: grid; place-items: center; font-size: 26px; font-weight: 800; pointer-events: none; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 6px); opacity: 0; background: var(--toast); color: var(--on-toast);
  padding: 10px 18px; border-radius: 12px; max-width: calc(100vw - 32px); box-shadow: 0 8px 24px var(--shadow);
  transition: opacity .2s ease-out, transform .2s ease-out; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 공유 창 */
dialog { border: 2px solid var(--border); border-radius: 20px; padding: 0; background: var(--surface); color: var(--text); width: min(520px, calc(100vw - 32px)); box-shadow: 0 20px 50px var(--shadow); }
dialog::backdrop { background: var(--veil); }
.dlg-head { background: var(--head); color: var(--on-head); padding: 10px 18px; font-weight: 600; }
.dlg-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.opt { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 34px; }
.opt-label { width: 108px; color: var(--soft); flex-shrink: 0; }
.dlg-foot { display: flex; gap: 10px; align-items: center; border-top: 2px solid var(--line); padding-top: 16px; }
.file-head { display: flex; gap: 12px; align-items: center; min-width: 0; }

@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .side { flex-direction: row; align-items: center; border-right: 0; border-bottom: 2px solid var(--border); padding: 8px 10px; overflow-x: auto; }
  .side .brand { height: 34px; margin: 0 6px 0 0; flex-shrink: 0; }
  .side .grow { display: none; }
  .theme { margin: 0 4px; }
  .who .cut { display: none; }
  .main { padding: 14px 12px 160px; }
  .c-date, .fhead .c-state, .fhead .c-act, .fhead .c-term { display: none; }
  .frow { flex-wrap: wrap; }
  .c-state:empty { display: none; }
  .c-act { width: 100%; justify-content: flex-start; padding-left: 38px; }
  .c-wide, .c-ended { width: 100%; padding-left: 38px; }
  .c-term { width: 100%; padding-left: 38px; }
  .c-term::before { content: attr(data-label); color: var(--soft); margin-right: 8px; }
  .frow > .c-name:first-child ~ * { padding-left: 0; }   /* 앞에 그림이 없는 줄은 들여 쓰지 않는다 */
  .opt-label { width: 100%; }
  .tools { flex-wrap: wrap; }
  .tools .field { flex-basis: 100%; }
}
