/* 첨부파일 - 끌어 놓기 상자 (21st.dev file-upload-2 를 옮긴 모양).
   상자는 <label> 이다.  여러 폼이 'form label' 에 글자 크기 · 격자를 걸어 두므로
   (업무노트 · 다이어리) 이 파일은 클래스 두 개 이상으로 잡아 그 규칙을 이긴다.
   색은 토큰만 쓰고 어두운 화면은 html[data-theme="dark"] 로만 덮는다. */

@property --att-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

.att-field {
  display: grid;
  gap: 8px;
  min-width: 0;
}
.att-field > .att-label {
  color: var(--brand-text-secondary);
  font-size: 13px;
  font-weight: 600;
}
.att-field > .att-label em {
  color: var(--brand-text-muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 400;
}
/* 놓인 자리의 이름표 모양을 따른다 */
.vault-form .att-field > .att-label { color: var(--brand-text-primary); font-size: 14px; }
.diary-form .att-field > .att-label { font-size: 11px; font-weight: 700; }
.diary-form .att-field > .att-label em { font-size: 10px; }
.work-note-form .att-field { margin-top: 10px; }
.work-note-form .att-field > .att-label { color: var(--brand-text-muted); font-size: 11px; font-weight: 400; }

/* ---- 상자 ---------------------------------------------------------------- */
.att-field .att-drop,
.att-upload .att-drop {
  --att-line: color-mix(in srgb, var(--brand-text-primary) 20%, transparent);
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 200px;
  box-sizing: border-box;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 22px 18px;
  border: 1px dashed var(--att-line);
  border-radius: 18px;
  background: transparent;
  color: var(--brand-text-primary);
  font-size: 14px;
  font-weight: 400;
  text-align: center;
  cursor: pointer;
  isolation: isolate;
  transition: border-color 200ms ease, background-color 200ms ease, box-shadow 200ms ease;
  -webkit-tap-highlight-color: transparent;
}
.att-field .att-drop.is-compact,
.att-upload .att-drop.is-compact { min-height: 160px; padding: 18px 16px; }
.att-field .att-drop:hover,
.att-upload .att-drop:hover {
  --att-line: color-mix(in srgb, var(--brand-text-primary) 38%, transparent);
  background: color-mix(in srgb, var(--brand-text-primary) 2.5%, transparent);
}
.att-field .att-drop:focus-visible,
.att-upload .att-drop:focus-visible {
  --att-line: var(--brand-accent);
  outline: none;
  box-shadow: var(--focus-ring, 0 0 0 3px rgba(0, 51, 255, 0.25));
}
.att-field .att-drop.is-dragging,
.att-upload .att-drop.is-dragging {
  --att-line: color-mix(in srgb, var(--brand-accent) 70%, transparent);
  background: color-mix(in srgb, var(--brand-accent) 6%, transparent);
}
.att-field .att-drop.is-rejected,
.att-upload .att-drop.is-rejected {
  --att-line: color-mix(in srgb, var(--brand-danger) 70%, transparent);
  animation: att-shake 360ms cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

/* 테두리 빛: 끌고 있을 때만, 테두리를 따라 2.4초에 한 바퀴 */
.att-drop > .att-beam {
  position: absolute;
  z-index: -1;
  inset: -1px;
  padding: 2px;
  border-radius: inherit;
  background: conic-gradient(
    from var(--att-angle),
    transparent 0deg,
    transparent 200deg,
    color-mix(in srgb, var(--brand-accent) 25%, transparent) 260deg,
    var(--brand-accent) 330deg,
    var(--brand-accent-hover, var(--brand-accent)) 350deg,
    transparent 360deg
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}
.att-drop.is-dragging > .att-beam {
  opacity: 1;
  animation: att-beam 2.4s linear infinite;
}
@keyframes att-beam { to { --att-angle: 360deg; } }
@keyframes att-shake {
  20%, 60% { transform: translateX(-3px); }
  40%, 80% { transform: translateX(3px); }
}

/* 가운데 아이콘 무리 */
.att-drop > .att-stack {
  position: relative;
  display: block;
  width: 150px;
  height: 64px;
  margin-bottom: 8px;
  pointer-events: none;
}
.att-stack-card {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  width: 48px;
  height: 48px;
  box-sizing: border-box;
  place-items: center;
  border: 1px solid var(--brand-border);
  border-radius: 12px;
  background: var(--brand-bg);
  color: var(--brand-text-muted);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: transform 500ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 500ms cubic-bezier(0.22, 1, 0.36, 1), color 300ms ease;
}
.att-stack-card .att-svg { width: 22px; height: 22px; }
.att-stack-card.is-left { transform: translate(-78%, -50%) rotate(-8deg); }
.att-stack-card.is-center { z-index: 2; transform: translate(-50%, -50%); color: var(--brand-text-secondary); }
.att-stack-card.is-right { transform: translate(-22%, -50%) rotate(8deg); }
.att-drop:hover .att-stack-card.is-center { color: var(--brand-text-primary); }
.att-drop.is-dragging .att-stack-card { box-shadow: 0 10px 24px -8px rgba(0, 0, 0, 0.22); color: var(--text-accent, var(--brand-accent)); }
.att-drop.is-dragging .att-stack-card.is-left { transform: translate(-114%, -50%) rotate(-12deg) scale(1.08); }
.att-drop.is-dragging .att-stack-card.is-center { transform: translate(-50%, -50%) scale(1.18); }
.att-drop.is-dragging .att-stack-card.is-right { transform: translate(14%, -50%) rotate(12deg) scale(1.08); }

.att-svg {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 글 */
.att-drop > .att-drop-text {
  display: grid;
  gap: 4px;
  max-width: 100%;
  color: var(--brand-text-primary);
  font-size: 14px;
  font-weight: 400;
}
.att-drop .att-drop-title { color: var(--brand-text-primary); font-size: 14px; font-weight: 600; line-height: 1.45; }
.att-drop .att-drop-desc { color: var(--brand-text-muted); font-size: 12px; font-weight: 400; line-height: 1.5; }
.att-drop .att-drop-error {
  color: var(--brand-danger);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.att-drop .att-drop-error[hidden] { display: none; }

/* 아래 알약 */
.att-drop > .att-drop-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 14px;
  border: 1px solid var(--brand-border);
  border-radius: 999px;
  background: var(--brand-surface);
  color: var(--brand-text-primary);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: border-color 200ms ease, background-color 200ms ease, color 200ms ease;
}
.att-drop:hover > .att-drop-cta { border-color: var(--brand-border-strong); }
.att-drop.is-dragging > .att-drop-cta {
  border-color: color-mix(in srgb, var(--brand-accent) 50%, transparent);
  background: color-mix(in srgb, var(--brand-accent) 10%, var(--brand-surface));
  color: var(--text-accent, var(--brand-accent));
}

/* 진짜 파일 칸은 숨기되 display:none 은 쓰지 않는다(폼 검사 · 라벨 연결 유지). */
.att-drop .att-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
  opacity: 0;
  pointer-events: none;
}

/* ---- 파일 목록 ------------------------------------------------------------ */
.att-list {
  display: grid;
  min-width: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--brand-border);
  border-radius: 12px;
  background: var(--brand-surface);
  list-style: none;
}
.att-list[hidden] { display: none; }
.att-row {
  --att-progress: 0%;
  position: relative;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 10px 10px 10px 12px;
  border-bottom: 1px solid var(--brand-border);
  transition: opacity 180ms ease, transform 180ms ease;
}
.att-row:last-child { border-bottom: 0; }
.att-row.is-uploading::after {
  position: absolute;
  bottom: 0;
  left: 0;
  width: var(--att-progress);
  height: 2px;
  background: var(--brand-accent);
  content: "";
  transition: width 160ms linear;
}
.att-row.is-leaving { opacity: 0; transform: translateY(-2px); }

.att-thumb {
  position: relative;
  display: grid;
  width: 40px;
  height: 40px;
  box-sizing: border-box;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--brand-border);
  border-radius: 8px;
  background: var(--brand-bg);
}
.att-thumb img { width: 100%; height: 100%; object-fit: cover; }
.att-thumb .file-card { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.56); }

