@layer tokens, base, components, pages, overrides;
@import url("../tokens.css?v=20261107_dialog_standard1") layer(tokens);
@import url("../base.css?v=20261021_shared_base1") layer(base);
@import url("../ui_components.css?v=20261107_dialog_standard1") layer(components);
@import url("../auth_dialog.css?v=20261029_item_login1") layer(components);
@import url("../posting_disclosures.css?v=20261019_legal_notice1") layer(components);
@import url("../site_navigation.css?v=20261031_nav_stability1") layer(overrides);

@layer pages {
  .item-exchange-page { color: var(--text-main); }
  .item-exchange-content { display: grid; align-content: start; gap: 12px; padding-top: 10px; padding-bottom: 30px; }
  .item-exchange-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; min-width: 0; }
  .item-exchange-heading h1 { margin: 2px 0 4px; font-size: clamp(22px, 1.8vw, 26px); line-height: 1.2; }
  .item-exchange-heading p { margin: 0; color: var(--text-muted); font-size: var(--font-small); }
  .item-exchange-eyebrow { color: var(--gold-primary); font-size: 11px; font-weight: 700; letter-spacing: .12em; }
  
  .item-exchange-page .ui-button { display: inline-flex; min-height: var(--button-height-compact); align-items: center; justify-content: center; gap: 6px; padding: var(--button-padding-compact-y) var(--button-padding-compact-x); border: 0; border-radius: var(--control-radius); color: var(--text-main); background: var(--bg-elevated); font: inherit; font-size: 13px; cursor: pointer; }
  .item-exchange-page .ui-button:hover { background: var(--bg-subtle); }
  .item-exchange-page .ui-button-primary { color: #17140c; background: var(--gold-primary); font-weight: 700; }
  .item-exchange-page .ui-button-primary:hover { background: var(--gold-hover); }
  .item-exchange-page .ui-button-compact { min-height: 28px; padding: 3px 8px; font-size: 12px; }
  
  .item-market-panel { display: grid; gap: 12px; min-width: 0; padding: 12px 16px; border-radius: var(--radius-lg); background: var(--bg-card); }
  .item-market-disclaimer { margin: 0; color: var(--text-dim); font-size: var(--font-small); line-height: 1.55; overflow-wrap: anywhere; }
  .item-market-disclaimer a { color: var(--blue-primary); text-decoration: underline; text-underline-offset: 2px; }

  .item-market-toast { position: fixed; z-index: 200; left: 50%; bottom: 20px; max-width: calc(100vw - 24px); padding: 10px 14px; border-radius: var(--radius-md); color: var(--text-main); background: var(--bg-elevated); box-shadow: var(--shadow-md); opacity: 0; pointer-events: none; transform: translate(-50%, 10px); transition: opacity var(--transition-fast), transform var(--transition-fast); }
  .item-market-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

  /* Simplified Trade Board & Comments */
  .trade-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
  .trade-search-wrap { flex: 1 1 240px; min-width: 0; }
  .trade-side-tabs { display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
  .trade-side-filter { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; padding: 4px 10px; border: 0; border-radius: var(--control-radius); color: var(--text-muted); background: var(--bg-elevated); font: inherit; font-size: 12px; cursor: pointer; }
  .trade-side-filter.is-active { color: var(--text-main); background: var(--bg-subtle); font-weight: 700; }
  .trade-search-label input { box-sizing: border-box; width: 100%; max-width: 360px; min-height: var(--control-height); padding: 8px 12px; border: 1px solid var(--control-border); border-radius: var(--control-radius); color: var(--text-main); background: var(--control-fill); font: inherit; font-size: var(--control-font-size); }
  .trade-count-badge { color: var(--text-dim); font-size: 13px; font-weight: 600; }
  .trade-toolbar-actions { display: inline-flex; align-items: center; gap: 10px; }
  @media (max-width: 640px) { .trade-toolbar-actions { width: 100%; justify-content: space-between; } }
  .trade-table-wrap { min-width: 0; overflow-x: auto; border-radius: var(--radius-md); }
  .trade-table { width: 100%; table-layout: fixed; border-collapse: collapse; text-align: left; font-size: 13.5px; }
  .trade-table th, .trade-table td { padding: 11px 12px; border-bottom: 1px solid rgba(148,163,184,.12); vertical-align: middle; }
  .trade-table td { white-space: nowrap; }
  .trade-table th { color: var(--text-dim); font-size: 11.5px; font-weight: 700; }
  .trade-th-title { width: 40%; }
  .trade-th-source { width: 15%; }
  .trade-th-time { width: 11%; }
  .trade-th-contact { width: 13%; }
  .trade-th-date { width: 12%; }
  .trade-th-views { width: 9%; text-align: right; }
  .trade-row:hover { background: rgba(255,255,255,.025); }
  .trade-row.is-expired, .trade-card.is-expired { opacity: .6; }
  .trade-expired-title, .trade-card.is-expired .trade-card-title { text-decoration: line-through; }
  .trade-expired-label { margin-left: var(--space-control); color: var(--text-muted); font-size: var(--font-small); }
  .trade-card.is-expired { cursor: default; }
  .trade-title-link { display: inline-flex; max-width: calc(100% - 72px); align-items: center; gap: 6px; padding: 0; border: 0; background: transparent; color: var(--text-main); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
  .trade-title-cell { max-width: 1px; }
  .trade-title-link strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .trade-title-link:hover { color: var(--gold-hover); text-decoration: underline; text-underline-offset: 3px; }
  .trade-comment-badge { color: var(--gold-primary); font-size: 12px; font-weight: 700; }
  .trade-chip { display: inline-flex; padding: 2px 7px; border-radius: 4px; background: rgba(217,183,101,.1); color: var(--gold-hover); font-size: 11.5px; font-weight: 600; }
  .trade-side-chip { display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 4px; background: var(--bg-subtle); font-size: 11.5px; font-weight: 700; line-height: 1.35; white-space: nowrap; }
  .trade-side-chip.is-sell { color: var(--green-deal); }
  .trade-side-chip.is-buy { color: var(--blue-primary); }
  .trade-side-chip.is-unknown { color: var(--gold-primary); }
  .trade-source-link { display: inline-flex; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 2px 7px; border-radius: 4px; color: var(--gold-hover); background: rgba(217,183,101,.1); font-size: 11.5px; font-weight: 600; text-decoration: none; }
  .trade-source-link:hover { color: var(--text-main); text-decoration: underline; text-underline-offset: 2px; }
  .trade-kakao-tag { display: inline-flex; padding: 2px 7px; border-radius: 4px; background: rgba(250,225,0,.12); color: #f5e042; font-size: 12px; font-weight: 700; }
  .trade-chat-author { color: var(--text-muted); font-size: 12px; overflow-wrap: anywhere; }
  .trade-muted-cell { color: var(--text-muted); font-size: 12.5px; }
  .trade-views-cell { color: var(--text-muted); font-size: 12.5px; text-align: right; }
  .trade-dim-cell { color: var(--text-dim); }
  .trade-empty { padding: 20px 12px; color: var(--text-muted); text-align: center; }

  .trade-mobile-list { display: none; }
  .trade-card { display: grid; gap: 6px; padding: 12px; border-radius: var(--radius-md); background: var(--bg-elevated); cursor: pointer; transition: background var(--transition-fast); }
  .trade-card:hover { background: var(--bg-subtle); }
  .trade-card-title { margin: 0; font-size: 15px; font-weight: 700; color: var(--text-main); }
  .trade-card-top { display: flex; align-items: center; justify-content: flex-start; gap: 8px; min-width: 0; }
  .trade-card-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .trade-card-meta { display: flex; flex-wrap: wrap; gap: 8px; color: var(--text-muted); font-size: 12px; }
  .trade-card-bottom { display: flex; align-items: center; justify-content: space-between; color: var(--text-dim); font-size: 11.5px; margin-top: 2px; }

  /* Dialogs */
  .trade-dialog { position: fixed; inset: 0; margin: auto; box-sizing: border-box; width: min(600px, calc(100vw - 20px)); max-height: calc(100dvh - 32px); padding: var(--space-card); border: 1px solid var(--border-light); border-radius: var(--radius-lg); background: var(--bg-card); color: var(--text-main); box-shadow: var(--shadow-lg); overflow-y: auto; }
  .trade-dialog-large { width: min(680px, calc(100vw - 20px)); }
  .trade-dialog-compact { width: min(400px, calc(100vw - 20px)); }
  .trade-dialog-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
  .trade-dialog-header > div { min-width: 0; }
  .trade-dialog-header[data-drag-handle] { cursor: grab; touch-action: none; }
  .trade-dialog-header[data-dragging] { cursor: grabbing; user-select: none; }
  .trade-dialog-header h2 { margin: 2px 0 0; font-size: 18px; font-weight: 750; }
  .trade-dialog-hint { margin: 0 0 14px; color: var(--text-muted); font-size: 12.5px; line-height: 1.5; }
  .trade-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .trade-field { display: flex; flex-direction: column; gap: 5px; }
  .trade-field-full { grid-column: 1 / -1; }
  .trade-field span { color: var(--text-muted); font-size: 12px; font-weight: 600; }
  .trade-required { color: var(--red-tag); }
  .trade-field input, .trade-field textarea { box-sizing: border-box; width: 100%; padding: 9px 12px; border: 1px solid var(--control-border); border-radius: var(--control-radius); color: var(--text-main); background: var(--control-fill); font: inherit; font-size: var(--control-font-size); }
  .trade-field textarea { min-height: 100px; resize: vertical; line-height: 1.6; }
  .trade-fieldset { grid-column: 1 / -1; margin: 0; padding: 12px; border: 1px solid var(--border-light); border-radius: var(--radius-md); background: rgba(0,0,0,.15); }
  .trade-fieldset legend { color: var(--gold-hover); font-size: 12px; font-weight: 700; padding: 0 6px; }
  .trade-source-inputs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .trade-form-error { margin: 8px 0 0; color: #f39a9a; font-size: 12px; }
  .trade-dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border-light); }
  .ui-button-danger { border-color: rgba(239,68,68,.3) !important; background: rgba(239,68,68,.18) !important; color: #fca5a5 !important; }
  .ui-button-danger:hover { background: rgba(239,68,68,.35) !important; color: #fff !important; }

  /* Detail View & Source Card */
  .trade-detail-body { display: grid; gap: 14px; min-width: 0; }
  .trade-detail-head { border-bottom: 1px solid var(--border-light); padding-bottom: 12px; }
  .trade-detail-heading { margin: 0 0 6px; font-size: 19px; line-height: 1.35; color: var(--text-main); overflow-wrap: anywhere; }
  .trade-detail-meta { display: flex; flex-wrap: wrap; gap: 10px; color: var(--text-muted); font-size: 12.5px; }
  .trade-source-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: var(--radius-md); background: var(--bg-elevated); border-left: 3px solid var(--gold-primary); flex-wrap: wrap; }
  .trade-source-info { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; }
  .trade-source-row { display: flex; align-items: center; gap: 6px; }
  .trade-source-k { color: var(--text-dim); font-size: 11.5px; }
  .trade-source-v { color: var(--text-main); }
  .trade-source-actions { display: flex; align-items: center; gap: 6px; }
  .trade-detail-content { padding: 14px 16px; border-radius: var(--radius-md); background: var(--bg-elevated); font-size: 14.5px; line-height: 1.7; color: var(--text-main); white-space: pre-wrap; word-break: break-word; }
  .trade-detail-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
  .trade-privacy-toggle { display: inline-flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 13px; cursor: pointer; }
  .trade-privacy-toggle input { width: 18px; height: 18px; accent-color: var(--gold-primary); }
  .trade-contact-detection { margin: 0 0 8px; color: var(--text-muted); font-size: 12px; }
  .trade-delete-btn { padding: 4px 10px; border: 1px solid rgba(239,68,68,.3); border-radius: var(--radius-sm); color: #fca5a5; background: transparent; font: inherit; font-size: 12px; cursor: pointer; }
  .trade-delete-btn:hover { background: rgba(239,68,68,.2); color: #fff; }

  /* Comments */
  .trade-comments-section { border-top: 1px solid var(--border-light); padding-top: 16px; display: grid; gap: 12px; }
  .trade-comments-title { margin: 0; font-size: 15px; font-weight: 700; color: var(--text-main); }
  .trade-comments-list { display: grid; gap: 8px; }
  .trade-comments-loading, .trade-comments-empty { margin: 0; padding: 16px 0; color: var(--text-dim); font-size: 13px; text-align: center; }
  .trade-comment-item { display: grid; gap: 4px; padding: 10px 12px; border-radius: var(--radius-md); background: var(--bg-elevated); }
  .trade-comment-meta { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text-muted); }
  .trade-comment-meta strong { color: var(--text-main); }
  .trade-comment-meta time { color: var(--text-dim); font-size: 11px; margin-left: 8px; margin-right: auto; }
  .trade-comment-delete { padding: 2px 6px; border: 0; background: transparent; color: var(--text-dim); font-size: 11px; cursor: pointer; }
  .trade-comment-delete:hover { color: var(--red-tag); }
  .trade-comment-body { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--text-main); white-space: pre-wrap; word-break: break-word; }
  .trade-comment-form { display: grid; gap: 8px; padding: 12px; border-radius: var(--radius-md); background: rgba(0,0,0,.2); border: 1px solid var(--border-light); }
  .trade-comment-inputs { display: flex; gap: 8px; }
  .trade-comment-inputs input { max-width: 160px; padding: 6px 10px; border: 1px solid var(--control-border); border-radius: var(--control-radius); background: var(--control-fill); color: var(--text-main); font: inherit; font-size: 12px; }
  .trade-comment-user { color: var(--gold-hover); font-weight: 700; font-size: 13px; align-self: center; }
  .trade-comment-form textarea { width: 100%; box-sizing: border-box; min-height: 56px; padding: 8px 10px; border: 1px solid var(--control-border); border-radius: var(--control-radius); background: var(--control-fill); color: var(--text-main); font: inherit; font-size: 13px; resize: vertical; }
  .trade-comment-submit-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

  @media(max-width: 720px) {
    .trade-side-tabs { width: 100%; }
    .trade-side-filter { flex: 1 1 0; justify-content: center; min-height: 38px; }
    .item-exchange-page .site-main-content { padding-inline: 8px; }
    .item-exchange-heading { align-items: flex-start; }
    .item-exchange-heading > button { min-height: 38px; }
    .trade-table { display: none; }
    .trade-mobile-list { display: grid; gap: 8px; }
    .trade-source-inputs { grid-template-columns: minmax(0, 1fr); }
    .trade-form-grid { grid-template-columns: minmax(0, 1fr); }
    .trade-source-box { flex-direction: column; align-items: flex-start; }
    .trade-comment-inputs { flex-direction: column; }
    .trade-comment-inputs input { max-width: 100%; }
    .trade-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  }
}
