:root {
    --bg: #f5f5f5;
    --white: #ffffff;
    --border: #e0e0e0;
    --text-main: #333;
    --accent: #007bff;
    --status-available: #1e90ff;
    --status-reserved: #ffb300;
    --status-sold: #9e9e9e;
    --fav-active: #ff4b6a;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text-main);
}

header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
}

header h1 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0.75rem 0 1.5rem;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.filter-bar form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
}

.field-group {
    display: flex;
    flex: 1;
    min-width: 120px;
}

.field-group input[type="text"],
.field-group select {
    width: 100%;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 2px;
    font-size: 0.85rem;
    background: #fafafa;
    font-size: 16px;
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn {
    padding: 0.4rem 0.75rem;
    border-radius: 2px;
    border: none;
    font-size: 0.8rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-outline {
    background: #fff;
    color: var(--accent);
    border: 1px solid var(--accent);
}

.items-section {
    margin: 0.6rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;

}

.items-section-title,
.favorite-title {
    font-size: 0.9rem;
    font-weight: 600;
}

.items-list {
    display: flex;
    flex-direction: column;
    /* gap: 0.5rem; */
}

.item-card {
    display: flex;
    gap: 0.75rem;
    padding: 0.6rem;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    /* box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03); */
    align-items: stretch;
}

.item-thumb-wrap {
    width: 100px;
    height: 100px;
    border-radius: 2px;
    overflow: hidden;
    background: #eee;
    position: relative;
    flex-shrink: 0;
}

.item-thumb-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.item-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.item-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
}

.item-id {
    font-size: 0.75rem;
    color: #777;
}




.item-title {
    font-size: 0.88rem;
    /* font-weight: 600; */
    margin-top: 0.1rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.item-price {
    font-size: 18px;
    font-weight: 700;
}

.item-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.status-badge {
    font-size: 0.8rem;
    padding: 0.15rem 0.75rem;
    border-radius: 2px;
    color: #fff;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-available {
    background: var(--status-available);
}

.status-reserved {
    background: var(--status-reserved);
}

.status-sold {
    background: var(--status-sold);
}



a.item-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex: 1;
    gap: 0.6rem;
}

@media (min-width: 768px) {
    .item-card {
        padding: 0.75rem;
    }
}

@media (max-width: 768px) {

    .items-section,
    .favorite-title {
        margin: .6rem;
    }

    .filter-bar {
        margin: .6rem;
    }
}

.item-new {
    font-size: 0.7rem;
    padding: 0 0.35rem;
    border-radius: 2px;
    background: #ff5252;
    color: #fff;
    font-weight: 600;
    height: 20px;
    line-height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.item-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    justify-content: flex-end;
    /* 左寄せにしたければ flex-start */
}

.item-tags-wrap {
    display: flex;
    flex-wrap: nowrap;
    /* 改行させない */
    gap: 0.25rem;
    overflow-x: auto;
    /* 横スクロール */
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    /* 親の中で収まるように */
}

.item-tag {
    font-size: 0.72rem;
    padding: 0 0.45rem;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 2px;
    border: 1px solid #ddd;
    background: #fafafa;
}

.tags-filter {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.35rem;
    overflow-x: auto;
    padding: 0.25rem 0;
    -webkit-overflow-scrolling: touch;
}

.tag-pill {
    border-radius: 999px;
    border: 1px solid #ddd;
    padding: 0.15rem 0.6rem;
    font-size: 0.8rem;
    background: #fff;
    white-space: nowrap;
    cursor: pointer;
}

.tag-pill.active {
    background: #007bff;
    border-color: #007bff;
    color: #fff;
}

.item-thumb-wrap {
    position: relative;
    /* すでにあればOK */
}

.viewed-label {
    position: absolute;
    left: 0;
    top: 0;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 0.7rem;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
}

/* ===== レイアウト切り替えボタン ===== */
.layout-toggle {
    display: flex;
    gap: 0.4rem;
}

.layout-btn.is-active {
    border-color: var(--accent);
    color: #fff;
    background: var(--accent);
}

/* ===== 2列レイアウト時の .items-list & .item-card 調整 ===== */
.items-list.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    /* gap: 0.5rem; */
    background: #fff;
}

.items-list.grid-2 .item-card {
    border-bottom: none;
    /* border-radius: 4px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03); */
}

.items-list.grid-2 .item-card:nth-child(odd) {
    padding-right: 0.3rem;
}

.items-list.grid-2 .item-card:nth-child(even) {
    padding-left: 0.3rem;

}

/* 2列時はカード内を縦並びに */
.items-list.grid-2 .item-link {
    flex-direction: column;
}

.items-list.grid-2 .item-thumb-wrap {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
}

.items-list.grid-2 .item-thumb-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.items-list.grid-2 .item-body {
    margin-top: 0.35rem;
}



/* 共通ボタンスタイル（既存 .btn と被らないように独立させてる） */
.layout-btn {
    width: 40px;
    height: 30px;
    border-radius: 2px;
    border: 1px solid #ccc;
    background: #fff;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

/* アクティブ時（ON） */
.layout-btn.is-active {
    border-color: var(--accent);
    background: rgba(0, 123, 255, 0.08);
}

/* ホバー時（PC向け） */
.layout-btn:hover {
    border-color: #aaa;
}

/* アイコンのベース */
.layout-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* 1列アイコン：横長長方形が上下に2つ */
.layout-icon-list {
    flex-direction: column;
    gap: 2px;
}

.layout-icon-list span {
    display: block;
    width: 18px;
    height: 7px;
    /* border-radius: 2px; */
    background: #777;
}

/* 2列アイコン：縦長長方形が左右に2つ */
.layout-icon-grid {
    flex-direction: row;
    gap: 2px;
}

.layout-icon-grid span {
    display: block;
    width: 8px;
    height: 16px;
    /* border-radius: 2px; */
    background: #777;
}

/* アクティブ時は中の棒もアクセント色に */
.layout-btn.is-active .layout-icon span {
    background: var(--accent);
}