.att-row-main { display: grid; gap: 2px; min-width: 0; }
.att-row-name {
  overflow: hidden;
  color: var(--brand-text-primary);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}
a.att-row-name:hover { color: var(--text-accent, var(--brand-accent)); text-decoration: underline; }
.att-row-meta {
  overflow: hidden;
  color: var(--brand-text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.att-row-meta.is-error { color: var(--brand-danger); white-space: normal; overflow-wrap: anywhere; }
.att-row-source { display: flex; min-width: 0; margin-top: 4px; }
.att-row-source > a,
.att-row-source > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  overflow: hidden;
  padding: 2px 10px;
  border: 1px solid var(--brand-border);
  border-radius: 999px;
  background: var(--brand-bg);
  color: var(--brand-text-secondary);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.att-row-source > a:hover { border-color: var(--brand-border-strong); color: var(--brand-text-primary); }
.att-row-source i { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--brand-accent); }

.att-row-actions { display: flex; align-items: center; gap: 6px; }
.att-row-actions form { display: contents; margin: 0; }
.att-icon-btn {
  display: inline-grid;
  width: 30px;
  height: 30px;
  flex: none;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--brand-text-muted);
  cursor: pointer;
  transition: background-color var(--transition-fast, 150ms) ease, color var(--transition-fast, 150ms) ease;
}
.att-icon-btn:hover { background: var(--brand-surface-muted); color: var(--brand-text-primary); text-decoration: none; }
.att-icon-btn.is-danger:hover { background: color-mix(in srgb, var(--brand-danger) 10%, var(--brand-surface)); color: var(--brand-danger); }
.att-icon-btn:focus-visible { outline: none; box-shadow: var(--focus-ring, 0 0 0 3px rgba(0, 51, 255, 0.25)); }
.att-icon-btn:disabled { opacity: 0.5; cursor: progress; }

