/* 공통 부품: 화면 머리, 패널, 카드, 버튼, 입력창, 목록. 모든 화면이 같은 부품을 씁니다. */

/* 화면 머리 */
.page-header {
  position: relative;
  display: flex; justify-content: space-between; gap: var(--space-4);
}
.page-header p { margin: var(--space-1) 0 0; max-width: 640px; }
.page-header > div:first-child { position: relative; }
.page-portrait { flex: 0 0 auto; width: 80px; height: 80px; }
.eyebrow { margin: 0 0 var(--space-1); font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; }

/* 잔액 표시 */
.balance-chip { flex: 0 0 auto; justify-items: end; }

/* 패널 (화면 안의 구역) */
.panel { margin-top: var(--space-5); }
.panel > h2, .section-title { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin: 0 0 var(--space-4); }
.section-title h2 { margin: 0; }
.panel-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 0 var(--space-5); }

/* 카드 */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--space-3); }
.card { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3) var(--space-4); }
.card h3, .card p { margin: 0; }
.card-meta { color: var(--color-text-muted); font-size: var(--text-sm); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); }
.card .actions { margin-top: auto; }

/* 아이템 카드: 아이콘을 왼쪽에, 이름·가격을 오른쪽에 두어 한 화면에 더 많이 보이게 */
.card-grid:has(> .card > .item-thumb) { grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: var(--space-2); }
.card:has(> .item-thumb) { display: grid; grid-template-columns: 48px minmax(0, 1fr); align-items: center; gap: 2px var(--space-3); padding: var(--space-2) var(--space-3); }
.card:has(> .item-thumb) > .item-thumb { grid-row: span 2; align-self: center; }
.card:has(> .item-thumb) > :not(.item-thumb) { grid-column: 2; min-width: 0; }
.card:has(> .item-thumb) > :is(form, .actions, .field-row) { grid-column: 1 / -1; margin-top: var(--space-1); }
.card:has(> .item-thumb) h3 { font-size: var(--text-md); line-height: 1.3; overflow-wrap: anywhere; }
.card:has(> .item-thumb) .card-meta { font-size: var(--text-xs); }

/* 버튼 */
.btn, form button:not([class]) {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1);
  font: 700 var(--text-sm) var(--font-body); text-decoration: none; white-space: nowrap; cursor: pointer;
}
.btn--primary { --btn-shade: var(--color-leaf-shade); }
.btn--danger { --btn-shade: var(--btn-danger-shade); }
.btn--small { --shadow-button: 0 2px 0 var(--btn-shade), 0 4px 0 var(--color-shadow); }
.btn:disabled, form button:disabled, .btn:disabled:hover { cursor: not-allowed; }

/* 입력창 */
.field-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: 0; }
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=hidden]), select, textarea {
  font: inherit; color: var(--color-text);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
}
input:focus, select:focus, textarea:focus { outline: none; }
.field-row input[type=number] { width: 60px; height: 30px; padding: 0 var(--space-2); }
.field-row:has(.btn) > input { margin-bottom: 4px; }
.card-grid > .empty, .photo-grid > .empty { grid-column: 1 / -1; }
.stack-form p { display: grid; gap: var(--space-1); margin: 0 0 var(--space-3); }
.stack-form label { font-weight: 700; font-size: var(--text-sm); }
.stack-form input:not([type=checkbox]), .stack-form select, .stack-form textarea { width: 100%; }
.stack-form textarea { min-height: 110px; resize: vertical; }
.stack-form .helptext, .stack-form p > span { color: var(--color-text-muted); font-size: var(--text-xs); }
.stack-form ul.errorlist, .errorlist { margin: 0; padding: 0; list-style: none; color: var(--color-berry); font-size: var(--text-sm); }
.stack-form p:has(input[type=checkbox]) { display: flex; align-items: center; gap: var(--space-2); }

/* 목록 */
.feed { display: grid; }
.feed > article { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-1) var(--space-3); padding: var(--space-3) 0; border-top: 1px solid var(--color-border); }
.feed > article:first-child { border-top: 0; padding-top: 0; }
.feed > article > div { flex: 1 1 240px; }
.feed p { margin: 0; }
.feed small, time { color: var(--color-text-muted); font-size: var(--text-sm); }
.stat-list { margin: 0; }
.stat-list > div { display: flex; justify-content: space-between; gap: var(--space-4); padding: var(--space-3) 0; border-bottom: 1px solid var(--color-border); }
.stat-list dt { color: var(--color-text-muted); }
.stat-list dd { margin: 0; text-align: right; font-weight: 700; }
.tag { display: inline-block; flex: 0 0 auto; white-space: nowrap; font-size: var(--text-xs); font-weight: 700; vertical-align: middle; }
.empty { padding: var(--space-4); text-align: center; color: var(--color-text-muted); margin: 0; }
.long-text { line-height: 1.8; white-space: normal; }
.quick-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--space-2); }
.quick-links a { display: grid; justify-items: center; gap: var(--space-1); padding: var(--space-3) var(--space-2); text-decoration: none; color: var(--color-text); font-weight: 500; transition: transform .08s, box-shadow .08s; }
.quick-links a:active { transform: translateY(2px); box-shadow: none; }
.quick-links .ui-icon { font-size: 1.6rem; }

/* 접기 */
details.fold { margin-bottom: var(--space-4); padding: var(--space-3) var(--space-4); background: var(--color-surface-alt); border-radius: var(--radius-md); }
details.fold summary { cursor: pointer; font-weight: 500; }
details.fold[open] summary { margin-bottom: var(--space-3); }

@media (max-width: 760px) {
  .page-header { flex-wrap: wrap; }
  .page-header > div:first-child { flex: 1 1 100%; }
  .balance-chip { justify-items: start; }
  .page-portrait { width: 72px; height: 72px; }
  .panel-grid { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 420px) {
  .card-grid { grid-template-columns: 1fr; }
}
.grow { flex: 1 1 auto; }
.card-grid + .card-grid { margin-top: var(--space-4); }
.subhead { margin-top: var(--space-5); }
.card form.actions { display: grid; gap: var(--space-2); justify-items: start; }
.card form.field-row.actions { display: flex; }
.race + .race { margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--color-border); }

/* 관리자 바로 수정 */
.admin-edit { display: inline-grid; place-items: center; width: 20px; height: 20px; margin-left: 4px; border-radius: 50%; font-size: 11px; text-decoration: none; vertical-align: middle; border: 1px solid #f0d58a; }
.admin-edit--add { width: auto; height: 26px; padding: 0 10px; border-radius: var(--radius-sm); font-size: var(--text-xs); font-weight: 700; gap: 4px; display: inline-flex; align-items: center; }
.countdown { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--color-leaf-deep); } .countdown.is-done { color: var(--color-berry); } .garden-plot .countdown { color: #fff; }
