/* 내 자료실 - 반응형 개인 보관함 스타일 */

:root {
  --bg: #f7efe4;
  --surface: #ffffff;
  --surface-2: #fbf6ec;
  --text: #3b2e22;
  --text-soft: #7b6a57;
  --border: #e6d8c4;
  --primary: #b17c4a;
  --primary-hover: #9a6739;
  --danger: #a8443a;
  --danger-hover: #8f3830;
  --shadow: 0 1px 2px rgba(60, 40, 20, 0.06), 0 8px 24px rgba(60, 40, 20, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans KR", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 16px;
  padding-bottom: 32px;
}

.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.header-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.header-sub {
  color: var(--text-soft);
  font-size: 0.92rem;
  margin-top: 2px;
}

.header-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.btn {
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  min-height: 44px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary, #fff);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
}

.btn-secondary:hover {
  background: var(--surface-2);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text);
}

.btn-ghost:hover {
  background: rgba(0, 0, 0, 0.04);
}

.btn-danger {
  background: var(--surface);
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.btn-small {
  font-size: 0.85rem;
  padding: 7px 12px;
  min-height: 36px;
}

.btn .icon {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.1em;
}

.notice {
  margin-bottom: 16px;
}

.notice-card {
  background: #fff4df;
  border: 1px solid #f0d9a8;
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}

.notice-text {
  flex: 1;
  font-size: 0.92rem;
  color: #5a4218;
}

.notice-close {
  background: transparent;
  border: none;
  font-weight: 600;
  color: #5a4218;
  padding: 4px 8px;
  min-height: 32px;
  font-size: 0.85rem;
}

.storage-hint {
  margin-bottom: 16px;
}

.storage-hint p {
  background: var(--surface);
  color: var(--text-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.82rem;
  line-height: 1.45;
}

.main {
  flex: 1;
}

.view {
  display: block;
}

.view.hidden {
  display: none;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 170px;
  touch-action: manipulation;
}

.card:active {
  transform: scale(0.98);
}

.card-cover {
  height: 110px;
  position: relative;
  background: var(--surface-2);
  overflow: hidden;
}

.card-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-cover-icon {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  background: var(--color, var(--surface-2));
}

.card-color-bar {
  height: 6px;
  background: var(--color, var(--primary));
}

.card-body {
  padding: 10px 12px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-title {
  font-weight: 600;
  font-size: 0.95rem;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  color: var(--text-soft);
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.empty-state,
.items-empty,
.search-empty {
  text-align: center;
  color: var(--text-soft);
  padding: 32px 16px;
  font-size: 0.95rem;
}

/* 상세 보기 */
.detail-back {
  margin-bottom: 16px;
}

.folder-header {
  display: flex;
  gap: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.folder-cover {
  width: 120px;
  height: 120px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
  flex-shrink: 0;
}

.folder-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.folder-cover-icon {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.2rem;
  background: var(--color, var(--surface-2));
}

.folder-cover-color {
  height: 100%;
  background: var(--color, var(--surface-2));
}

.folder-info {
  flex: 1;
  min-width: 200px;
}

.folder-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
  word-break: break-word;
}

.folder-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.detail-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 16px 0;
}

.tool-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.item-thumb {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
  flex-shrink: 0;
  display: block;
}

.item-thumb-icon {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
}

.item-body {
  flex: 1;
  min-width: 120px;
}

.item-name {
  font-weight: 600;
  word-break: break-word;
}

.item-sub {
  color: var(--text-soft);
  font-size: 0.82rem;
  margin-top: 2px;
}

.item-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.item-hint {
  color: var(--text-soft);
  font-size: 0.82rem;
  line-height: 1.45;
}

.modal-error {
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1.2em;
}

/* 검색 */
.search-layout {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  max-width: 720px;
  margin: 0 auto;
}

.search-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.search-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.search-input-wrap {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.search-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font: inherit;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
}

.search-input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.search-result-item:hover {
  border-color: var(--primary);
}

.search-result-text {
  flex: 1;
  word-break: break-word;
  font-weight: 500;
}

.search-result-sub {
  display: block;
  margin-top: 2px;
  color: var(--text-soft);
  font-size: 0.82rem;
  font-weight: 400;
}

.search-result-tag {
  font-size: 0.72rem;
  color: var(--text-soft);
  background: var(--border);
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}


.hidden {
  display: none !important;
}

/* 모달 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(40, 28, 16, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  backdrop-filter: blur(2px);
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(40, 28, 16, 0.25);
  width: 100%;
  max-width: 480px;
  padding: 20px;
  max-height: 90vh;
  overflow: auto;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 14px;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-label {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
}

.modal-hint {
  font-size: 0.78rem;
  color: var(--text-soft);
}

.modal-input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 44px;
  font: inherit;
}

/* 모달 안의 색상 선택·파일 선택도 손가락 터치 높이를 확보 */
.modal-field input[type="color"],
.modal-field input[type="file"] {
  min-height: 44px;
  padding: 8px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
  padding: 10px 12px;
  font: inherit;
  background: var(--surface);
}

.modal-input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.icon-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 8px;
}

.icon-option {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  cursor: pointer;
  touch-action: manipulation;
}

.icon-option.selected {
  border: 2px solid var(--primary);
  background: #fdeee2;
  transform: scale(1.05);
}

.icon-option:active {
  transform: scale(0.95);
}

.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.color-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s ease;
}

.color-swatch.selected {
  border-color: var(--text);
  transform: scale(1.1);
}

.color-swatch:active {
  transform: scale(0.95);
}

.color-swatch-wrap {
  position: relative;
  display: inline-block;
}

.color-swatch-wrap input[type="color"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  border: none;
  padding: 0;
}

.cover-upload {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.cover-preview {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.cover-clear {
  border: none;
  background: transparent;
  color: var(--danger);
  font-weight: 600;
  padding: 6px 8px;
  min-height: 36px;
}

.cover-clear:disabled {
  color: var(--border);
  pointer-events: none;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.form-actions-right {
  margin-left: auto;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 18px;
}

.footer {
  margin-top: 16px;
  color: var(--text-soft);
  font-size: 0.8rem;
  text-align: center;
}

.keyboard-hint {
  font-size: 0.78rem;
  color: var(--text-soft);
  margin-top: 6px;
}

/* 반응형 조정 */
@media (max-width: 560px) {
  .app {
    padding: 12px;
  }

  .header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    margin-left: 0;
  }

  .header-actions .btn {
    flex: 1;
  }

  .cards {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
  }

  .card {
    min-height: 150px;
  }

  .card-cover {
    height: 90px;
  }

  .folder-header {
    flex-direction: column;
  }

  .folder-cover {
    width: 100%;
    height: 180px;
  }

  .item-card {
    flex-direction: column;
    align-items: stretch;
  }

  .item-thumb,
  .item-thumb-icon {
    width: 100%;
    height: 80px;
  }
}

@media (min-width: 561px) and (max-width: 920px) {
  .cards {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  }
}

/* 좁은 화면 가로 넘침 방지: 기존 레이아웃을 바꾸지 않고 긴 텍스트(링크 주소·파일명)만 줄바꿈되게 보강 */
.item-body {
  min-width: 0;
}

.item-name,
.item-sub,
.search-result-text {
  overflow-wrap: anywhere;
}

.item-actions {
  max-width: 100%;
}

/* 아이콘 이미지 (폴더 아이콘 자리에 표시되는 사용자 사진) */
.card-cover-icon,
.folder-cover-icon {
  overflow: hidden;
}

.card-cover-icon .card-icon-img,
.folder-cover-icon .detail-icon-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}

.icon-preview {
  border-radius: 50%;
}

/* 아이콘 카테고리 */
.icon-groups {
  max-height: 190px;
  overflow-y: auto;
  padding-right: 4px;
}

.icon-group-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-soft);
  margin: 8px 0 4px;
}

/* 자주 쓰는 색상 */
.fav-swatch {
  position: relative;
  display: inline-flex;
}

.fav-del {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 11px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

/* 꾸미기(사이트 테마) */
.theme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}

.theme-row label {
  font-size: 0.92rem;
}

.theme-row input[type="color"] {
  width: 48px;
  height: 36px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
}

/* 강조 색상이 적용되는 지점 (값이 없으면 기존과 동일하게 표시) */
.color-swatch.selected {
  border-color: var(--accent, var(--text));
}

.icon-option.selected {
  border-color: var(--accent, var(--primary));
}

.search-result-item:hover {
  border-color: var(--accent, var(--primary));
}

.notice-card {
  border-color: var(--accent, #f0d9a8);
}