/* 상태 알약 (label-badges 모양) */
.att-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border: 1px solid var(--brand-border);
  border-radius: 999px;
  background: var(--brand-bg);
  color: var(--brand-text-secondary);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.att-status > i { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--brand-text-muted); }
.att-status.is-ready > i { background: var(--brand-accent); }
.att-status.is-uploading > i { background: var(--brand-accent); animation: att-pulse 1s ease-in-out infinite; }
.att-status.is-done > i { background: var(--brand-success, var(--brand-accent)); }
.att-status.is-failed { color: var(--brand-danger); }
.att-status.is-failed > i { background: var(--brand-danger); }
@keyframes att-pulse { 50% { opacity: 0.35; } }

/* ---- 보기 화면 패널 -------------------------------------------------------- */
.att-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
  margin-top: 8px;
  padding: 18px;
  border: 1px solid var(--brand-border);
  border-radius: 14px;
  background: var(--brand-surface);
}
.att-panel-head { display: flex; align-items: center; gap: 8px; }
.att-panel .att-panel-head h2 { margin: 0; padding: 0; border: 0; color: var(--brand-text-primary); font-size: 15px; font-weight: 700; line-height: 1.4; letter-spacing: 0; }
.att-panel .att-panel-head h2::before,
.att-panel .att-panel-head h2::after { content: none; }
.att-count {
  min-width: 22px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--brand-surface-muted);
  color: var(--brand-text-secondary);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.att-upload { display: grid; gap: 10px; min-width: 0; margin: 0; }
.att-noscript-submit { justify-self: start; }
/* 보관함 보기: 색 카드 안이라 배경을 조금 비춘다 */
.vault-detail .att-panel { background: color-mix(in srgb, var(--brand-surface) 88%, transparent); }
.diary-detail-card .att-panel { margin-top: 0; margin-bottom: 20px; }

