*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f5f5f0;
    color: #1a1a1a;
    font-size: 18px;
}

.app { max-width: 520px; margin: 0 auto; padding: 0 0 2rem; }

/* タブバー */
.tab-bar {
    display: flex;
    background: #fff;
    border-bottom: 1px solid #e8e8e4;
    position: sticky;
    top: 0;
    z-index: 10;
}
.tab {
    flex: 1;
    padding: 16px 4px;
    font-size: 15px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    color: #888;
}
.tab.active { color: #1a1a1a; border-bottom-color: #1a1a1a; font-weight: 500; }
.tab-logout {
    padding: 16px 16px;
    font-size: 14px;
    background: none;
    border: none;
    cursor: pointer;
    color: #aaa;
}
.tab-logout:hover { color: #e24b4a; }

/* カード */
.card {
    background: #fff;
    border: 1px solid #ebebeb;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin: 0 1rem 10px;
}
.item-card { margin-bottom: 8px; }

/* アイテム行 */
.item-row { display: flex; align-items: center; gap: 10px; }
.item-info { flex: 1; min-width: 0; }
.item-name { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: 14px; color: #888; margin-top: 4px; }
.done-text { text-decoration: line-through; color: #bbb; }

/* チェック円 */
.check-circle {
    width: 32px; height: 32px;
    border-radius: 50%;
    border: 1.5px solid #ccc;
    cursor: pointer;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, border-color 0.15s;
}
.check-circle.checked { background: #1D9E75; border-color: #1D9E75; }
.check-circle.checked::after {
    content: '';
    width: 10px; height: 6px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg) translateY(-1px);
    display: block;
}

/* ボタン類 */
.btn-del {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 1px solid #e0e0e0;
    background: none;
    cursor: pointer;
    font-size: 20px;
    color: #aaa;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.btn-del:hover { background: #fef2f2; border-color: #fca5a5; color: #e24b4a; }
.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: none;
    cursor: pointer;
    color: #666;
}
.btn-sm:hover { background: #f5f5f0; }
.btn-primary {
    padding: 8px 16px;
    background: #1a1a1a;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}
.btn-primary:hover { background: #333; }
.btn-primary.btn-large {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    margin-top: 8px;
}
.btn-add-from-master {
    padding: 8px 16px;
    font-size: 14px;
    border: 1px solid #1D9E75;
    border-radius: 8px;
    background: none;
    color: #1D9E75;
    cursor: pointer;
    flex-shrink: 0;
}
.btn-add-from-master:hover { background: #e1f5ee; }

/* プログレスバー */
.header-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 1rem 8px; }
.count-text { font-size: 15px; color: #888; }
.progress-wrap { height: 4px; background: #ebebeb; margin: 0 1rem 12px; border-radius: 2px; }
.progress-bar { height: 4px; background: #1D9E75; border-radius: 2px; transition: width 0.3s; }

/* フォーム */
.form-group { margin-bottom: 16px; }
label { font-size: 15px; color: #666; display: block; margin-bottom: 6px; }
input[type=text], input[type=password], textarea {
    width: 100%;
    padding: 12px 14px;
    font-size: 16px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    color: #1a1a1a;
    font-family: inherit;
}
input:focus, textarea:focus { outline: none; border-color: #1a1a1a; }
textarea { resize: none; height: 64px; }
.check-label { display: flex; align-items: center; gap: 10px; font-size: 15px; color: #555; margin: 6px 0 10px; cursor: pointer; }
.check-label input { width: auto; }

/* よく買うもの チップ */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip {
    font-size: 15px;
    padding: 8px 18px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    background: #fff;
    cursor: pointer;
}
.chip:hover { background: #f5f5f0; border-color: #ccc; }

/* その他 */
.section-title { font-size: 14px; font-weight: 500; color: #999; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px; }
.empty, .loading { text-align: center; padding: 2.5rem 1rem; font-size: 16px; color: #aaa; }
.divider { border: none; border-top: 1px solid #ebebeb; margin: 8px 1rem; }
.done-label { font-size: 14px; color: #aaa; padding: 0 1rem; margin-bottom: 8px; }
.error { color: #e24b4a; font-size: 15px; margin-bottom: 12px; }

/* ログイン画面 */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: #f5f5f0;
}
.login-wrap .card { width: 100%; max-width: 360px; }
.login-wrap h2 { font-size: 24px; font-weight: 500; margin-bottom: 1.5rem; text-align: center; }
.login-wrap .btn-sub {
    width: 100%;
    padding: 14px;
    background: none;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    margin-top: 8px;
    color: #555;
}
.login-wrap .btn-sub:hover { background: #f5f5f0; }

/* トースト通知 */
.toast {
    background: #1D9E75;
    color: #fff;
    font-size: 15px;
    padding: 12px 18px;
    border-radius: 8px;
    margin: 0 1rem 12px;
    text-align: center;
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* モーダル */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    width: 90%;
    max-width: 320px;
}
.modal h3 {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 1rem;
}
.modal-buttons {
    display: flex;
    gap: 8px;
    margin-top: 1rem;
}
.modal-buttons button {
    flex: 1;
}
.form-control {
    width: 100%;
    padding: 12px 14px;
    font-size: 16px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    color: #1a1a1a;
    font-family: inherit;
}

/* 数量コントロール */
.quantity-control {
    display: flex;
    align-items: center;
    gap: 8px;
}
.quantity-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: 18px;
    font-weight: 500;
    color: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.quantity-btn:hover {
    background: #f5f5f0;
    border-color: #ccc;
}
.quantity-value {
    font-size: 15px;
    font-weight: 500;
    min-width: 24px;
    text-align: center;
}