/* 일정 창 */
.att-existing[hidden],
.att-field [hidden],
.att-panel [hidden] { display: none !important; }
/* 일정 창은 두 줄 높이 띠로(2026-11-16 사용자 '첨부파일 칸이 너무 커, 2줄 정도로') - 아이콘 무리는 빼고 글 · 단추를 한 줄에 */
.desk-sched .att-field .att-drop.is-compact {
  min-height: 0;
  flex-direction: row;
  justify-content: flex-start;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  border-radius: 12px;
  text-align: left;
}
.desk-sched .att-field .att-drop.is-compact > .att-stack { display: none; }
.desk-sched .att-field .att-drop.is-compact > .att-drop-text { flex: 1 1 auto; min-width: 0; gap: 0; }
.desk-sched .att-field .att-drop.is-compact .att-drop-title { font-size: 13px; }
.desk-sched .att-field .att-drop.is-compact > .att-drop-cta { flex: none; margin: 0; }
/* 휴대폰은 끌어 놓을 일이 없다 - 안내 첫 줄은 빼고 형식 · 크기만(두 줄 높이 그대로) */
@media (max-width: 560px) {
  .desk-sched .att-field .att-drop.is-compact .att-drop-title { display: none; }
}
.desk-sched .att-existing .att-list { margin-top: 2px; }
/* 붙은 파일 + 상태 글을 묶는 범위.  자리는 차지하지 않는다(창의 격자를 그대로). */
.att-scope { display: contents; }
.att-inline-note {
  margin: 0;
  color: var(--brand-text-secondary);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.att-inline-note::before {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--brand-success, var(--brand-accent));
  content: "";
  vertical-align: 1px;
}
.att-inline-note.is-error { color: var(--brand-danger); }
.att-inline-note.is-error::before { background: var(--brand-danger); }
.att-inline-note[hidden] { display: none; }

/* 내 파일 화면 */
.att-page { display: grid; gap: 20px; }
.att-page-head h1 { margin: 4px 0 8px; }
.att-page-desc { margin: 0; color: var(--brand-text-secondary); font-size: 14px; }
.att-page-note { margin: 0; color: var(--brand-text-muted); font-size: 12px; }

@media (max-width: 560px) {
  .att-field .att-drop,
  .att-upload .att-drop { min-height: 180px; padding: 18px 12px; }
  .att-field .att-drop.is-compact,
  .att-upload .att-drop.is-compact { min-height: 150px; }
  .att-row { gap: 10px; padding: 10px 8px 10px 10px; }
  .att-row .att-status { padding: 2px 8px; }
  .att-panel { padding: 14px; }
}

/* ---- 어두운 화면 ------------------------------------------------------------ */
html[data-theme="dark"] .att-field .att-drop,
html[data-theme="dark"] .att-upload .att-drop {
  --att-line: color-mix(in srgb, var(--brand-text-primary) 22%, transparent);
}
html[data-theme="dark"] .att-field .att-drop:hover,
html[data-theme="dark"] .att-upload .att-drop:hover {
  --att-line: color-mix(in srgb, var(--brand-text-primary) 40%, transparent);
  background: color-mix(in srgb, var(--brand-text-primary) 4%, transparent);
}
html[data-theme="dark"] .att-field .att-drop.is-dragging,
html[data-theme="dark"] .att-upload .att-drop.is-dragging {
  --att-line: color-mix(in srgb, var(--brand-accent) 75%, transparent);
  background: color-mix(in srgb, var(--brand-accent) 10%, transparent);
}
html[data-theme="dark"] .att-stack-card { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); }
html[data-theme="dark"] .att-drop.is-dragging .att-stack-card { box-shadow: 0 12px 28px -8px rgba(0, 0, 0, 0.7); }

/* 구글 드라이브 사본이 있는 파일 - 드라이브에서 열기 */
.att-icon-btn.is-drive { color: var(--brand-highlight, var(--brand-accent)); }
